Last change
on this file since 467 was
458,
checked in by ymipsl, 11 years ago
|
Add new parsing expression functionnalities
adding new files
YM
|
File size:
1.2 KB
|
Line | |
---|
1 | #ifndef __XIOS_SIMPLE_NODE_EXPR_HPP__ |
---|
2 | #define __XIOS_SIMPLE_NODE_EXPR_HPP__ |
---|
3 | |
---|
4 | #include<string> |
---|
5 | #include<vector> |
---|
6 | |
---|
7 | class CSimpleNodeExpr |
---|
8 | { |
---|
9 | public : |
---|
10 | |
---|
11 | enum ENodeType |
---|
12 | { |
---|
13 | scalarDouble, scalarVariable, opScalar, opScalarScalar, |
---|
14 | fieldInstant, fieldAverage, opFieldScalar, opScalarField, opFieldField, opField |
---|
15 | } ; |
---|
16 | |
---|
17 | CSimpleNodeExpr(ENodeType nodeType, const std::string* str) : nodeType(nodeType) |
---|
18 | { |
---|
19 | id=*str ; |
---|
20 | } |
---|
21 | |
---|
22 | CSimpleNodeExpr(ENodeType nodeType, const char* str) : nodeType(nodeType) |
---|
23 | { |
---|
24 | id=std::string(str) ; |
---|
25 | } |
---|
26 | |
---|
27 | void addChild(CSimpleNodeExpr* child) |
---|
28 | { |
---|
29 | children.push_back(child) ; |
---|
30 | } |
---|
31 | |
---|
32 | std::string print(void) |
---|
33 | { |
---|
34 | if (nodeType==scalarDouble) return id ; |
---|
35 | else if (nodeType==scalarVariable) return "$"+id ; |
---|
36 | else if (nodeType==fieldInstant) return id ; |
---|
37 | else if (nodeType==fieldAverage) return "@"+id ; |
---|
38 | else if (nodeType==opScalar || nodeType==opField) return id+"("+children[0]->print()+")" ; |
---|
39 | else return "("+children[0]->print()+id+children[1]->print()+")" ; |
---|
40 | } |
---|
41 | ~CSimpleNodeExpr() |
---|
42 | { |
---|
43 | for(std::vector<CSimpleNodeExpr*>::iterator it=children.begin();it!=children.end();++it) delete *it ; |
---|
44 | } |
---|
45 | |
---|
46 | ENodeType nodeType ; |
---|
47 | std::string id ; |
---|
48 | |
---|
49 | std::vector<CSimpleNodeExpr*> children ; |
---|
50 | } ; |
---|
51 | |
---|
52 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.