Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-27 09:30:28

0001 /*
0002  * Copyright 2021 Google Inc. All rights reserved.
0003  *
0004  * Licensed under the Apache License, Version 2.0 (the "License");
0005  * you may not use this file except in compliance with the License.
0006  * You may obtain a copy of the License at
0007  *
0008  *     http://www.apache.org/licenses/LICENSE-2.0
0009  *
0010  * Unless required by applicable law or agreed to in writing, software
0011  * distributed under the License is distributed on an "AS IS" BASIS,
0012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013  * See the License for the specific language governing permissions and
0014  * limitations under the License.
0015  */
0016 
0017 #ifndef FLATBUFFERS_STRUCT_H_
0018 #define FLATBUFFERS_STRUCT_H_
0019 
0020 #include "flatbuffers/base.h"
0021 
0022 namespace flatbuffers {
0023 
0024 // "structs" are flat structures that do not have an offset table, thus
0025 // always have all members present and do not support forwards/backwards
0026 // compatible extensions.
0027 
0028 class Struct FLATBUFFERS_FINAL_CLASS {
0029  public:
0030   template<typename T> T GetField(uoffset_t o) const {
0031     return ReadScalar<T>(&data_[o]);
0032   }
0033 
0034   template<typename T> T GetStruct(uoffset_t o) const {
0035     return reinterpret_cast<T>(&data_[o]);
0036   }
0037 
0038   const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; }
0039   uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; }
0040 
0041  private:
0042   // private constructor & copy constructor: you obtain instances of this
0043   // class by pointing to existing data only
0044   Struct();
0045   Struct(const Struct &);
0046   Struct &operator=(const Struct &);
0047 
0048   uint8_t data_[1];
0049 };
0050 
0051 }  // namespace flatbuffers
0052 
0053 #endif  // FLATBUFFERS_STRUCT_H_