Skip to content

Commit

Permalink
adjust projectinfo reader to addon structure
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLokison committed Feb 4, 2025
1 parent 412a66b commit 4e28c0a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
13 changes: 13 additions & 0 deletions code/foundation/io/jsonreader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,19 @@ JsonReader::GetChildNodeName(SizeT childIndex)
return "";
}

//------------------------------------------------------------------------------
/**
*/
bool
JsonReader::IsString() const
{
n_assert(this->IsOpen());
n_assert(0 != this->curNode);
return this->curNode->is_string();
}


//------------------------------------------------------------------------------
/**
Expand Down
2 changes: 2 additions & 0 deletions code/foundation/io/jsonreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class JsonReader : public StreamReader
/// gets the childname of the child at index, or empty string if no child exists or has no name.
Util::String GetChildNodeName(SizeT childIndex);

/// check if current node is a string
bool IsString() const;
/// check if current node is an array
bool IsArray() const;
/// check if current node is an object (can have keys)
Expand Down
11 changes: 6 additions & 5 deletions toolkit/toolkit-common/projectinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,8 @@ ProjectInfo::ParseProjectInfoFile(const IO::URI & path)

if (jsonReader->SetToFirstChild()) do
{
if (!jsonReader->HasChildren())
{
this->attrs.Add(jsonReader->GetCurrentNodeName(), jsonReader->GetString());
}
else
String thing = jsonReader->GetCurrentNodeName();
if (jsonReader->HasChildren())
{
String currentKey = jsonReader->GetCurrentNodeName();
Dictionary<String, String> values;
Expand All @@ -216,6 +213,10 @@ ProjectInfo::ParseProjectInfoFile(const IO::URI & path)
while (jsonReader->SetToNextChild());
this->listAttrs.Add(currentKey, values);
}
else if (jsonReader->IsString())
{
this->attrs.Add(jsonReader->GetCurrentNodeName(), jsonReader->GetString());
}
}
while (jsonReader->SetToNextChild());
return Success;
Expand Down

0 comments on commit 4e28c0a

Please sign in to comment.