| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 typedef enum { | 66 typedef enum { |
| 67 TypeNull = 0, | 67 TypeNull = 0, |
| 68 TypeBoolean, | 68 TypeBoolean, |
| 69 TypeNumber, | 69 TypeNumber, |
| 70 TypeString, | 70 TypeString, |
| 71 TypeObject, | 71 TypeObject, |
| 72 TypeArray | 72 TypeArray |
| 73 } Type; | 73 } Type; |
| 74 | 74 |
| 75 Type type() const { return m_type; } | 75 Type getType() const { return m_type; } |
| 76 | 76 |
| 77 bool isNull() const { return m_type == TypeNull; } | 77 bool isNull() const { return m_type == TypeNull; } |
| 78 | 78 |
| 79 virtual bool asBoolean(bool* output) const; | 79 virtual bool asBoolean(bool* output) const; |
| 80 virtual bool asNumber(double* output) const; | 80 virtual bool asNumber(double* output) const; |
| 81 virtual bool asNumber(long* output) const; | 81 virtual bool asNumber(long* output) const; |
| 82 virtual bool asNumber(int* output) const; | 82 virtual bool asNumber(int* output) const; |
| 83 virtual bool asNumber(unsigned long* output) const; | 83 virtual bool asNumber(unsigned long* output) const; |
| 84 virtual bool asNumber(unsigned* output) const; | 84 virtual bool asNumber(unsigned* output) const; |
| 85 virtual bool asString(String* output) const; | 85 virtual bool asString(String* output) const; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 typedef Dictionary::iterator iterator; | 172 typedef Dictionary::iterator iterator; |
| 173 typedef Dictionary::const_iterator const_iterator; | 173 typedef Dictionary::const_iterator const_iterator; |
| 174 | 174 |
| 175 static PassRefPtr<JSONObject> create() | 175 static PassRefPtr<JSONObject> create() |
| 176 { | 176 { |
| 177 return adoptRef(new JSONObject()); | 177 return adoptRef(new JSONObject()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 static PassRefPtr<JSONObject> cast(PassRefPtr<JSONValue> value) | 180 static PassRefPtr<JSONObject> cast(PassRefPtr<JSONValue> value) |
| 181 { | 181 { |
| 182 if (!value || value->type() != TypeObject) | 182 if (!value || value->getType() != TypeObject) |
| 183 return nullptr; | 183 return nullptr; |
| 184 return adoptRef(static_cast<JSONObject*>(value.leakRef())); | 184 return adoptRef(static_cast<JSONObject*>(value.leakRef())); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void writeJSON(StringBuilder* output) const override; | 187 void writeJSON(StringBuilder* output) const override; |
| 188 | 188 |
| 189 int size() const { return m_data.size(); } | 189 int size() const { return m_data.size(); } |
| 190 | 190 |
| 191 void setBoolean(const String& name, bool); | 191 void setBoolean(const String& name, bool); |
| 192 void setNumber(const String& name, double); | 192 void setNumber(const String& name, double); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 typedef Vector<RefPtr<JSONValue>>::iterator iterator; | 235 typedef Vector<RefPtr<JSONValue>>::iterator iterator; |
| 236 typedef Vector<RefPtr<JSONValue>>::const_iterator const_iterator; | 236 typedef Vector<RefPtr<JSONValue>>::const_iterator const_iterator; |
| 237 | 237 |
| 238 static PassRefPtr<JSONArray> create() | 238 static PassRefPtr<JSONArray> create() |
| 239 { | 239 { |
| 240 return adoptRef(new JSONArray()); | 240 return adoptRef(new JSONArray()); |
| 241 } | 241 } |
| 242 | 242 |
| 243 static PassRefPtr<JSONArray> cast(PassRefPtr<JSONValue> value) | 243 static PassRefPtr<JSONArray> cast(PassRefPtr<JSONValue> value) |
| 244 { | 244 { |
| 245 if (!value || value->type() != TypeArray) | 245 if (!value || value->getType() != TypeArray) |
| 246 return nullptr; | 246 return nullptr; |
| 247 return adoptRef(static_cast<JSONArray*>(value.leakRef())); | 247 return adoptRef(static_cast<JSONArray*>(value.leakRef())); |
| 248 } | 248 } |
| 249 | 249 |
| 250 ~JSONArray() override; | 250 ~JSONArray() override; |
| 251 | 251 |
| 252 void writeJSON(StringBuilder* output) const override; | 252 void writeJSON(StringBuilder* output) const override; |
| 253 | 253 |
| 254 void pushBoolean(bool); | 254 void pushBoolean(bool); |
| 255 void pushInt(int); | 255 void pushInt(int); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 274 JSONArray(); | 274 JSONArray(); |
| 275 Vector<RefPtr<JSONValue>> m_data; | 275 Vector<RefPtr<JSONValue>> m_data; |
| 276 }; | 276 }; |
| 277 | 277 |
| 278 PLATFORM_EXPORT void escapeStringForJSON(const String&, StringBuilder*); | 278 PLATFORM_EXPORT void escapeStringForJSON(const String&, StringBuilder*); |
| 279 void doubleQuoteStringForJSON(const String&, StringBuilder*); | 279 void doubleQuoteStringForJSON(const String&, StringBuilder*); |
| 280 | 280 |
| 281 } // namespace blink | 281 } // namespace blink |
| 282 | 282 |
| 283 #endif // JSONValues_h | 283 #endif // JSONValues_h |
| OLD | NEW |