|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58134 - in trunk: boost/program_options libs/program_options/test
From: s.ochsenknecht_at_[hidden]
Date: 2009-12-04 05:15:13
Author: s_ochsenknecht
Date: 2009-12-04 05:15:11 EST (Fri, 04 Dec 2009)
New Revision: 58134
URL: http://svn.boost.org/trac/boost/changeset/58134
Log:
Changed defaults for split_unix() function to be more compliant to unix command line style
Text files modified:
trunk/boost/program_options/parsers.hpp | 8 ++++----
trunk/libs/program_options/test/split_test.cpp | 21 +++++++++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
Modified: trunk/boost/program_options/parsers.hpp
==============================================================================
--- trunk/boost/program_options/parsers.hpp (original)
+++ trunk/boost/program_options/parsers.hpp 2009-12-04 05:15:11 EST (Fri, 04 Dec 2009)
@@ -210,14 +210,14 @@
and escape characters '\'
*/
BOOST_PROGRAM_OPTIONS_DECL std::vector<std::string>
- split_unix(const std::string& cmdline, const std::string& seperator = " ",
- const std::string& quote = "\"", const std::string& escape = "\\");
+ split_unix(const std::string& cmdline, const std::string& seperator = " \t",
+ const std::string& quote = "'\"", const std::string& escape = "\\");
#ifndef BOOST_NO_STD_WSTRING
/** @overload */
BOOST_PROGRAM_OPTIONS_DECL std::vector<std::wstring>
- split_unix(const std::wstring& cmdline, const std::wstring& seperator = L" ",
- const std::wstring& quote = L"\"", const std::wstring& escape = L"\\");
+ split_unix(const std::wstring& cmdline, const std::wstring& seperator = L" \t",
+ const std::wstring& quote = L"'\"", const std::wstring& escape = L"\\");
#endif
#ifdef _WIN32
Modified: trunk/libs/program_options/test/split_test.cpp
==============================================================================
--- trunk/libs/program_options/test/split_test.cpp (original)
+++ trunk/libs/program_options/test/split_test.cpp 2009-12-04 05:15:11 EST (Fri, 04 Dec 2009)
@@ -148,6 +148,26 @@
notify(vm);
}
+void split_defaults(const options_description& description)
+{
+ const char* cmdline = "prg --input \t \'input file.txt\' \t --optimization 4 --opt \\\"option1\\ option2\\\"";
+
+ vector< string > tokens = split_unix(cmdline);
+
+ BOOST_REQUIRE(tokens.size() == 7);
+ check_value(tokens[0], "prg");
+ check_value(tokens[1], "--input");
+ check_value(tokens[2], "input file.txt");
+ check_value(tokens[3], "--optimization");
+ check_value(tokens[4], "4");
+ check_value(tokens[5], "--opt");
+ check_value(tokens[6], "\"option1 option2\"");
+
+ variables_map vm;
+ store(command_line_parser(tokens).options(description).run(), vm);
+ notify(vm);
+}
+
int main(int /*ac*/, char** /*av*/)
{
options_description desc;
@@ -163,6 +183,7 @@
split_quotes(desc);
split_escape(desc);
split_single_quote(desc);
+ split_defaults(desc);
return 0;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk