nlib
HttpStyleUri.h
Go to the documentation of this file.
1 
2 /*--------------------------------------------------------------------------------*
3  Project: CrossRoad
4  Copyright (C)Nintendo All rights reserved.
5 
6  These coded instructions, statements, and computer programs contain proprietary
7  information of Nintendo and/or its licensed developers and are protected by
8  national and international copyright laws. They may not be disclosed to third
9  parties or copied or duplicated in any form, in whole or in part, without the
10  prior written consent of Nintendo.
11 
12  The content herein is highly confidential and should be handled accordingly.
13  *--------------------------------------------------------------------------------*/
14 
15 #pragma once
16 #ifndef INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
17 #define INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
18 
19 #include <utility> // for std::pair
20 #include "nn/nlib/Config.h"
21 #include "nn/nlib/Uri.h"
22 #include "nn/nlib/Swap.h"
23 
24 NLIB_NAMESPACE_BEGIN
25 
27  public:
28  typedef std::pair<const char*, const char*> KeyValue;
29  HttpStyleUri() NLIB_NOEXCEPT : prv_(NULL) {}
31  NLIB_MOVE_MEMBER_HELPER_1(HttpStyleUri, prv_);
32  bool FromUri(const Uri& uri) NLIB_NOEXCEPT;
33  bool ToUri(Uri* uri) const NLIB_NOEXCEPT;
34  bool Parse(const char* str) NLIB_NOEXCEPT;
35  bool ComposeString(
36  char* buf,
37  size_t size) const NLIB_NOEXCEPT;
38  template <size_t N>
40  char (&buf)[N]) const NLIB_NOEXCEPT {
41  return this->ComposeString(buf, N);
42  }
43  bool SetScheme(const char* scheme) NLIB_NOEXCEPT;
44  bool SetUserInfo(const char* userinfo) NLIB_NOEXCEPT;
45  bool SetHost(const char* host) NLIB_NOEXCEPT;
46  bool SetPort(int port) NLIB_NOEXCEPT;
47  bool SetPath(const char* path) NLIB_NOEXCEPT;
48  bool SetQuery(const char* query) NLIB_NOEXCEPT;
49  bool SetFragment(const char* fragment) NLIB_NOEXCEPT;
50  bool AddQuery(const char* key, const char* value) NLIB_NOEXCEPT;
51  const char* GetScheme() const NLIB_NOEXCEPT;
52  const char* GetUserInfo() const NLIB_NOEXCEPT;
53  const char* GetHost() const NLIB_NOEXCEPT;
54  int GetPort() const NLIB_NOEXCEPT;
55  size_t GetNumSegment() const NLIB_NOEXCEPT;
56  const char* GetSegment(size_t i) const NLIB_NOEXCEPT;
57  bool IsPathDirectory() const NLIB_NOEXCEPT;
58  const char* GetQueryValue(const char* key) const NLIB_NOEXCEPT;
59  size_t GetNumQuery() const NLIB_NOEXCEPT;
60  const KeyValue* GetQueryKeyValue(size_t i) const NLIB_NOEXCEPT;
61  const char* GetFragment() const NLIB_NOEXCEPT;
62  bool AddBaseUri(const Uri& relative, const HttpStyleUri& base) NLIB_NOEXCEPT;
63  void Reset() NLIB_NOEXCEPT;
64  void swap(HttpStyleUri& rhs) NLIB_NOEXCEPT {
65  using std::swap;
66  swap(prv_, rhs.prv_);
67  }
68 
69  private:
70  NLIB_VIS_HIDDEN bool CheckInit() const NLIB_NOEXCEPT;
71  struct HttpStyleUriPrivate;
72  mutable HttpStyleUriPrivate* prv_;
74 };
75 
76 NLIB_NAMESPACE_END
77 NLIB_DEFINE_STD_SWAP(::nlib_ns::HttpStyleUri)
78 #endif // INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
Definition: Config.h:163
The class for parsing URIs that use the http and https schemes, and for constructing URI strings...
Definition: HttpStyleUri.h:26
#define NLIB_VIS_HIDDEN
Symbols for functions and classes are not made available outside of the library.
Definition: Platform_unix.h:88
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:89
std::pair< const char *, const char * > KeyValue
The type that stores query keys and values.
Definition: HttpStyleUri.h:28
bool ComposeString(char(&buf)[N]) const noexcept
Calls ComposeString(buf, N).
Definition: HttpStyleUri.h:39
HttpStyleUri() noexcept
Instantiates the object with default parameters (default constructor). Initializes an object...
Definition: HttpStyleUri.h:29
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:99
A file that contains the configuration information for each development environment.
The class for parsing and constructing regular URIs.
Definition: Uri.h:31
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:229