mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
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
This commit is contained in:
parent
d81c4751df
commit
fc3de8c150
@ -13,11 +13,14 @@
|
|||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LyXAction.h"
|
#include "LyXAction.h"
|
||||||
|
|
||||||
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace lyx::support;
|
||||||
|
|
||||||
namespace lyx {
|
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);
|
istringstream is(str);
|
||||||
while (is) {
|
while (is) {
|
||||||
|
if (args.size() == max) {
|
||||||
|
string s;
|
||||||
|
getline(is, s);
|
||||||
|
args.push_back(trim(s));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char c;
|
char c;
|
||||||
string s;
|
string s;
|
||||||
is >> c;
|
is >> c;
|
||||||
@ -90,11 +102,20 @@ void splitArg(vector<string> & args, string const & str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
string FuncRequest::getArg(unsigned int i) const
|
string FuncRequest::getArg(unsigned int i) const
|
||||||
{
|
{
|
||||||
vector<string> args;
|
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();
|
return i < args.size() ? args[i] : string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,10 @@ public:
|
|||||||
/// argument parsing, extract argument i as std::string
|
/// argument parsing, extract argument i as std::string
|
||||||
std::string getArg(unsigned int i) const;
|
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
|
/// access the whole argument
|
||||||
docstring const & argument() const { return argument_; }
|
docstring const & argument() const { return argument_; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user