/src/MapServer/src/flatgeobuf/include/flatbuffers/struct.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2021 Google Inc. All rights reserved. |
3 | | * |
4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | * you may not use this file except in compliance with the License. |
6 | | * You may obtain a copy of the License at |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | |
17 | | #ifndef FLATBUFFERS_STRUCT_H_ |
18 | | #define FLATBUFFERS_STRUCT_H_ |
19 | | |
20 | | #include "flatbuffers/base.h" |
21 | | |
22 | | namespace mapserver { |
23 | | namespace flatbuffers { |
24 | | |
25 | | // "structs" are flat structures that do not have an offset table, thus |
26 | | // always have all members present and do not support forwards/backwards |
27 | | // compatible extensions. |
28 | | |
29 | | class Struct FLATBUFFERS_FINAL_CLASS { |
30 | | public: |
31 | | template<typename T> T GetField(uoffset_t o) const { |
32 | | return ReadScalar<T>(&data_[o]); |
33 | | } |
34 | | |
35 | | template<typename T> T GetStruct(uoffset_t o) const { |
36 | | return reinterpret_cast<T>(&data_[o]); |
37 | | } |
38 | | |
39 | 0 | const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; } |
40 | 0 | uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; } |
41 | | |
42 | | private: |
43 | | // private constructor & copy constructor: you obtain instances of this |
44 | | // class by pointing to existing data only |
45 | | Struct(); |
46 | | Struct(const Struct &); |
47 | | Struct &operator=(const Struct &); |
48 | | |
49 | | uint8_t data_[1]; |
50 | | }; |
51 | | |
52 | | } // namespace flatbuffers |
53 | | } // namespace mapserver |
54 | | |
55 | | #endif // FLATBUFFERS_STRUCT_H_ |