Go to the documentation of this file.
33 std::vector<const ControlSpec*>::iterator i =
_specList.begin();
34 std::vector<const ControlSpec*>::iterator
const e =
_specList.end();
35 for (; i != e; ++i)
delete *i;
68 inline bool isWS(
const char*
source,
int start,
int end) {
69 for (
int i = start; i < end; ++i)
70 if (
source[i] !=
'\n')
return false;
77 typedef std::vector<std::pair<int, int> > Comments;
78 const Comments& comments =
expr.getComments();
79 const std::string& s =
expr.getExpr();
82 for (Comments::const_iterator i = comments.begin(); i != comments.end(); ++i) {
84 return s.substr(i->first, i->second - i->first + 1);
94 int numParsed = sscanf(comment.c_str(),
"#%lf,%lf\n", &
_min, &
_max);
102 std::stringstream ss;
122 int numParsed = sscanf(comment.c_str(),
"#%lf,%lf\n", &
_min, &
_max);
123 if (numParsed != 2) {
130 std::stringstream ss;
145 for (
int i = 1; i < num - 2; i += 3)
147 static_cast<const ExprNumNode*>(cnode->
child(i))->
value(),
148 static_cast<const ExprNumNode*>(cnode->
child(i + 1))->
value(),
162 std::stringstream ss;
165 <<
"curve(" << _lookupText;
166 int num = _vec.size();
167 for (
int i = 0; i < num; ++i) ss << _vec[i]._pos << _vec[i]._val << (
int)_vec[i]._interp;
182 ExprCcurveAssignSpec::
190 int num = cnode->numChildren();
191 for(
int i = 1; i < num - 2; i += 3)
192 if(dynamic_cast<const ExprNumNode*>(cnode->child(i+1)))
194 static_cast<const ExprNumNode*>(cnode->child(i))->
value(),
195 static_cast<const ExprNumNode*>(cnode->child(i+1))->
value(),
200 ExprCcurveAssignSpec::toString()
const
202 std::stringstream ss;
208 int num = _vec.size();
209 for(
int i = 0; i < num; ++i)
215 << (
int)_vec[i]._interp;
221 const ExprCcurveAssignSpec*
222 ExprCcurveAssignSpec::match(
const ExprNode* node)
225 return new ExprCcurveAssignSpec(*assign);
234 std::stringstream ss;
256 char* name =
new char[comment.length() + 1];
257 char* type =
new char[comment.length() + 1];
258 int numMatched = sscanf(comment.c_str(),
"#%s %s\n", type, name);
261 if (numMatched == 2) {
263 if (!strcmp(type,
"string"))
265 else if (!strcmp(type,
"file"))
267 else if (!strcmp(type,
"directory"))
271 if (valid)
return new ExprStrSpec(*strnode, name, newType);
const ExprStrNode * isString(const ExprNode *testee)
const ExprAssignNode * isVectorAssign(const ExprNode *testee)
std::string _name
Name of control.
int numChildren() const
Number of children.
double _min
Range of values.
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
static const ExprVectorAssignSpec * match(const ExprNode *node)
std::vector< typename Curve< T >::CV > _vec
Control points of curve spline.
double _min
Range of values.
Node that stores a numeric constant.
bool isWS(const char *source, int start, int end)
Returns true if no newline separates comment and node.
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
const Vec3d & value() const
std::string toString() const
Access to original string representation of current expression.
ExprScalarAssignSpec(const ExprAssignNode &node)
const ExprAssignNode * isCurveAssign(const ExprNode *testee)
Node that calls a function.
Node that compute a local variable assignment.
std::string _lookupText
Lookup subexpression text.
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
virtual bool examine(const ExprNode *examinee)
static const ExprStrSpec * match(const ExprNode *node)
ExprCurveAssignSpec(const ExprAssignNode &node)
ExprStrSpec(const ExprStrNode &node, char *name, Type type)
Takes name and type comments and takes ownership of them!
std::vector< const ControlSpec * > _specList
static const ExprCurveAssignSpec * match(const ExprNode *node)
const ExprAssignNode * isScalarAssign(const ExprNode *testee)
Curve assignment expression. Assignment of curve to a variable.
Generic Expression control specification.
Variable equals vector control specification.
For any rgb or hsl value(except for negative s values)
Node that stores a string.
ExprVectorAssignSpec(const ExprAssignNode &node)
Variable equals scalar control specification.
const Expression * expr() const
Access expression.
const std::vector< const ControlSpec * >::const_iterator end() const
std::vector< const ControlSpec * >::const_iterator begin() const
const ExprNode * child(size_t i) const
Get 0 indexed child.
short int endPos() const
Access end position in input string.
std::string findComment(const ExprNode &node)
Checks if there is whitespace in the range specified in the string.
InterpType
Supported interpolation types.
static const ExprScalarAssignSpec * match(const ExprNode *node)
When x is within< i > range</i > of source
</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")
const ExprAssignNode * isCcurveAssign(const ExprNode *testee)
const std::string & name() const