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
cbd08cb7
Commit
cbd08cb7
authored
Apr 26, 2017
by
Adam Cozzette
Committed by
GitHub
Apr 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3018 from acozzette/using-namespace-std
Remove "using namespace std" from stubs/common.h
parents
54d1701f
7c76ac17
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
108 additions
and
98 deletions
+108
-98
command_line_interface.cc
src/google/protobuf/compiler/command_line_interface.cc
+6
-6
csharp_field_base.cc
src/google/protobuf/compiler/csharp/csharp_field_base.cc
+4
-4
javanano_file.cc
src/google/protobuf/compiler/javanano/javanano_file.cc
+3
-3
javanano_helpers.cc
src/google/protobuf/compiler/javanano/javanano_helpers.cc
+4
-4
javanano_message.cc
src/google/protobuf/compiler/javanano/javanano_message.cc
+1
-1
objectivec_extension.cc
...ogle/protobuf/compiler/objectivec/objectivec_extension.cc
+3
-3
objectivec_field.cc
src/google/protobuf/compiler/objectivec/objectivec_field.cc
+2
-2
objectivec_helpers.cc
...google/protobuf/compiler/objectivec/objectivec_helpers.cc
+34
-34
objectivec_message.cc
...google/protobuf/compiler/objectivec/objectivec_message.cc
+3
-3
zero_copy_stream_impl_lite.h
src/google/protobuf/io/zero_copy_stream_impl_lite.h
+1
-1
lite_unittest.cc
src/google/protobuf/lite_unittest.cc
+20
-22
common.h
src/google/protobuf/stubs/common.h
+13
-1
int128_unittest.cc
src/google/protobuf/stubs/int128_unittest.cc
+7
-7
strutil.cc
src/google/protobuf/stubs/strutil.cc
+6
-6
delimited_message_util_test.cc
src/google/protobuf/util/delimited_message_util_test.cc
+1
-1
No files found.
src/google/protobuf/compiler/command_line_interface.cc
View file @
cbd08cb7
...
@@ -804,8 +804,8 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
...
@@ -804,8 +804,8 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
// Enforce --disallow_services.
// Enforce --disallow_services.
if
(
disallow_services_
&&
parsed_file
->
service_count
()
>
0
)
{
if
(
disallow_services_
&&
parsed_file
->
service_count
()
>
0
)
{
cerr
<<
parsed_file
->
name
()
<<
": This file contains services, but "
std
::
cerr
<<
parsed_file
->
name
()
<<
": This file contains services, but "
"--disallow_services was used."
<<
endl
;
"--disallow_services was used."
<<
std
::
endl
;
return
1
;
return
1
;
}
}
...
@@ -816,7 +816,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
...
@@ -816,7 +816,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
if
(
direct_dependencies_
.
find
(
parsed_file
->
dependency
(
i
)
->
name
())
==
if
(
direct_dependencies_
.
find
(
parsed_file
->
dependency
(
i
)
->
name
())
==
direct_dependencies_
.
end
())
{
direct_dependencies_
.
end
())
{
indirect_imports
=
true
;
indirect_imports
=
true
;
cerr
<<
parsed_file
->
name
()
<<
": "
std
::
cerr
<<
parsed_file
->
name
()
<<
": "
<<
StringReplace
(
direct_dependencies_violation_msg_
,
"%s"
,
<<
StringReplace
(
direct_dependencies_violation_msg_
,
"%s"
,
parsed_file
->
dependency
(
i
)
->
name
(),
parsed_file
->
dependency
(
i
)
->
name
(),
true
/* replace_all */
)
true
/* replace_all */
)
...
@@ -1221,7 +1221,7 @@ CommandLineInterface::InterpretArgument(const string& name,
...
@@ -1221,7 +1221,7 @@ CommandLineInterface::InterpretArgument(const string& name,
if
(
access
(
disk_path
.
c_str
(),
F_OK
)
<
0
)
{
if
(
access
(
disk_path
.
c_str
(),
F_OK
)
<
0
)
{
// Try the original path; it may have just happed to have a '=' in it.
// Try the original path; it may have just happed to have a '=' in it.
if
(
access
(
parts
[
i
].
c_str
(),
F_OK
)
<
0
)
{
if
(
access
(
parts
[
i
].
c_str
(),
F_OK
)
<
0
)
{
cerr
<<
disk_path
<<
": warning: directory does not exist."
<<
endl
;
std
::
cerr
<<
disk_path
<<
": warning: directory does not exist."
<<
std
::
endl
;
}
else
{
}
else
{
virtual_path
=
""
;
virtual_path
=
""
;
disk_path
=
parts
[
i
];
disk_path
=
parts
[
i
];
...
@@ -1302,9 +1302,9 @@ CommandLineInterface::InterpretArgument(const string& name,
...
@@ -1302,9 +1302,9 @@ CommandLineInterface::InterpretArgument(const string& name,
if
(
!
version_info_
.
empty
())
{
if
(
!
version_info_
.
empty
())
{
std
::
cout
<<
version_info_
<<
std
::
endl
;
std
::
cout
<<
version_info_
<<
std
::
endl
;
}
}
cout
<<
"libprotoc "
std
::
cout
<<
"libprotoc "
<<
protobuf
::
internal
::
VersionString
(
GOOGLE_PROTOBUF_VERSION
)
<<
protobuf
::
internal
::
VersionString
(
GOOGLE_PROTOBUF_VERSION
)
<<
endl
;
<<
std
::
endl
;
return
PARSE_ARGUMENT_DONE_AND_EXIT
;
// Exit without running compiler.
return
PARSE_ARGUMENT_DONE_AND_EXIT
;
// Exit without running compiler.
}
else
if
(
name
==
"--disallow_services"
)
{
}
else
if
(
name
==
"--disallow_services"
)
{
...
...
src/google/protobuf/compiler/csharp/csharp_field_base.cc
View file @
cbd08cb7
...
@@ -322,9 +322,9 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor)
...
@@ -322,9 +322,9 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor)
}
}
case
FieldDescriptor
:
:
TYPE_DOUBLE
:
{
case
FieldDescriptor
:
:
TYPE_DOUBLE
:
{
double
value
=
descriptor
->
default_value_double
();
double
value
=
descriptor
->
default_value_double
();
if
(
value
==
numeric_limits
<
double
>::
infinity
())
{
if
(
value
==
std
::
numeric_limits
<
double
>::
infinity
())
{
return
"double.PositiveInfinity"
;
return
"double.PositiveInfinity"
;
}
else
if
(
value
==
-
numeric_limits
<
double
>::
infinity
())
{
}
else
if
(
value
==
-
std
::
numeric_limits
<
double
>::
infinity
())
{
return
"double.NegativeInfinity"
;
return
"double.NegativeInfinity"
;
}
else
if
(
MathLimits
<
double
>::
IsNaN
(
value
))
{
}
else
if
(
MathLimits
<
double
>::
IsNaN
(
value
))
{
return
"double.NaN"
;
return
"double.NaN"
;
...
@@ -333,9 +333,9 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor)
...
@@ -333,9 +333,9 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor)
}
}
case
FieldDescriptor
:
:
TYPE_FLOAT
:
{
case
FieldDescriptor
:
:
TYPE_FLOAT
:
{
float
value
=
descriptor
->
default_value_float
();
float
value
=
descriptor
->
default_value_float
();
if
(
value
==
numeric_limits
<
float
>::
infinity
())
{
if
(
value
==
std
::
numeric_limits
<
float
>::
infinity
())
{
return
"float.PositiveInfinity"
;
return
"float.PositiveInfinity"
;
}
else
if
(
value
==
-
numeric_limits
<
float
>::
infinity
())
{
}
else
if
(
value
==
-
std
::
numeric_limits
<
float
>::
infinity
())
{
return
"float.NegativeInfinity"
;
return
"float.NegativeInfinity"
;
}
else
if
(
MathLimits
<
float
>::
IsNaN
(
value
))
{
}
else
if
(
MathLimits
<
float
>::
IsNaN
(
value
))
{
return
"float.NaN"
;
return
"float.NaN"
;
...
...
src/google/protobuf/compiler/javanano/javanano_file.cc
View file @
cbd08cb7
...
@@ -120,12 +120,12 @@ bool FileGenerator::Validate(string* error) {
...
@@ -120,12 +120,12 @@ bool FileGenerator::Validate(string* error) {
if
(
!
params_
.
has_java_outer_classname
(
file_
->
name
())
if
(
!
params_
.
has_java_outer_classname
(
file_
->
name
())
&&
file_
->
message_type_count
()
==
1
&&
file_
->
message_type_count
()
==
1
&&
file_
->
enum_type_count
()
==
0
&&
file_
->
extension_count
()
==
0
)
{
&&
file_
->
enum_type_count
()
==
0
&&
file_
->
extension_count
()
==
0
)
{
cout
<<
"INFO: "
<<
file_
->
name
()
<<
":"
<<
endl
;
std
::
cout
<<
"INFO: "
<<
file_
->
name
()
<<
":"
<<
std
::
endl
;
cout
<<
"Javanano generator has changed to align with java generator. "
std
::
cout
<<
"Javanano generator has changed to align with java generator. "
"An outer class will be created for this file and the single message "
"An outer class will be created for this file and the single message "
"in the file will become a nested class. Use java_multiple_files to "
"in the file will become a nested class. Use java_multiple_files to "
"skip generating the outer class, or set an explicit "
"skip generating the outer class, or set an explicit "
"java_outer_classname to suppress this message."
<<
endl
;
"java_outer_classname to suppress this message."
<<
std
::
endl
;
}
}
// Check that no class name matches the file's class name. This is a common
// Check that no class name matches the file's class name. This is a common
...
...
src/google/protobuf/compiler/javanano/javanano_helpers.cc
View file @
cbd08cb7
...
@@ -428,9 +428,9 @@ string DefaultValue(const Params& params, const FieldDescriptor* field) {
...
@@ -428,9 +428,9 @@ string DefaultValue(const Params& params, const FieldDescriptor* field) {
"L"
;
"L"
;
case
FieldDescriptor
:
:
CPPTYPE_DOUBLE
:
{
case
FieldDescriptor
:
:
CPPTYPE_DOUBLE
:
{
double
value
=
field
->
default_value_double
();
double
value
=
field
->
default_value_double
();
if
(
value
==
numeric_limits
<
double
>::
infinity
())
{
if
(
value
==
std
::
numeric_limits
<
double
>::
infinity
())
{
return
"Double.POSITIVE_INFINITY"
;
return
"Double.POSITIVE_INFINITY"
;
}
else
if
(
value
==
-
numeric_limits
<
double
>::
infinity
())
{
}
else
if
(
value
==
-
std
::
numeric_limits
<
double
>::
infinity
())
{
return
"Double.NEGATIVE_INFINITY"
;
return
"Double.NEGATIVE_INFINITY"
;
}
else
if
(
value
!=
value
)
{
}
else
if
(
value
!=
value
)
{
return
"Double.NaN"
;
return
"Double.NaN"
;
...
@@ -440,9 +440,9 @@ string DefaultValue(const Params& params, const FieldDescriptor* field) {
...
@@ -440,9 +440,9 @@ string DefaultValue(const Params& params, const FieldDescriptor* field) {
}
}
case
FieldDescriptor
:
:
CPPTYPE_FLOAT
:
{
case
FieldDescriptor
:
:
CPPTYPE_FLOAT
:
{
float
value
=
field
->
default_value_float
();
float
value
=
field
->
default_value_float
();
if
(
value
==
numeric_limits
<
float
>::
infinity
())
{
if
(
value
==
std
::
numeric_limits
<
float
>::
infinity
())
{
return
"Float.POSITIVE_INFINITY"
;
return
"Float.POSITIVE_INFINITY"
;
}
else
if
(
value
==
-
numeric_limits
<
float
>::
infinity
())
{
}
else
if
(
value
==
-
std
::
numeric_limits
<
float
>::
infinity
())
{
return
"Float.NEGATIVE_INFINITY"
;
return
"Float.NEGATIVE_INFINITY"
;
}
else
if
(
value
!=
value
)
{
}
else
if
(
value
!=
value
)
{
return
"Float.NaN"
;
return
"Float.NaN"
;
...
...
src/google/protobuf/compiler/javanano/javanano_message.cc
View file @
cbd08cb7
...
@@ -69,7 +69,7 @@ const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
...
@@ -69,7 +69,7 @@ const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
fields
[
i
]
=
descriptor
->
field
(
i
);
fields
[
i
]
=
descriptor
->
field
(
i
);
}
}
sort
(
fields
,
fields
+
descriptor
->
field_count
(),
s
td
::
s
ort
(
fields
,
fields
+
descriptor
->
field_count
(),
FieldOrderingByNumber
());
FieldOrderingByNumber
());
return
fields
;
return
fields
;
}
}
...
...
src/google/protobuf/compiler/objectivec/objectivec_extension.cc
View file @
cbd08cb7
...
@@ -49,9 +49,9 @@ ExtensionGenerator::ExtensionGenerator(const string& root_class_name,
...
@@ -49,9 +49,9 @@ ExtensionGenerator::ExtensionGenerator(const string& root_class_name,
if
(
descriptor
->
is_map
())
{
if
(
descriptor
->
is_map
())
{
// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some
// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some
// error cases, so it seems to be ok to use as a back door for errors.
// error cases, so it seems to be ok to use as a back door for errors.
cerr
<<
"error: Extension is a map<>!"
std
::
cerr
<<
"error: Extension is a map<>!"
<<
" That used to be blocked by the compiler."
<<
endl
;
<<
" That used to be blocked by the compiler."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
abort
();
abort
();
}
}
}
}
...
...
src/google/protobuf/compiler/objectivec/objectivec_field.cc
View file @
cbd08cb7
...
@@ -228,8 +228,8 @@ int FieldGenerator::ExtraRuntimeHasBitsNeeded(void) const {
...
@@ -228,8 +228,8 @@ int FieldGenerator::ExtraRuntimeHasBitsNeeded(void) const {
void
FieldGenerator
::
SetExtraRuntimeHasBitsBase
(
int
index_base
)
{
void
FieldGenerator
::
SetExtraRuntimeHasBitsBase
(
int
index_base
)
{
// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some
// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some
// error cases, so it seems to be ok to use as a back door for errors.
// error cases, so it seems to be ok to use as a back door for errors.
cerr
<<
"Error: should have overridden SetExtraRuntimeHasBitsBase()."
<<
endl
;
std
::
cerr
<<
"Error: should have overridden SetExtraRuntimeHasBitsBase()."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
abort
();
abort
();
}
}
...
...
src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
View file @
cbd08cb7
...
@@ -1063,21 +1063,21 @@ bool ValidateObjCClassPrefix(
...
@@ -1063,21 +1063,21 @@ bool ValidateObjCClassPrefix(
// to Apple's rules (the checks above implicitly whitelist anything that
// to Apple's rules (the checks above implicitly whitelist anything that
// doesn't meet these rules).
// doesn't meet these rules).
if
(
!
ascii_isupper
(
prefix
[
0
]))
{
if
(
!
ascii_isupper
(
prefix
[
0
]))
{
cerr
<<
endl
std
::
cerr
<<
std
::
endl
<<
"protoc:0: warning: Invalid 'option objc_class_prefix =
\"
"
<<
"protoc:0: warning: Invalid 'option objc_class_prefix =
\"
"
<<
prefix
<<
"
\"
;' in '"
<<
file
->
name
()
<<
"';"
<<
prefix
<<
"
\"
;' in '"
<<
file
->
name
()
<<
"';"
<<
" it should start with a capital letter."
<<
endl
;
<<
" it should start with a capital letter."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
}
}
if
(
prefix
.
length
()
<
3
)
{
if
(
prefix
.
length
()
<
3
)
{
// Apple reserves 2 character prefixes for themselves. They do use some
// Apple reserves 2 character prefixes for themselves. They do use some
// 3 character prefixes, but they haven't updated the rules/docs.
// 3 character prefixes, but they haven't updated the rules/docs.
cerr
<<
endl
std
::
cerr
<<
std
::
endl
<<
"protoc:0: warning: Invalid 'option objc_class_prefix =
\"
"
<<
"protoc:0: warning: Invalid 'option objc_class_prefix =
\"
"
<<
prefix
<<
"
\"
;' in '"
<<
file
->
name
()
<<
"';"
<<
prefix
<<
"
\"
;' in '"
<<
file
->
name
()
<<
"';"
<<
" Apple recommends they should be at least 3 characters long."
<<
" Apple recommends they should be at least 3 characters long."
<<
endl
;
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
}
}
// Look for any other package that uses the same prefix.
// Look for any other package that uses the same prefix.
...
@@ -1096,22 +1096,22 @@ bool ValidateObjCClassPrefix(
...
@@ -1096,22 +1096,22 @@ bool ValidateObjCClassPrefix(
// The file does not have a package and ...
// The file does not have a package and ...
if
(
other_package_for_prefix
.
empty
())
{
if
(
other_package_for_prefix
.
empty
())
{
// ... no other package has declared that prefix.
// ... no other package has declared that prefix.
cerr
<<
endl
std
::
cerr
<<
std
::
endl
<<
"protoc:0: warning: File '"
<<
file
->
name
()
<<
"' has no "
<<
"protoc:0: warning: File '"
<<
file
->
name
()
<<
"' has no "
<<
"package. Consider adding a new package to the proto and adding '"
<<
"package. Consider adding a new package to the proto and adding '"
<<
"new.package = "
<<
prefix
<<
"' to the expected prefixes file ("
<<
"new.package = "
<<
prefix
<<
"' to the expected prefixes file ("
<<
expected_prefixes_path
<<
")."
<<
endl
;
<<
expected_prefixes_path
<<
")."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
}
else
{
}
else
{
// ... another package has declared the same prefix.
// ... another package has declared the same prefix.
cerr
<<
endl
std
::
cerr
<<
std
::
endl
<<
"protoc:0: warning: File '"
<<
file
->
name
()
<<
"' has no package "
<<
"protoc:0: warning: File '"
<<
file
->
name
()
<<
"' has no package "
<<
"and package '"
<<
other_package_for_prefix
<<
"' already uses '"
<<
"and package '"
<<
other_package_for_prefix
<<
"' already uses '"
<<
prefix
<<
"' as its prefix. Consider either adding a new package "
<<
prefix
<<
"' as its prefix. Consider either adding a new package "
<<
"to the proto, or reusing one of the packages already using this "
<<
"to the proto, or reusing one of the packages already using this "
<<
"prefix in the expected prefixes file ("
<<
"prefix in the expected prefixes file ("
<<
expected_prefixes_path
<<
")."
<<
endl
;
<<
expected_prefixes_path
<<
")."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
}
}
return
true
;
return
true
;
}
}
...
@@ -1133,12 +1133,12 @@ bool ValidateObjCClassPrefix(
...
@@ -1133,12 +1133,12 @@ bool ValidateObjCClassPrefix(
// Check: Warning - If the given package/prefix pair wasn't expected, issue a
// Check: Warning - If the given package/prefix pair wasn't expected, issue a
// warning issue a warning suggesting it gets added to the file.
// warning issue a warning suggesting it gets added to the file.
if
(
!
expected_package_prefixes
.
empty
())
{
if
(
!
expected_package_prefixes
.
empty
())
{
cerr
<<
endl
std
::
cerr
<<
std
::
endl
<<
"protoc:0: warning: Found unexpected 'option objc_class_prefix =
\"
"
<<
"protoc:0: warning: Found unexpected 'option objc_class_prefix =
\"
"
<<
prefix
<<
"
\"
;' in '"
<<
file
->
name
()
<<
"';"
<<
prefix
<<
"
\"
;' in '"
<<
file
->
name
()
<<
"';"
<<
" consider adding it to the expected prefixes file ("
<<
" consider adding it to the expected prefixes file ("
<<
expected_prefixes_path
<<
")."
<<
endl
;
<<
expected_prefixes_path
<<
")."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
}
}
return
true
;
return
true
;
...
@@ -1180,10 +1180,10 @@ void TextFormatDecodeData::AddString(int32 key,
...
@@ -1180,10 +1180,10 @@ void TextFormatDecodeData::AddString(int32 key,
for
(
vector
<
DataEntry
>::
const_iterator
i
=
entries_
.
begin
();
for
(
vector
<
DataEntry
>::
const_iterator
i
=
entries_
.
begin
();
i
!=
entries_
.
end
();
++
i
)
{
i
!=
entries_
.
end
();
++
i
)
{
if
(
i
->
first
==
key
)
{
if
(
i
->
first
==
key
)
{
cerr
<<
"error: duplicate key ("
<<
key
std
::
cerr
<<
"error: duplicate key ("
<<
key
<<
") making TextFormat data, input:
\"
"
<<
input_for_decode
<<
") making TextFormat data, input:
\"
"
<<
input_for_decode
<<
"
\"
, desired:
\"
"
<<
desired_output
<<
"
\"
."
<<
endl
;
<<
"
\"
, desired:
\"
"
<<
desired_output
<<
"
\"
."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
abort
();
abort
();
}
}
}
}
...
@@ -1194,7 +1194,7 @@ void TextFormatDecodeData::AddString(int32 key,
...
@@ -1194,7 +1194,7 @@ void TextFormatDecodeData::AddString(int32 key,
}
}
string
TextFormatDecodeData
::
Data
()
const
{
string
TextFormatDecodeData
::
Data
()
const
{
ostringstream
data_stringstream
;
std
::
ostringstream
data_stringstream
;
if
(
num_entries
()
>
0
)
{
if
(
num_entries
()
>
0
)
{
io
::
OstreamOutputStream
data_outputstream
(
&
data_stringstream
);
io
::
OstreamOutputStream
data_outputstream
(
&
data_stringstream
);
...
@@ -1335,18 +1335,18 @@ string DirectDecodeString(const string& str) {
...
@@ -1335,18 +1335,18 @@ string DirectDecodeString(const string& str) {
string
TextFormatDecodeData
::
DecodeDataForString
(
const
string
&
input_for_decode
,
string
TextFormatDecodeData
::
DecodeDataForString
(
const
string
&
input_for_decode
,
const
string
&
desired_output
)
{
const
string
&
desired_output
)
{
if
((
input_for_decode
.
size
()
==
0
)
||
(
desired_output
.
size
()
==
0
))
{
if
((
input_for_decode
.
size
()
==
0
)
||
(
desired_output
.
size
()
==
0
))
{
cerr
<<
"error: got empty string for making TextFormat data, input:
\"
"
std
::
cerr
<<
"error: got empty string for making TextFormat data, input:
\"
"
<<
input_for_decode
<<
"
\"
, desired:
\"
"
<<
desired_output
<<
"
\"
."
<<
input_for_decode
<<
"
\"
, desired:
\"
"
<<
desired_output
<<
"
\"
."
<<
endl
;
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
abort
();
abort
();
}
}
if
((
input_for_decode
.
find
(
'\0'
)
!=
string
::
npos
)
||
if
((
input_for_decode
.
find
(
'\0'
)
!=
string
::
npos
)
||
(
desired_output
.
find
(
'\0'
)
!=
string
::
npos
))
{
(
desired_output
.
find
(
'\0'
)
!=
string
::
npos
))
{
cerr
<<
"error: got a null char in a string for making TextFormat data,"
std
::
cerr
<<
"error: got a null char in a string for making TextFormat data,"
<<
" input:
\"
"
<<
CEscape
(
input_for_decode
)
<<
"
\"
, desired:
\"
"
<<
" input:
\"
"
<<
CEscape
(
input_for_decode
)
<<
"
\"
, desired:
\"
"
<<
CEscape
(
desired_output
)
<<
"
\"
."
<<
endl
;
<<
CEscape
(
desired_output
)
<<
"
\"
."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
abort
();
abort
();
}
}
...
@@ -1611,9 +1611,9 @@ void ImportWriter::ParseFrameworkMappings() {
...
@@ -1611,9 +1611,9 @@ void ImportWriter::ParseFrameworkMappings() {
string
parse_error
;
string
parse_error
;
if
(
!
ParseSimpleFile
(
named_framework_to_proto_path_mappings_path_
,
if
(
!
ParseSimpleFile
(
named_framework_to_proto_path_mappings_path_
,
&
collector
,
&
parse_error
))
{
&
collector
,
&
parse_error
))
{
cerr
<<
"error parsing "
<<
named_framework_to_proto_path_mappings_path_
std
::
cerr
<<
"error parsing "
<<
named_framework_to_proto_path_mappings_path_
<<
" : "
<<
parse_error
<<
endl
;
<<
" : "
<<
parse_error
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
}
}
}
}
...
@@ -1643,16 +1643,16 @@ bool ImportWriter::ProtoFrameworkCollector::ConsumeLine(
...
@@ -1643,16 +1643,16 @@ bool ImportWriter::ProtoFrameworkCollector::ConsumeLine(
map
<
string
,
string
>::
iterator
existing_entry
=
map
<
string
,
string
>::
iterator
existing_entry
=
map_
->
find
(
proto_file
.
ToString
());
map_
->
find
(
proto_file
.
ToString
());
if
(
existing_entry
!=
map_
->
end
())
{
if
(
existing_entry
!=
map_
->
end
())
{
cerr
<<
"warning: duplicate proto file reference, replacing framework entry for '"
std
::
cerr
<<
"warning: duplicate proto file reference, replacing framework entry for '"
<<
proto_file
.
ToString
()
<<
"' with '"
<<
framework_name
.
ToString
()
<<
proto_file
.
ToString
()
<<
"' with '"
<<
framework_name
.
ToString
()
<<
"' (was '"
<<
existing_entry
->
second
<<
"')."
<<
endl
;
<<
"' (was '"
<<
existing_entry
->
second
<<
"')."
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
}
}
if
(
proto_file
.
find
(
' '
)
!=
StringPiece
::
npos
)
{
if
(
proto_file
.
find
(
' '
)
!=
StringPiece
::
npos
)
{
cerr
<<
"note: framework mapping file had a proto file with a space in, hopefully that isn't a missing comma: '"
std
::
cerr
<<
"note: framework mapping file had a proto file with a space in, hopefully that isn't a missing comma: '"
<<
proto_file
.
ToString
()
<<
"'"
<<
endl
;
<<
proto_file
.
ToString
()
<<
"'"
<<
std
::
endl
;
cerr
.
flush
();
std
::
cerr
.
flush
();
}
}
(
*
map_
)[
proto_file
.
ToString
()]
=
framework_name
.
ToString
();
(
*
map_
)[
proto_file
.
ToString
()]
=
framework_name
.
ToString
();
...
...
src/google/protobuf/compiler/objectivec/objectivec_message.cc
View file @
cbd08cb7
...
@@ -156,7 +156,7 @@ const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
...
@@ -156,7 +156,7 @@ const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
fields
[
i
]
=
descriptor
->
field
(
i
);
fields
[
i
]
=
descriptor
->
field
(
i
);
}
}
sort
(
fields
,
fields
+
descriptor
->
field_count
(),
FieldOrderingByNumber
());
s
td
::
s
ort
(
fields
,
fields
+
descriptor
->
field_count
(),
FieldOrderingByNumber
());
return
fields
;
return
fields
;
}
}
...
@@ -168,7 +168,7 @@ const FieldDescriptor** SortFieldsByStorageSize(const Descriptor* descriptor) {
...
@@ -168,7 +168,7 @@ const FieldDescriptor** SortFieldsByStorageSize(const Descriptor* descriptor) {
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
fields
[
i
]
=
descriptor
->
field
(
i
);
fields
[
i
]
=
descriptor
->
field
(
i
);
}
}
sort
(
fields
,
fields
+
descriptor
->
field_count
(),
s
td
::
s
ort
(
fields
,
fields
+
descriptor
->
field_count
(),
FieldOrderingByStorageSize
());
FieldOrderingByStorageSize
());
return
fields
;
return
fields
;
}
}
...
@@ -430,7 +430,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
...
@@ -430,7 +430,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
sorted_extensions
.
push_back
(
descriptor_
->
extension_range
(
i
));
sorted_extensions
.
push_back
(
descriptor_
->
extension_range
(
i
));
}
}
sort
(
sorted_extensions
.
begin
(),
sorted_extensions
.
end
(),
s
td
::
s
ort
(
sorted_extensions
.
begin
(),
sorted_extensions
.
end
(),
ExtensionRangeOrdering
());
ExtensionRangeOrdering
());
// Assign has bits:
// Assign has bits:
...
...
src/google/protobuf/io/zero_copy_stream_impl_lite.h
View file @
cbd08cb7
...
@@ -399,7 +399,7 @@ inline std::pair<char*, bool> as_string_data(string* s) {
...
@@ -399,7 +399,7 @@ inline std::pair<char*, bool> as_string_data(string* s) {
#ifdef LANG_CXX11
#ifdef LANG_CXX11
return
std
::
make_pair
(
p
,
true
);
return
std
::
make_pair
(
p
,
true
);
#else
#else
return
make_pair
(
p
,
p
!=
NULL
);
return
std
::
make_pair
(
p
,
p
!=
NULL
);
#endif
#endif
}
}
...
...
src/google/protobuf/lite_unittest.cc
View file @
cbd08cb7
...
@@ -46,8 +46,6 @@
...
@@ -46,8 +46,6 @@
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/strutil.h>
using
namespace
std
;
namespace
{
namespace
{
// Helper methods to test parsing merge behavior.
// Helper methods to test parsing merge behavior.
void
ExpectMessageMerged
(
const
google
::
protobuf
::
unittest
::
TestAllTypesLite
&
message
)
{
void
ExpectMessageMerged
(
const
google
::
protobuf
::
unittest
::
TestAllTypesLite
&
message
)
{
...
@@ -71,7 +69,7 @@ void SetAllTypesInEmptyMessageUnknownFields(
...
@@ -71,7 +69,7 @@ void SetAllTypesInEmptyMessageUnknownFields(
protobuf_unittest
::
TestAllTypesLite
message
;
protobuf_unittest
::
TestAllTypesLite
message
;
google
::
protobuf
::
TestUtilLite
::
ExpectClear
(
message
);
google
::
protobuf
::
TestUtilLite
::
ExpectClear
(
message
);
google
::
protobuf
::
TestUtilLite
::
SetAllFields
(
&
message
);
google
::
protobuf
::
TestUtilLite
::
SetAllFields
(
&
message
);
string
data
=
message
.
SerializeAsString
();
st
d
::
st
ring
data
=
message
.
SerializeAsString
();
empty_message
->
ParseFromString
(
data
);
empty_message
->
ParseFromString
(
data
);
}
}
...
@@ -83,7 +81,7 @@ void SetSomeTypesInEmptyMessageUnknownFields(
...
@@ -83,7 +81,7 @@ void SetSomeTypesInEmptyMessageUnknownFields(
message
.
set_optional_int64
(
102
);
message
.
set_optional_int64
(
102
);
message
.
set_optional_uint32
(
103
);
message
.
set_optional_uint32
(
103
);
message
.
set_optional_uint64
(
104
);
message
.
set_optional_uint64
(
104
);
string
data
=
message
.
SerializeAsString
();
st
d
::
st
ring
data
=
message
.
SerializeAsString
();
empty_message
->
ParseFromString
(
data
);
empty_message
->
ParseFromString
(
data
);
}
}
...
@@ -96,7 +94,7 @@ void SetSomeTypesInEmptyMessageUnknownFields(
...
@@ -96,7 +94,7 @@ void SetSomeTypesInEmptyMessageUnknownFields(
#define ASSERT_EQ GOOGLE_CHECK_EQ
#define ASSERT_EQ GOOGLE_CHECK_EQ
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
string
data
,
data2
,
packed_data
;
st
d
::
st
ring
data
,
data2
,
packed_data
;
{
{
protobuf_unittest
::
TestAllTypesLite
message
,
message2
,
message3
;
protobuf_unittest
::
TestAllTypesLite
message
,
message2
,
message3
;
...
@@ -119,7 +117,7 @@ int main(int argc, char* argv[]) {
...
@@ -119,7 +117,7 @@ int main(int argc, char* argv[]) {
google
::
protobuf
::
TestUtilLite
::
ExpectExtensionsClear
(
message
);
google
::
protobuf
::
TestUtilLite
::
ExpectExtensionsClear
(
message
);
google
::
protobuf
::
TestUtilLite
::
SetAllExtensions
(
&
message
);
google
::
protobuf
::
TestUtilLite
::
SetAllExtensions
(
&
message
);
message2
.
CopyFrom
(
message
);
message2
.
CopyFrom
(
message
);
string
extensions_data
=
message
.
SerializeAsString
();
st
d
::
st
ring
extensions_data
=
message
.
SerializeAsString
();
message3
.
ParseFromString
(
extensions_data
);
message3
.
ParseFromString
(
extensions_data
);
google
::
protobuf
::
TestUtilLite
::
ExpectAllExtensionsSet
(
message
);
google
::
protobuf
::
TestUtilLite
::
ExpectAllExtensionsSet
(
message
);
google
::
protobuf
::
TestUtilLite
::
ExpectAllExtensionsSet
(
message2
);
google
::
protobuf
::
TestUtilLite
::
ExpectAllExtensionsSet
(
message2
);
...
@@ -151,7 +149,7 @@ int main(int argc, char* argv[]) {
...
@@ -151,7 +149,7 @@ int main(int argc, char* argv[]) {
google
::
protobuf
::
TestUtilLite
::
ExpectPackedExtensionsClear
(
message
);
google
::
protobuf
::
TestUtilLite
::
ExpectPackedExtensionsClear
(
message
);
google
::
protobuf
::
TestUtilLite
::
SetPackedExtensions
(
&
message
);
google
::
protobuf
::
TestUtilLite
::
SetPackedExtensions
(
&
message
);
message2
.
CopyFrom
(
message
);
message2
.
CopyFrom
(
message
);
string
packed_extensions_data
=
message
.
SerializeAsString
();
st
d
::
st
ring
packed_extensions_data
=
message
.
SerializeAsString
();
GOOGLE_CHECK
(
packed_extensions_data
==
packed_data
);
GOOGLE_CHECK
(
packed_extensions_data
==
packed_data
);
message3
.
ParseFromString
(
packed_extensions_data
);
message3
.
ParseFromString
(
packed_extensions_data
);
google
::
protobuf
::
TestUtilLite
::
ExpectPackedExtensionsSet
(
message
);
google
::
protobuf
::
TestUtilLite
::
ExpectPackedExtensionsSet
(
message
);
...
@@ -195,7 +193,7 @@ int main(int argc, char* argv[]) {
...
@@ -195,7 +193,7 @@ int main(int argc, char* argv[]) {
#undef ASSIGN_REPEATED_GROUP
#undef ASSIGN_REPEATED_GROUP
string
buffer
;
st
d
::
st
ring
buffer
;
generator
.
SerializeToString
(
&
buffer
);
generator
.
SerializeToString
(
&
buffer
);
google
::
protobuf
::
unittest
::
TestParsingMergeLite
parsing_merge
;
google
::
protobuf
::
unittest
::
TestParsingMergeLite
parsing_merge
;
parsing_merge
.
ParseFromString
(
buffer
);
parsing_merge
.
ParseFromString
(
buffer
);
...
@@ -330,7 +328,7 @@ int main(int argc, char* argv[]) {
...
@@ -330,7 +328,7 @@ int main(int argc, char* argv[]) {
{
{
// Test unknown enum value
// Test unknown enum value
protobuf_unittest
::
TestAllTypesLite
message
;
protobuf_unittest
::
TestAllTypesLite
message
;
string
buffer
;
st
d
::
st
ring
buffer
;
{
{
google
::
protobuf
::
io
::
StringOutputStream
output_stream
(
&
buffer
);
google
::
protobuf
::
io
::
StringOutputStream
output_stream
(
&
buffer
);
google
::
protobuf
::
io
::
CodedOutputStream
coded_output
(
&
output_stream
);
google
::
protobuf
::
io
::
CodedOutputStream
coded_output
(
&
output_stream
);
...
@@ -517,7 +515,7 @@ int main(int argc, char* argv[]) {
...
@@ -517,7 +515,7 @@ int main(int argc, char* argv[]) {
{
{
// Test the generated SerializeWithCachedSizesToArray()
// Test the generated SerializeWithCachedSizesToArray()
protobuf_unittest
::
TestMapLite
message1
,
message2
;
protobuf_unittest
::
TestMapLite
message1
,
message2
;
string
data
;
st
d
::
st
ring
data
;
google
::
protobuf
::
MapLiteTestUtil
::
SetMapFields
(
&
message1
);
google
::
protobuf
::
MapLiteTestUtil
::
SetMapFields
(
&
message1
);
int
size
=
message1
.
ByteSize
();
int
size
=
message1
.
ByteSize
();
data
.
resize
(
size
);
data
.
resize
(
size
);
...
@@ -533,7 +531,7 @@ int main(int argc, char* argv[]) {
...
@@ -533,7 +531,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
TestMapLite
message1
,
message2
;
protobuf_unittest
::
TestMapLite
message1
,
message2
;
google
::
protobuf
::
MapLiteTestUtil
::
SetMapFields
(
&
message1
);
google
::
protobuf
::
MapLiteTestUtil
::
SetMapFields
(
&
message1
);
int
size
=
message1
.
ByteSize
();
int
size
=
message1
.
ByteSize
();
string
data
;
st
d
::
st
ring
data
;
data
.
resize
(
size
);
data
.
resize
(
size
);
{
{
// Allow the output stream to buffer only one byte at a time.
// Allow the output stream to buffer only one byte at a time.
...
@@ -556,7 +554,7 @@ int main(int argc, char* argv[]) {
...
@@ -556,7 +554,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
E_PROTO2_MAP_ENUM_FOO_LITE
;
protobuf_unittest
::
E_PROTO2_MAP_ENUM_FOO_LITE
;
(
*
from
.
mutable_unknown_map_field
())[
0
]
=
(
*
from
.
mutable_unknown_map_field
())[
0
]
=
protobuf_unittest
::
E_PROTO2_MAP_ENUM_EXTRA_LITE
;
protobuf_unittest
::
E_PROTO2_MAP_ENUM_EXTRA_LITE
;
string
data
;
st
d
::
st
ring
data
;
from
.
SerializeToString
(
&
data
);
from
.
SerializeToString
(
&
data
);
protobuf_unittest
::
TestEnumMapLite
to
;
protobuf_unittest
::
TestEnumMapLite
to
;
...
@@ -582,7 +580,7 @@ int main(int argc, char* argv[]) {
...
@@ -582,7 +580,7 @@ int main(int argc, char* argv[]) {
{
{
// StandardWireFormat
// StandardWireFormat
protobuf_unittest
::
TestMapLite
message
;
protobuf_unittest
::
TestMapLite
message
;
string
data
=
"
\x0A\x04\x08\x01\x10\x01
"
;
st
d
::
st
ring
data
=
"
\x0A\x04\x08\x01\x10\x01
"
;
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
...
@@ -594,7 +592,7 @@ int main(int argc, char* argv[]) {
...
@@ -594,7 +592,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
TestMapLite
message
;
protobuf_unittest
::
TestMapLite
message
;
// put value before key in wire format
// put value before key in wire format
string
data
=
"
\x0A\x04\x10\x01\x08\x02
"
;
st
d
::
st
ring
data
=
"
\x0A\x04\x10\x01\x08\x02
"
;
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
...
@@ -606,7 +604,7 @@ int main(int argc, char* argv[]) {
...
@@ -606,7 +604,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
TestMapLite
message
;
protobuf_unittest
::
TestMapLite
message
;
// Two key fields in wire format
// Two key fields in wire format
string
data
=
"
\x0A\x06\x08\x01\x08\x02\x10\x01
"
;
st
d
::
st
ring
data
=
"
\x0A\x06\x08\x01\x08\x02\x10\x01
"
;
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
...
@@ -618,7 +616,7 @@ int main(int argc, char* argv[]) {
...
@@ -618,7 +616,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
TestMapLite
message
;
protobuf_unittest
::
TestMapLite
message
;
// Two value fields in wire format
// Two value fields in wire format
string
data
=
"
\x0A\x06\x08\x01\x10\x01\x10\x02
"
;
st
d
::
st
ring
data
=
"
\x0A\x06\x08\x01\x10\x01\x10\x02
"
;
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
...
@@ -630,7 +628,7 @@ int main(int argc, char* argv[]) {
...
@@ -630,7 +628,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
TestMapLite
message
;
protobuf_unittest
::
TestMapLite
message
;
// No key field in wire format
// No key field in wire format
string
data
=
"
\x0A\x02\x10\x01
"
;
st
d
::
st
ring
data
=
"
\x0A\x02\x10\x01
"
;
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
...
@@ -642,7 +640,7 @@ int main(int argc, char* argv[]) {
...
@@ -642,7 +640,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
TestMapLite
message
;
protobuf_unittest
::
TestMapLite
message
;
// No value field in wire format
// No value field in wire format
string
data
=
"
\x0A\x02\x08\x01
"
;
st
d
::
st
ring
data
=
"
\x0A\x02\x08\x01
"
;
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
...
@@ -654,7 +652,7 @@ int main(int argc, char* argv[]) {
...
@@ -654,7 +652,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
TestMapLite
message
;
protobuf_unittest
::
TestMapLite
message
;
// Unknown field in wire format
// Unknown field in wire format
string
data
=
"
\x0A\x06\x08\x02\x10\x03\x18\x01
"
;
st
d
::
st
ring
data
=
"
\x0A\x06\x08\x02\x10\x03\x18\x01
"
;
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_TRUE
(
message
.
ParseFromString
(
data
));
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
EXPECT_EQ
(
1
,
message
.
map_int32_int32
().
size
());
...
@@ -666,7 +664,7 @@ int main(int argc, char* argv[]) {
...
@@ -666,7 +664,7 @@ int main(int argc, char* argv[]) {
protobuf_unittest
::
TestMapLite
message
;
protobuf_unittest
::
TestMapLite
message
;
// corrupted data in wire format
// corrupted data in wire format
string
data
=
"
\x0A\x06\x08\x02\x11\x03
"
;
st
d
::
st
ring
data
=
"
\x0A\x06\x08\x02\x11\x03
"
;
EXPECT_FALSE
(
message
.
ParseFromString
(
data
));
EXPECT_FALSE
(
message
.
ParseFromString
(
data
));
}
}
...
@@ -693,7 +691,7 @@ int main(int argc, char* argv[]) {
...
@@ -693,7 +691,7 @@ int main(int argc, char* argv[]) {
v2_message
.
set_int_field
(
800
);
v2_message
.
set_int_field
(
800
);
// Set enum field to the value not understood by the old client.
// Set enum field to the value not understood by the old client.
v2_message
.
set_enum_field
(
protobuf_unittest
::
V2_SECOND
);
v2_message
.
set_enum_field
(
protobuf_unittest
::
V2_SECOND
);
string
v2_bytes
=
v2_message
.
SerializeAsString
();
st
d
::
st
ring
v2_bytes
=
v2_message
.
SerializeAsString
();
protobuf_unittest
::
V1MessageLite
v1_message
;
protobuf_unittest
::
V1MessageLite
v1_message
;
v1_message
.
ParseFromString
(
v2_bytes
);
v1_message
.
ParseFromString
(
v2_bytes
);
...
@@ -704,7 +702,7 @@ int main(int argc, char* argv[]) {
...
@@ -704,7 +702,7 @@ int main(int argc, char* argv[]) {
EXPECT_EQ
(
v1_message
.
enum_field
(),
protobuf_unittest
::
V1_FIRST
);
EXPECT_EQ
(
v1_message
.
enum_field
(),
protobuf_unittest
::
V1_FIRST
);
// However, when re-serialized, it should preserve enum value.
// However, when re-serialized, it should preserve enum value.
string
v1_bytes
=
v1_message
.
SerializeAsString
();
st
d
::
st
ring
v1_bytes
=
v1_message
.
SerializeAsString
();
protobuf_unittest
::
V2MessageLite
same_v2_message
;
protobuf_unittest
::
V2MessageLite
same_v2_message
;
same_v2_message
.
ParseFromString
(
v1_bytes
);
same_v2_message
.
ParseFromString
(
v1_bytes
);
...
...
src/google/protobuf/stubs/common.h
View file @
cbd08cb7
...
@@ -35,7 +35,12 @@
...
@@ -35,7 +35,12 @@
#ifndef GOOGLE_PROTOBUF_COMMON_H__
#ifndef GOOGLE_PROTOBUF_COMMON_H__
#define GOOGLE_PROTOBUF_COMMON_H__
#define GOOGLE_PROTOBUF_COMMON_H__
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <string>
#include <vector>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/macros.h>
#include <google/protobuf/stubs/macros.h>
...
@@ -220,7 +225,14 @@ class FatalException : public std::exception {
...
@@ -220,7 +225,14 @@ class FatalException : public std::exception {
// This is at the end of the file instead of the beginning to work around a bug
// This is at the end of the file instead of the beginning to work around a bug
// in some versions of MSVC.
// in some versions of MSVC.
using
namespace
std
;
// Don't do this at home, kids.
// TODO(acozzette): remove these using statements
using
std
::
istream
;
using
std
::
map
;
using
std
::
ostream
;
using
std
::
pair
;
using
std
::
set
;
using
std
::
string
;
using
std
::
vector
;
}
// namespace protobuf
}
// namespace protobuf
}
// namespace google
}
// namespace google
...
...
src/google/protobuf/stubs/int128_unittest.cc
View file @
cbd08cb7
...
@@ -370,29 +370,29 @@ TEST(Int128, DivideAndMod) {
...
@@ -370,29 +370,29 @@ TEST(Int128, DivideAndMod) {
EXPECT_EQ
(
r
,
result_r
);
EXPECT_EQ
(
r
,
result_r
);
// Try the other way around.
// Try the other way around.
swap
(
q
,
b
);
s
td
::
s
wap
(
q
,
b
);
result_q
=
a
/
b
;
result_q
=
a
/
b
;
result_r
=
a
%
b
;
result_r
=
a
%
b
;
EXPECT_EQ
(
q
,
result_q
);
EXPECT_EQ
(
q
,
result_q
);
EXPECT_EQ
(
r
,
result_r
);
EXPECT_EQ
(
r
,
result_r
);
// Restore.
// Restore.
swap
(
b
,
q
);
s
td
::
s
wap
(
b
,
q
);
// Dividend < divisor; result should be q:0 r:<dividend>.
// Dividend < divisor; result should be q:0 r:<dividend>.
swap
(
a
,
b
);
s
td
::
s
wap
(
a
,
b
);
result_q
=
a
/
b
;
result_q
=
a
/
b
;
result_r
=
a
%
b
;
result_r
=
a
%
b
;
EXPECT_EQ
(
0
,
result_q
);
EXPECT_EQ
(
0
,
result_q
);
EXPECT_EQ
(
a
,
result_r
);
EXPECT_EQ
(
a
,
result_r
);
// Try the other way around.
// Try the other way around.
swap
(
a
,
q
);
s
td
::
s
wap
(
a
,
q
);
result_q
=
a
/
b
;
result_q
=
a
/
b
;
result_r
=
a
%
b
;
result_r
=
a
%
b
;
EXPECT_EQ
(
0
,
result_q
);
EXPECT_EQ
(
0
,
result_q
);
EXPECT_EQ
(
a
,
result_r
);
EXPECT_EQ
(
a
,
result_r
);
// Restore.
// Restore.
swap
(
q
,
a
);
s
td
::
s
wap
(
q
,
a
);
swap
(
b
,
a
);
s
td
::
s
wap
(
b
,
a
);
// Try a large remainder.
// Try a large remainder.
b
=
a
/
2
+
1
;
b
=
a
/
2
+
1
;
...
@@ -501,7 +501,7 @@ TEST(Int128, OStream) {
...
@@ -501,7 +501,7 @@ TEST(Int128, OStream) {
{
uint128
(
12345
),
std
::
ios
::
dec
|
std
::
ios
::
left
,
6
,
'_'
,
"12345_"
},
{
uint128
(
12345
),
std
::
ios
::
dec
|
std
::
ios
::
left
,
6
,
'_'
,
"12345_"
},
};
};
for
(
size_t
i
=
0
;
i
<
GOOGLE_ARRAYSIZE
(
cases
);
++
i
)
{
for
(
size_t
i
=
0
;
i
<
GOOGLE_ARRAYSIZE
(
cases
);
++
i
)
{
ostringstream
os
;
std
::
ostringstream
os
;
os
.
flags
(
cases
[
i
].
flags
);
os
.
flags
(
cases
[
i
].
flags
);
os
.
width
(
cases
[
i
].
width
);
os
.
width
(
cases
[
i
].
width
);
os
.
fill
(
cases
[
i
].
fill
);
os
.
fill
(
cases
[
i
].
fill
);
...
...
src/google/protobuf/stubs/strutil.cc
View file @
cbd08cb7
...
@@ -227,7 +227,7 @@ void SplitStringToIteratorUsing(const string& full,
...
@@ -227,7 +227,7 @@ void SplitStringToIteratorUsing(const string& full,
void
SplitStringUsing
(
const
string
&
full
,
void
SplitStringUsing
(
const
string
&
full
,
const
char
*
delim
,
const
char
*
delim
,
vector
<
string
>*
result
)
{
vector
<
string
>*
result
)
{
back_insert_iterator
<
vector
<
string
>
>
it
(
*
result
);
std
::
back_insert_iterator
<
vector
<
string
>
>
it
(
*
result
);
SplitStringToIteratorUsing
(
full
,
delim
,
it
);
SplitStringToIteratorUsing
(
full
,
delim
,
it
);
}
}
...
@@ -265,7 +265,7 @@ void SplitStringToIteratorAllowEmpty(const StringType& full,
...
@@ -265,7 +265,7 @@ void SplitStringToIteratorAllowEmpty(const StringType& full,
void
SplitStringAllowEmpty
(
const
string
&
full
,
const
char
*
delim
,
void
SplitStringAllowEmpty
(
const
string
&
full
,
const
char
*
delim
,
vector
<
string
>*
result
)
{
vector
<
string
>*
result
)
{
back_insert_iterator
<
vector
<
string
>
>
it
(
*
result
);
std
::
back_insert_iterator
<
vector
<
string
>
>
it
(
*
result
);
SplitStringToIteratorAllowEmpty
(
full
,
delim
,
0
,
it
);
SplitStringToIteratorAllowEmpty
(
full
,
delim
,
0
,
it
);
}
}
...
@@ -1262,10 +1262,10 @@ char* DoubleToBuffer(double value, char* buffer) {
...
@@ -1262,10 +1262,10 @@ char* DoubleToBuffer(double value, char* buffer) {
// this assert.
// this assert.
GOOGLE_COMPILE_ASSERT
(
DBL_DIG
<
20
,
DBL_DIG_is_too_big
);
GOOGLE_COMPILE_ASSERT
(
DBL_DIG
<
20
,
DBL_DIG_is_too_big
);
if
(
value
==
numeric_limits
<
double
>::
infinity
())
{
if
(
value
==
std
::
numeric_limits
<
double
>::
infinity
())
{
strcpy
(
buffer
,
"inf"
);
strcpy
(
buffer
,
"inf"
);
return
buffer
;
return
buffer
;
}
else
if
(
value
==
-
numeric_limits
<
double
>::
infinity
())
{
}
else
if
(
value
==
-
std
::
numeric_limits
<
double
>::
infinity
())
{
strcpy
(
buffer
,
"-inf"
);
strcpy
(
buffer
,
"-inf"
);
return
buffer
;
return
buffer
;
}
else
if
(
MathLimits
<
double
>::
IsNaN
(
value
))
{
}
else
if
(
MathLimits
<
double
>::
IsNaN
(
value
))
{
...
@@ -1380,10 +1380,10 @@ char* FloatToBuffer(float value, char* buffer) {
...
@@ -1380,10 +1380,10 @@ char* FloatToBuffer(float value, char* buffer) {
// this assert.
// this assert.
GOOGLE_COMPILE_ASSERT
(
FLT_DIG
<
10
,
FLT_DIG_is_too_big
);
GOOGLE_COMPILE_ASSERT
(
FLT_DIG
<
10
,
FLT_DIG_is_too_big
);
if
(
value
==
numeric_limits
<
double
>::
infinity
())
{
if
(
value
==
std
::
numeric_limits
<
double
>::
infinity
())
{
strcpy
(
buffer
,
"inf"
);
strcpy
(
buffer
,
"inf"
);
return
buffer
;
return
buffer
;
}
else
if
(
value
==
-
numeric_limits
<
double
>::
infinity
())
{
}
else
if
(
value
==
-
std
::
numeric_limits
<
double
>::
infinity
())
{
strcpy
(
buffer
,
"-inf"
);
strcpy
(
buffer
,
"-inf"
);
return
buffer
;
return
buffer
;
}
else
if
(
MathLimits
<
float
>::
IsNaN
(
value
))
{
}
else
if
(
MathLimits
<
float
>::
IsNaN
(
value
))
{
...
...
src/google/protobuf/util/delimited_message_util_test.cc
View file @
cbd08cb7
...
@@ -15,7 +15,7 @@ namespace protobuf {
...
@@ -15,7 +15,7 @@ namespace protobuf {
namespace
util
{
namespace
util
{
TEST
(
DelimitedMessageUtilTest
,
DelimitedMessages
)
{
TEST
(
DelimitedMessageUtilTest
,
DelimitedMessages
)
{
stringstream
stream
;
st
d
::
st
ringstream
stream
;
{
{
protobuf_unittest
::
TestAllTypes
message1
;
protobuf_unittest
::
TestAllTypes
message1
;
...
...
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