aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/descriptor.cc
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2014-11-14 11:50:31 -0800
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2014-11-14 11:50:31 -0800
commitf157a5651c79a7a36e242af216a5d5b383ba8af2 (patch)
tree368bb0ca0e89ab7514302e4df00435a4ef461a28 /src/google/protobuf/descriptor.cc
parentfaf581d20866ad5e586b3e515f6c547d2dcec2c1 (diff)
Down-integrate from internal code base (C++ maps support).
Diffstat (limited to 'src/google/protobuf/descriptor.cc')
-rw-r--r--src/google/protobuf/descriptor.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index 06184820..d3a60045 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -1617,6 +1617,10 @@ bool DescriptorPool::TryFindExtensionInFallbackDatabase(
// ===================================================================
+bool FieldDescriptor::is_map() const {
+ return type() == TYPE_MESSAGE && message_type()->options().map_entry();
+}
+
string FieldDescriptor::DefaultValueAsString(bool quote_string_type) const {
GOOGLE_CHECK(has_default_value()) << "No default value";
switch (cpp_type()) {
@@ -2184,9 +2188,7 @@ void FieldDescriptor::DebugString(int depth,
string field_type;
// Special case map fields.
- bool is_map = false;
- if (type() == TYPE_MESSAGE && message_type()->options().map_entry()) {
- is_map = true;
+ if (is_map()) {
strings::SubstituteAndAppend(
&field_type, "map<$0, $1>",
message_type()->field(0)->FieldTypeNameDebugString(),
@@ -2196,7 +2198,7 @@ void FieldDescriptor::DebugString(int depth,
}
string label;
- if (print_label_flag == PRINT_LABEL && !is_map) {
+ if (print_label_flag == PRINT_LABEL && !is_map()) {
label = kLabelToName[this->label()];
label.push_back(' ');
}
@@ -4964,8 +4966,7 @@ void DescriptorBuilder::ValidateFieldOptions(FieldDescriptor* field,
}
// Validate map types.
- if (field->type() == FieldDescriptor::TYPE_MESSAGE &&
- field->message_type()->options().map_entry()) {
+ if (field->is_map()) {
if (!ValidateMapEntry(field, proto)) {
AddError(field->full_name(), proto,
DescriptorPool::ErrorCollector::OTHER,