Program Listing for File struct-data-editor.h

Return to documentation for file (include\reflection\struct-data-editor.h)

/******************************************************************************
© Intel Corporation.

This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.


 This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.

******************************************************************************/

#pragma once

#include <cstdint>

namespace gpa {
namespace serialization {

class Struct;
class Field;
class Union;

class StructDataEditor
{
public:
    StructDataEditor(void const* data, Struct const* structDef);

    StructDataEditor(void* data, Struct const* structDef);

    StructDataEditor(void const* data, Union const* unionDef);

    StructDataEditor(void* data, Union const* unionDef);
    bool ReadOnly() const;

    Struct const* StructDef() const;

    Union const* UnionDef() const;

    enum Result {
        kError,
        kGetSuccess,
        kGetInvalidTypeConversion,
        kSetSuccess,
        kSetInvalidTypeConversion,
        kSetReadOnly,
    };

    template<typename T>
    T Get(Field const* field, Result* result = nullptr) const;

    template<typename T>
    Result Set(Field const* field, T value);

protected:
    void const* mData;
    void* mMutableData;
    Struct const* mStructDef;
    Union const* mUnionDef;
};

}  // namespace serialization
}  // namespace gpa