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 Dec 24, 2024
1 parent cb62376 commit 17cb155
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 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
14 changes: 7 additions & 7 deletions toolkit/toolkit-common/projectinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,22 @@ 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;
jsonReader->SetToFirstChild();
do
{
values.Add(jsonReader->GetString("Name"), jsonReader->GetString("Value"));
}
while (jsonReader->SetToNextChild());
} 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 17cb155

Please sign in to comment.