aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSid Nayyar <sidnayyar@google.com>2024-02-19 17:31:38 +0000
committerGiuliano Procida <gprocida@google.com>2024-03-08 14:23:00 +0000
commit6820d9a59cb0a4d0ecd80db8e3664d727c0072b4 (patch)
treeadf1e54787f518250b86d6ae03cfd375ea3c0815
parent66a5e24ce20d5dd6b258b7d75e8201800be6933c (diff)
downloadstg-6820d9a59cb0a4d0ecd80db8e3664d727c0072b4.tar.gz
proto writer: move printing code into `Writer::Write` method
There are going to be too many parameters for the `Print` function with annotations. Since there is no advantage to abstract the printing code out, it was better to pull it into `Writer::Write` method. PiperOrigin-RevId: 608355274 Change-Id: I72d29f7bedb81f2a434847f354f643309cfcb1a1
-rw-r--r--proto_writer.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/proto_writer.cc b/proto_writer.cc
index d3de03d..cd9e576 100644
--- a/proto_writer.cc
+++ b/proto_writer.cc
@@ -506,21 +506,19 @@ const uint32_t kWrittenFormatVersion = 2;
} // namespace
-void Print(const STG& stg, std::ostream& os) {
- google::protobuf::TextFormat::Printer printer;
- printer.SetDefaultFieldValuePrinter(new HexPrinter());
- std::string output;
- printer.PrintToString(stg, &output);
- os << output;
-}
-
void Writer::Write(const Id& root, std::ostream& os) {
proto::STG stg;
StableId stable_id(graph_);
stg.set_root_id(Transform<StableId>(graph_, stg, stable_id)(root));
SortNodes(stg);
stg.set_version(kWrittenFormatVersion);
- Print(stg, os);
+
+ // Print
+ google::protobuf::TextFormat::Printer printer;
+ printer.SetDefaultFieldValuePrinter(new HexPrinter());
+ std::string output;
+ printer.PrintToString(stg, &output);
+ os << output;
}
} // namespace proto