diff options
author | romanenko-ii <romanenko-ii@yandex-team.ru> | 2022-02-10 16:50:36 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:36 +0300 |
commit | 4ee92606ffd02329182167a0db41aae105a62c6c (patch) | |
tree | f6187d19276dcdb5d877fafd9a142ccc9299ab06 /library/cpp/protobuf/util/pb_io.cpp | |
parent | ba437f673c54060a998d3fc113ad4674f6e6422f (diff) | |
download | ydb-4ee92606ffd02329182167a0db41aae105a62c6c.tar.gz |
Restoring authorship annotation for <romanenko-ii@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/protobuf/util/pb_io.cpp')
-rw-r--r-- | library/cpp/protobuf/util/pb_io.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index 6270ee0624..650d76cbab 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -10,17 +10,17 @@ #include <util/generic/string.h> #include <util/stream/file.h> #include <util/stream/str.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NProtoBuf { - - class TEnumIdValuePrinter : public google::protobuf::TextFormat::FastFieldValuePrinter { - public: - void PrintEnum(int32 val, const TString& /*name*/, google::protobuf::TextFormat::BaseTextGenerator* generator) const override { - generator->PrintString(ToString(val)); - } - }; - + + class TEnumIdValuePrinter : public google::protobuf::TextFormat::FastFieldValuePrinter { + public: + void PrintEnum(int32 val, const TString& /*name*/, google::protobuf::TextFormat::BaseTextGenerator* generator) const override { + generator->PrintString(ToString(val)); + } + }; + void ParseFromBase64String(const TStringBuf dataBase64, Message& m, bool allowUneven) { if (!m.ParseFromString(allowUneven ? Base64DecodeUneven(dataBase64) : Base64StrictDecode(dataBase64))) { ythrow yexception() << "can't parse " << m.GetTypeName() << " from base64-encoded string"; @@ -108,16 +108,16 @@ void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName) SerializeToTextFormat(m, stream); } -void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& out) { - google::protobuf::TextFormat::Printer printer; - printer.SetDefaultFieldValuePrinter(new NProtoBuf::TEnumIdValuePrinter()); - NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); - - if (!printer.Print(m, &adaptor)) { - ythrow yexception() << "SerializeToTextFormatWithEnumId failed on Print"; - } -} - +void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& out) { + google::protobuf::TextFormat::Printer printer; + printer.SetDefaultFieldValuePrinter(new NProtoBuf::TEnumIdValuePrinter()); + NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); + + if (!printer.Print(m, &adaptor)) { + ythrow yexception() << "SerializeToTextFormatWithEnumId failed on Print"; + } +} + void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out) { google::protobuf::TextFormat::Printer printer; printer.SetUseUtf8StringEscaping(true); |