22 std::vector<std::pair<int,int> >& comments,
const char* str);
41 std::vector<std::pair<int,int> > comments;
47 std::string comment=
"";
48 for(
size_t ci=0;ci<comments.size();ci++){
49 if(comments[ci].first>=endPos){
51 size_t pos=
_expr.find(
'\n',endPos);
52 if(pos==std::string::npos || pos>=(
size_t)comments[ci].second){
53 comment=
_expr.substr(comments[ci].first,comments[ci].second-comments[ci].first);
79 std::stringstream stream;
86 stream<<
_expr.substr(offset,
_expr.size()-offset);
108 for(
size_t i=0,sz=
_editables.size();i<sz;i++){
virtual void appendString(std::stringstream &stream) const =0
void setExpr(const std::string &expr)
Set's expressions and parses it into "control editable form".
</pre >< h2 > Evaluating expressions</h2 > Evaluating an expression is pretty easy But before we can do that we need to make an instance< pre > GrapherExpr expr("x+x^2")
virtual bool controlsMatch(const Editable &) const =0
std::string getEditedExpr() const
Return a reconstructed expression using all the editable's current values.
std::vector< Editable * > _editables
bool ExprSpecParse(std::vector< Editable * > &literals, std::vector< std::string > &variables, std::vector< std::pair< int, int > > &comments, const char *str)
</pre > Once we have this we need an instance to store our variable and provide a reference to that We make it because it may be useful to use the same ExprVarRef from multiple expressions!For if you have expressions that all have access to the same variables
Factors a SeExpr into an editable expression with controls (i.e. value boxes, curve boxes) ...
void updateString(const EditableExpression &other)
Update the string refered to into the controls (this is only valid if controlsmatch) ...
virtual bool parseComment(const std::string &comment)=0
parses a comment. if false is returned then delete the control from the editable
bool controlsMatch(const EditableExpression &other) const
Check if the other editable expression has editables that all match i.e. the controls are same...
std::vector< std::string > _variables
you may not use this file except in compliance with the License and the following modification to it
void updatePositions(const Editable &other)
void cleanup()
clean memeory