1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.
3 // http://code.google.com/p/protobuf/
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
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>
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
{
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
,
63 vector
<string
>* errors
);
66 // All methods are static. No need to construct.
67 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps
);
70 } // namespace internal
71 } // namespace protobuf
74 #endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__