nlib
UriTemplate.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_URITEMPLATE_H_
4 #define INCLUDE_NN_NLIB_URITEMPLATE_H_
5 
6 #include "nn/nlib/Uri.h"
7 #include "nn/nlib/Nlist.h"
8 #include "nn/nlib/UniquePtr.h"
9 
10 NLIB_NAMESPACE_BEGIN
11 
12 class OutputStream;
13 
14 // See RFC6570: https://tools.ietf.org/html/rfc6570
16  public:
19  NLIB_VIS_PUBLIC errno_t SetTemplate(const char* str) NLIB_NOEXCEPT;
20  NLIB_VIS_PUBLIC errno_t SetParameter(const char* param, const char* value) NLIB_NOEXCEPT;
21  void ResetParameter() NLIB_NOEXCEPT {
22  StringList<> tmp;
23  tmp.swap(m_Pv);
24  }
26 
27  NLIB_VIS_PUBLIC bool Resolve(char* str, size_t n) const NLIB_NOEXCEPT;
28  template <size_t N>
29  bool Resolve(char (&str)[N]) const NLIB_NOEXCEPT {
30  return Resolve(&str[0], N);
31  }
32 
33  private:
34  UniquePtr<char[]> m_Template;
35  StringList<> m_Pv;
37 };
38 
39 NLIB_NAMESPACE_END
40 
41 #endif // INCLUDE_NN_NLIB_URITEMPLATE_H_
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Platform.h:2151
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
#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:126
Defines that class that is corresponding to std::unique_ptr.
The class that supports URI Template (RFC 6570, Level 3).
Definition: UriTemplate.h:15
Defines the class that resembles std::vector but can store objects that cannot be copied...
void ResetParameter() noexcept
Clears all settings for parameters and their values.
Definition: UriTemplate.h:21
bool Resolve(char(&str)[N]) const noexcept
Definition: UriTemplate.h:29
Defines the class for handling URIs.
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:51
The base class for output streams. This class cannot be instantiated.
Definition: OutputStream.h:17
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:24