Bayeux  3.4.1
Core Foundation library for SuperNEMO
urn.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2017-03-05
4  * Last modified: 2017-03-05
5  *
6  * License:
7  *
8  * Copyright (C) 2017 Francois Mauger <mauger@lpccaen.in2p3.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or (at
13  * your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  *
25  * Description:
26  *
27  * Utilities for URN manipulation.
28  *
29  */
30 
31 #ifndef DATATOOLS_URN_H
32 #define DATATOOLS_URN_H
33 
34 // Standard Library:
35 #include <string>
36 #include <vector>
37 
38 // Datatools:
40 
41 namespace datatools {
42 
47 
55  class urn
57  {
58  public:
59 
61  static const std::string & urn_scheme();
62 
64  static char urn_separator();
65 
67  urn();
68 
70  urn(const std::vector<std::string> & segments_);
71 
73  virtual ~urn();
74 
76  bool is_valid() const;
77 
79  bool has_namespace() const;
80 
82  const std::string & get_namespace() const;
83 
85  void set_segments(const std::vector<std::string> & segments_);
86 
88  void append_segment(const std::string & segment_);
89 
91  std::size_t get_depth() const;
92 
94  void reset();
95 
97  const std::vector<std::string> & get_segments() const;
98 
100  void to_string(std::string &) const;
101 
103  std::string to_string() const;
104 
106  bool from_string(const std::string &);
107 
108  friend std::ostream & operator<<(std::ostream &, const urn &);
109 
110  private:
111 
112  std::vector<std::string> _segments_;
113 
116 
117  };
118 
119 } // end of namespace datatools
120 
121 #endif // DATATOOLS_URN_H
122 
123 // Local Variables: --
124 // mode: c++ --
125 // c-file-style: "gnu" --
126 // tab-width: 2 --
127 // End: --
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
urn()
Default constructor.
virtual ~urn()
Destructor.
static char urn_separator()
Return the URN separator.
friend std::ostream & operator<<(std::ostream &, const urn &)
#define DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED(ClassName)
Definition: i_serializable.h:371
bool is_valid() const
Check validity.
std::size_t get_depth() const
Return the depth of the path segments.
bool has_namespace() const
Check is namespace is set.
A class representing a simplified URN conforming parts of the RFC2141.
Definition: urn.h:55
std::string to_string() const
Return a string representation.
void append_segment(const std::string &segment_)
Append a path segment.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
void reset()
Clear the path segments.
bool from_string(const std::string &)
Initialize from a string.
const std::vector< std::string > & get_segments() const
Return the path segments.
void set_segments(const std::vector< std::string > &segments_)
Set path segments.
static const std::string & urn_scheme()
Return the URN scheme.
const std::string & get_namespace() const
Return the namespace.