mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
fileapi: Factor out helper to construct a version object
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,8 @@ private:
|
||||
static const char* ObjectKindName(ObjectKind kind);
|
||||
static std::string ObjectName(Object const& o);
|
||||
|
||||
static Json::Value BuildVersion(unsigned int major, unsigned int minor);
|
||||
|
||||
Json::Value BuildObject(Object const& object);
|
||||
|
||||
ClientRequests BuildClientRequests(Json::Value const& requests);
|
||||
|
||||
Reference in New Issue
Block a user