Parser
- Added static method to scan argv[] for overrides without a parse tree, so that any rc:<file> arguments can be used to locate the rc file, load it, and proceed with command line parsing which relies on things like rc.dateformat.
This commit is contained in:
@@ -62,6 +62,26 @@ Parser::~Parser ()
|
|||||||
delete _tree;
|
delete _tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Static method.
|
||||||
|
void Parser::getOverrides (
|
||||||
|
int argc,
|
||||||
|
const char** argv,
|
||||||
|
std::string& rc_file)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < argc; ++i)
|
||||||
|
{
|
||||||
|
std::string raw = argv[i];
|
||||||
|
if (raw.length () > 3 &&
|
||||||
|
raw.substr (0, 3) == "rc:")
|
||||||
|
{
|
||||||
|
rc_file = raw.substr (3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep looping, so we capture the last one.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// char** argv --> std::vector <std::string> _args
|
// char** argv --> std::vector <std::string> _args
|
||||||
void Parser::initialize (int argc, const char** argv)
|
void Parser::initialize (int argc, const char** argv)
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ class Parser
|
|||||||
public:
|
public:
|
||||||
Parser ();
|
Parser ();
|
||||||
~Parser ();
|
~Parser ();
|
||||||
|
|
||||||
|
static void getOverrides (int, const char**, std::string&);
|
||||||
|
|
||||||
void initialize (int, const char**);
|
void initialize (int, const char**);
|
||||||
void clear ();
|
void clear ();
|
||||||
void appendStdin ();
|
void appendStdin ();
|
||||||
|
|||||||
Reference in New Issue
Block a user