Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1592)

Unified Diff: third_party/libaddressinput/chromium/cpp/src/util/json.cc

Issue 389863002: Remove Chrome's own version of libaddressinput in favor of the upstream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/cpp/src/util/json.cc
diff --git a/third_party/libaddressinput/chromium/cpp/src/util/json.cc b/third_party/libaddressinput/chromium/cpp/src/util/json.cc
deleted file mode 100644
index 6a95722e2147a72226c0713483c90e960bb7fa51..0000000000000000000000000000000000000000
--- a/third_party/libaddressinput/chromium/cpp/src/util/json.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (C) 2013 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "json.h"
-
-#include <libaddressinput/util/basictypes.h>
-#include <libaddressinput/util/scoped_ptr.h>
-
-#include <cassert>
-#include <cstddef>
-#include <cstring>
-#include <string>
-
-#include <rapidjson/document.h>
-#include <rapidjson/reader.h>
-
-namespace i18n {
-namespace addressinput {
-
-namespace {
-
-class Rapidjson : public Json {
- public:
- Rapidjson() : dict_() {}
-
- virtual ~Rapidjson() {}
-
- virtual bool ParseObject(const std::string& json) {
- scoped_ptr<rapidjson::Document> document(new rapidjson::Document);
- document->Parse<rapidjson::kParseValidateEncodingFlag>(json.c_str());
- if (!document->HasParseError() && document->IsObject()) {
- dict_.reset(document.release());
- return true;
- }
- return false;
- }
-
- virtual bool GetStringValueForKey(const std::string& key,
- std::string* value) const {
- assert(dict_ != NULL);
-
- // Owned by |dict_|.
- const rapidjson::Value::Member* member = dict_->FindMember(key.c_str());
- if (member == NULL || !member->value.IsString()) {
- return false;
- }
-
- if (value) {
- value->assign(member->value.GetString(), member->value.GetStringLength());
- }
-
- return true;
- }
-
- virtual bool GetJsonValueForKey(const std::string& key,
- scoped_ptr<Json>* value) const {
- assert(dict_ != NULL);
-
- // Owned by |dict_|.
- const rapidjson::Value::Member* member = dict_->FindMember(key.c_str());
- if (member == NULL || !member->value.IsObject()) {
- return false;
- }
-
- if (value) {
- scoped_ptr<rapidjson::Value> copy(new rapidjson::Value);
-
- // Rapidjson provides only move operations in public API, but implements
- // the move operation with a memcpy and delete:
- //
- // https://code.google.com/p/rapidjson/source/browse/trunk/include/rapidjson/document.h?r=131#173
- //
- // We need a copy of the object, so we use memcpy manually.
- memcpy(copy.get(), &member->value, sizeof(rapidjson::Value));
-
- value->reset(new Rapidjson(copy.Pass()));
- }
-
- return true;
- }
-
- protected:
- explicit Rapidjson(scoped_ptr<rapidjson::Value> dict)
- : dict_(dict.Pass()) {}
-
- // JSON value.
- scoped_ptr<rapidjson::Value> dict_;
-
- DISALLOW_COPY_AND_ASSIGN(Rapidjson);
-};
-
-} // namespace
-
-Json::~Json() {}
-
-// static
-scoped_ptr<Json> Json::Build() {
- return scoped_ptr<Json>(new Rapidjson);
-}
-
-Json::Json() {}
-
-} // namespace addressinput
-} // namespace i18n
« no previous file with comments | « third_party/libaddressinput/chromium/cpp/src/util/json.h ('k') | third_party/libaddressinput/chromium/cpp/src/util/md5.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698