Index: third_party/protobuf/src/google/protobuf/text_format.h |
diff --git a/third_party/protobuf/src/google/protobuf/text_format.h b/third_party/protobuf/src/google/protobuf/text_format.h |
index 6717aecd81b7bca87be5f5589bef9ac9c8948d1e..01f3ffb0865e673c68baee2fbc213a93c948eed5 100644 |
--- a/third_party/protobuf/src/google/protobuf/text_format.h |
+++ b/third_party/protobuf/src/google/protobuf/text_format.h |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
// Copyright 2008 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
+// http://code.google.com/p/protobuf/ |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -39,16 +39,11 @@ |
#define GOOGLE_PROTOBUF_TEXT_FORMAT_H__ |
#include <map> |
-#include <memory> |
-#ifndef _SHARED_PTR_H |
-#include <google/protobuf/stubs/shared_ptr.h> |
-#endif |
#include <string> |
#include <vector> |
- |
#include <google/protobuf/stubs/common.h> |
-#include <google/protobuf/descriptor.h> |
#include <google/protobuf/message.h> |
+#include <google/protobuf/descriptor.h> |
namespace google { |
namespace protobuf { |
@@ -90,41 +85,6 @@ class LIBPROTOBUF_EXPORT TextFormat { |
int index, |
string* output); |
- // The default printer that converts scalar values from fields into |
- // their string representation. |
- // You can derive from this FieldValuePrinter if you want to have |
- // fields to be printed in a different way and register it at the |
- // Printer. |
- class LIBPROTOBUF_EXPORT FieldValuePrinter { |
- public: |
- FieldValuePrinter(); |
- virtual ~FieldValuePrinter(); |
- virtual string PrintBool(bool val) const; |
- virtual string PrintInt32(int32 val) const; |
- virtual string PrintUInt32(uint32 val) const; |
- virtual string PrintInt64(int64 val) const; |
- virtual string PrintUInt64(uint64 val) const; |
- virtual string PrintFloat(float val) const; |
- virtual string PrintDouble(double val) const; |
- virtual string PrintString(const string& val) const; |
- virtual string PrintBytes(const string& val) const; |
- virtual string PrintEnum(int32 val, const string& name) const; |
- virtual string PrintFieldName(const Message& message, |
- const Reflection* reflection, |
- const FieldDescriptor* field) const; |
- virtual string PrintMessageStart(const Message& message, |
- int field_index, |
- int field_count, |
- bool single_line_mode) const; |
- virtual string PrintMessageEnd(const Message& message, |
- int field_index, |
- int field_count, |
- bool single_line_mode) const; |
- |
- private: |
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldValuePrinter); |
- }; |
- |
// Class for those users which require more fine-grained control over how |
// a protobuffer message is printed out. |
class LIBPROTOBUF_EXPORT Printer { |
@@ -160,15 +120,6 @@ class LIBPROTOBUF_EXPORT TextFormat { |
single_line_mode_ = single_line_mode; |
} |
- bool IsInSingleLineMode() { |
- return single_line_mode_; |
- } |
- |
- // If use_field_number is true, uses field number instead of field name. |
- void SetUseFieldNumber(bool use_field_number) { |
- use_field_number_ = use_field_number; |
- } |
- |
// Set true to print repeated primitives in a format like: |
// field_name: [1, 2, 3, 4] |
// instead of printing each value on its own line. Short format applies |
@@ -181,52 +132,11 @@ class LIBPROTOBUF_EXPORT TextFormat { |
// Set true to output UTF-8 instead of ASCII. The only difference |
// is that bytes >= 0x80 in string fields will not be escaped, |
// because they are assumed to be part of UTF-8 multi-byte |
- // sequences. This will change the default FieldValuePrinter. |
- void SetUseUtf8StringEscaping(bool as_utf8); |
- |
- // Set the default FieldValuePrinter that is used for all fields that |
- // don't have a field-specific printer registered. |
- // Takes ownership of the printer. |
- void SetDefaultFieldValuePrinter(const FieldValuePrinter* printer); |
- |
- // Sets whether we want to hide unknown fields or not. |
- // Usually unknown fields are printed in a generic way that includes the |
- // tag number of the field instead of field name. However, sometimes it |
- // is useful to be able to print the message without unknown fields (e.g. |
- // for the python protobuf version to maintain consistency between its pure |
- // python and c++ implementations). |
- void SetHideUnknownFields(bool hide) { |
- hide_unknown_fields_ = hide; |
- } |
- |
- // If print_message_fields_in_index_order is true, print fields of a proto |
- // message using the order defined in source code instead of the field |
- // number. By default, use the field number order. |
- void SetPrintMessageFieldsInIndexOrder( |
- bool print_message_fields_in_index_order) { |
- print_message_fields_in_index_order_ = |
- print_message_fields_in_index_order; |
+ // sequences. |
+ void SetUseUtf8StringEscaping(bool as_utf8) { |
+ utf8_string_escaping_ = as_utf8; |
} |
- // If expand==true, expand google.protobuf.Any payloads. The output |
- // will be of form |
- // [type_url] { <value_printed_in_text> } |
- // |
- // If expand==false, print Any using the default printer. The output will |
- // look like |
- // type_url: "<type_url>" value: "serialized_content" |
- void SetExpandAny(bool expand) { |
- expand_any_ = expand; |
- } |
- |
- // Register a custom field-specific FieldValuePrinter for fields |
- // with a particular FieldDescriptor. |
- // Returns "true" if the registration succeeded, or "false", if there is |
- // already a printer for that FieldDescriptor. |
- // Takes ownership of the printer on successful registration. |
- bool RegisterFieldValuePrinter(const FieldDescriptor* field, |
- const FieldValuePrinter* printer); |
- |
private: |
// Forward declaration of an internal class used to print the text |
// output to the OutputStream (see text_format.cc for implementation). |
@@ -270,43 +180,18 @@ class LIBPROTOBUF_EXPORT TextFormat { |
void PrintUnknownFields(const UnknownFieldSet& unknown_fields, |
TextGenerator& generator) const; |
- bool PrintAny(const Message& message, TextGenerator& generator) const; |
- |
int initial_indent_level_; |
bool single_line_mode_; |
- bool use_field_number_; |
- |
bool use_short_repeated_primitives_; |
- bool hide_unknown_fields_; |
- |
- bool print_message_fields_in_index_order_; |
- |
- bool expand_any_; |
- |
- google::protobuf::scoped_ptr<const FieldValuePrinter> default_field_value_printer_; |
- typedef map<const FieldDescriptor*, |
- const FieldValuePrinter*> CustomPrinterMap; |
- CustomPrinterMap custom_printers_; |
+ bool utf8_string_escaping_; |
}; |
// Parses a text-format protocol message from the given input stream to |
- // the given message object. This function parses the human-readable format |
- // written by Print(). Returns true on success. The message is cleared first, |
- // even if the function fails -- See Merge() to avoid this behavior. |
- // |
- // Example input: "user {\n id: 123 extra { gender: MALE language: 'en' }\n}" |
- // |
- // One use for this function is parsing handwritten strings in test code. |
- // Another use is to parse the output from google::protobuf::Message::DebugString() |
- // (or ShortDebugString()), because these functions output using |
- // google::protobuf::TextFormat::Print(). |
- // |
- // If you would like to read a protocol buffer serialized in the |
- // (non-human-readable) binary wire format, see |
- // google::protobuf::MessageLite::ParseFromString(). |
+ // the given message object. This function parses the format written |
+ // by Print(). |
static bool Parse(io::ZeroCopyInputStream* input, Message* output); |
// Like Parse(), but reads directly from a string. |
static bool ParseFromString(const string& input, Message* output); |
@@ -429,24 +314,12 @@ class LIBPROTOBUF_EXPORT TextFormat { |
allow_partial_ = allow; |
} |
- // Allow field names to be matched case-insensitively. |
- // This is not advisable if there are fields that only differ in case, or |
- // if you want to enforce writing in the canonical form. |
- // This is 'false' by default. |
- void AllowCaseInsensitiveField(bool allow) { |
- allow_case_insensitive_field_ = allow; |
- } |
- |
// Like TextFormat::ParseFieldValueFromString |
bool ParseFieldValueFromString(const string& input, |
const FieldDescriptor* field, |
Message* output); |
- void AllowFieldNumber(bool allow) { |
- allow_field_number_ = allow; |
- } |
- |
private: |
// Forward declaration of an internal class used to parse text |
// representations (see text_format.cc for implementation). |
@@ -462,15 +335,9 @@ class LIBPROTOBUF_EXPORT TextFormat { |
Finder* finder_; |
ParseInfoTree* parse_info_tree_; |
bool allow_partial_; |
- bool allow_case_insensitive_field_; |
bool allow_unknown_field_; |
- bool allow_unknown_enum_; |
- bool allow_field_number_; |
- bool allow_relaxed_whitespace_; |
- bool allow_singular_overwrites_; |
}; |
- |
private: |
// Hack: ParseInfoTree declares TextFormat as a friend which should extend |
// the friendship to TextFormat::Parser::ParserImpl, but unfortunately some |
@@ -491,7 +358,6 @@ inline void TextFormat::RecordLocation(ParseInfoTree* info_tree, |
info_tree->RecordLocation(field, location); |
} |
- |
inline TextFormat::ParseInfoTree* TextFormat::CreateNested( |
ParseInfoTree* info_tree, const FieldDescriptor* field) { |
return info_tree->CreateNested(field); |