Jump to content

TablePlusPlus Loading and saving


reepblue
 Share

Recommended Posts

This is for a Leadwerks project and over the few months I've fell in love with tableplusplus and I've used it for my input system in Ultra Engine. I'm trying to port it to Leadwerks but it seems my implementation of the loading and saving isn't correct. My JSON parsers work fine but no data loads, and tables don't save as pretty as when using the json library alone.

Anything I'm doing wrong?

#ifdef __TABLE_PLUS_PLUS
    table Table::Load(const std::string& path)
    {
        auto j3 = JSON::Load(path);
        table t(j3);
        return t;
    }

    table Table::Load(Stream* stream)
    {
        auto j3 = JSON::Load(stream);
        table t(j3);
        return t;
    }

    bool Table::Save(table& t, const std::string& path)
    {
        nlohmann::json j3 = t.to_json();
        return JSON::Save(j3, path);
    }

    table Table::Load(const std::wstring& path)
    {
        auto j3 = JSON::Load(path);
        table t(j3);
        return t;
    }

    table Table::Load(shared_ptr<FileStream> stream)
    {
        auto j3 = JSON::Load(stream);
        table t(j3);
        return t;
    }

    bool Table::Save(table& t, const std::wstring& path)
    {
        nlohmann::json j3 = t.to_json();
        return JSON::Save(j3, path);
    }
#endif

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Nevermind, loading is fine, saving is the remaining issue. 

For the record, this is how I'm saving my json files.

    bool JSON::Save(nlohmann::json& j3, const std::string& path)
    {
        std::ofstream o(path);
        o << std::setw(4) << j3 << std::endl;

        return (bool)FileSystem::GetFileType(path);
    }

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...