/usr/local/include/libprotobuf-mutator/port/protobuf.h
Line | Count | Source |
1 | | // Copyright 2017 Google Inc. All rights reserved. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #ifndef PORT_PROTOBUF_H_ |
16 | | #define PORT_PROTOBUF_H_ |
17 | | |
18 | | #include <string> |
19 | | |
20 | | #include "google/protobuf/any.pb.h" |
21 | | #include "google/protobuf/descriptor.pb.h" |
22 | | #include "google/protobuf/message.h" |
23 | | #include "google/protobuf/text_format.h" |
24 | | #include "google/protobuf/util/message_differencer.h" |
25 | | #include "google/protobuf/wire_format.h" |
26 | | |
27 | | // clang-format off |
28 | | #include "google/protobuf/port_def.inc" // MUST be last header included |
29 | | // clang-format on |
30 | | namespace google { |
31 | | namespace protobuf { |
32 | | #if PROTOBUF_VERSION < 4025000 |
33 | | |
34 | | template <typename T> |
35 | | const T* DownCastMessage(const Message* message) { |
36 | | return static_cast<const T*>(message); |
37 | | } |
38 | | |
39 | | template <typename T> |
40 | | T* DownCastMessage(Message* message) { |
41 | | const Message* message_const = message; |
42 | | return const_cast<T*>(DownCastMessage<T>(message_const)); |
43 | | } |
44 | | |
45 | | #elif PROTOBUF_VERSION < 5029000 |
46 | | |
47 | | template <typename T> |
48 | | const T* DownCastMessage(const Message* message) { |
49 | | return DownCastToGenerated<T>(message); |
50 | | } |
51 | | |
52 | | template <typename T> |
53 | 4.51k | T* DownCastMessage(Message* message) { |
54 | 4.51k | return DownCastToGenerated<T>(message); |
55 | 4.51k | } |
56 | | |
57 | | #endif // PROTOBUF_VERSION |
58 | | } // namespace protobuf |
59 | | } // namespace google |
60 | | #include "google/protobuf/port_undef.inc" |
61 | | |
62 | | |
63 | | namespace protobuf_mutator { |
64 | | |
65 | | namespace protobuf = google::protobuf; |
66 | | |
67 | | } // namespace protobuf_mutator |
68 | | |
69 | | #endif // PORT_PROTOBUF_H_ |