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: 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 
105  private: std::unique_ptr<URIPathPrivate> dataPtr;
106  };
107 
109  class GZ_COMMON_VISIBLE URIQuery
110  {
112  public: URIQuery();
113 
116  public: URIQuery(const std::string &_str);
117 
120  public: URIQuery(const URIQuery &_query);
121 
123  public: virtual ~URIQuery();
124 
126  public: void Clear();
127 
131  public: void Insert(const std::string &_key,
132  const std::string &_value);
133 
137  public: URIQuery &operator=(const URIQuery &_query);
138 
142  public: bool operator==(const URIQuery &_query) const;
143 
148  public: std::string Str(const std::string &_delim = "&") const;
149 
153  public: static bool Valid(const std::string &_str);
154 
157  public: bool Valid() const;
158 
162  public: bool Parse(const std::string &_string);
163 
166  private: std::unique_ptr<URIQueryPrivate> dataPtr;
167  };
168 
170  class GZ_COMMON_VISIBLE URI
171  {
173  public: URI();
174 
177  public: URI(const std::string &_str);
178 
181  public: URI(const URI &_uri);
182 
184  public: ~URI();
185 
191  public: std::string Str() const;
192 
194  public: void Clear();
195 
198  public: std::string Scheme() const;
199 
202  public: void SetScheme(const std::string &_scheme);
203 
206  public: URIPath &Path();
207 
210  public: URIQuery &Query();
211 
215  public: URI &operator=(const URI &_uri);
216 
220  public: bool operator==(const URI &_uri) const;
221 
224  public: bool Valid() const;
225 
229  public: static bool Valid(const std::string &_str);
230 
234  public: bool Parse(const std::string &_str);
235 
238  private: std::unique_ptr<URIPrivate> dataPtr;
239  };
240  }
241 }
242 #endif
243 
A complete URI.
Definition: URI.hh:170
The path component of a URI.
Definition: URI.hh:35
The query component of a URI.
Definition: URI.hh:109