#include <google/protobuf/text_format.h>
#include <float.h>
#include <stdio.h>
#include <algorithm>
#include <atomic>
#include <climits>
#include <cmath>
#include <limits>
#include <utility>
#include <vector>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/any.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/io/strtod.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
namespace {
inline bool IsHexNumber(const std::string& str) { … }
inline bool IsOctNumber(const std::string& str) { … }
}
namespace internal {
const char kDebugStringSilentMarker[] = …;
const char kDebugStringSilentMarkerForDetection[] = …;
PROTOBUF_EXPORT std::atomic<bool> enable_debug_text_format_marker;
}
std::string Message::DebugString() const { … }
std::string Message::ShortDebugString() const { … }
std::string Message::Utf8DebugString() const { … }
void Message::PrintDebugString() const { … }
void TextFormat::ParseInfoTree::RecordLocation(
const FieldDescriptor* field, TextFormat::ParseLocationRange range) { … }
TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::CreateNested(
const FieldDescriptor* field) { … }
void CheckFieldIndex(const FieldDescriptor* field, int index) { … }
TextFormat::ParseLocationRange TextFormat::ParseInfoTree::GetLocationRange(
const FieldDescriptor* field, int index) const { … }
TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested(
const FieldDescriptor* field, int index) const { … }
namespace {
const FieldDescriptor* DefaultFinderFindExtension(Message* message,
const std::string& name) { … }
const FieldDescriptor* DefaultFinderFindExtensionByNumber(
const Descriptor* descriptor, int number) { … }
const Descriptor* DefaultFinderFindAnyType(const Message& message,
const std::string& prefix,
const std::string& name) { … }
}
#define DO …
class TextFormat::Parser::ParserImpl { … };
class TextFormat::Printer::TextGenerator
: public TextFormat::BaseTextGenerator { … };
class TextFormat::Printer::DebugStringFieldValuePrinter
: public TextFormat::FastFieldValuePrinter { … };
class TextFormat::Printer::FastFieldValuePrinterUtf8Escaping
: public TextFormat::Printer::DebugStringFieldValuePrinter { … };
TextFormat::Finder::~Finder() { … }
const FieldDescriptor* TextFormat::Finder::FindExtension(
Message* message, const std::string& name) const { … }
const FieldDescriptor* TextFormat::Finder::FindExtensionByNumber(
const Descriptor* descriptor, int number) const { … }
const Descriptor* TextFormat::Finder::FindAnyType(
const Message& message, const std::string& prefix,
const std::string& name) const { … }
MessageFactory* TextFormat::Finder::FindExtensionFactory(
const FieldDescriptor* ) const { … }
TextFormat::Parser::Parser()
: … { … }
TextFormat::Parser::~Parser() { … }
namespace {
bool CheckParseInputSize(StringPiece input,
io::ErrorCollector* error_collector) { … }
}
bool TextFormat::Parser::Parse(io::ZeroCopyInputStream* input,
Message* output) { … }
bool TextFormat::Parser::ParseFromString(ConstStringParam input,
Message* output) { … }
bool TextFormat::Parser::Merge(io::ZeroCopyInputStream* input,
Message* output) { … }
bool TextFormat::Parser::MergeFromString(ConstStringParam input,
Message* output) { … }
bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* ,
Message* output,
ParserImpl* parser_impl) { … }
bool TextFormat::Parser::ParseFieldValueFromString(const std::string& input,
const FieldDescriptor* field,
Message* output) { … }
bool TextFormat::Parse(io::ZeroCopyInputStream* input,
Message* output) { … }
bool TextFormat::Merge(io::ZeroCopyInputStream* input,
Message* output) { … }
bool TextFormat::ParseFromString(ConstStringParam input,
Message* output) { … }
bool TextFormat::MergeFromString(ConstStringParam input,
Message* output) { … }
#undef DO
TextFormat::BaseTextGenerator::~BaseTextGenerator() { … }
namespace {
class StringBaseTextGenerator : public TextFormat::BaseTextGenerator { … };
}
TextFormat::FieldValuePrinter::FieldValuePrinter() { … }
TextFormat::FieldValuePrinter::~FieldValuePrinter() { … }
#if 0
#define FORWARD_IMPL …
#else
#define FORWARD_IMPL …
#endif
std::string TextFormat::FieldValuePrinter::PrintBool(bool val) const { … }
std::string TextFormat::FieldValuePrinter::PrintInt32(int32_t val) const { … }
std::string TextFormat::FieldValuePrinter::PrintUInt32(uint32_t val) const { … }
std::string TextFormat::FieldValuePrinter::PrintInt64(int64_t val) const { … }
std::string TextFormat::FieldValuePrinter::PrintUInt64(uint64_t val) const { … }
std::string TextFormat::FieldValuePrinter::PrintFloat(float val) const { … }
std::string TextFormat::FieldValuePrinter::PrintDouble(double val) const { … }
std::string TextFormat::FieldValuePrinter::PrintString(
const std::string& val) const { … }
std::string TextFormat::FieldValuePrinter::PrintBytes(
const std::string& val) const { … }
std::string TextFormat::FieldValuePrinter::PrintEnum(
int32_t val, const std::string& name) const { … }
std::string TextFormat::FieldValuePrinter::PrintFieldName(
const Message& message, const Reflection* reflection,
const FieldDescriptor* field) const { … }
std::string TextFormat::FieldValuePrinter::PrintMessageStart(
const Message& message, int field_index, int field_count,
bool single_line_mode) const { … }
std::string TextFormat::FieldValuePrinter::PrintMessageEnd(
const Message& message, int field_index, int field_count,
bool single_line_mode) const { … }
#undef FORWARD_IMPL
TextFormat::FastFieldValuePrinter::FastFieldValuePrinter() { … }
TextFormat::FastFieldValuePrinter::~FastFieldValuePrinter() { … }
void TextFormat::FastFieldValuePrinter::PrintBool(
bool val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintInt32(
int32_t val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintUInt32(
uint32_t val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintInt64(
int64_t val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintUInt64(
uint64_t val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintFloat(
float val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintDouble(
double val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintEnum(
int32_t , const std::string& name,
BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintString(
const std::string& val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintBytes(
const std::string& val, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintFieldName(
const Message& message, int , int ,
const Reflection* reflection, const FieldDescriptor* field,
BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintFieldName(
const Message& , const Reflection* ,
const FieldDescriptor* field, BaseTextGenerator* generator) const { … }
void TextFormat::FastFieldValuePrinter::PrintMessageStart(
const Message& , int , int ,
bool single_line_mode, BaseTextGenerator* generator) const { … }
bool TextFormat::FastFieldValuePrinter::PrintMessageContent(
const Message& , int , int ,
bool , BaseTextGenerator* ) const { … }
void TextFormat::FastFieldValuePrinter::PrintMessageEnd(
const Message& , int , int ,
bool single_line_mode, BaseTextGenerator* generator) const { … }
namespace {
class FieldValuePrinterWrapper : public TextFormat::FastFieldValuePrinter { … };
}
const char* const TextFormat::Printer::kDoNotParse = …;
TextFormat::Printer::Printer()
: … { … }
void TextFormat::Printer::SetUseUtf8StringEscaping(bool as_utf8) { … }
void TextFormat::Printer::SetDefaultFieldValuePrinter(
const FieldValuePrinter* printer) { … }
void TextFormat::Printer::SetDefaultFieldValuePrinter(
const FastFieldValuePrinter* printer) { … }
bool TextFormat::Printer::RegisterFieldValuePrinter(
const FieldDescriptor* field, const FieldValuePrinter* printer) { … }
bool TextFormat::Printer::RegisterFieldValuePrinter(
const FieldDescriptor* field, const FastFieldValuePrinter* printer) { … }
bool TextFormat::Printer::RegisterMessagePrinter(
const Descriptor* descriptor, const MessagePrinter* printer) { … }
bool TextFormat::Printer::PrintToString(const Message& message,
std::string* output) const { … }
bool TextFormat::Printer::PrintUnknownFieldsToString(
const UnknownFieldSet& unknown_fields, std::string* output) const { … }
bool TextFormat::Printer::Print(const Message& message,
io::ZeroCopyOutputStream* output) const { … }
static constexpr int kUnknownFieldRecursionLimit = …;
bool TextFormat::Printer::PrintUnknownFields(
const UnknownFieldSet& unknown_fields,
io::ZeroCopyOutputStream* output) const { … }
namespace {
struct FieldIndexSorter { … };
}
bool TextFormat::Printer::PrintAny(const Message& message,
TextGenerator* generator) const { … }
void TextFormat::Printer::Print(const Message& message,
TextGenerator* generator) const { … }
void TextFormat::Printer::PrintFieldValueToString(const Message& message,
const FieldDescriptor* field,
int index,
std::string* output) const { … }
class MapEntryMessageComparator { … };
namespace internal {
class MapFieldPrinterHelper { … };
bool MapFieldPrinterHelper::SortMap(
const Message& message, const Reflection* reflection,
const FieldDescriptor* field,
std::vector<const Message*>* sorted_map_field) { … }
void MapFieldPrinterHelper::CopyKey(const MapKey& key, Message* message,
const FieldDescriptor* field_desc) { … }
void MapFieldPrinterHelper::CopyValue(const MapValueRef& value,
Message* message,
const FieldDescriptor* field_desc) { … }
}
void TextFormat::Printer::PrintField(const Message& message,
const Reflection* reflection,
const FieldDescriptor* field,
TextGenerator* generator) const { … }
void TextFormat::Printer::PrintShortRepeatedField(
const Message& message, const Reflection* reflection,
const FieldDescriptor* field, TextGenerator* generator) const { … }
void TextFormat::Printer::PrintFieldName(const Message& message,
int field_index, int field_count,
const Reflection* reflection,
const FieldDescriptor* field,
TextGenerator* generator) const { … }
void TextFormat::Printer::PrintFieldValue(const Message& message,
const Reflection* reflection,
const FieldDescriptor* field,
int index,
TextGenerator* generator) const { … }
bool TextFormat::Print(const Message& message,
io::ZeroCopyOutputStream* output) { … }
bool TextFormat::PrintUnknownFields(
const UnknownFieldSet& unknown_fields, io::ZeroCopyOutputStream* output) { … }
bool TextFormat::PrintToString(const Message& message,
std::string* output) { … }
bool TextFormat::PrintUnknownFieldsToString(
const UnknownFieldSet& unknown_fields, std::string* output) { … }
void TextFormat::PrintFieldValueToString(
const Message& message, const FieldDescriptor* field, int index,
std::string* output) { … }
bool TextFormat::ParseFieldValueFromString(
const std::string& input, const FieldDescriptor* field, Message* message) { … }
void TextFormat::Printer::PrintUnknownFields(
const UnknownFieldSet& unknown_fields, TextGenerator* generator,
int recursion_budget) const { … }
}
}
#include <google/protobuf/port_undef.inc>