Index: third_party/protobuf/src/google/protobuf/util/internal/object_source.h |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h b/third_party/protobuf/src/google/protobuf/util/internal/object_source.h |
similarity index 57% |
copy from third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h |
copy to third_party/protobuf/src/google/protobuf/util/internal/object_source.h |
index 009ed9ffacaf207d4fb6322dca43697499b32991..2c31cfb09e77215783d96813b78477b881cd96ec 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h |
+++ b/third_party/protobuf/src/google/protobuf/util/internal/object_source.h |
@@ -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,50 +28,52 @@ |
// (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. |
- |
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ |
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ |
- |
-#include <string> |
+#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ |
+#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ |
#include <google/protobuf/stubs/common.h> |
+#include <google/protobuf/stubs/stringpiece.h> |
+#include <google/protobuf/stubs/status.h> |
namespace google { |
namespace protobuf { |
- class FieldDescriptor; // descriptor.h |
- namespace io { |
- class Printer; // printer.h |
- } |
-} |
+namespace util { |
+namespace converter { |
-namespace protobuf { |
-namespace compiler { |
-namespace java { |
+class ObjectWriter; |
-// Generates code for an extension, which may be within the scope of some |
-// message or may be at file scope. This is much simpler than FieldGenerator |
-// since extensions are just simple identifiers with interesting types. |
-class ExtensionGenerator { |
+// An ObjectSource is anything that can write to an ObjectWriter. |
+// Implementation of this interface typically provide constructors or |
+// factory methods to create an instance based on some source data, for |
+// example, a character stream, or protobuf. |
+// |
+// Derived classes could be thread-unsafe. |
+class LIBPROTOBUF_EXPORT ObjectSource { |
public: |
- explicit ExtensionGenerator(const FieldDescriptor* descriptor); |
- ~ExtensionGenerator(); |
+ virtual ~ObjectSource() {} |
+ |
+ // Writes to the ObjectWriter |
+ virtual util::Status WriteTo(ObjectWriter* ow) const { |
+ return NamedWriteTo("", ow); |
+ } |
+ |
+ // Writes to the ObjectWriter with a custom name for the message. |
+ // This is useful when you chain ObjectSource together by embedding one |
+ // within another. |
+ virtual util::Status NamedWriteTo(StringPiece name, |
+ ObjectWriter* ow) const = 0; |
- void Generate(io::Printer* printer); |
- void GenerateNonNestedInitializationCode(io::Printer* printer); |
- void GenerateRegistrationCode(io::Printer* printer); |
+ protected: |
+ ObjectSource() {} |
private: |
- const FieldDescriptor* descriptor_; |
- string scope_; |
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); |
+ // Do not add any data members to this class. |
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectSource); |
}; |
-} // namespace java |
-} // namespace compiler |
+} // namespace converter |
+} // namespace util |
} // namespace protobuf |
} // namespace google |
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__ |
+#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ |