| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Values_h | 5 #ifndef Values_h |
| 6 #define Values_h | 6 #define Values_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/Forward.h" | 10 #include "wtf/Forward.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 public: | 26 public: |
| 27 static const int maxDepth = 1000; | 27 static const int maxDepth = 1000; |
| 28 | 28 |
| 29 virtual ~Value() { } | 29 virtual ~Value() { } |
| 30 | 30 |
| 31 static PassRefPtr<Value> null() | 31 static PassRefPtr<Value> null() |
| 32 { | 32 { |
| 33 return adoptRef(new Value()); | 33 return adoptRef(new Value()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 typedef enum { | 36 enum ValueType { |
| 37 TypeNull = 0, | 37 TypeNull = 0, |
| 38 TypeBoolean, | 38 TypeBoolean, |
| 39 TypeNumber, | 39 TypeNumber, |
| 40 TypeString, | 40 TypeString, |
| 41 TypeObject, | 41 TypeObject, |
| 42 TypeArray | 42 TypeArray |
| 43 } Type; | 43 }; |
| 44 | 44 |
| 45 Type type() const { return m_type; } | 45 ValueType type() const { return m_type; } |
| 46 | 46 |
| 47 bool isNull() const { return m_type == TypeNull; } | 47 bool isNull() const { return m_type == TypeNull; } |
| 48 | 48 |
| 49 virtual bool asBoolean(bool* output) const; | 49 virtual bool asBoolean(bool* output) const; |
| 50 virtual bool asNumber(double* output) const; | 50 virtual bool asNumber(double* output) const; |
| 51 virtual bool asNumber(int* output) const; | 51 virtual bool asNumber(int* output) const; |
| 52 virtual bool asString(String* output) const; | 52 virtual bool asString(String* output) const; |
| 53 | 53 |
| 54 String toJSONString() const; | 54 String toJSONString() const; |
| 55 virtual void writeJSON(StringBuilder* output) const; | 55 virtual void writeJSON(StringBuilder* output) const; |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 Value() : m_type(TypeNull) { } | 58 Value() : m_type(TypeNull) { } |
| 59 explicit Value(Type type) : m_type(type) { } | 59 explicit Value(ValueType type) : m_type(type) { } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 friend class DictionaryValue; | 62 friend class DictionaryValue; |
| 63 friend class ListValue; | 63 friend class ListValue; |
| 64 | 64 |
| 65 Type m_type; | 65 ValueType m_type; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class PLATFORM_EXPORT FundamentalValue : public Value { | 68 class PLATFORM_EXPORT FundamentalValue : public Value { |
| 69 public: | 69 public: |
| 70 | 70 |
| 71 static PassRefPtr<FundamentalValue> create(bool value) | 71 static PassRefPtr<FundamentalValue> create(bool value) |
| 72 { | 72 { |
| 73 return adoptRef(new FundamentalValue(value)); | 73 return adoptRef(new FundamentalValue(value)); |
| 74 } | 74 } |
| 75 | 75 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 219 |
| 220 private: | 220 private: |
| 221 ListValue(); | 221 ListValue(); |
| 222 Vector<RefPtr<Value>> m_data; | 222 Vector<RefPtr<Value>> m_data; |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 } // namespace protocol | 225 } // namespace protocol |
| 226 } // namespace blink | 226 } // namespace blink |
| 227 | 227 |
| 228 #endif // Values_h | 228 #endif // Values_h |
| OLD | NEW |