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 
18 #ifndef GAZEBO_COMMON_URI_HH_
19 #define GAZEBO_COMMON_URI_HH_
20 
21 #include <memory>
22 #include <string>
23 #include "gazebo/util/system.hh"
24 
25 namespace gazebo
26 {
27  namespace common
28  {
29  // Forward declare private data classes.
30  class URIPathPrivate;
31  class URIQueryPrivate;
32  class URIPrivate;
33 
35  class GZ_COMMON_VISIBLE URIPath
36  {
38  public: URIPath();
39 
42  public: URIPath(const URIPath &_path);
43 
46  public: explicit URIPath(const std::string &_str);
47 
49  public: virtual ~URIPath();
50 
52  public: void Clear();
53 
56  public: void PushFront(const std::string &_part);
57 
61  public: void PushBack(const std::string &_part);
62 
66  public: const URIPath &operator/=(const std::string &_part);
67 
72  public: const URIPath operator/(const std::string &_part) const;
73 
77  public: bool operator==(const URIPath &_path) const;
78 
82  public: std::string Str(const std::string &_delim = "/") const;
83 
87  public: URIPath &operator=(const URIPath &_path);
88 
92  public: static bool Valid(const std::string &_str);
93 
96  public: bool Valid() const;
97 
101  public: bool Parse(const std::string &_str);
102 
107  public: bool Contains(const URIPath &_other) const;
108 
111  private: std::unique_ptr<URIPathPrivate> dataPtr;
112  };
113 
115  class GZ_COMMON_VISIBLE URIQuery
116  {
118  public: URIQuery();
119 
122  public: explicit URIQuery(const std::string &_str);
123 
126  public: URIQuery(const URIQuery &_query);
127 
129  public: virtual ~URIQuery();
130 
132  public: void Clear();
133 
137  public: void Insert(const std::string &_key,
138  const std::string &_value);
139 
143  public: URIQuery &operator=(const URIQuery &_query);
144 
148  public: bool operator==(const URIQuery &_query) const;
149 
154  public: std::string Str(const std::string &_delim = "&") const;
155 
159  public: static bool Valid(const std::string &_str);
160 
163  public: bool Valid() const;
164 
168  public: bool Parse(const std::string &_string);
169 
172  private: std::unique_ptr<URIQueryPrivate> dataPtr;
173  };
174 
176  class GZ_COMMON_VISIBLE URI
177  {
179  public: URI();
180 
183  // cppcheck-suppress noExplicitConstructor
184  public: URI(const std::string &_str);
185 
188  public: URI(const URI &_uri);
189 
191  public: ~URI();
192 
198  public: std::string Str() const;
199 
201  public: void Clear();
202 
205  public: std::string Scheme() const;
206 
209  public: void SetScheme(const std::string &_scheme);
210 
213  public: URIPath &Path();
214 
217  public: const URIPath &Path() const;
218 
221  public: URIQuery &Query();
222 
225  public: const URIQuery &Query() const;
226 
230  public: URI &operator=(const URI &_uri);
231 
235  public: bool operator==(const URI &_uri) const;
236 
239  public: bool Valid() const;
240 
244  public: static bool Valid(const std::string &_str);
245 
249  public: bool Parse(const std::string &_str);
250 
253  private: std::unique_ptr<URIPrivate> dataPtr;
254  };
255  }
256 }
257 #endif
std::string Str() const
Get the URI as a string, which has the form:
A complete URI.
Definition: URI.hh:176
std::string Scheme() const
Get the URI's scheme.
Forward declarations for the common classes.
Definition: Animation.hh:26
void PushBack(const std::string &_part)
Push a new part onto the back of this path.
~URI()
Destructor.
The query component of a URI.
Definition: URI.hh:115
bool Valid() const
Return true if this is a valid path.
common
Definition: FuelModelDatabase.hh:37
bool Valid() const
Validate this URI.
void Insert(const std::string &_key, const std::string &_value)
Get this query with a new _key=_value pair added.
std::string Str(const std::string &_delim="/") const
Get the path as a string.
URIQuery()
Constructor.
std::string Str(const std::string &_delim="&") const
Get the query as a string.
bool operator==(const URI &_uri) const
Return true if the two URIs match.
bool operator==(const URIQuery &_query) const
Return true if the two queries contain the same values.
void PushFront(const std::string &_part)
Push a new part onto the front of this path.
void Clear()
Remove all values of the query.
const URIPath & operator/=(const std::string &_part)
Compound assignment operator.
URIPath & Path()
Get a mutable version of the path component.
bool Parse(const std::string &_str)
Parse a string as URIPath.
The path component of a URI.
Definition: URI.hh:35
URIQuery & operator=(const URIQuery &_query)
Equal operator.
URIPath()
Constructor.
virtual ~URIQuery()
Destructor.
URIQuery & Query()
Get a mutable version of the query component.
void Clear()
Remove all parts of the path.
URI & operator=(const URI &_uri)
Equal operator.
void Clear()
Remove all components of the URI.
const URIPath operator/(const std::string &_part) const
Get the current path with the _part added to the end.
virtual ~URIPath()
Destructor.
bool Valid() const
Check if this is a valid URI query.
URI()
Default constructor.
void SetScheme(const std::string &_scheme)
Set the URI's scheme.
URIPath & operator=(const URIPath &_path)
Equal operator.
bool operator==(const URIPath &_path) const
Return true if the two paths match.
bool Contains(const URIPath &_other) const
Returns true if _other is a subset of this, counting from the beginning.
bool Parse(const std::string &_string)
Parse a string as URIQuery.
bool Parse(const std::string &_str)
Parse a string as URI.