From fc3de8c1509c4fec4b924c711488f67d964bf8d6 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 2 Dec 2009 09:39:39 +0000 Subject: [PATCH] new method getLongArg that grabs all the remainder of the argument string git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32283 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/FuncRequest.cpp | 25 +++++++++++++++++++++++-- src/FuncRequest.h | 4 ++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/FuncRequest.cpp b/src/FuncRequest.cpp index 3eb0990a01..eeebca2891 100644 --- a/src/FuncRequest.cpp +++ b/src/FuncRequest.cpp @@ -13,11 +13,14 @@ #include "FuncRequest.h" #include "LyXAction.h" +#include "support/lstrings.h" + #include #include #include using namespace std; +using namespace lyx::support; namespace lyx { @@ -71,10 +74,19 @@ mouse_button::state FuncRequest::button() const } -void splitArg(vector & args, string const & str) +namespace { + +void splitArg(vector & args, string const & str, unsigned int max) { istringstream is(str); while (is) { + if (args.size() == max) { + string s; + getline(is, s); + args.push_back(trim(s)); + return; + } + char c; string s; is >> c; @@ -90,11 +102,20 @@ void splitArg(vector & args, string const & str) } } +} string FuncRequest::getArg(unsigned int i) const { vector args; - splitArg(args, to_utf8(argument_)); + splitArg(args, to_utf8(argument_), string::npos); + return i < args.size() ? args[i] : string(); +} + + +string FuncRequest::getLongArg(unsigned int i) const +{ + vector args; + splitArg(args, to_utf8(argument_), i); return i < args.size() ? args[i] : string(); } diff --git a/src/FuncRequest.h b/src/FuncRequest.h index 799fdd6a82..993f0a24bb 100644 --- a/src/FuncRequest.h +++ b/src/FuncRequest.h @@ -64,6 +64,10 @@ public: /// argument parsing, extract argument i as std::string std::string getArg(unsigned int i) const; + /// argument parsing, extract argument i as std::string, + /// eating all characters up to the end of the command line + std::string getLongArg(unsigned int i) const; + /// access the whole argument docstring const & argument() const { return argument_; } -- 2.39.2