ConstantExpression.h revision 521656973a277bd727a96fa812315daf416668f4
1#ifndef CONSTANT_EXPRESSION_H_
2
3#define CONSTANT_EXPRESSION_H_
4
5#include <android-base/macros.h>
6#include <string>
7
8namespace android {
9
10
11/**
12 * A constant expression is represented by a tree.
13 */
14struct ConstantExpression {
15    /* Literals, identifiers */
16    ConstantExpression(const char *value);
17    /* binary operations */
18    ConstantExpression(const ConstantExpression *value1,
19        const char *op, const ConstantExpression* value2);
20    /* unary operations */
21    ConstantExpression(const char *op, const ConstantExpression *value);
22    /* ternary ?: */
23    ConstantExpression(const ConstantExpression *cond,
24                       const ConstantExpression *trueVal,
25                       const ConstantExpression *falseVal);
26
27    /* Original expression. */
28    const char *c_str() const;
29    /* Evaluated result. */
30    const char *value() const;
31
32private:
33    std::string mValue;
34
35    DISALLOW_COPY_AND_ASSIGN(ConstantExpression);
36};
37
38}  // namespace android
39
40#endif  // CONSTANT_EXPRESSION_H_
41