nlib
HttpStyleUri.h
Go to the documentation of this file.
1 
2 /*---------------------------------------------------------------------------*
3 
4  Project: CrossRoad
5  Copyright (C)2012-2016 Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12 
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 
23 NLIB_NAMESPACE_BEGIN
24 
26  public:
27  typedef std::pair<const char*, const char*> KeyValue;
28  HttpStyleUri() NLIB_NOEXCEPT : prv_(NULL) {}
30  bool FromUri(const Uri& uri) NLIB_NOEXCEPT;
31  bool ToUri(Uri* uri) const NLIB_NOEXCEPT;
32  bool Parse(const char* str) NLIB_NOEXCEPT;
33  bool ComposeString(
34  char* buf,
35  size_t size) const NLIB_NOEXCEPT;
36  template <size_t N>
38  char (&buf)[N]) const NLIB_NOEXCEPT {
39  return this->ComposeString(buf, N);
40  }
41  bool SetScheme(const char* scheme) NLIB_NOEXCEPT;
42  bool SetUserInfo(const char* userinfo) NLIB_NOEXCEPT;
43  bool SetHost(const char* host) NLIB_NOEXCEPT;
44  bool SetPort(int port) NLIB_NOEXCEPT;
45  bool SetPath(const char* path) NLIB_NOEXCEPT;
46  bool SetQuery(const char* query) NLIB_NOEXCEPT;
47  bool SetFragment(const char* fragment) NLIB_NOEXCEPT;
48  bool AddQuery(const char* key, const char* value) NLIB_NOEXCEPT;
49  const char* GetScheme() const NLIB_NOEXCEPT;
50  const char* GetUserInfo() const NLIB_NOEXCEPT;
51  const char* GetHost() const NLIB_NOEXCEPT;
52  int GetPort() const NLIB_NOEXCEPT;
53  size_t GetNumSegment() const NLIB_NOEXCEPT;
54  const char* GetSegment(size_t i) const NLIB_NOEXCEPT;
55  bool IsPathDirectory() const NLIB_NOEXCEPT;
56  const char* GetQueryValue(const char* key) const NLIB_NOEXCEPT;
57  size_t GetNumQuery() const NLIB_NOEXCEPT;
58  const KeyValue* GetQueryKeyValue(size_t i) const NLIB_NOEXCEPT;
59  const char* GetFragment() const NLIB_NOEXCEPT;
60  bool AddBaseUri(const Uri& relative, const HttpStyleUri& base) NLIB_NOEXCEPT;
61  void Reset() NLIB_NOEXCEPT;
62 
63  private:
64  NLIB_VIS_HIDDEN bool CheckInit() const NLIB_NOEXCEPT;
65  struct HttpStyleUriPrivate;
66  mutable HttpStyleUriPrivate* prv_;
67 };
68 
69 NLIB_NAMESPACE_END
70 #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:25
#define NLIB_VIS_HIDDEN
Symbols for functions and classes are not made available outside of the library.
Definition: Platform_unix.h:86
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:87
std::pair< const char *, const char * > KeyValue
The type that stores query keys and values.
Definition: HttpStyleUri.h:27
bool ComposeString(char(&buf)[N]) const noexcept
Calls ComposeString(buf, N).
Definition: HttpStyleUri.h:37
HttpStyleUri() noexcept
Instantiates the object with default parameters (default constructor). Initializes an object...
Definition: HttpStyleUri.h:28
#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:30
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:224