~ubuntu-branches/ubuntu/wily/opencollada/wily-proposed

« back to all changes in this revision

Viewing changes to Externals/MathMLSolver/src/AST/MathMLASTBinaryComparisionExpression.cpp

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "MathMLSolverStableHeaders.h"
 
2
#include "MathMLASTBinaryComparisionExpression.h"
 
3
 
 
4
namespace MathML
 
5
{
 
6
 
 
7
    namespace AST
 
8
    {
 
9
        //---------------------------------------------------------------------------------
 
10
        BinaryComparisonExpression::BinaryComparisonExpression()
 
11
                : mLeftOperand( 0 )
 
12
                , mRightOperand( 0 ),
 
13
                  mOperator( EQ )
 
14
        {}
 
15
 
 
16
        BinaryComparisonExpression::~BinaryComparisonExpression()
 
17
        {
 
18
            delete mLeftOperand;
 
19
            delete mRightOperand;
 
20
        }
 
21
 
 
22
        //---------------------------------------------------------------------------------
 
23
        void BinaryComparisonExpression::accept( IVisitor* visitor ) const
 
24
        {
 
25
            visitor->visit( this );
 
26
        }
 
27
 
 
28
        //---------------------------------------------------------------------------------
 
29
        BinaryComparisonExpression::Operator BinaryComparisonExpression::getOperator() const
 
30
        {
 
31
            return mOperator;
 
32
        }
 
33
 
 
34
        //---------------------------------------------------------------------------------
 
35
        void BinaryComparisonExpression::setOperator( Operator op )
 
36
        {
 
37
            mOperator = op;
 
38
        }
 
39
 
 
40
        //---------------------------------------------------------------------------------
 
41
        const String& BinaryComparisonExpression::getOperatorString() const
 
42
        {
 
43
            return operatorString( mOperator );
 
44
        }
 
45
 
 
46
        //---------------------------------------------------------------------------------
 
47
        const String& BinaryComparisonExpression::operatorString( Operator op )
 
48
        {
 
49
            switch ( op )
 
50
            {
 
51
 
 
52
            case EQ:
 
53
                return OPERATOR_COMPARE_EQ;
 
54
 
 
55
            case NEQ:
 
56
                return OPERATOR_COMPARE_NEQ;
 
57
 
 
58
            case LTE:
 
59
                return OPERATOR_COMPARE_LTE;
 
60
 
 
61
            case GTE:
 
62
                return OPERATOR_COMPARE_GTE;
 
63
 
 
64
            case LT:
 
65
                return OPERATOR_COMPARE_LT;
 
66
 
 
67
            case GT:
 
68
                return OPERATOR_COMPARE_GT;
 
69
            }
 
70
 
 
71
            return OPERATOR_COMPARE_ILLEGAL;
 
72
        }
 
73
 
 
74
        //---------------------------------------------------------------------------------
 
75
        void BinaryComparisonExpression::setOperator( const String& op )
 
76
        {
 
77
            if ( op == OPERATOR_COMPARE_EQ )
 
78
            {
 
79
                mOperator = EQ;
 
80
            }
 
81
 
 
82
            else if ( op == OPERATOR_COMPARE_NEQ )
 
83
            {
 
84
                mOperator = NEQ;
 
85
            }
 
86
 
 
87
            else if ( op == OPERATOR_COMPARE_LTE )
 
88
            {
 
89
                mOperator = LTE;
 
90
            }
 
91
 
 
92
            else if ( op == OPERATOR_COMPARE_GTE )
 
93
            {
 
94
                mOperator = GTE;
 
95
            }
 
96
 
 
97
            else if ( op == OPERATOR_COMPARE_LT )
 
98
            {
 
99
                mOperator = LT;
 
100
            }
 
101
 
 
102
            else if ( op == OPERATOR_COMPARE_GT )
 
103
            {
 
104
                mOperator = GT;
 
105
            }
 
106
        }
 
107
 
 
108
        //---------------------------------------------------------------------------------
 
109
        INode* BinaryComparisonExpression::getLeftOperand() const
 
110
        {
 
111
            return mLeftOperand;
 
112
        }
 
113
 
 
114
        //---------------------------------------------------------------------------------
 
115
        void BinaryComparisonExpression::setLeftOperand( INode* operand )
 
116
        {
 
117
            mLeftOperand = operand;
 
118
        }
 
119
 
 
120
        //---------------------------------------------------------------------------------
 
121
        INode* BinaryComparisonExpression::getRightOperand() const
 
122
        {
 
123
            return mRightOperand;
 
124
        }
 
125
 
 
126
        //---------------------------------------------------------------------------------
 
127
        void BinaryComparisonExpression::setRightOperand( INode* operand )
 
128
        {
 
129
            mRightOperand = operand;
 
130
        }
 
131
 
 
132
        //-----------------------------------------------------------------
 
133
        INode* BinaryComparisonExpression::clone(CloneFlags cloneFlags) const
 
134
        {
 
135
            BinaryComparisonExpression* copy = new BinaryComparisonExpression();
 
136
            copy->mOperator = mOperator;
 
137
 
 
138
            if ( mLeftOperand )
 
139
                copy->mLeftOperand = mLeftOperand->clone(cloneFlags);
 
140
            else
 
141
                copy->mLeftOperand = 0;
 
142
 
 
143
            if ( mRightOperand )
 
144
                copy->mRightOperand = mRightOperand->clone(cloneFlags);
 
145
            else
 
146
                copy->mRightOperand = 0;
 
147
 
 
148
            return copy;
 
149
        }
 
150
 
 
151
    } //namespace AST
 
152
 
 
153
} //namespace MathML
 
154