Initial import of v2.0.0beta
[protobuf.git] / src / google / protobuf / reflection_ops.h
blob4a7f76bbe9cfa3d52410130d59cafcb95d0d7c26
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.
3 // http://code.google.com/p/protobuf/
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // Author: kenton@google.com (Kenton Varda)
18 // Based on original Protocol Buffers design by
19 // Sanjay Ghemawat, Jeff Dean, and others.
21 // This header is logically internal, but is made public because it is used
22 // from protocol-compiler-generated code, which may reside in other components.
24 #ifndef GOOGLE_PROTOBUF_REFLECTION_OPS_H__
25 #define GOOGLE_PROTOBUF_REFLECTION_OPS_H__
27 #include <google/protobuf/message.h>
29 namespace google {
30 namespace protobuf {
31 namespace internal {
33 // Basic operations that can be performed using Message::Reflection.
34 // These can be used as a cheap way to implement the corresponding
35 // methods of the Message interface, though they are likely to be
36 // slower than implementations tailored for the specific message type.
38 // This class should stay limited to operations needed to implement
39 // the Message interface.
41 // This class is really a namespace that contains only static methods.
42 class LIBPROTOBUF_EXPORT ReflectionOps {
43 public:
44 static void Copy(const Descriptor* descriptor,
45 const Message::Reflection& from,
46 Message::Reflection* to);
47 static void Merge(const Descriptor* descriptor,
48 const Message::Reflection& from,
49 Message::Reflection* to);
50 static void Clear(const Descriptor* descriptor,
51 Message::Reflection* reflection);
52 static bool IsInitialized(const Descriptor* descriptor,
53 const Message::Reflection& reflection);
54 static void DiscardUnknownFields(const Descriptor* descriptor,
55 Message::Reflection* reflection);
57 // Finds all unset required fields in the message and adds their full
58 // paths (e.g. "foo.bar[5].baz") to *names. "prefix" will be attached to
59 // the front of each name.
60 static void FindInitializationErrors(const Descriptor* descriptor,
61 const Message::Reflection& reflection,
62 const string& prefix,
63 vector<string>* errors);
65 private:
66 // All methods are static. No need to construct.
67 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps);
70 } // namespace internal
71 } // namespace protobuf
73 } // namespace google
74 #endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__