Index: third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc |
diff --git a/third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h b/third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc |
similarity index 52% |
copy from third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h |
copy to third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc |
index 144f44f0635304bd7acc72ae628eab2d0a1998d3..57cc08a1d7a4f333616f8a8cc750880751d69a19 100644 |
--- a/third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h |
+++ 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,41 +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: jasonh@google.com (Jason Hsueh) |
-// |
-// Implements methods of coded_stream.h that need to be inlined for performance |
-// reasons, but should not be defined in a public header. |
- |
-#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ |
-#define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ |
+#include <google/protobuf/util/internal/object_writer.h> |
-#include <google/protobuf/io/coded_stream.h> |
-#include <string> |
-#include <google/protobuf/stubs/stl_util.h> |
+#include <google/protobuf/util/internal/datapiece.h> |
namespace google { |
namespace protobuf { |
-namespace io { |
+namespace util { |
+namespace converter { |
-inline bool CodedInputStream::InternalReadStringInline(string* buffer, |
- int size) { |
- if (size < 0) return false; // security: size is often user-supplied |
- |
- if (BufferSize() >= size) { |
- STLStringResizeUninitialized(buffer, size); |
- // When buffer is empty, string_as_array(buffer) will return NULL but memcpy |
- // requires non-NULL pointers even when size is 0. Hench this check. |
- if (size > 0) { |
- memcpy(string_as_array(buffer), buffer_, size); |
- Advance(size); |
+// 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; |
} |
- return true; |
+ 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; |
+ } |
+ default: |
+ break; |
} |
- |
- return ReadStringFallback(buffer, size); |
} |
-} // namespace io |
+} // namespace converter |
+} // namespace util |
} // namespace protobuf |
} // namespace google |
-#endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ |