Ignition Common

API Reference

3.6.1
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 
63  public: void SetAbsolute(bool _absolute = true);
64 
66  public: void SetRelative();
67 
73  public: void PushFront(const std::string &_part);
74 
82  public: void PushBack(const std::string &_part);
83 
87  public: const URIPath &operator/=(const std::string &_part);
88 
93  public: const URIPath operator/(const std::string &_part) const;
94 
98  public: bool operator==(const URIPath &_path) const;
99 
103  public: std::string Str(const std::string &_delim = "/") const;
104 
108  public: URIPath &operator=(const URIPath &_path);
109 
113  public: static bool Valid(const std::string &_str);
114 
117  public: bool Valid() const;
118 
122  public: bool Parse(const std::string &_str);
123 
127  private: std::unique_ptr<URIPathPrivate> dataPtr;
129  };
130 
132  class IGNITION_COMMON_VISIBLE URIQuery
133  {
135  public: URIQuery();
136 
139  public: explicit URIQuery(const std::string &_str);
140 
143  public: URIQuery(const URIQuery &_query);
144 
146  public: virtual ~URIQuery();
147 
149  public: void Clear();
150 
154  public: void Insert(const std::string &_key,
155  const std::string &_value);
156 
160  public: URIQuery &operator=(const URIQuery &_query);
161 
165  public: bool operator==(const URIQuery &_query) const;
166 
171  public: std::string Str(const std::string &_delim = "&") const;
172 
176  public: static bool Valid(const std::string &_str);
177 
180  public: bool Valid() const;
181 
185  public: bool Parse(const std::string &_string);
186 
190  private: std::unique_ptr<URIQueryPrivate> dataPtr;
192  };
193 
195  class IGNITION_COMMON_VISIBLE URIFragment
196  {
198  public: URIFragment();
199 
202  public: explicit URIFragment(const std::string &_str);
203 
206  public: URIFragment(const URIFragment &_fragment);
207 
209  public: virtual ~URIFragment();
210 
212  public: void Clear();
213 
217  public: URIFragment &operator=(const URIFragment &_fragment);
218 
222  public: URIFragment &operator=(const std::string &_fragment);
223 
227  public: bool operator==(const URIFragment &_fragment) const;
228 
231  public: std::string Str() const;
232 
236  public: static bool Valid(const std::string &_str);
237 
240  public: bool Valid() const;
241 
245  public: bool Parse(const std::string &_string);
246 
250  private: std::unique_ptr<URIFragmentPrivate> dataPtr;
252  };
253 
255  // cppcheck-suppress class_X_Y
256  class IGNITION_COMMON_VISIBLE URI
257  {
259  public: URI();
260 
263  public: explicit URI(const std::string &_str);
264 
267  public: URI(const URI &_uri);
268 
270  public: ~URI();
271 
277  public: std::string Str() const;
278 
280  public: void Clear();
281 
284  public: std::string Scheme() const;
285 
288  public: void SetScheme(const std::string &_scheme);
289 
292  public: URIPath &Path();
293 
296  public: const URIPath &Path() const;
297 
300  public: URIQuery &Query();
301 
304  public: const URIQuery &Query() const;
305 
308  public: URIFragment &Fragment();
309 
312  public: const URIFragment &Fragment() const;
313 
317  public: URI &operator=(const URI &_uri);
318 
322  public: bool operator==(const URI &_uri) const;
323 
326  public: bool Valid() const;
327 
331  public: static bool Valid(const std::string &_str);
332 
336  public: bool Parse(const std::string &_str);
337 
341  private: std::unique_ptr<URIPrivate> dataPtr;
343  };
344  }
345 }
346 #endif
The query component of a URI.
Definition: URI.hh:132
#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:256
The fragment component of a URI.
Definition: URI.hh:195
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