Gazebo Common

API Reference

5.7.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 <optional>
21 #include <string>
22 
23 #include <gz/common/Export.hh>
24 
25 #include <gz/utils/ImplPtr.hh>
26 
27 namespace gz
28 {
29  namespace common
30  {
55  class GZ_COMMON_VISIBLE URIAuthority
56  {
58  public: URIAuthority();
59 
62  public: explicit URIAuthority(const std::string &_str);
63 
65  public: void Clear();
66 
70  public: std::string UserInfo() const;
71 
74  public: void SetUserInfo(const std::string &_userInfo);
75 
78  public: std::string Host() const;
79 
82  public: void SetHost(const std::string &_host);
83 
86  public: bool EmptyHostValid() const;
87 
92  public: void SetEmptyHostValid(bool _valid);
93 
96  public: std::optional<int> Port() const;
97 
99  public: void SetPort(int _port);
100 
104  public: bool operator==(const URIAuthority &_auth) const;
105 
108  public: std::string Str() const;
109 
116  public: static bool Valid(const std::string &_str,
117  bool _emptyHostValid = false);
118 
121  public: bool Valid() const;
122 
129  public: bool Parse(const std::string &_str,
130  bool _emptyHostValid = false);
131 
133  GZ_UTILS_IMPL_PTR(dataPtr)
134  };
135 
145  class GZ_COMMON_VISIBLE URIPath
146  {
148  public: URIPath();
149 
152  public: explicit URIPath(const std::string &_str);
153 
155  public: void Clear();
156 
159  public: bool IsAbsolute() const;
160 
166  public: void SetAbsolute(bool _absolute = true);
167 
171  public: void SetRelative();
172 
180  public: void PushFront(const std::string &_part);
181 
190  public: void PushBack(const std::string &_part);
191 
196 
200  public: std::string PopBack();
201 
205  public: const URIPath &operator/=(const std::string &_part);
206 
211  public: const URIPath operator/(const std::string &_part) const;
212 
216  public: bool operator==(const URIPath &_path) const;
217 
221  public: std::string Str(const std::string &_delim = "/") const;
222 
226  public: static bool Valid(const std::string &_str);
227 
230  public: bool Valid() const;
231 
235  public: bool Parse(const std::string &_str);
236 
238  GZ_UTILS_IMPL_PTR(dataPtr)
239  };
240 
242  class GZ_COMMON_VISIBLE URIQuery
243  {
245  public: URIQuery();
246 
249  public: explicit URIQuery(const std::string &_str);
250 
252  public: void Clear();
253 
257  public: void Insert(const std::string &_key,
258  const std::string &_value);
259 
263  public: bool operator==(const URIQuery &_query) const;
264 
269  public: std::string Str(const std::string &_delim = "&") const;
270 
274  public: static bool Valid(const std::string &_str);
275 
278  public: bool Valid() const;
279 
283  public: bool Parse(const std::string &_string);
284 
286  GZ_UTILS_IMPL_PTR(dataPtr)
287  };
288 
290  class GZ_COMMON_VISIBLE URIFragment
291  {
293  public: URIFragment();
294 
297  public: explicit URIFragment(const std::string &_str);
298 
300  public: void Clear();
301 
305  public: URIFragment &operator=(const std::string &_fragment);
306 
310  public: bool operator==(const URIFragment &_fragment) const;
311 
314  public: std::string Str() const;
315 
319  public: static bool Valid(const std::string &_str);
320 
323  public: bool Valid() const;
324 
328  public: bool Parse(const std::string &_string);
329 
331  GZ_UTILS_IMPL_PTR(dataPtr)
332  };
333 
338  // cppcheck-suppress class_X_Y
339  class GZ_COMMON_VISIBLE URI
340  {
342  public: URI();
343 
348  public: explicit URI(const std::string &_str,
349  bool _hasAuthority = false);
350 
356  public: std::string Str() const;
357 
359  public: void Clear();
360 
363  public: std::string Scheme() const;
364 
367  public: void SetScheme(const std::string &_scheme);
368 
371  public: void SetAuthority(const URIAuthority &_authority);
372 
378  public: std::optional<URIAuthority> Authority() const;
379 
382  public: URIPath &Path();
383 
386  public: const URIPath &Path() const;
387 
390  public: URIQuery &Query();
391 
394  public: const URIQuery &Query() const;
395 
398  public: URIFragment &Fragment();
399 
402  public: const URIFragment &Fragment() const;
403 
407  public: bool operator==(const URI &_uri) const;
408 
411  public: bool Valid() const;
412 
416  public: static bool Valid(const std::string &_str);
417 
425  public: bool Parse(const std::string &_str);
426 
428  GZ_UTILS_IMPL_PTR(dataPtr)
429  };
430  }
431 }
432 #endif