# CommandLineArguments.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/core/base/CommandLineArguments.hpp"
# CommandLineArguments
Class for storing and managing Command Line arguments.
namespace oatpp { namespace base {
class CommandLineArguments {}
}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | CommandLineArguments | Multiple implementations:
|
bool | hasArgument | Check the specified argument is present. |
v_int32 | getArgumentIndex | Get index of the argument specified by name. |
const char* | getArgumentStartingWith | Get argument which starts with the prefix. |
const char* | getNamedArgumentValue | Get value preceded by the argument. |
# CommandLineArguments::CommandLineArguments
- Default constructor.
CommandLineArguments()
- Constructor.
- @param argc - count of arguments in argv[] array.
- @param argv - array of arguments.
CommandLineArguments(int argc, const char * argv[])
# CommandLineArguments::hasArgument
Check the specified argument is present.
- @param argName - name of the target argument.
- @return -
true
if present.
bool hasArgument(const char* argName) const
# CommandLineArguments::getArgumentIndex
Get index of the argument specified by name.
- @param argName - name of the target argument.
- @return - index of the argument in argv[] array. -1 if there is no such argument.
v_int32 getArgumentIndex(const char* argName) const
# CommandLineArguments::getArgumentStartingWith
Get argument which starts with the prefix.
Example:
For command line: -k -c 1000 -n 100 'http://127.0.0.1:8000/'
getArgumentWhichStartsWith("http") == http://127.0.0.1:8000/
- @param argNamePrefix - prefix to search.
- @param defaultValue - default value to return in case not found.
- @return - argument which starts with the specified prefix. defaultValue if not found.
const char* getArgumentStartingWith(const char* argNamePrefix, const char* defaultValue = nullptr) const
# CommandLineArguments::getNamedArgumentValue
Get value preceded by the argument.
Example:
For command line: -k -c 1000 -n 100
getNamedArgumentValue("-c") == "1000"
, getNamedArgumentValue("-n") == "100"
- @param argName - name of the preceded argument.
- @param defaultValue - default value to return in case not found.
- @return - value preceded by the argument. defaultValue if not found.
const char* getNamedArgumentValue(const char* argName, const char* defaultValue = nullptr) const
# CommandLineArguments::Parser
Command Line arguments parser.
namespace oatpp { namespace base {
class CommandLineArguments {
class Parser {}
};
}}
# Methods
Return Type | Name | Summary |
---|---|---|
bool | hasArgument | Check the specified argument is present among command line arguments. |
v_int32 | getArgumentIndex | get index of the argument with the name == argName |
const char* | getArgumentStartingWith | Get argument which starts with the prefix. |
const char* | getNamedArgumentValue | Get value preceded by the argument. |
# CommandLineArguments::Parser::hasArgument
Check the specified argument is present among command line arguments.
- @param argc - count of arguments in argv array.
- @param argv - array of arguments.
- @param argName - name of the target argument.
- @return -
true
ifgetArgumentIndex(argName) >= 0
static bool hasArgument(int argc, const char * argv[], const char* argName)
# CommandLineArguments::Parser::getArgumentIndex
get index of the argument with the name == argName
static v_int32 getArgumentIndex(int argc, const char * argv[], const char* argName)
# CommandLineArguments::Parser::getArgumentStartingWith
Get argument which starts with the prefix.
Example:
For command line: -k -c 1000 -n 100 http://127.0.0.1:8000/
getArgumentWhichStartsWith("http") == http://127.0.0.1:8000/
- @param argc - count of arguments in argv array.
- @param argv - array of arguments.
- @param argNamePrefix - prefix to search.
- @param defaultValue - default value to return in case not found.
- @return - argument which starts with the specified prefix.
static const char* getArgumentStartingWith(int argc, const char * argv[], const char* argNamePrefix, const char* defaultValue = nullptr)
# CommandLineArguments::Parser::getNamedArgumentValue
Get value preceded by the argument.
Example:
For command line: -k -c 1000 -n 100
getNamedArgumentValue("-c") == "1000"
, getNamedArgumentValue("-n") == "100"
- @param argc - count of arguments in argv array.
- @param argv - array of arguments.
- @param argName - name of the preceded argument.
- @param defaultValue - default value to return in case not found.
- @return - value preceded by the argument.
static const char* getNamedArgumentValue(int argc, const char * argv[], const char* argName, const char* defaultValue = nullptr)