]> git.lyx.org Git - features.git/commitdiff
new method getLongArg that grabs all the remainder of the argument string
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 2 Dec 2009 09:39:39 +0000 (09:39 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 2 Dec 2009 09:39:39 +0000 (09:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32283 a592a061-630c-0410-9148-cb99ea01b6c8

src/FuncRequest.cpp
src/FuncRequest.h

index 3eb0990a01f7d15e787bf1c6a0247c3914ef3271..eeebca2891c6346a79582809b060aaed1ab4485d 100644 (file)
 #include "FuncRequest.h"
 #include "LyXAction.h"
 
+#include "support/lstrings.h"
+
 #include <iostream>
 #include <sstream>
 #include <vector>
 
 using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
@@ -71,10 +74,19 @@ mouse_button::state FuncRequest::button() const
 }
 
 
-void splitArg(vector<string> & args, string const & str)
+namespace {
+
+void splitArg(vector<string> & 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<string> & args, string const & str)
        }
 }
 
+}
 
 string FuncRequest::getArg(unsigned int i) const
 {
        vector<string> 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<string> args;
+       splitArg(args, to_utf8(argument_), i);
        return i < args.size() ? args[i] : string();
 }
 
index 799fdd6a82b2941ac137b91303ce3caa5ca054bc..993f0a24bbcca4436a96e85ae31b39cb282edc64 100644 (file)
@@ -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_; }