objectbox / objectbox-generator

ObjectBox Generator based on FlatBuffers schema files (fbs) for C and C++ (more languages in the future)
https://objectbox.io
GNU Affero General Public License v3.0
36 stars 11 forks source link

C/C++ auxiliary class - split #5

Closed vaind closed 3 years ago

vaind commented 4 years ago

A generated code currently looks like this

namespace gen {
struct RelSource_;

struct RelSource {
    using _OBX_MetaInfo = RelSource_;

    uint64_t id;
    uint64_t typefulId;
};

struct RelSource_ {
    static const obx_schema_id id = 1;
    static const obx_schema_id typefulId = 2;

    static constexpr obx_schema_id entityId() { return 2; }

    static void setObjectId(RelSource& object, obx_id newId) { object.id = newId; }

    /// Write given object to the FlatBufferBuilder
    static void toFlatBuffer(flatbuffers::FlatBufferBuilder& fbb, const RelSource& object);

    /// Read an object from a valid FlatBuffer
    static RelSource fromFlatBuffer(const void* data, size_t size);

    /// Read an object from a valid FlatBuffer
    static std::unique_ptr<RelSource> newFromFlatBuffer(const void* data, size_t size);

    /// Read an object from a valid FlatBuffer
    static void fromFlatBuffer(const void* data, size_t size, RelSource& outObject);
};
}  // namespace gen

Consider splitting out the "binding" methods to a separate class, leaving properties in the "underscore" one. Reasons: