Запись в файл иерархии классов со множеством указателей, контейнеров и переменных

какой самый лучший способ записать в файл структуру DocumentData ?

#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>

// Физический движек Bullet
#include <btBulletDynamicsCommon.h>
#include <BulletCollision/NarrowPhaseCollision/btRaycastCallback.h>
#include <BulletCollision/Gimpact/btGImpactShape.h>

// ============================================================================
//  Math
// ----------------------------------------------------------------------------
struct Vector2D {
    Vector2D(float X, float Y) :
        x(X), y(Y)
    { }

    float x, y;
};
struct Vector3D {
    Vector3D(float X = 0.0, float Y = 0.0, float Z = 0.0) :
        x(X), y(Y), z(Z)
    { }

    float x, y, z;
};

// ============================================================================
//  Geometry
// ----------------------------------------------------------------------------
struct Vertex {
    Vector3D A, B, C;
};
struct Mesh {
    std::vector<Vertex> Vertices;
    std::vector<UINT> Indices;
};

class Object {
public:
    Object(
        Vector3D Position, Vector2D Angle, Vector3D Size,
        std::wstring Name
    ) :
        m_Name(Name), m_Position(Position), m_Angle(Angle), m_Size(Size),
        m_pMesh(nullptr),       
        m_Motionstate(nullptr), m_BoxCollisionShape(nullptr), m_RigidBody(nullptr),
        m_fIsSelected(false)
    { 
        // *Инициализация объекта* 
    }

    // *Другие методы*

private:
    btDefaultMotionState* m_Motionstate;
    btCollisionShape* m_BoxCollisionShape;
    btRigidBody* m_RigidBody;
    btDiscreteDynamicsWorld* m_DynamicsWorldPtr;

    std::wstring m_Name;
    Mesh* m_pMesh;

    Vector3D m_Size;
    Vector3D m_Position;
    Vector2D m_Angle;

    UINT m_ID;
    bool m_fIsSelected;
};

// ============================================================================
//  Other
// ----------------------------------------------------------------------------
struct Event {
    std::vector<Object*> Objects = { };
    UINT Type = 0;
};

class IEntity : public Object {
public:
    IEntity(
        Vector3D Position, Vector3D Velocity, Vector3D Size, Vector2D Angle,
        int Health, int Damage, float Speed, bool Fly, bool Move, std::wstring Name
    ) :
        Object(Position, Angle, Size, Name),

        m_Velocity(Velocity),
        m_Health(Health), m_Damage(Damage), m_Speed(Speed),
        m_Fly(Fly), m_Move(Move), 
        m_IsGround(false),m_Live(true)
    { }

    virtual void Update() = 0;

    // *Другие методы*

protected:
    Vector3D m_Velocity;

    int m_Health;
    int m_Damage;

    float m_Speed;

    bool m_IsGround;
    bool m_Fly;
    bool m_Move;
    bool m_Live;
};

class Camera : public IEntity {
public:
    Camera(Vector3D Position, Vector2D Angle, UINT Mode) :
        IEntity(Position, { }, { 1.f, 1.f, 1.f }, Angle, 0, 0, 0.5, true, true, L"Camera"),
        m_Mode(Mode)
    { }

    void Update() override {
        // *Определение*
    }

protected:
    UINT m_Mode;
};

// ============================================================================
//  Document
// ----------------------------------------------------------------------------
struct DocumentData {
    // EditingHistory data
    std::list<Event> EditingHistory_Events;
    std::set<Object*> EditingHistory_Objects;
    int EditingHistory_SelectedEvent;

    // ObjectList data
    std::vector<UINT> ObjectList_ObjectIDs;

    // Engine data
    Camera* EngineCamera;
    UINT LastObjectID;

    // Document
    std::wstring FilePath;
    bool fSafeEntidingHistory;
};

Ответы (0 шт):