nlib
HttpStyleUri.h
[詳解]
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;
30  ~HttpStyleUri() NLIB_NOEXCEPT { Reset(); }
31  NLIB_DEFMOVE_PIMPL(HttpStyleUri);
32  bool FromUri(const Uri& uri) NLIB_NOEXCEPT;
33  bool ToUri(Uri* uri) const NLIB_NOEXCEPT;
34  bool Parse(const char* first, const char* last) NLIB_NOEXCEPT;
35  bool Parse(const char* str) NLIB_NOEXCEPT {
36  return Parse(str, str + nlib_strlen(str));
37  }
38  bool ComposeString(
39  char* buf,
40  size_t size) const NLIB_NOEXCEPT;
41  template <size_t N>
43  char (&buf)[N]) const NLIB_NOEXCEPT {
44  return this->ComposeString(buf, N);
45  }
46  bool SetScheme(const char* scheme) NLIB_NOEXCEPT;
47  bool SetUserInfo(const char* userinfo) NLIB_NOEXCEPT;
48  bool SetHost(const char* host) NLIB_NOEXCEPT;
49  bool SetPort(int port) NLIB_NOEXCEPT;
50  bool SetPath(const char* path) NLIB_NOEXCEPT;
51  bool SetQuery(const char* query) NLIB_NOEXCEPT;
52  bool SetFragment(const char* fragment) NLIB_NOEXCEPT;
53  bool AddQuery(const char* key, const char* value) NLIB_NOEXCEPT;
54  const char* GetScheme() const NLIB_NOEXCEPT;
55  const char* GetUserInfo() const NLIB_NOEXCEPT;
56  const char* GetHost() const NLIB_NOEXCEPT;
57  int GetPort() const NLIB_NOEXCEPT;
58  size_t GetNumSegment() const NLIB_NOEXCEPT;
59  const char* GetSegment(size_t i) const NLIB_NOEXCEPT;
60  bool IsPathDirectory() const NLIB_NOEXCEPT;
61  const char* GetQueryValue(const char* key) const NLIB_NOEXCEPT;
62  size_t GetNumQuery() const NLIB_NOEXCEPT;
63  const KeyValue* GetQueryKeyValue(size_t i) const NLIB_NOEXCEPT;
64  const char* GetFragment() const NLIB_NOEXCEPT;
65  bool AddBaseUri(const Uri& relative, const HttpStyleUri& base) NLIB_NOEXCEPT;
66  void Reset() NLIB_NOEXCEPT;
67  NLIB_DEPRECATED void swap(HttpStyleUri& rhs) NLIB_NOEXCEPT {
68  using std::swap;
69  swap(prv_, rhs.prv_);
70  }
71 
72  private:
73  NLIB_VIS_HIDDEN bool CheckInit() const NLIB_NOEXCEPT;
74  struct HttpStyleUriPrivate;
75  mutable HttpStyleUriPrivate* prv_;
77 };
78 
79 NLIB_NAMESPACE_END
80 #ifndef __cpp_rvalue_references
81 NLIB_DEFINE_STD_SWAP(::nlib_ns::HttpStyleUri)
82 #endif
83 #endif // INCLUDE_NN_NLIB_HTTPSTYLEURI_H_
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
Definition: Config.h:179
http/httpsスキームを用いたURIをパースしたりURI文字列を構築したりするためのクラスです。 ...
Definition: HttpStyleUri.h:26
bool Parse(const char *str) noexcept
Parse(str, str + nlib_strlen(str))を返します。
Definition: HttpStyleUri.h:35
#define NLIB_VIS_HIDDEN
関数やクラス等のシンボルをライブラリの外部に公開しません。
Definition: Platform_unix.h:88
#define NLIB_DEPRECATED
関数等がdeprecatedになったことを示します。
Definition: Config.h:109
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:89
std::pair< const char *, const char * > KeyValue
クエリのキーと値を格納する型です。
Definition: HttpStyleUri.h:28
bool ComposeString(char(&buf)[N]) const noexcept
ComposeString(buf, N) を呼び出します。
Definition: HttpStyleUri.h:42
constexpr HttpStyleUri() noexcept
デフォルトコンストラクタです。オブジェクトを初期化します。
Definition: HttpStyleUri.h:29
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:105
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
Definition: Config.h:107
開発環境別の設定が書かれるファイルです。
一般的なURIをパースしたり構築したりするためのクラスです。
Definition: Uri.h:51
URIを扱うためのクラスを定義しています。
size_t nlib_strlen(const char *s)
内部でstrlen()を呼び出します。独自の実装が動作する場合もあります。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:245