| Index: third_party/protobuf/src/google/protobuf/util/field_mask_util.h
|
| diff --git a/third_party/protobuf/src/google/protobuf/util/field_mask_util.h b/third_party/protobuf/src/google/protobuf/util/field_mask_util.h
|
| index 644161b940190735e6956c0cedbf1c3aff63c933..ab1f2e94c3a8e312790d92fccb5ba2088dfaf09f 100644
|
| --- a/third_party/protobuf/src/google/protobuf/util/field_mask_util.h
|
| +++ b/third_party/protobuf/src/google/protobuf/util/field_mask_util.h
|
| @@ -28,6 +28,8 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| +// Defines utilities for the FieldMask well known type.
|
| +
|
| #ifndef GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
|
| #define GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
|
|
|
| @@ -57,17 +59,26 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
|
| static bool ToJsonString(const FieldMask& mask, string* out);
|
| static bool FromJsonString(StringPiece str, FieldMask* out);
|
|
|
| + // Get the descriptors of the fields which the given path from the message
|
| + // descriptor traverses, if field_descriptors is not null.
|
| + // Return false if the path is not valid, and the content of field_descriptors
|
| + // is unspecified.
|
| + static bool GetFieldDescriptors(
|
| + const Descriptor* descriptor, StringPiece path,
|
| + std::vector<const FieldDescriptor*>* field_descriptors);
|
| +
|
| // Checks whether the given path is valid for type T.
|
| template <typename T>
|
| static bool IsValidPath(StringPiece path) {
|
| - return InternalIsValidPath(T::descriptor(), path);
|
| + return GetFieldDescriptors(T::descriptor(), path, NULL);
|
| }
|
|
|
| // Checks whether the given FieldMask is valid for type T.
|
| template <typename T>
|
| static bool IsValidFieldMask(const FieldMask& mask) {
|
| for (int i = 0; i < mask.paths_size(); ++i) {
|
| - if (!InternalIsValidPath(T::descriptor(), mask.paths(i))) return false;
|
| + if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), NULL))
|
| + return false;
|
| }
|
| return true;
|
| }
|
| @@ -107,10 +118,16 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
|
| static bool IsPathInFieldMask(StringPiece path, const FieldMask& mask);
|
|
|
| class MergeOptions;
|
| - // Merges fields specified in a FieldMask into another message.
|
| + // Merges fields specified in a FieldMask into another message. See the
|
| + // comments in MergeOptions regarding compatibility with
|
| + // google/protobuf/field_mask.proto
|
| static void MergeMessageTo(const Message& source, const FieldMask& mask,
|
| const MergeOptions& options, Message* destination);
|
|
|
| + // Removes from 'message' any field that is not represented in the given
|
| + // FieldMask. If the FieldMask is empty, does nothing.
|
| + static void TrimMessage(const FieldMask& mask, Message* message);
|
| +
|
| private:
|
| friend class SnakeCaseCamelCaseTest;
|
| // Converts a field name from snake_case to camelCase:
|
| @@ -141,13 +158,14 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
|
| // successfully.
|
| static bool CamelCaseToSnakeCase(StringPiece input, string* output);
|
|
|
| - static bool InternalIsValidPath(const Descriptor* descriptor,
|
| - StringPiece path);
|
| -
|
| static void InternalGetFieldMaskForAllFields(const Descriptor* descriptor,
|
| FieldMask* out);
|
| };
|
|
|
| +// Note that for compatibility with the defined behaviour for FieldMask in
|
| +// google/protobuf/field_mask.proto, set replace_message_fields and
|
| +// replace_repeated_fields to 'true'. The default options are not compatible
|
| +// with google/protobuf/field_mask.proto.
|
| class LIBPROTOBUF_EXPORT FieldMaskUtil::MergeOptions {
|
| public:
|
| MergeOptions()
|
|
|