OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TOOLS_GN_VALUE_H_ | 5 #ifndef TOOLS_GN_VALUE_H_ |
6 #define TOOLS_GN_VALUE_H_ | 6 #define TOOLS_GN_VALUE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 DCHECK(type_ == SCOPE); | 99 DCHECK(type_ == SCOPE); |
100 return scope_value_.get(); | 100 return scope_value_.get(); |
101 } | 101 } |
102 const Scope* scope_value() const { | 102 const Scope* scope_value() const { |
103 DCHECK(type_ == SCOPE); | 103 DCHECK(type_ == SCOPE); |
104 return scope_value_.get(); | 104 return scope_value_.get(); |
105 } | 105 } |
106 void SetScopeValue(scoped_ptr<Scope> scope); | 106 void SetScopeValue(scoped_ptr<Scope> scope); |
107 | 107 |
108 // Converts the given value to a string. Returns true if strings should be | 108 // Converts the given value to a string. Returns true if strings should be |
109 // quoted or the ToString of a string should be the string itself. | 109 // quoted or the ToString of a string should be the string itself. If the |
| 110 // string is quoted, it will also enable escaping. |
110 std::string ToString(bool quote_strings) const; | 111 std::string ToString(bool quote_strings) const; |
111 | 112 |
112 // Verifies that the value is of the given type. If it isn't, returns | 113 // Verifies that the value is of the given type. If it isn't, returns |
113 // false and sets the error. | 114 // false and sets the error. |
114 bool VerifyTypeIs(Type t, Err* err) const; | 115 bool VerifyTypeIs(Type t, Err* err) const; |
115 | 116 |
116 // Compares values. Only the "value" is compared, not the origin. | 117 // Compares values. Only the "value" is compared, not the origin. |
117 bool operator==(const Value& other) const; | 118 bool operator==(const Value& other) const; |
118 bool operator!=(const Value& other) const; | 119 bool operator!=(const Value& other) const; |
119 | 120 |
120 private: | 121 private: |
121 // This are a lot of objects associated with every Value that need | 122 // This are a lot of objects associated with every Value that need |
122 // initialization and tear down every time. It might be more efficient to | 123 // initialization and tear down every time. It might be more efficient to |
123 // create a union of ManualConstructor objects (see SmallMap) and only | 124 // create a union of ManualConstructor objects (see SmallMap) and only |
124 // use the one we care about. | 125 // use the one we care about. |
125 Type type_; | 126 Type type_; |
126 std::string string_value_; | 127 std::string string_value_; |
127 bool boolean_value_; | 128 bool boolean_value_; |
128 int64 int_value_; | 129 int64 int_value_; |
129 std::vector<Value> list_value_; | 130 std::vector<Value> list_value_; |
130 scoped_ptr<Scope> scope_value_; | 131 scoped_ptr<Scope> scope_value_; |
131 | 132 |
132 const ParseNode* origin_; | 133 const ParseNode* origin_; |
133 }; | 134 }; |
134 | 135 |
135 #endif // TOOLS_GN_VALUE_H_ | 136 #endif // TOOLS_GN_VALUE_H_ |
OLD | NEW |