Debian Codegraph @

CodeLite/CxxPreProcessorExpression.h

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // Copyright : (C) 2015 Eran Ifrah
5 // File name : CxxPreProcessorExpression.h
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 #ifndef EXPRESSION_H
27 #define EXPRESSION_H
28
29 #include <cstdlib>
30 #include "codelite_exports.h"
31
32 class WXDLLIMPEXP_CL CxxPreProcessorExpression
33 {
34 public:
35 enum eOperand {
36 kNONE,
37 kAND,
38 kOR,
39 kGreaterThan,
40 kGreaterThanEqual,
41 kLowerThan,
42 kLowerThanEqual,
43 };
44
45 protected:
46 CxxPreProcessorExpression* m_next;
47 bool m_isNot;
48 eOperand m_operand;
49 bool m_defined;
50 bool m_valueSet;
51 double m_valueLong;
52 private:
53 /**
54 * @brief return the value as 'bool'
55 */
56 bool DoIsTrue();
57
58 /**
59 * @brief return the value as 'long'
60 */
61 double DoGetLong();
62
63 public:
64 CxxPreProcessorExpression(bool value);
65 virtual ~CxxPreProcessorExpression();
66
67 bool IsTrue();
68
69 /**
70 * @brief return true if this expression already assigned with a value
71 */
72 bool IsValueSet() const
73 {
74 return m_valueSet;
75 }
76 /**
77 * @brief the current expression is from a 'defined' condition?
78 */
79 void SetDefined(bool defined)
80 {
81 this->m_defined = defined;
82 }
83 /**
84 * @brief is the current expression is from a 'defined' condition?
85 */
86 bool IsDefined() const
87 {
88 return m_defined;
89 }
90 /**
91 * @brief when encountering an expression of type
92 * #if !(expression) => SetNot() marks the exclamation mark
93 */
94 void SetNot();
95
96 /**
97 * @brief set the next expression in the chain
98 */
99 CxxPreProcessorExpression* SetNext(CxxPreProcessorExpression::eOperand operand, CxxPreProcessorExpression* expr);
100
101 /**
102 * @brief set value to the current expression
103 */
104 void SetValue(bool value);
105 /**
106 * @brief set value to the current expression
107 */
108 void SetValue(double value);
109 };
110
111 #endif // EXPRESSION_H