nlib
HttpStyleUri.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
4 #define INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
5 
6 #include <utility> // for std::pair
7 #include "nn/nlib/Config.h"
8 #include "nn/nlib/Uri.h"
9 
10 NLIB_NAMESPACE_BEGIN
11 
13  public:
14  typedef std::pair<const char*, const char*> KeyValue;
15  HttpStyleUri() NLIB_NOEXCEPT : prv_(NULL) {}
17  bool FromUri(const Uri& uri) NLIB_NOEXCEPT;
18  bool ToUri(Uri* uri) const NLIB_NOEXCEPT;
19  bool Parse(const char* str) NLIB_NOEXCEPT;
20  bool ComposeString(
21  char* buf,
22  size_t size) const NLIB_NOEXCEPT;
23  template <size_t N>
25  char (&buf)[N]) const NLIB_NOEXCEPT {
26  return this->ComposeString(buf, N);
27  }
28  bool SetScheme(const char* scheme) NLIB_NOEXCEPT;
29  bool SetUserInfo(const char* userinfo) NLIB_NOEXCEPT;
30  bool SetHost(const char* host) NLIB_NOEXCEPT;
31  bool SetPort(int port) NLIB_NOEXCEPT;
32  bool SetPath(const char* path) NLIB_NOEXCEPT;
33  bool SetQuery(const char* query) NLIB_NOEXCEPT;
34  bool SetFragment(const char* fragment) NLIB_NOEXCEPT;
35  bool AddQuery(const char* key, const char* value) NLIB_NOEXCEPT;
36  const char* GetScheme() const NLIB_NOEXCEPT;
37  const char* GetUserInfo() const NLIB_NOEXCEPT;
38  const char* GetHost() const NLIB_NOEXCEPT;
39  int GetPort() const NLIB_NOEXCEPT;
40  size_t GetNumSegment() const NLIB_NOEXCEPT;
41  const char* GetSegment(size_t i) const NLIB_NOEXCEPT;
42  bool IsPathDirectory() const NLIB_NOEXCEPT;
43  const char* GetQueryValue(const char* key) const NLIB_NOEXCEPT;
44  size_t GetNumQuery() const NLIB_NOEXCEPT;
45  const KeyValue* GetQueryKeyValue(size_t i) const NLIB_NOEXCEPT;
46  const char* GetFragment() const NLIB_NOEXCEPT;
47  bool AddBaseUri(const Uri& relative, const HttpStyleUri& base) NLIB_NOEXCEPT;
48  void Reset() NLIB_NOEXCEPT;
49 
50  private:
51  NLIB_VIS_HIDDEN bool CheckInit() const NLIB_NOEXCEPT;
52  struct HttpStyleUriPrivate;
53  mutable HttpStyleUriPrivate* prv_;
54 };
55 
56 NLIB_NAMESPACE_END
57 #endif // INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
The class for parsing URIs that use the http and https schemes, and for constructing URI strings...
Definition: HttpStyleUri.h:12
#define NLIB_VIS_HIDDEN
Symbols for functions and classes are not made available outside of the library.
Definition: Platform_unix.h:60
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:61
std::pair< const char *, const char * > KeyValue
The type that stores query keys and values.
Definition: HttpStyleUri.h:14
bool ComposeString(char(&buf)[N]) const noexcept
Calls ComposeString(buf, N).
Definition: HttpStyleUri.h:24
HttpStyleUri() noexcept
Instantiates the object with default parameters (default constructor). Initializes an object...
Definition: HttpStyleUri.h:15
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:86
A file that contains the configuration information for each development environment.
The class for parsing and constructing regular URIs.
Definition: Uri.h:17
Defines the class for handling URIs.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
Definition: Config.h:211