summaryrefslogtreecommitdiffstats
path: root/src/google/protobuf/io/printer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/io/printer.cc')
-rw-r--r--src/google/protobuf/io/printer.cc20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc
index c8df417..c7d3074 100644
--- a/src/google/protobuf/io/printer.cc
+++ b/src/google/protobuf/io/printer.cc
@@ -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
@@ -35,6 +35,7 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -50,8 +51,8 @@ Printer::Printer(ZeroCopyOutputStream* output, char variable_delimiter)
}
Printer::~Printer() {
- // Only BackUp() if we have called Next() at least once and never failed.
- if (buffer_size_ > 0 && !failed_) {
+ // Only BackUp() if we're sure we've successfully called Next() at least once.
+ if (buffer_size_ > 0) {
output_->BackUp(buffer_size_);
}
}
@@ -131,17 +132,6 @@ void Printer::Print(const char* text,
Print(vars, text);
}
-void Printer::Print(const char* text,
- const char* variable1, const string& value1,
- const char* variable2, const string& value2,
- const char* variable3, const string& value3) {
- map<string, string> vars;
- vars[variable1] = value1;
- vars[variable2] = value2;
- vars[variable3] = value3;
- Print(vars, text);
-}
-
void Printer::Indent() {
indent_ += " ";
}
@@ -168,7 +158,7 @@ void Printer::WriteRaw(const char* data, int size) {
if (failed_) return;
if (size == 0) return;
- if (at_start_of_line_ && (size > 0) && (data[0] != '\n')) {
+ if (at_start_of_line_) {
// Insert an indent.
at_start_of_line_ = false;
WriteRaw(indent_.data(), indent_.size());