Ignition Common

API Reference

3.9.0
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 IGNITION_COMMON_URI_HH_
18 #define IGNITION_COMMON_URI_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <ignition/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
The query component of a URI.
Definition: URI.hh:139
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
STL class.
The path component of a URI.
Definition: URI.hh:37
A complete URI.
Definition: URI.hh:263
The fragment component of a URI.
Definition: URI.hh:202
Forward declarations for the common classes.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64