| OLD | NEW |
| 1 // Copyright (C) 2013 Google Inc. | 1 // Copyright (C) 2013 Google Inc. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 public: | 33 public: |
| 34 virtual ~Json(); | 34 virtual ~Json(); |
| 35 | 35 |
| 36 // Returns a new instance of |Json| object. | 36 // Returns a new instance of |Json| object. |
| 37 static scoped_ptr<Json> Build(); | 37 static scoped_ptr<Json> Build(); |
| 38 | 38 |
| 39 // Parses the |json| string and returns true if |json| is valid and it is an | 39 // Parses the |json| string and returns true if |json| is valid and it is an |
| 40 // object. | 40 // object. |
| 41 virtual bool ParseObject(const std::string& json) = 0; | 41 virtual bool ParseObject(const std::string& json) = 0; |
| 42 | 42 |
| 43 // Sets |value| to the string for |key| if it exists, or false if the key | 43 // Sets |value| to the string for |key| if it exists and has a string value. |
| 44 // doesn't exist or doesn't correspond to a string. The JSON object must be | 44 // Returns false if the key doesn't exist or doesn't correspond to a string. |
| 45 // parsed successfully in ParseObject() before invoking this method. | 45 // The JSON object must be parsed successfully in ParseObject() before |
| 46 // invoking this method. |
| 46 virtual bool GetStringValueForKey(const std::string& key, | 47 virtual bool GetStringValueForKey(const std::string& key, |
| 47 std::string* value) const = 0; | 48 std::string* value) const = 0; |
| 48 | 49 |
| 50 // Sets |value| to the dictionary for |key| if it exists and has a dictionary |
| 51 // value. Returns false if the key doesn't exist or doesn't correspond to a |
| 52 // dictionary. The JSON object must be parsed successfully in ParseObject() |
| 53 // before invoking this method. |
| 54 virtual bool GetJsonValueForKey(const std::string& key, |
| 55 scoped_ptr<Json>* value) const = 0; |
| 56 |
| 49 protected: | 57 protected: |
| 50 Json(); | 58 Json(); |
| 51 }; | 59 }; |
| 52 | 60 |
| 53 } // namespace addressinput | 61 } // namespace addressinput |
| 54 } // namespace i18n | 62 } // namespace i18n |
| 55 | 63 |
| 56 #endif // I18N_ADDRESSINPUT_UTIL_JSON_H_ | 64 #endif // I18N_ADDRESSINPUT_UTIL_JSON_H_ |
| OLD | NEW |