Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
49f24afb
Commit
49f24afb
authored
Oct 09, 2015
by
Paul Yang
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #815 from TeBoring/third-party
Use std::get where it's available
parents
693cb3d2
7c14dc83
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
37 additions
and
348 deletions
+37
-348
cpp_unittest.cc
src/google/protobuf/compiler/cpp/cpp_unittest.cc
+1
-0
map.h
src/google/protobuf/map.h
+6
-0
proto_cast.h
src/google/protobuf/proto_cast.h
+0
-59
proto_cast_test.cc
src/google/protobuf/proto_cast_test.cc
+0
-60
callback.h
src/google/protobuf/stubs/callback.h
+2
-2
common.h
src/google/protobuf/stubs/common.h
+1
-1
common_unittest.cc
src/google/protobuf/stubs/common_unittest.cc
+2
-0
hash.h
src/google/protobuf/stubs/hash.h
+7
-2
int128.cc
src/google/protobuf/stubs/int128.cc
+2
-1
once_unittest.cc
src/google/protobuf/stubs/once_unittest.cc
+4
-2
unknown_enum_impl.h
src/google/protobuf/unknown_enum_impl.h
+0
-154
unknown_enum_test.proto
src/google/protobuf/unknown_enum_test.proto
+0
-62
protostream_objectwriter.cc
...google/protobuf/util/internal/protostream_objectwriter.cc
+1
-1
protostream_objectwriter_test.cc
...e/protobuf/util/internal/protostream_objectwriter_test.cc
+6
-1
message_differencer.cc
src/google/protobuf/util/message_differencer.cc
+5
-3
No files found.
src/google/protobuf/compiler/cpp/cpp_unittest.cc
View file @
49f24afb
...
...
@@ -82,6 +82,7 @@
namespace
google
{
namespace
protobuf
{
using
internal
::
NewPermanentCallback
;
namespace
compiler
{
namespace
cpp
{
...
...
src/google/protobuf/map.h
View file @
49f24afb
...
...
@@ -190,6 +190,8 @@ class LIBPROTOBUF_EXPORT MapKey {
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
false
;
}
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
false
;
}
void
CopyFrom
(
const
MapKey
&
other
)
{
...
...
@@ -852,6 +854,8 @@ struct hash<google::protobuf::MapKey> {
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
0
;
}
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
0
;
}
bool
operator
()(
const
google
::
protobuf
::
MapKey
&
map_key1
,
...
...
@@ -875,6 +879,8 @@ struct hash<google::protobuf::MapKey> {
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
true
;
}
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
true
;
}
};
GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END
...
...
src/google/protobuf/proto_cast.h
deleted
100644 → 0
View file @
693cb3d2
// 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_PROTO_CAST_H__
#define GOOGLE_PROTOBUF_UTIL_PROTO_CAST_H__
#include <string>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
// proto_cast<> is used to simulate over-the-wire conversion of one
// proto message into another. This is primarily useful for unit tests
// which validate the version-compatibility semantics of protobufs.
// Usage is similar to C++-style typecasts:
//
// OldMessage old_message = /*...*/;
// NewMessage new_message = proto_cast<NewMessage>(old_message);
namespace
google
{
template
<
typename
NewProto
,
typename
OldProto
>
NewProto
proto_cast
(
const
OldProto
&
old_proto
)
{
string
wire_format
;
GOOGLE_CHECK
(
old_proto
.
SerializeToString
(
&
wire_format
));
NewProto
new_proto
;
GOOGLE_CHECK
(
new_proto
.
ParseFromString
(
wire_format
));
return
new_proto
;
}
}
// namespace google
#endif // GOOGLE_PROTOBUF_UTIL_PROTO_CAST_H__
src/google/protobuf/proto_cast_test.cc
deleted
100644 → 0
View file @
693cb3d2
// 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/proto_cast.h>
#include <google/protobuf/util/unknown_enum_test.pb.h>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
namespace
google
{
using
google
::
protobuf
::
util
::
UpRevision
;
using
google
::
protobuf
::
util
::
DownRevision
;
namespace
{
TEST
(
ProtoCastTest
,
V2KnownValue
)
{
UpRevision
sender
;
sender
.
set_value
(
UpRevision
::
NONDEFAULT_VALUE
);
DownRevision
receiver
=
proto_cast
<
DownRevision
>
(
sender
);
ASSERT_EQ
(
DownRevision
::
NONDEFAULT_VALUE
,
receiver
.
value
());
}
TEST
(
ProtoCastTest
,
V2UnknownValue
)
{
UpRevision
sender
;
sender
.
set_value
(
UpRevision
::
NEW_VALUE
);
DownRevision
receiver
=
proto_cast
<
DownRevision
>
(
sender
);
ASSERT_EQ
(
DownRevision
::
DEFAULT_VALUE
,
receiver
.
value
());
}
}
// namespace
}
// namespace google
src/google/protobuf/stubs/callback.h
View file @
49f24afb
...
...
@@ -325,8 +325,6 @@ class MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> {
typename
remove_reference
<
P5
>::
type
p5_
;
};
}
// namespace internal
// See Closure.
inline
Closure
*
NewCallback
(
void
(
*
function
)())
{
return
new
internal
::
FunctionClosure0
(
function
,
true
);
...
...
@@ -452,6 +450,8 @@ inline ResultCallback2<R, A1, A2>* NewPermanentCallback(
p2
,
p3
,
p4
,
p5
);
}
}
// namespace internal
// A function which does nothing. Useful for creating no-op callbacks, e.g.:
// Closure* nothing = NewCallback(&DoNothing);
void
LIBPROTOBUF_EXPORT
DoNothing
();
...
...
src/google/protobuf/stubs/common.h
View file @
49f24afb
...
...
@@ -146,7 +146,7 @@ namespace internal {
LIBPROTOBUF_EXPORT
bool
IsStructurallyValidUTF8
(
const
char
*
buf
,
int
len
);
inline
bool
IsStructurallyValidUTF8
(
const
std
::
string
&
str
)
{
return
IsStructurallyValidUTF8
(
str
.
data
(),
st
r
.
length
(
));
return
IsStructurallyValidUTF8
(
str
.
data
(),
st
atic_cast
<
int
>
(
str
.
length
()
));
}
// Returns initial number of bytes of structually valid UTF-8.
...
...
src/google/protobuf/stubs/common_unittest.cc
View file @
49f24afb
...
...
@@ -41,6 +41,8 @@
namespace
google
{
namespace
protobuf
{
using
internal
::
NewCallback
;
using
internal
::
NewPermanentCallback
;
namespace
{
// TODO(kenton): More tests.
...
...
src/google/protobuf/stubs/hash.h
View file @
49f24afb
...
...
@@ -41,9 +41,14 @@
#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
// Android
#if defined(__ANDROID__)
# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
// Use C++11 unordered_{map|set} if available.
#if ((_LIBCPP_STD_VER >= 11) || \
(((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \
#
el
if ((_LIBCPP_STD_VER >= 11) || \
(((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \
(__GLIBCXX__ > 20090421)))
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
...
...
src/google/protobuf/stubs/int128.cc
View file @
49f24afb
...
...
@@ -188,7 +188,8 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) {
if
((
flags
&
std
::
ios
::
adjustfield
)
==
std
::
ios
::
left
)
{
rep
.
append
(
width
-
rep
.
size
(),
o
.
fill
());
}
else
{
rep
.
insert
(
0
,
width
-
rep
.
size
(),
o
.
fill
());
rep
.
insert
(
static_cast
<
std
::
string
::
size_type
>
(
0
),
width
-
rep
.
size
(),
o
.
fill
());
}
}
...
...
src/google/protobuf/stubs/once_unittest.cc
View file @
49f24afb
...
...
@@ -43,6 +43,7 @@
namespace
google
{
namespace
protobuf
{
using
internal
::
NewCallback
;
namespace
{
class
OnceInitTest
:
public
testing
::
Test
{
...
...
@@ -127,10 +128,11 @@ class OnceInitTest : public testing::Test {
};
TestThread
*
RunInitOnceInNewThread
()
{
return
new
TestThread
(
NewCallback
(
this
,
&
OnceInitTest
::
InitOnce
));
return
new
TestThread
(
internal
::
NewCallback
(
this
,
&
OnceInitTest
::
InitOnce
));
}
TestThread
*
RunInitRecursiveOnceInNewThread
()
{
return
new
TestThread
(
NewCallback
(
this
,
&
OnceInitTest
::
InitRecursiveOnce
));
return
new
TestThread
(
internal
::
NewCallback
(
this
,
&
OnceInitTest
::
InitRecursiveOnce
));
}
enum
State
{
...
...
src/google/protobuf/unknown_enum_impl.h
deleted
100644 → 0
View file @
693cb3d2
// 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_UNKNOWN_ENUM_IMPL_H__
#define GOOGLE_PROTOBUF_UTIL_UNKNOWN_ENUM_IMPL_H__
#include <stdlib.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/bridge/compatibility_mode_support.h>
namespace
google
{
namespace
protobuf
{
// google/protobuf/message.h
class
Message
;
namespace
util
{
// NOTE: You should not call these functions directly. Instead use either
// HAS_UNKNOWN_ENUM() or GET_UNKNOWN_ENUM(), defined in the public header.
// The macro-versions operate in a type-safe manner and behave appropriately
// for the proto version of the message, whereas these versions assume a
// specific proto version and allow the caller to pass in any arbitrary integer
// value as a field number.
//
// Returns whether the message has unrecognized the enum value for a given
// field. It also stores the value into the unknown_value parameter if the
// function returns true and the pointer is not NULL.
//
// In proto2, invalid enum values will be treated as unknown fields. This
// function checks that case.
bool
HasUnknownEnum
(
const
Message
&
message
,
int32
field_number
,
int32
*
unknown_value
=
NULL
);
// Same as above, but returns all unknown enums.
bool
GetRepeatedEnumUnknowns
(
const
Message
&
message
,
int32
field_number
,
vector
<
int32
>*
unknown_values
=
NULL
);
// In proto1, invalue enum values are stored in the same way as valid enum
// values.
// TODO(karner): Delete this once the migration to proto2 is complete.
bool
HasUnknownEnumProto1
(
const
Message
&
message
,
int32
field_number
,
int32
*
unknown_value
);
// Same as above, but returns all unknown enums.
bool
GetRepeatedEnumUnknownsProto1
(
const
Message
&
message
,
int32
field_number
,
vector
<
int32
>*
unknown_values
);
// Invokes the appropriate version based on whether the message is proto1
// or proto2.
template
<
typename
T
>
bool
HasUnknownEnum_Template
(
const
T
&
message
,
int32
field_number
,
int32
*
unknown_value
=
NULL
)
{
if
(
internal
::
is_base_of
<
bridge
::
internal
::
Proto1CompatibleMessage
,
T
>::
value
||
!
internal
::
is_base_of
<
ProtocolMessage
,
T
>::
value
)
{
return
HasUnknownEnum
(
message
,
field_number
,
unknown_value
);
}
else
{
return
HasUnknownEnumProto1
(
message
,
field_number
,
unknown_value
);
}
}
// Invokes the appropriate version based on whether the message is proto1
// or proto2.
template
<
typename
T
>
bool
GetRepeatedEnumUnknowns_Template
(
const
T
&
message
,
int32
field_number
,
vector
<
int32
>*
unknown_values
=
NULL
)
{
if
(
internal
::
is_base_of
<
bridge
::
internal
::
Proto1CompatibleMessage
,
T
>::
value
||
!
internal
::
is_base_of
<
ProtocolMessage
,
T
>::
value
)
{
return
GetRepeatedEnumUnknowns
(
message
,
field_number
,
unknown_values
);
}
else
{
return
GetRepeatedEnumUnknownsProto1
(
message
,
field_number
,
unknown_values
);
}
}
// NOTE: You should not call these functions directly. Instead use
// CLEAR_UNKNOWN_ENUM(), defined in the public header. The macro-versions
// operate in a type-safe manner and behave appropriately for the proto
// version of the message, whereas these versions assume a specific proto
// version and allow the caller to pass in any arbitrary integer value as a
// field number.
//
// Clears the unknown entries of the given field of the message.
void
ClearUnknownEnum
(
Message
*
message
,
int32
field_number
);
// In proto1, clears the field if the value is out of range.
// TODO(karner): Delete this or make it proto2-only once the migration
// to proto2 is complete.
void
ClearUnknownEnumProto1
(
Message
*
message
,
int32
field_number
);
template
<
typename
T
>
void
ClearUnknownEnum_Template
(
T
*
message
,
int32
field_number
)
{
if
(
internal
::
is_base_of
<
bridge
::
internal
::
Proto1CompatibleMessage
,
T
>::
value
||
!
internal
::
is_base_of
<
ProtocolMessage
,
T
>::
value
)
{
ClearUnknownEnum
(
message
,
field_number
);
}
else
{
ClearUnknownEnumProto1
(
message
,
field_number
);
}
}
// NOTE: You should not call these functions directly. Instead use
// SET_UNKNOWN_ENUM(), defined in the public header. The macro-versions
// operate in a type-safe manner and behave appropriately for the proto
// version of the message, whereas these versions assume a specific proto
// version and allow the caller to pass in any arbitrary integer value as a
// field number.
//
// Sets the given value in the unknown fields of the message.
void
SetUnknownEnum
(
Message
*
message
,
int32
field_number
,
int32
unknown_value
);
// In proto1, invalue enum values are stored in the same way as valid enum
// values.
// TODO(karner): Delete this once the migration to proto2 is complete.
void
SetUnknownEnumProto1
(
Message
*
message
,
int32
field_number
,
int32
unknown_value
);
// Invokes the appropriate version based on whether the message is proto1
// or proto2.
template
<
typename
T
>
void
SetUnknownEnum_Template
(
T
*
message
,
int32
field_number
,
int32
unknown_value
)
{
if
(
internal
::
is_base_of
<
bridge
::
internal
::
Proto1CompatibleMessage
,
T
>::
value
||
!
internal
::
is_base_of
<
ProtocolMessage
,
T
>::
value
)
{
SetUnknownEnum
(
message
,
field_number
,
unknown_value
);
}
else
{
SetUnknownEnumProto1
(
message
,
field_number
,
unknown_value
);
}
}
}
// namespace util
}
// namespace protobuf
}
// namespace google
#endif // GOOGLE_PROTOBUF_UTIL_UNKNOWN_ENUM_IMPL_H__
src/google/protobuf/unknown_enum_test.proto
deleted
100644 → 0
View file @
693cb3d2
// 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.
// Definitions of protos for testing cross-version compatibility. The
// UpRevision message acts as if it were a newer version of the DownRevision
// message. That is, UpRevision shares all the same fields as DownRevision,
// but UpRevision can add fields and add enum values.
syntax
=
"proto2"
;
package
google
.
protobuf.util
;
option
csharp_namespace
=
"Google.ProtocolBuffers.TestProtos"
;
message
DownRevision
{
enum
Enum
{
DEFAULT_VALUE
=
2
;
NONDEFAULT_VALUE
=
3
;
}
optional
Enum
value
=
1
[
default
=
DEFAULT_VALUE
];
repeated
Enum
values
=
2
;
}
message
UpRevision
{
enum
Enum
{
DEFAULT_VALUE
=
2
;
NONDEFAULT_VALUE
=
3
;
NEW_VALUE
=
4
;
NEW_VALUE_2
=
5
;
NEW_VALUE_3
=
6
;
}
optional
Enum
value
=
1
[
default
=
DEFAULT_VALUE
];
repeated
Enum
values
=
2
;
}
src/google/protobuf/util/internal/protostream_objectwriter.cc
View file @
49f24afb
...
...
@@ -1129,7 +1129,7 @@ Status ProtoStreamObjectWriter::RenderFieldMask(ProtoStreamObjectWriter* ow,
// conversions as much as possible. Because ToSnakeCase sometimes returns the
// wrong value.
google
::
protobuf
::
scoped_ptr
<
ResultCallback1
<
util
::
Status
,
StringPiece
>
>
callback
(
NewPermanentCallback
(
&
RenderOneFieldPath
,
ow
));
google
::
protobuf
::
internal
::
NewPermanentCallback
(
&
RenderOneFieldPath
,
ow
));
return
DecodeCompactFieldMaskPaths
(
data
.
str
(),
callback
.
get
());
}
...
...
src/google/protobuf/util/internal/protostream_objectwriter_test.cc
View file @
49f24afb
...
...
@@ -159,7 +159,12 @@ class BaseProtoStreamObjectWriterTest
MATCHER_P
(
HasObjectLocation
,
expected
,
"Verifies the expected object location"
)
{
string
actual
=
std
::
tr1
::
get
<
0
>
(
arg
).
ToString
();
string
actual
;
#if __cplusplus >= 201103L
actual
=
std
::
get
<
0
>
(
arg
).
ToString
();
#else
actual
=
std
::
tr1
::
get
<
0
>
(
arg
).
ToString
();
#endif
if
(
actual
.
compare
(
expected
)
==
0
)
return
true
;
*
result_listener
<<
"actual location is: "
<<
actual
;
return
false
;
...
...
src/google/protobuf/util/message_differencer.cc
View file @
49f24afb
...
...
@@ -1363,9 +1363,11 @@ bool MessageDifferencer::MatchRepeatedFieldIndices(
// doesn't neccessarily imply Compare(b, c). Therefore a naive greedy
// algorithm will fail to find a maximum matching.
// Here we use the argumenting path algorithm.
MaximumMatcher
::
NodeMatchCallback
*
callback
=
NewPermanentCallback
(
this
,
&
MessageDifferencer
::
IsMatch
,
repeated_field
,
key_comparator
,
&
message1
,
&
message2
,
parent_fields
);
MaximumMatcher
::
NodeMatchCallback
*
callback
=
google
::
protobuf
::
internal
::
NewPermanentCallback
(
this
,
&
MessageDifferencer
::
IsMatch
,
repeated_field
,
key_comparator
,
&
message1
,
&
message2
,
parent_fields
);
MaximumMatcher
matcher
(
count1
,
count2
,
callback
,
match_list1
,
match_list2
);
// If diff info is not needed, we should end the matching process as
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment