The class for getting the native path string from the URI path notation that is not machine-dependent.
More...
#include "nn/nlib/NativePathMapper.h"
|
errno_t | AddMap (const char *native_prefix, const char *uri_prefix) noexcept |
| Registers the prefix of the native path string and the prefix of the corresponding URI path string. More...
|
|
errno_t | ResolvePath (size_t *count, char *native, size_t n, const char *uri_path) const noexcept |
| Converts a URI path string into a native path string. More...
|
|
template<size_t N> |
errno_t | ResolvePath (size_t *count, char(&native)[N], const char *uri_path) const noexcept |
| Returns ResolvePath(count, native, N, uri_path) .
|
|
|
| NativePathMapper () noexcept |
| Instantiates the object.
|
|
| ~NativePathMapper () noexcept |
| Destructor.
|
|
The class for getting the native path string from the URI path notation that is not machine-dependent.
- Description
- The path strings passed to nlib functions should be formatted in the native format of the operating system that you are running. This simplifies use of nlib on a single platform but may cause issues when writing programs for multiple platforms. Use the
NativePathMapper
class to convert URIs to native path strings. This allows you to avoid having to write separate code for addressing path strings on each platform.
Definition at line 10 of file NativePathMapper.h.
§ AddMap()
nn::nlib::NativePathMapper::AddMap |
( |
const char * |
native_prefix, |
|
|
const char * |
uri_prefix |
|
) |
| |
|
noexcept |
Registers the prefix of the native path string and the prefix of the corresponding URI path string.
- Parameters
-
[in] | native_prefix | The native path string prefix. |
[in] | uri_prefix | The path string prefix of the URI corresponding to nativePrefix. |
- Return values
-
0 | Success. |
EINVAL | Indicates that nativePrefix or uriPrefix is NULL , an empty string, or an invalid UTF-8 string. |
EINVAL | Indicates that uriPrefix is not a URI string. |
EINVAL | Indicates that the URI scheme of uriPrefix is not nlibpath . |
EINVAL | Indicates that uriPrefix is not an absolute path. |
ENOMEM | Indicates that internal memory allocation failed. |
- Description
- The hostname, query, and fragment parts of uriPrefix are ignored.
§ ResolvePath()
nn::nlib::NativePathMapper::ResolvePath |
( |
size_t * |
count, |
|
|
char * |
native, |
|
|
size_t |
n, |
|
|
const char * |
uri_path |
|
) |
| const |
|
noexcept |
Converts a URI path string into a native path string.
- Parameters
-
[out] | count | The number of bytes in the written string (not including the terminating null character). |
[out] | native | The buffer to which the native path string is written. |
[in] | n | The size of the buffer. |
[in] | uri_path | A URI path string. |
- Return values
-
0 | Success. |
EINVAL | Indicates that native is NULL and n is not 0 . |
EINVAL | Indicates that uriPath is NULL or an empty string or an invalid UTF-8 string. |
EINVAL | Indicates that uriPrefix is not a URI string. |
EINVAL | Indicates that the URI scheme of uriPath is not nlibpath . |
ESRCH | Indicates that the native path string corresponding to the URI is not registered. |
ERANGE | Indicates that the buffer for native is not large enough. |
ENOMEM | Indicates that internal memory allocation failed. |
- Description
- The hostname, query, and fragment parts of uriPath are ignored. You can get the number of bytes in the path string after it has been converted by calling this function with native set to
NULL
and n set to 0
.
- Be careful about storing UTF-8 strings even with the Windows version.
The documentation for this class was generated from the following files: