A very quick and easy question.
I have a working Class InsetCommandParams that does no more than
manipulate the command parameters cmdname, options and contents in exactly the
same manner to the existing InsetCommand class. In addition it has two methods
that can convert a single string to/from an InsetCommandParams.
My question is will you be happy if I replace the strings and associated
methods in InsetCommand with a single PUBLIC instance of InsetCommandParams?
Angus
-----------------------------------------------------
class InsetCommandParams {
public:
InsetCommandParams();
explicit
InsetCommandParams( string const & n,
string const & o = string(),
string const & c = string() );
string const & getCmdName() const { return cmdname; }
string const & getOptions() const { return options; }
string const & getContents() const { return contents; }
void setCmdName( string const & n ) { cmdname = n; }
void setOptions(string const & o) { options = o; }
void setContents(string const & c) { contents = c; }
void addContents(string const & c) { contents += c; }
string bufferGet() const;
void bufferSet( string const & );
private:
string cmdname;
string options;
string contents;
};
-----------------------------------------------------
#include "insetcommand.h"
InsetCommandParams::InsetCommandParams()
{}
InsetCommandParams::InsetCommandParams( string const & n,
string const & o,
string const & c)
: cmdname(n), options(o), contents(c)
{}
string InsetCommandParams::bufferGet() const
{
string b(cmdname);
b += "||||" + options + "||||" + contents;
return b;
}
void InsetCommandParams::bufferSet( string const & b )
{
string::size_type idx = b.find("||||");
if( idx == string::npos ) return;
cmdname = b.substr(0, idx);
string tmp = b.substr(idx+4);
idx = tmp.find("||||");
if( idx == string::npos ) {
options = tmp;
} else {
options = tmp.substr(0, idx);
contents = tmp.substr(idx+4);
}
}