| Index: third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/code_generator.cc b/third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc
|
| similarity index 52%
|
| copy from third_party/protobuf/src/google/protobuf/compiler/code_generator.cc
|
| copy to third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc
|
| index 455c239a936bd9cec724ab65e85092b743fa1070..57cc08a1d7a4f333616f8a8cc750880751d69a19 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/code_generator.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc
|
| @@ -1,6 +1,6 @@
|
| // Protocol Buffers - Google's data interchange format
|
| // Copyright 2008 Google Inc. All rights reserved.
|
| -// http://code.google.com/p/protobuf/
|
| +// https://developers.google.com/protocol-buffers/
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -28,53 +28,65 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Author: kenton@google.com (Kenton Varda)
|
| -// Based on original Protocol Buffers design by
|
| -// Sanjay Ghemawat, Jeff Dean, and others.
|
| +#include <google/protobuf/util/internal/object_writer.h>
|
|
|
| -#include <google/protobuf/compiler/code_generator.h>
|
| -
|
| -#include <google/protobuf/stubs/common.h>
|
| -#include <google/protobuf/stubs/strutil.h>
|
| +#include <google/protobuf/util/internal/datapiece.h>
|
|
|
| namespace google {
|
| namespace protobuf {
|
| -namespace compiler {
|
| -
|
| -CodeGenerator::~CodeGenerator() {}
|
| -GeneratorContext::~GeneratorContext() {}
|
| -
|
| -io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
|
| - const string& filename, const string& insertion_point) {
|
| - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
|
| - return NULL; // make compiler happy
|
| -}
|
| +namespace util {
|
| +namespace converter {
|
|
|
| -void GeneratorContext::ListParsedFiles(
|
| - vector<const FileDescriptor*>* output) {
|
| - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
|
| -}
|
| -
|
| -// Parses a set of comma-delimited name/value pairs.
|
| -void ParseGeneratorParameter(const string& text,
|
| - vector<pair<string, string> >* output) {
|
| - vector<string> parts;
|
| - SplitStringUsing(text, ",", &parts);
|
| -
|
| - for (int i = 0; i < parts.size(); i++) {
|
| - string::size_type equals_pos = parts[i].find_first_of('=');
|
| - pair<string, string> value;
|
| - if (equals_pos == string::npos) {
|
| - value.first = parts[i];
|
| - value.second = "";
|
| - } else {
|
| - value.first = parts[i].substr(0, equals_pos);
|
| - value.second = parts[i].substr(equals_pos + 1);
|
| +// static
|
| +void ObjectWriter::RenderDataPieceTo(const DataPiece& data, StringPiece name,
|
| + ObjectWriter* ow) {
|
| + switch (data.type()) {
|
| + case DataPiece::TYPE_INT32: {
|
| + ow->RenderInt32(name, data.ToInt32().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_INT64: {
|
| + ow->RenderInt64(name, data.ToInt64().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_UINT32: {
|
| + ow->RenderUint32(name, data.ToUint32().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_UINT64: {
|
| + ow->RenderUint64(name, data.ToUint64().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_DOUBLE: {
|
| + ow->RenderDouble(name, data.ToDouble().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_FLOAT: {
|
| + ow->RenderFloat(name, data.ToFloat().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_BOOL: {
|
| + ow->RenderBool(name, data.ToBool().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_STRING: {
|
| + ow->RenderString(name, data.ToString().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_BYTES: {
|
| + ow->RenderBytes(name, data.ToBytes().ValueOrDie());
|
| + break;
|
| + }
|
| + case DataPiece::TYPE_NULL: {
|
| + ow->RenderNull(name);
|
| + break;
|
| }
|
| - output->push_back(value);
|
| + default:
|
| + break;
|
| }
|
| }
|
|
|
| -} // namespace compiler
|
| +} // namespace converter
|
| +} // namespace util
|
| } // namespace protobuf
|
| } // namespace google
|
|
|