diff options
author | Brad King <brad.king@kitware.com> | 2019-06-07 15:01:43 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-06-07 15:08:38 (GMT) |
commit | 6b815e58baa037335fb0008f6d0345fa29931e08 (patch) | |
tree | 078cb95d16977c02f3af896720e94a1b4882bed9 /Source/cmFileAPI.cxx | |
parent | a4231943117f5ba3dd0fdc6c8b1824334162b69f (diff) | |
download | CMake-6b815e58baa037335fb0008f6d0345fa29931e08.zip CMake-6b815e58baa037335fb0008f6d0345fa29931e08.tar.gz CMake-6b815e58baa037335fb0008f6d0345fa29931e08.tar.bz2 |
fileapi: Factor out helper to construct a version object
Diffstat (limited to 'Source/cmFileAPI.cxx')
-rw-r--r-- | Source/cmFileAPI.cxx | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index 34b6b33..9cb484c 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -413,6 +413,14 @@ std::string cmFileAPI::ObjectName(Object const& o) return name; } +Json::Value cmFileAPI::BuildVersion(unsigned int major, unsigned int minor) +{ + Json::Value version; + version["major"] = major; + version["minor"] = minor; + return version; +} + Json::Value cmFileAPI::BuildObject(Object const& object) { Json::Value value; @@ -680,10 +688,9 @@ Json::Value cmFileAPI::BuildCodeModel(Object const& object) Json::Value codemodel = cmFileAPICodemodelDump(*this, object.Version); codemodel["kind"] = this->ObjectKindName(object.Kind); - Json::Value& version = codemodel["version"] = Json::objectValue; + Json::Value& version = codemodel["version"]; if (object.Version == 2) { - version["major"] = 2; - version["minor"] = CodeModelV2Minor; + version = BuildVersion(2, CodeModelV2Minor); } else { return codemodel; // should be unreachable } @@ -716,10 +723,9 @@ Json::Value cmFileAPI::BuildCache(Object const& object) Json::Value cache = cmFileAPICacheDump(*this, object.Version); cache["kind"] = this->ObjectKindName(object.Kind); - Json::Value& version = cache["version"] = Json::objectValue; + Json::Value& version = cache["version"]; if (object.Version == 2) { - version["major"] = 2; - version["minor"] = CacheV2Minor; + version = BuildVersion(2, CacheV2Minor); } else { return cache; // should be unreachable } @@ -752,10 +758,9 @@ Json::Value cmFileAPI::BuildCMakeFiles(Object const& object) Json::Value cmakeFiles = cmFileAPICMakeFilesDump(*this, object.Version); cmakeFiles["kind"] = this->ObjectKindName(object.Kind); - Json::Value& version = cmakeFiles["version"] = Json::objectValue; + Json::Value& version = cmakeFiles["version"]; if (object.Version == 1) { - version["major"] = 1; - version["minor"] = CMakeFilesV1Minor; + version = BuildVersion(1, CMakeFilesV1Minor); } else { return cmakeFiles; // should be unreachable } @@ -788,13 +793,11 @@ Json::Value cmFileAPI::BuildInternalTest(Object const& object) { Json::Value test = Json::objectValue; test["kind"] = this->ObjectKindName(object.Kind); - Json::Value& version = test["version"] = Json::objectValue; + Json::Value& version = test["version"]; if (object.Version == 2) { - version["major"] = 2; - version["minor"] = InternalTestV2Minor; + version = BuildVersion(2, InternalTestV2Minor); } else { - version["major"] = 1; - version["minor"] = InternalTestV1Minor; + version = BuildVersion(1, InternalTestV1Minor); } return test; } |