Gazebo Common

API Reference

3.17.0
gz/common/URI.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_COMMON_URI_HH_
18 #define GZ_COMMON_URI_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <gz/common/Export.hh>
25 
26 namespace ignition
27 {
28  namespace common
29  {
30  // Forward declare private data classes.
31  class URIPathPrivate;
32  class URIQueryPrivate;
33  class URIFragmentPrivate;
34  class URIPrivate;
35 
37  class IGNITION_COMMON_VISIBLE URIPath
38  {
40  public: URIPath();
41 
44  public: URIPath(const URIPath &_path);
45 
48  public: explicit URIPath(const std::string &_str);
49 
51  public: virtual ~URIPath();
52 
54  public: void Clear();
55 
58  public: bool IsAbsolute() const;
59 
65  public: void SetAbsolute(bool _absolute = true);
66 
70  public: void SetRelative();
71 
79  public: void PushFront(const std::string &_part);
80 
89  public: void PushBack(const std::string &_part);
90 
94  public: const URIPath &operator/=(const std::string &_part);
95 
100  public: const URIPath operator/(const std::string &_part) const;
101 
105  public: bool operator==(const URIPath &_path) const;
106 
110  public: std::string Str(const std::string &_delim = "/") const;
111 
115  public: URIPath &operator=(const URIPath &_path);
116 
120  public: static bool Valid(const std::string &_str);
121 
124  public: bool Valid() const;
125 
129  public: bool Parse(const std::string &_str);
130 
134  private: std::unique_ptr<URIPathPrivate> dataPtr;
136  };
137 
139  class IGNITION_COMMON_VISIBLE URIQuery
140  {
142  public: URIQuery();
143 
146  public: explicit URIQuery(const std::string &_str);
147 
150  public: URIQuery(const URIQuery &_query);
151 
153  public: virtual ~URIQuery();
154 
156  public: void Clear();
157 
161  public: void Insert(const std::string &_key,
162  const std::string &_value);
163 
167  public: URIQuery &operator=(const URIQuery &_query);
168 
172  public: bool operator==(const URIQuery &_query) const;
173 
178  public: std::string Str(const std::string &_delim = "&") const;
179 
183  public: static bool Valid(const std::string &_str);
184 
187  public: bool Valid() const;
188 
192  public: bool Parse(const std::string &_string);
193 
197  private: std::unique_ptr<URIQueryPrivate> dataPtr;
199  };
200 
202  class IGNITION_COMMON_VISIBLE URIFragment
203  {
205  public: URIFragment();
206 
209  public: explicit URIFragment(const std::string &_str);
210 
213  public: URIFragment(const URIFragment &_fragment);
214 
216  public: virtual ~URIFragment();
217 
219  public: void Clear();
220 
224  public: URIFragment &operator=(const URIFragment &_fragment);
225 
229  public: URIFragment &operator=(const std::string &_fragment);
230 
234  public: bool operator==(const URIFragment &_fragment) const;
235 
238  public: std::string Str() const;
239 
243  public: static bool Valid(const std::string &_str);
244 
247  public: bool Valid() const;
248 
252  public: bool Parse(const std::string &_string);
253 
257  private: std::unique_ptr<URIFragmentPrivate> dataPtr;
259  };
260 
262  // cppcheck-suppress class_X_Y
263  class IGNITION_COMMON_VISIBLE URI
264  {
266  public: URI();
267 
270  public: explicit URI(const std::string &_str);
271 
274  public: URI(const URI &_uri);
275 
277  public: ~URI();
278 
284  public: std::string Str() const;
285 
287  public: void Clear();
288 
291  public: std::string Scheme() const;
292 
295  public: void SetScheme(const std::string &_scheme);
296 
299  public: URIPath &Path();
300 
303  public: const URIPath &Path() const;
304 
307  public: URIQuery &Query();
308 
311  public: const URIQuery &Query() const;
312 
315  public: URIFragment &Fragment();
316 
319  public: const URIFragment &Fragment() const;
320 
324  public: URI &operator=(const URI &_uri);
325 
329  public: bool operator==(const URI &_uri) const;
330 
333  public: bool Valid() const;
334 
338  public: static bool Valid(const std::string &_str);
339 
343  public: bool Parse(const std::string &_str);
344 
348  private: std::unique_ptr<URIPrivate> dataPtr;
350  };
351  }
352 }
353 #endif
bool IsAbsolute() const
Returns whether the path is absolute or not.
const URIPath operator/(const std::string &_part) const
Get the current path with the _part added to the end.
bool operator==(const URIPath &_path) const
Return true if the two paths match.
Forward declarations for the common classes.
STL class.
std::string Str(const std::string &_delim="&") const
Get the query as a string.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: gz/common/SuppressWarning.hh:65
void SetRelative()
Set the path to be relative.
URIQuery & operator=(const URIQuery &_query)
Assignment operator.
std::string Scheme() const
Get the URI's scheme.
void Clear()
Remove all components of the URI.
void Clear()
Remove all values of the query.
bool Parse(const std::string &_string)
Parse a string as URIQuery.
bool Valid() const
Validate this URI.
virtual ~URIFragment()
Destructor.
bool Valid() const
Check if this is a valid URI query.
void SetAbsolute(bool _absolute=true)
Set whether the path is to be treated absolute or not.
bool operator==(const URI &_uri) const
Return true if the two URIs match.
The path component of a URI.
Definition: gz/common/URI.hh:37
void PushBack(const std::string &_part)
Push a new part onto the back of this path.
A complete URI.
Definition: gz/common/URI.hh:263
The fragment component of a URI.
Definition: gz/common/URI.hh:202
bool operator==(const URIQuery &_query) const
Return true if the two queries contain the same values.
bool Parse(const std::string &_str)
Parse a string as URIPath.
void SetScheme(const std::string &_scheme)
Set the URI's scheme.
bool Valid() const
Check if this is a valid URI fragment.
const URIPath & operator/=(const std::string &_part)
Compound assignment operator.
URIFragment & operator=(const URIFragment &_fragment)
Assignment operator.
void Insert(const std::string &_key, const std::string &_value)
Get this query with a new _key=_value pair added.
The query component of a URI.
Definition: gz/common/URI.hh:139
bool Parse(const std::string &_string)
Parse a string as URIFragment.
URI & operator=(const URI &_uri)
Assignment operator.
void Clear()
Remove all parts of the path.
std::string Str() const
Get the fragment as a string.
URIFragment & Fragment()
Get a mutable version of the fragment component.
URIPath & Path()
Get a mutable version of the path component.
URIQuery & Query()
Get a mutable version of the query component.
std::string Str() const
Get the URI as a string, which has the form:
virtual ~URIQuery()
Destructor.
virtual ~URIPath()
Destructor.
URIPath & operator=(const URIPath &_path)
Assignment operator.
void PushFront(const std::string &_part)
Push a new part onto the front of this path.
bool Valid() const
Return true if this is a valid path.
void Clear()
Remove all values of the fragment.
URI()
Default constructor.
bool Parse(const std::string &_str)
Parse a string as URI.
std::string Str(const std::string &_delim="/") const
Get the path as a string.
bool operator==(const URIFragment &_fragment) const
Return true if the two fragments contain the same values.
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68