The class for parsing URIs that use the file scheme and for constructing URI strings.
More...
#include "nn/nlib/FileStyleUri.h"
|
constexpr | FileStyleUri () noexcept |
| Instantiates the object with default parameters (default constructor). Initializes an object.
|
|
bool | FromUri (const Uri &uri) noexcept |
| Converts from a URI object. More...
|
|
bool | ToUri (Uri *uri) const noexcept |
| Converts to a URI object. More...
|
|
bool | Parse (const char *first, const char *last) noexcept |
| Parses a URI string. More...
|
|
bool | Parse (const char *str) noexcept |
| Returns Parse(str, str + nlib_strlen(str)) .
|
|
bool | ComposeString (char *buf, size_t size) const noexcept |
| Writes a URI string. More...
|
|
template<size_t N> |
bool | ComposeString (char(&buf)[N]) const noexcept |
| Writes a URI string. More...
|
|
bool | SetPath (const char *path) noexcept |
| Sets a path. More...
|
|
size_t | GetNumSegment () const noexcept |
| Gets the number of stored segments. More...
|
|
const char * | GetSegment (size_t i) const noexcept |
| Specifies an index and gets a segment. More...
|
|
bool | AddBaseUri (const Uri &relative, const FileStyleUri &base) noexcept |
| Resolves the relative path using the base URI. More...
|
|
void | Reset () noexcept |
| Initializes (resets) an object.
|
|
bool | IsPathDirectory () const noexcept |
| Gets whether the path is in the form of a directory path. More...
|
|
The class for parsing URIs that use the file scheme and for constructing URI strings.
- Deprecated:
- This class will be deleted in a future implementation. Use
Uri
, Uri::EncodePath()
, and Uri::DecodePath()
instead.
- Description
- The URI string of characters is checked, divided up, normalized, and stored. During parsing, partial strings such as the "../" and "./" dot-segments are normalized and then the whole string is divided into segments and stored. For example, a path like
/test/../../../a/b/c
would be normalized to /a/b/c
and then divided into segments and stored. The percent-encoded characters in each segment are decoded.
- This class ignores hostnames, query strings and fragments.
- The following are examples of file scheme URIs.
- The vertical bar character (" | ") does not conform with RFC 3986, so it cannot be parsed in strings like the following.
Definition at line 25 of file FileStyleUri.h.
◆ AddBaseUri()
nn::nlib::FileStyleUri::AddBaseUri |
( |
const Uri & |
relative, |
|
|
const FileStyleUri & |
base |
|
) |
| |
|
noexcept |
Resolves the relative path using the base URI.
- Parameters
-
[in] | relative | A relative path. |
[in] | base | A base URI. |
- Returns
- Returns
true
when successful.
- Description
- If the function succeeds, the relative path gets stored in the object.
◆ ComposeString() [1/2]
nn::nlib::FileStyleUri::ComposeString |
( |
char * |
buf, |
|
|
size_t |
size |
|
) |
| const |
|
noexcept |
Writes a URI string.
- Parameters
-
[out] | buf | The pointer to the buffer to which the string was written. |
[in] | size | The size of the buffer. |
- Returns
- Returns
true
when successful.
- Description
- This function uses of the
ToUri
and Uri::ComposeString
functions.
◆ ComposeString() [2/2]
template<size_t N>
nn::nlib::FileStyleUri::ComposeString |
( |
char(&) |
buf[N] | ) |
const |
|
inlinenoexcept |
Writes a URI string.
- Parameters
-
[out] | buf | The buffer to which the string was written. |
- Returns
- Returns
true
when successful.
Definition at line 44 of file FileStyleUri.h.
◆ FromUri()
nn::nlib::FileStyleUri::FromUri |
( |
const Uri & |
uri | ) |
|
|
noexcept |
Converts from a URI object.
- Parameters
-
[in] | uri | The reference to the URI object. |
- Returns
- Returns
true
when successful.
- Description
- During this URI conversion process, strings other than the path are ignored.
◆ GetNumSegment()
nn::nlib::FileStyleUri::GetNumSegment |
( |
| ) |
const |
|
noexcept |
Gets the number of stored segments.
- Returns
- The number of segments.
◆ GetSegment()
nn::nlib::FileStyleUri::GetSegment |
( |
size_t |
i | ) |
const |
|
noexcept |
Specifies an index and gets a segment.
- Parameters
-
[in] | i | The index for a segment. |
- Returns
- The string of the specified segment.
- Description
- If the function could get the specified segment, it returns the pointer to that string. If it failed, it returns
NULL
. The segment string is percent-encoded.
◆ IsPathDirectory()
nn::nlib::FileStyleUri::IsPathDirectory |
( |
| ) |
const |
|
noexcept |
Gets whether the path is in the form of a directory path.
- Returns
- Returns
true
if the path is a directory path.
- Description
- Returns whether the path string ends with a forward slash ( '/' ).
◆ Parse()
nn::nlib::FileStyleUri::Parse |
( |
const char * |
first, |
|
|
const char * |
last |
|
) |
| |
|
noexcept |
Parses a URI string.
- Parameters
-
[in] | first | The first character of the string you want to parse. |
[in] | last | The last character of the string you want to parse. |
- Returns
- Returns
true
when successful.
- Description
- This function uses of the
Uri::Parse
and FromUri
functions. The query and fragment sections of the URI are discarded.
◆ SetPath()
nn::nlib::FileStyleUri::SetPath |
( |
const char * |
path | ) |
|
|
noexcept |
Sets a path.
- Parameters
-
- Returns
- Returns
true
when successful.
- Description
- The path is decomposed into its fragments and stored. The forward slash ( '/') is used as the delimiter. You cannot use '\' for this purpose. In addition, percent-encoding is not required (with the exception of '/').
◆ ToUri()
nn::nlib::FileStyleUri::ToUri |
( |
Uri * |
uri | ) |
const |
|
noexcept |
Converts to a URI object.
- Parameters
-
[out] | uri | Pointer to the URI object. |
- Returns
- Returns
true
when successful.
The documentation for this class was generated from the following files: