diff options
author | Adam Cozzette <acozzette@google.com> | 2016-11-17 16:48:38 -0800 |
---|---|---|
committer | Adam Cozzette <acozzette@google.com> | 2016-11-17 16:59:59 -0800 |
commit | 5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74 (patch) | |
tree | 0276f81f8848a05d84cd7e287b43d665e30f04e3 /src/google/protobuf/util/field_mask_util.cc | |
parent | e28286fa05d8327fd6c5aa70cfb3be558f0932b8 (diff) | |
download | protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.tar.gz protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.tar.bz2 protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.zip |
Integrated internal changes from Google
Diffstat (limited to 'src/google/protobuf/util/field_mask_util.cc')
-rw-r--r-- | src/google/protobuf/util/field_mask_util.cc | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc index 9dfcbd72..07550e6d 100644 --- a/src/google/protobuf/util/field_mask_util.cc +++ b/src/google/protobuf/util/field_mask_util.cc @@ -45,7 +45,7 @@ string FieldMaskUtil::ToString(const FieldMask& mask) { void FieldMaskUtil::FromString(StringPiece str, FieldMask* out) { out->Clear(); - vector<string> paths = Split(str, ","); + std::vector<string> paths = Split(str, ","); for (int i = 0; i < paths.size(); ++i) { if (paths[i].empty()) continue; out->add_paths(paths[i]); @@ -116,7 +116,7 @@ bool FieldMaskUtil::ToJsonString(const FieldMask& mask, string* out) { bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) { out->Clear(); - vector<string> paths = Split(str, ","); + std::vector<string> paths = Split(str, ","); for (int i = 0; i < paths.size(); ++i) { if (paths[i].empty()) continue; string snakecase_path; @@ -128,9 +128,13 @@ bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) { return true; } -bool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor, - StringPiece path) { - vector<string> parts = Split(path, "."); +bool FieldMaskUtil::GetFieldDescriptors( + const Descriptor* descriptor, StringPiece path, + std::vector<const FieldDescriptor*>* field_descriptors) { + if (field_descriptors != NULL) { + field_descriptors->clear(); + } + std::vector<string> parts = Split(path, "."); for (int i = 0; i < parts.size(); ++i) { const string& field_name = parts[i]; if (descriptor == NULL) { @@ -140,6 +144,9 @@ bool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor, if (field == NULL) { return false; } + if (field_descriptors != NULL) { + field_descriptors->push_back(field); + } if (!field->is_repeated() && field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { descriptor = field->message_type(); @@ -216,14 +223,14 @@ class FieldMaskTree { ~Node() { ClearChildren(); } void ClearChildren() { - for (map<string, Node*>::iterator it = children.begin(); + for (std::map<string, Node*>::iterator it = children.begin(); it != children.end(); ++it) { delete it->second; } children.clear(); } - map<string, Node*> children; + std::map<string, Node*> children; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node); @@ -274,7 +281,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node, out->add_paths(prefix); return; } - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { string current_path = prefix.empty() ? it->first : prefix + "." + it->first; MergeToFieldMask(current_path, it->second, out); @@ -282,7 +289,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node, } void FieldMaskTree::AddPath(const string& path) { - vector<string> parts = Split(path, "."); + std::vector<string> parts = Split(path, "."); if (parts.empty()) { return; } @@ -309,7 +316,7 @@ void FieldMaskTree::AddPath(const string& path) { } void FieldMaskTree::IntersectPath(const string& path, FieldMaskTree* out) { - vector<string> parts = Split(path, "."); + std::vector<string> parts = Split(path, "."); if (parts.empty()) { return; } @@ -339,7 +346,7 @@ void FieldMaskTree::MergeLeafNodesToTree(const string& prefix, const Node* node, if (node->children.empty()) { out->AddPath(prefix); } - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { string current_path = prefix.empty() ? it->first : prefix + "." + it->first; MergeLeafNodesToTree(current_path, it->second, out); @@ -353,7 +360,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source, const Reflection* source_reflection = source.GetReflection(); const Reflection* destination_reflection = destination->GetReflection(); const Descriptor* descriptor = source.GetDescriptor(); - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { const string& field_name = it->first; const Node* child = it->second; |