]> git.lyx.org Git - lyx.git/blobdiff - src/funcrequest.C
Alfredo's second patch
[lyx.git] / src / funcrequest.C
index 75d9cbaab8efc217ad021543d40b12c8df066c24..28007f08e68e871ba424cfb55ea9ac25fd430b31 100644 (file)
 #include "lyxfunc.h" // only for setMessage()
 #include "frontends/LyXView.h"
 #include "debug.h"
+#include "Lsstream.h"
+
+
+using std::vector;
+using std::getline;
 
 
 FuncRequest::FuncRequest()
@@ -98,3 +103,29 @@ void FuncRequest::errorMessage(string const & msg) const
        else
                lyxerr  << "Dropping error message '" << msg << "'\n";
 }
+
+
+void split(vector<string> & args, string str)
+{
+       istringstream is(str);
+       while (is) {
+               char c;
+               string s;
+               is >> c;
+               if (c == '"')
+                       getline(is, s, '"');
+               else {
+                       is.putback(c);
+                       is >> s;
+               }
+               args.push_back(s);
+       }
+}
+
+
+string FuncRequest::getArg(int i) const
+{
+       vector<string> args;
+       split(args, argument);
+       return i < args.size() ? args[i] : string();
+}