aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2015-12-22 14:36:04 -0800
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2015-12-28 14:18:49 -0800
commitb7610f129df84d7f823f64d5dce9bfa1578cf49e (patch)
tree0da8267d920a3c6c5b20ae983d09c8d8967ee0cd /src/google/protobuf/util
parent7f82325998a1812c119eb8894bc3bee21dd99628 (diff)
Add missing files to EXTRA_DIST.
Also delete some unused files.
Diffstat (limited to 'src/google/protobuf/util')
-rw-r--r--src/google/protobuf/util/internal/snake2camel_objectwriter.h165
-rw-r--r--src/google/protobuf/util/internal/snake2camel_objectwriter_test.cc57
-rwxr-xr-xsrc/google/protobuf/util/message_differencer_unittest.cc11
3 files changed, 6 insertions, 227 deletions
diff --git a/src/google/protobuf/util/internal/snake2camel_objectwriter.h b/src/google/protobuf/util/internal/snake2camel_objectwriter.h
deleted file mode 100644
index 9b4ab8a3..00000000
--- a/src/google/protobuf/util/internal/snake2camel_objectwriter.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_SNAKE2CAMEL_OBJECTWRITER_H__
-#define GOOGLE_PROTOBUF_UTIL_CONVERTER_SNAKE2CAMEL_OBJECTWRITER_H__
-
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/stringpiece.h>
-#include <google/protobuf/util/internal/object_writer.h>
-#include <google/protobuf/util/internal/utility.h>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-// Snake2CamelObjectWriter is an ObjectWriter than translates each field name
-// from snake_case to camelCase. Typical usage is:
-// ProtoStreamObjectSource psos(...);
-// JsonObjectWriter jow(...);
-// Snake2CamelObjectWriter snake_to_camel(&jow);
-// psos.writeTo(&snake_to_camel);
-class Snake2CamelObjectWriter : public ObjectWriter {
- public:
- explicit Snake2CamelObjectWriter(ObjectWriter* ow)
- : ow_(ow), normalize_case_(true) {}
- virtual ~Snake2CamelObjectWriter() {}
-
- // ObjectWriter methods.
- virtual Snake2CamelObjectWriter* StartObject(StringPiece name) {
- ow_->StartObject(name);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* EndObject() {
- ow_->EndObject();
- return this;
- }
-
- virtual Snake2CamelObjectWriter* StartList(StringPiece name) {
- ow_->StartList(name);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* EndList() {
- ow_->EndList();
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderBool(StringPiece name, bool value) {
- ow_->RenderBool(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderInt32(StringPiece name, int32 value) {
- ow_->RenderInt32(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderUint32(StringPiece name,
- uint32 value) {
- ow_->RenderUint32(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderInt64(StringPiece name, int64 value) {
- ow_->RenderInt64(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderUint64(StringPiece name,
- uint64 value) {
- ow_->RenderUint64(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderDouble(StringPiece name,
- double value) {
- ow_->RenderDouble(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderFloat(StringPiece name, float value) {
- ow_->RenderFloat(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderString(StringPiece name,
- StringPiece value) {
- ow_->RenderString(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderBytes(StringPiece name,
- StringPiece value) {
- ow_->RenderBytes(name, value);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* RenderNull(StringPiece name) {
- ow_->RenderNull(name);
- return this;
- }
-
- virtual Snake2CamelObjectWriter* DisableCaseNormalizationForNextKey() {
- normalize_case_ = false;
- return this;
- }
-
- private:
- ObjectWriter* ow_;
- bool normalize_case_;
-
- bool ShouldNormalizeCase(StringPiece name) {
- if (normalize_case_) {
- return !IsCamel(name);
- } else {
- normalize_case_ = true;
- return false;
- }
- }
-
- bool IsCamel(StringPiece name) {
- return name.empty() || (ascii_islower(name[0]) && !name.contains("_"));
- }
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Snake2CamelObjectWriter);
-};
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-
-} // namespace google
-#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_SNAKE2CAMEL_OBJECTWRITER_H__
diff --git a/src/google/protobuf/util/internal/snake2camel_objectwriter_test.cc b/src/google/protobuf/util/internal/snake2camel_objectwriter_test.cc
deleted file mode 100644
index e5db844c..00000000
--- a/src/google/protobuf/util/internal/snake2camel_objectwriter_test.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <google/protobuf/util/internal/snake2camel_objectwriter.h>
-#include <google/protobuf/util/internal/expecting_objectwriter.h>
-#include <gtest/gtest.h>
-
-namespace google {
-namespace protobuf {
-namespace util {
-namespace converter {
-
-class Snake2CamelObjectWriterTest : public ::testing::Test {
- protected:
- Snake2CamelObjectWriterTest() : mock_(), expects_(&mock_), testing_(&mock_) {}
- virtual ~Snake2CamelObjectWriterTest() {}
-
- MockObjectWriter mock_;
- ExpectingObjectWriter expects_;
- Snake2CamelObjectWriter testing_;
-};
-
-// All tests are deleted as they are no longer needed. This file will be removed
-// after the component dependecies are cleaned up.
-// TODO(skarvaje): Remove this file.
-
-} // namespace converter
-} // namespace util
-} // namespace protobuf
-} // namespace google
diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc
index 4e9ca348..16f151af 100755
--- a/src/google/protobuf/util/message_differencer_unittest.cc
+++ b/src/google/protobuf/util/message_differencer_unittest.cc
@@ -1454,11 +1454,10 @@ static const char* const kIgnoredFields[] = {"rm.b", "rm.m.b"};
class TestIgnorer : public util::MessageDifferencer::IgnoreCriteria {
public:
- bool IsIgnored(
+ virtual bool IsIgnored(
const Message& message1, const Message& message2,
const FieldDescriptor* field,
- const vector<util::MessageDifferencer::SpecificField>& parent_fields)
- override {
+ const vector<util::MessageDifferencer::SpecificField>& parent_fields) {
string name = "";
for (int i = 0; i < parent_fields.size(); ++i) {
name += parent_fields[i].field->name() + ".";
@@ -1500,8 +1499,10 @@ TEST(MessageDifferencerTest, TreatRepeatedFieldAsMapWithIgnoredKeyFields) {
class ValueProductMapKeyComparator
: public util::MessageDifferencer::MapKeyComparator {
public:
- virtual bool IsMatch(const Message &message1,
- const Message &message2) const {
+ typedef util::MessageDifferencer::SpecificField SpecificField;
+ virtual bool IsMatch(
+ const Message &message1, const Message &message2,
+ const vector<SpecificField>& parent_fields) const {
const Reflection* reflection1 = message1.GetReflection();
const Reflection* reflection2 = message2.GetReflection();
// FieldDescriptor for item.ra