aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--msvc/sibs.exebin415232 -> 415744 bytes
-rw-r--r--src/Package.cpp42
3 files changed, 26 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index 67847e9..90f7754 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ sibs.kdev4
build/
cmake/build/
cmake-build-debug/
+.vs/
diff --git a/msvc/sibs.exe b/msvc/sibs.exe
index 44f8871..a6ce4e0 100644
--- a/msvc/sibs.exe
+++ b/msvc/sibs.exe
Binary files differ
diff --git a/src/Package.cpp b/src/Package.cpp
index d59c6a9..5969ac5 100644
--- a/src/Package.cpp
+++ b/src/Package.cpp
@@ -27,20 +27,20 @@ namespace sibs
Result<PackageMetadata> getPackageMetadata(Value::ConstObject jsonObj)
{
- const auto &description = jsonObj["description"];
- if(!description.IsString()) return Result<PackageMetadata>::Err("Expected description to be a string");
- const auto &version = jsonObj["version"];
- if(!version.IsString()) return Result<PackageMetadata>::Err("Expected version to be a string");
- const auto &platforms = jsonObj["platforms"];
- if(!platforms.IsArray() || platforms.GetArray().Empty()) return Result<PackageMetadata>::Err("Expected platforms to be an array of strings");
- const auto &urls = jsonObj["urls"];
- if(!urls.IsArray() || urls.GetArray().Empty()) return Result<PackageMetadata>::Err("Expected urls to be an array of string");
+ const auto &description = jsonObj.FindMember("description");
+ if(description == jsonObj.MemberEnd() || !description->value.IsString()) return Result<PackageMetadata>::Err("Expected description to be a string");
+ const auto &version = jsonObj.FindMember("version");
+ if(version == jsonObj.MemberEnd() || !version->value.IsString()) return Result<PackageMetadata>::Err("Expected version to be a string");
+ const auto &platforms = jsonObj.FindMember("platforms");
+ if(platforms == jsonObj.MemberEnd() || !platforms->value.IsArray() || platforms->value.GetArray().Empty()) return Result<PackageMetadata>::Err("Expected platforms to be an array of strings");
+ const auto &urls = jsonObj.FindMember("urls");
+ if(urls == jsonObj.MemberEnd() || !urls->value.IsArray() || urls->value.GetArray().Empty()) return Result<PackageMetadata>::Err("Expected urls to be an array of string");
PackageMetadata packageMetadata;
- packageMetadata.description.assign(description.GetString(), description.GetStringLength());
- packageMetadata.version.assign(version.GetString(), version.GetStringLength());
+ packageMetadata.description.assign(description->value.GetString(), description->value.GetStringLength());
+ packageMetadata.version.assign(version->value.GetString(), version->value.GetStringLength());
- const auto &platformsArray = platforms.GetArray();
+ const auto &platformsArray = platforms->value.GetArray();
packageMetadata.platforms.reserve(platformsArray.Size());
for(int i = 0; i < platformsArray.Size(); ++i)
{
@@ -50,7 +50,7 @@ namespace sibs
packageMetadata.platforms.push_back(platformElement.GetString());
}
- const auto &urlsArray = urls.GetArray();
+ const auto &urlsArray = urls->value.GetArray();
packageMetadata.urls.reserve(urlsArray.Size());
for(int i = 0; i < urlsArray.Size(); ++i)
{
@@ -129,17 +129,25 @@ namespace sibs
const Document &packageDoc = *packageList.unwrap();
- const Value &packageMetaDataJson = packageDoc[packageName];
- if(packageMetaDataJson.IsObject())
+ auto packageMetaDataJsonIt = packageDoc.FindMember(packageName);
+ if (packageMetaDataJsonIt == packageDoc.MemberEnd())
+ {
+ string errMsg = "No package with the name \"";
+ errMsg += packageName;
+ errMsg += "\" was found";
+ return Result<string>::Err(errMsg);
+ }
+
+ if(packageMetaDataJsonIt->value.IsObject())
{
- Result<PackageMetadata> packageMetadataResult = getPackageMetadata(packageMetaDataJson.GetObject());
+ Result<PackageMetadata> packageMetadataResult = getPackageMetadata(packageMetaDataJsonIt->value.GetObject());
if(!packageMetadataResult) return Result<string>::Err(packageMetadataResult);
return ::sibs::getPackageUrl(packageMetadataResult.unwrap(), packageName, packageVersion, platform);
}
- else if(packageMetaDataJson.IsArray())
+ else if(packageMetaDataJsonIt->value.IsArray())
{
int i = 0;
- for(const auto &packageData : packageMetaDataJson.GetArray())
+ for(const auto &packageData : packageMetaDataJsonIt->value.GetArray())
{
if(!packageData.IsObject())
{