AWS SDK for C++  0.14.3
AWS SDK for C++
URI.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-201 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <aws/core/Core_EXPORTS.h>
19 
20 #include <aws/core/http/Scheme.h>
23 
24 #include <stdint.h>
25 
26 namespace Aws
27 {
28  namespace Http
29  {
30  extern AWS_CORE_API const char* SEPARATOR;
31  static const uint16_t HTTP_DEFAULT_PORT = 80;
32  static const uint16_t HTTPS_DEFAULT_PORT = 443;
33 
35 
40  {
41  public:
45  URI();
49  URI(const Aws::String&);
53  URI(const char*);
54 
55  URI& operator = (const Aws::String&);
56  URI& operator = (const char*);
57 
58  bool operator == (const URI&) const;
59  bool operator == (const Aws::String&) const;
60  bool operator == (const char*) const;
61  bool operator != (const URI&) const;
62  bool operator != (const Aws::String&) const;
63  bool operator != (const char*) const;
64 
68  inline Scheme GetScheme() const { return m_scheme; }
69 
73  void SetScheme(Scheme value);
74 
78  inline const Aws::String& GetAuthority() const { return m_authority; }
79 
83  inline void SetAuthority(const Aws::String& value) { m_authority = value; }
84 
88  inline uint16_t GetPort() const { return m_port; }
89 
94  inline void SetPort(uint16_t value) { m_port = value; }
95 
100  inline const Aws::String& GetPath() const { return m_path; }
101 
105  inline Aws::String GetURLEncodedPath() const { return URLEncodePath(m_path); }
106 
110  void SetPath(const Aws::String& value);
111 
115  inline const Aws::String& GetQueryString() const { return m_queryString; }
116 
117  Aws::String GetFormParameters() const;
118 
122  void CanonicalizeQueryString();
123 
128  QueryStringParameterCollection GetQueryStringParameters(bool decode = true) const;
129 
133  void AddQueryStringParameter(const char* key, const Aws::String& value);
134 
138  Aws::String GetURIString(bool includeQueryString = true) const;
139 
143  static Aws::String URLEncodePath(const Aws::String& path);
144 
145  private:
146  void ParseURIParts(const Aws::String& uri);
147  void ExtractAndSetScheme(const Aws::String& uri);
148  void ExtractAndSetAuthority(const Aws::String& uri);
149  void ExtractAndSetPort(const Aws::String& uri);
150  void ExtractAndSetPath(const Aws::String& uri);
151  void ExtractAndSetQueryString(const Aws::String& uri);
152  bool CompareURIParts(const URI& other) const;
153 
154  Scheme m_scheme;
155  Aws::String m_authority;
156  uint16_t m_port;
157  Aws::String m_path;
158  Aws::String m_queryString;
159  };
160 
161  } // namespace Http
162 } // namespace Aws
163 
const Aws::String & GetAuthority() const
Definition: URI.h:78
const Aws::String & GetQueryString() const
Definition: URI.h:115
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition: AWSMap.h:28
const Aws::String & GetPath() const
Definition: URI.h:100
static const uint16_t HTTP_DEFAULT_PORT
Definition: URI.h:31
Scheme GetScheme() const
Definition: URI.h:68
Aws::Map< Aws::String, Aws::String > QueryStringParameterCollection
Definition: URI.h:34
uint16_t GetPort() const
Definition: URI.h:88
void SetPort(uint16_t value)
Definition: URI.h:94
AWS_CORE_API const char * SEPARATOR
Aws::String GetURLEncodedPath() const
Definition: URI.h:105
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
static const uint16_t HTTPS_DEFAULT_PORT
Definition: URI.h:32
void SetAuthority(const Aws::String &value)
Definition: URI.h:83
#define AWS_CORE_API
Definition: Core_EXPORTS.h:35
JSON (JavaScript Object Notation).