3 #ifndef INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
4 #define INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
15 typedef std::pair<const char*, const char*>
KeyValue;
22 NLIB_VIS_PUBLIC bool ComposeString(
char* buf,
size_t size) const NLIB_NOEXCEPT;
24 bool ComposeString(
char (&buf)[N]) const NLIB_NOEXCEPT {
25 return this->ComposeString(buf, N);
32 bool SetQuery(
const char* query) NLIB_NOEXCEPT {
return m_Query.Set(query); }
34 bool AddQuery(
const char* key,
const char* value) NLIB_NOEXCEPT {
35 return m_Query.Add(key, value);
38 return m_IsSchemeHttps ?
"https" :
"http";
40 const char*
GetUserInfo() const NLIB_NOEXCEPT {
return m_UserInfo.get(); }
41 const char*
GetHost() const NLIB_NOEXCEPT {
return m_Host.get(); }
42 int GetPort() const NLIB_NOEXCEPT {
return m_Port; }
44 return m_Segments.GetNumSegment();
47 return m_Segments.GetSegment(i);
50 return m_Segments.IsDirectory();
53 return m_Query.GetValue(key);
55 size_t GetNumQuery() const NLIB_NOEXCEPT {
return m_Query.GetNumQuery(); }
57 return m_Query.GetKeyValue(i);
59 const char*
GetFragment() const NLIB_NOEXCEPT {
return m_Fragment.get(); }
64 bool ComposeQuery(
char* first,
char* last) const NLIB_NOEXCEPT {
65 return m_Query.Compose(&first, last);
71 UniquePtr<char[]> m_UserInfo;
72 UniquePtr<char[]> m_Host;
73 UniquePtr<char[]> m_Fragment;
74 detail::Segments m_Segments;
75 detail::Query m_Query;
79 #endif // INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
const KeyValue * GetQueryKeyValue(size_t i) const noexcept
Specifies an index and gets a key/value pair. If not found, returns NULL.
bool AddQuery(const char *key, const char *value) noexcept
Adds a key and value to a query.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
bool SetQuery(const char *query) noexcept
Sets a query based on a query string.
Defines that class that is corresponding to std::unique_ptr.
The class for parsing URIs that use the http and https schemes, and for constructing URI strings...
size_t GetNumQuery() const noexcept
Gets the value corresponding to the key. If not found, returns NULL.
const char * GetScheme() const noexcept
Gets the name of the URI scheme. The name is either http or https.
std::pair< const char *, const char * > KeyValue
The type that stores query keys and values.
HttpStyleUri() noexcept
Instantiates the object with default parameters (default constructor). Initializes an object...
int GetPort() const noexcept
Gets the port number.
const char * GetSegment(size_t i) const noexcept
Specifies an index and gets a segment.
const char * GetUserInfo() const noexcept
Gets the user information.
const char * GetHost() const noexcept
Gets the hostname.
bool IsPathDirectory() const noexcept
Gets whether the path is in the form of a directory path.
The class for parsing and constructing regular URIs.
size_t GetNumSegment() const noexcept
Gets the number of stored segments.
Defines the class for handling URIs.
const char * GetFragment() const noexcept
Gets a fragment string.
const char * GetQueryValue(const char *key) const noexcept
Specifies a key and gets a value. If not found, returns NULL.