#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 {
}
-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;
}
}
+}
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();
}
/// 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_; }