print ABR file structure recursively

This commit is contained in:
2019-02-07 22:05:30 +01:00
parent 17d5320ecb
commit f76a5c2fc3
4 changed files with 100 additions and 54 deletions

View File

@@ -45,6 +45,8 @@ bool ABR::section_desc()
auto name = rkey_or_string();
auto list = rstring(4);
auto list_val = call(list);
auto out = list_val->str(0, "");
std::cout << out;
return true;
}
@@ -66,14 +68,14 @@ std::shared_ptr<ABR::List> ABR::parse_vlls()
{
auto ret = std::make_shared<List>();
auto count = ru32();
printf("list: %d\n", count);
//printf("list: %d\n", count);
for (int i = 0; i < count; i++)
{
auto type = rstring(4);
auto item = call(type);
if (!item)
return nullptr;
ret->children.push_back(item);
ret->items.push_back(item);
}
return ret;
}
@@ -82,7 +84,7 @@ std::shared_ptr<ABR::String> ABR::parse_text()
{
auto ret = std::make_shared<String>();
ret->value = rwstring();
wprintf(L"text: %s\n", ret->value.c_str());
//wprintf(L"text: %s\n", ret->value.c_str());
return ret;
}
@@ -100,7 +102,7 @@ std::shared_ptr<ABR::Descriptor> ABR::parse_objc()
ret->name = rwstring();
ret->class_id = rkey_or_string();
auto count = ru32();
printf("objc type %s, %d props\n", ret->class_id.c_str(), count);
//printf("objc type %s, %d props\n", ret->class_id.c_str(), count);
for (int i = 0; i < count; i++)
{
auto key = rkey_or_string();
@@ -121,7 +123,7 @@ std::shared_ptr<ABR::UnitFloat> ABR::parse_untf()
auto ret = std::make_shared<UnitFloat>();
ret->unit = rstring(4);
ret->value = rdbl();
printf("float %s: %f\n", ret->unit.c_str(), ret->value);
//printf("float %s: %f\n", ret->unit.c_str(), ret->value);
return ret;
}
@@ -129,7 +131,7 @@ std::shared_ptr<ABR::Boolean> ABR::parse_bool()
{
auto ret = std::make_shared<Boolean>();
ret->value = ru8();
printf("bool: %s\n", ret->value ? "true" : "false");
//printf("bool: %s\n", ret->value ? "true" : "false");
return ret;
}
@@ -137,7 +139,7 @@ std::shared_ptr<ABR::Integer> ABR::parse_long()
{
auto ret = std::make_shared<Integer>();
ret->value = ru32();
printf("long: %d\n", ret->value);
//printf("long: %d\n", ret->value);
return ret;
}
@@ -145,7 +147,7 @@ std::shared_ptr<ABR::Double> ABR::parse_doub()
{
auto ret = std::make_shared<Double>();
ret->value = rdbl();
printf("double: %d\n", ret->value);
//printf("double: %d\n", ret->value);
return ret;
}
@@ -154,7 +156,7 @@ std::shared_ptr<ABR::Enum> ABR::parse_enum()
auto ret = std::make_shared<Enum>();
auto t = rkey_or_string();
auto e = rkey_or_string();
printf("enum: %s %s\n", t.c_str(), e.c_str());
//printf("enum: %s %s\n", t.c_str(), e.c_str());
return ret;
}