23 std::vector<std::pair<int, int> >& comments,
36 std::vector<std::pair<int, int> > comments;
41 int endPos = literal.
endPos;
42 std::string comment =
"";
43 for (
size_t ci = 0; ci < comments.size(); ci++) {
44 if (comments[ci].first >= endPos) {
46 size_t pos =
_expr.find(
'\n', endPos);
47 if (pos == std::string::npos || pos >= (
size_t)comments[ci].second) {
48 comment =
_expr.substr(comments[ci].first, comments[ci].second - comments[ci].first);
71 std::stringstream stream;
72 for (
size_t i = 0, sz =
_editables.size(); i < sz; i++) {
78 stream <<
_expr.substr(offset,
_expr.size() - offset);
87 for (
size_t i = 0, sz =
_editables.size(); i < sz; i++) {
98 for (
size_t i = 0, sz =
_editables.size(); i < sz; i++) {
bool ExprSpecParse(std::vector< Editable * > &literals, std::vector< std::string > &variables, std::vector< std::pair< int, int > > &comments, const char *str)
Factors a SeExpr into an editable expression with controls (i.e. value boxes, curve boxes)
std::vector< std::string > _variables
void setExpr(const std::string &expr)
Set's expressions and parses it into "control editable form".
std::string getEditedExpr() const
Return a reconstructed expression using all the editable's current values.
std::vector< Editable * > _editables
bool controlsMatch(const EditableExpression &other) const
Check if the other editable expression has editables that all match i.e. the controls are same.
void cleanup()
clean memeory
void updateString(const EditableExpression &other)
Update the string refered to into the controls (this is only valid if controlsmatch)
you may not use this file except in compliance with the License and the following modification to it
void updatePositions(const Editable &other)
virtual void appendString(std::stringstream &stream) const =0
virtual bool parseComment(const std::string &comment)=0
parses a comment. if false is returned then delete the control from the editable
virtual bool controlsMatch(const Editable &) const =0
</pre >< h3 > Binding our variable reference</h3 > If we now tried to use the variable would still not be found by our expressions To make it bindable we need to override the resolveVar() function as follows</pre >< h3 > Variable setting</h3 > Next we need to make a way of setting the variable As the controlling code will use the expression it will repeatedly alternate between setting the independent variables that are used and calling evaluate(). What it has to do depends very much on the application. In this case we only need to set the independent variable x as</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")
</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