nlib
|
The class for parsing command line flags. More...
#include "nn/nlib/Nflags.h"
Static Public Member Functions | |
static errno_t | Parse (int *argc, char ***argv) noexcept |
Parses command-line flags. More... | |
static errno_t | Parse (int *argc, wchar_t ***argv) noexcept |
Parses command-line flags. More... | |
static void | PrintHelp () noexcept |
Displays command-line Help. More... | |
static const char * | GetErrorMessage () noexcept |
Gets the error message string. More... | |
static errno_t | GetFileName (const char *path, char(&filename)[kMaxFileName]) noexcept |
Gets the filename from the path string specified by the command-line string. More... | |
static errno_t | GetDirName (const char *path, char(&dirname)[kMaxDirName]) noexcept |
Gets the directory name from the path string specified by the command-line string. More... | |
static errno_t | GetStringCommaList (char *arg, char **vec, size_t vec_count, size_t *written_count) noexcept |
Breaks up comma-delimited strings (of command line arguments) and stores them in an array. More... | |
template<size_t N> | |
static errno_t | GetStringCommaList (char *arg, char *(&vec)[N], size_t *written_count) noexcept |
The function template version of GetStringCommaList . | |
static errno_t | GetInt32CommaList (char *arg, int32_t *vec, size_t vec_count, size_t *written_count) noexcept |
Breaks up comma-delimited strings (of command-line arguments), converts them into integers, and stores them in an array. More... | |
template<size_t N> | |
static errno_t | GetInt32CommaList (char *arg, int32_t(&vec)[N], size_t *written_count) noexcept |
The function template version of GetInt32CommaList . | |
static errno_t | GetDoubleCommaList (char *arg, double *vec, size_t vec_count, size_t *written_count) noexcept |
Breaks up comma-delimited strings (of command-line arguments), converts them into double type, and stores them in an array. More... | |
template<size_t N> | |
static errno_t | GetDoubleCommaList (char *arg, double(&vec)[N], size_t *written_count) noexcept |
The function template version of GetDoubleCommaList . | |
static bool | GetBoolFromEnv (const char *varname, bool defval) noexcept |
Parses an environment variable value and returns a boolean value. Returns the default value if the environment variable does not exist or could not be parsed. More... | |
static int32_t | GetInt32FromEnv (const char *varname, int32_t defval) noexcept |
Parses an environment variable value and returns an int32_t value. Returns the default value if the environment variable does not exist or could not be parsed. More... | |
static int64_t | GetInt64FromEnv (const char *varname, int64_t defval) noexcept |
Parses an environment variable value and returns an int64_t value. Returns the default value if the environment variable does not exist or could not be parsed. More... | |
static double | GetDoubleFromEnv (const char *varname, double defval) noexcept |
Parses an environment variable value and returns a double value. Returns the default value if the environment variable does not exist or could not be parsed. More... | |
static const char * | GetStringFromEnv (UniquePtr< char[]> &buf, const char *varname, const char *defval) noexcept |
Returns an environment variable value as a string. The buffer allocated for storing the string is stored in buf. More... | |
The class for parsing command line flags.
Nflags
you can distribute the command line flag definitions to multiple files. Using this property, you can set command-line arguments in various libraries and modules, which makes it easy to customize how a program starts from the command line without recompiling. Nflags
. For more information, see the function and macro references.
|
staticnoexcept |
Parses an environment variable value and returns a boolean value. Returns the default value if the environment variable does not exist or could not be parsed.
[in] | varname | The name of the environment variable. |
[in] | defval | The default return value. |
true
if the environment variable value is "1", "t", "true", "y", or "yes". Returns false
if the value is "0", "f", "false", "n", or "no". Returns defval otherwise.
|
staticnoexcept |
Gets the directory name from the path string specified by the command-line string.
[in] | path | The path string. |
[out] | dirname | The directory name string. |
0
on success.
|
staticnoexcept |
Breaks up comma-delimited strings (of command-line arguments), converts them into double
type, and stores them in an array.
N | The maximum number of numerical value lists stored. |
[in,out] | arg | Comma-delimited strings. |
[out] | vec | The array storing the numerical values. |
[in] | vec_count | The size of the vec array. |
[out] | written_count | The number of stored values. |
0 | No error occurred. |
EINVAL | NULL or 0 was passed to the argument. |
ERANGE | The number of comma-delimited strings exceeds the number of elements of vec. |
EILSEQ | The comma-delimited string could be converted into numerical values. |
|
staticnoexcept |
Parses an environment variable value and returns a double value. Returns the default value if the environment variable does not exist or could not be parsed.
[in] | varname | The name of the environment variable. |
[in] | defval | The default return value. |
|
staticnoexcept |
Gets the error message string.
Parse
function. You can use this function to reference that string.
|
staticnoexcept |
Gets the filename from the path string specified by the command-line string.
[in] | path | The path string. |
[out] | filename | The filename string. |
0
on success.
|
staticnoexcept |
Breaks up comma-delimited strings (of command-line arguments), converts them into integers, and stores them in an array.
N | The maximum number of integer lists stored. |
[in,out] | arg | Comma-delimited strings. |
[out] | vec | An array storing the integers. |
[in] | vec_count | The size of the vec array. |
[out] | written_count | The number of stored integers. |
0 | No error occurred. |
EINVAL | NULL or 0 was passed to the argument. |
ERANGE | The number of comma-delimited strings exceeds the number of elements of vec. |
EILSEQ | The comma-delimited string could be converted into integers. |
|
staticnoexcept |
Parses an environment variable value and returns an int32_t value. Returns the default value if the environment variable does not exist or could not be parsed.
[in] | varname | The name of the environment variable. |
[in] | defval | The default return value. |
|
staticnoexcept |
Parses an environment variable value and returns an int64_t value. Returns the default value if the environment variable does not exist or could not be parsed.
[in] | varname | The name of the environment variable. |
[in] | defval | The default return value. |
|
staticnoexcept |
Breaks up comma-delimited strings (of command line arguments) and stores them in an array.
N | The maximum number of string lists stored. |
[in,out] | arg | Comma-delimited strings. |
[out] | vec | An array storing pointers to the strings. |
[in] | vec_count | The size of the vec array. |
[out] | written_count | The number of stored strings. |
0 | Success. |
EINVAL | NULL or 0 was passed to the argument. |
ERANGE | The number of comma-delimited strings exceeds the number of elements of vec. |
--file=file1.txt,file2.txt,file3.txt
command-line flag arguments.
|
staticnoexcept |
Returns an environment variable value as a string. The buffer allocated for storing the string is stored in buf.
[in,out] | buf | Dynamically allocated internal memory. |
[in] | varname | The name of the environment variable. |
[in] | defval | The default return value. |
|
staticnoexcept |
Parses command-line flags.
[in,out] | argc | Pointers to the number of command-line flags. |
[in,out] | argv | Pointers to the command-line flags. |
0 | Parsing was successful. |
EILSEQ | Invalid format. |
ENOENT | The specified option does not exist. |
main
function are passed to the function. The parameters are parsed, the defined options are discovered, and the variables are set.
|
staticnoexcept |
Parses command-line flags.
[in,out] | argc | Pointers to the number of command-line flags. |
[in,out] | argv | Pointers to the command-line flags. |
0 | Parsing was successful. |
EILSEQ | Invalid format. |
ENOENT | The specified option does not exist. |
main
function are passed to the function. The parameters are parsed, the defined options are discovered, and the variables are set.
|
staticnoexcept |
Displays command-line Help.
NLIB_FLAGS_help
is true
after the command line has been parsed, and then end the program. If this function is not called, the command-line Help is not displayed even if the --help
option has been specified. © 2013, 2014, 2015 Nintendo Co., Ltd. All rights reserved.