diff options
Diffstat (limited to 'core/src/Model/Project.cpp')
-rw-r--r-- | core/src/Model/Project.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/core/src/Model/Project.cpp b/core/src/Model/Project.cpp index c54a02c..f070940 100644 --- a/core/src/Model/Project.cpp +++ b/core/src/Model/Project.cpp @@ -25,11 +25,12 @@ Project Project::Load(const fs::path& path) { Project proj; proj.mRootPath = path.parent_path(); + proj.mRootPathString = proj.mRootPath.string(); Json::Value root; ifs >> root; - const auto& croot = root; // Use const reference so that accessors default to returning a null if not found, instead of siliently creating new elements + const auto& croot = root; // Use const reference so that accessors default to returning a null if not found, instead of silently creating new elements if (!croot.isObject()) { throw std::runtime_error(kInvalidFormatErr); } @@ -46,6 +47,7 @@ Project Project::Load(const fs::path& path) { Project Project::Create(std::string name, const fs::path& path) { Project proj; proj.mRootPath = path; + proj.mRootPathString = path.string(); proj.mName = std::move(name); return proj; } @@ -54,6 +56,10 @@ const fs::path& Project::GetPath() const { return mRootPath; } +const std::string& Project::GetPathString() const { + return mRootPathString; +} + const std::string& Project::GetName() const { return mName; } @@ -61,3 +67,17 @@ const std::string& Project::GetName() const { void Project::SetName(std::string name) { mName = std::move(name); } + +Json::Value Project::Serialize() { + Json::Value root(Json::objectValue); + + root["Name"] = mName; + + return root; +} + +void Project::WriteToDisk() { + auto root = Serialize(); + std::ofstream ofs(mRootPath / "cplt_project.json"); + ofs << root; +} |