WIP serializer

This commit is contained in:
2019-03-07 14:52:51 +01:00
parent 5329147d58
commit 1b56dff7d0
2 changed files with 202 additions and 92 deletions

View File

@@ -349,7 +349,7 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
return ret;
}
std::shared_ptr<ABR::VMArray> ABR::parse_vmem()
std::shared_ptr<SerializedStreamReader::VMArray> SerializedStreamReader::parse_vmem()
{
// Virtual Memory Array List
auto vmem_version = ru32(); // = 3
@@ -416,7 +416,7 @@ std::shared_ptr<ABR::VMArray> ABR::parse_vmem()
return ret;
}
std::shared_ptr<ABR::List> ABR::parse_vlls()
std::shared_ptr<SerializedStreamReader::List> SerializedStreamReader::parse_vlls()
{
auto ret = std::make_shared<List>();
auto count = ru32();
@@ -432,7 +432,7 @@ std::shared_ptr<ABR::List> ABR::parse_vlls()
return ret;
}
std::shared_ptr<ABR::String> ABR::parse_text()
std::shared_ptr<SerializedStreamReader::String> SerializedStreamReader::parse_text()
{
auto ret = std::make_shared<String>();
ret->value = rwstring();
@@ -440,7 +440,7 @@ std::shared_ptr<ABR::String> ABR::parse_text()
return ret;
}
std::shared_ptr<ABR::Descriptor> ABR::parse_objc()
std::shared_ptr<SerializedStreamReader::Descriptor> SerializedStreamReader::parse_objc()
{
auto ret = std::make_shared<Descriptor>();
ret->name = rwstring();
@@ -462,7 +462,7 @@ std::shared_ptr<ABR::Descriptor> ABR::parse_objc()
return ret;
}
std::shared_ptr<ABR::UnitFloat> ABR::parse_untf()
std::shared_ptr<SerializedStreamReader::UnitFloat> SerializedStreamReader::parse_untf()
{
auto ret = std::make_shared<UnitFloat>();
ret->unit = rstring(4);
@@ -471,7 +471,7 @@ std::shared_ptr<ABR::UnitFloat> ABR::parse_untf()
return ret;
}
std::shared_ptr<ABR::Boolean> ABR::parse_bool()
std::shared_ptr<SerializedStreamReader::Boolean> SerializedStreamReader::parse_bool()
{
auto ret = std::make_shared<Boolean>();
ret->value = ru8();
@@ -479,7 +479,7 @@ std::shared_ptr<ABR::Boolean> ABR::parse_bool()
return ret;
}
std::shared_ptr<ABR::Integer> ABR::parse_long()
std::shared_ptr<SerializedStreamReader::Integer> SerializedStreamReader::parse_long()
{
auto ret = std::make_shared<Integer>();
ret->value = ru32();
@@ -487,7 +487,7 @@ std::shared_ptr<ABR::Integer> ABR::parse_long()
return ret;
}
std::shared_ptr<ABR::Double> ABR::parse_doub()
std::shared_ptr<SerializedStreamReader::Double> SerializedStreamReader::parse_doub()
{
auto ret = std::make_shared<Double>();
ret->value = rdbl();
@@ -495,7 +495,7 @@ std::shared_ptr<ABR::Double> ABR::parse_doub()
return ret;
}
std::shared_ptr<ABR::Enum> ABR::parse_enum()
std::shared_ptr<SerializedStreamReader::Enum> SerializedStreamReader::parse_enum()
{
auto ret = std::make_shared<Enum>();
ret->type = rkey_or_string();
@@ -504,26 +504,26 @@ std::shared_ptr<ABR::Enum> ABR::parse_enum()
return ret;
}
std::shared_ptr<ABR::RawData> ABR::parse_tdta()
std::shared_ptr<SerializedStreamReader::RawData> SerializedStreamReader::parse_tdta()
{
auto ret = std::make_shared<RawData>();
ret->data = rraw();
return ret;
}
ABR::ABR()
SerializedStreamReader::SerializedStreamReader()
{
m_parser_table = std::map<std::string, std::function<ABR::Type::Ref()>>
m_parser_table = std::map<std::string, std::function<SerializedStreamReader::Type::Ref()>>
{
{ "VlLs", std::bind(&ABR::parse_vlls, this) },
{ "TEXT", std::bind(&ABR::parse_text, this) },
{ "Objc", std::bind(&ABR::parse_objc, this) },
{ "UntF", std::bind(&ABR::parse_untf, this) },
{ "bool", std::bind(&ABR::parse_bool, this) },
{ "long", std::bind(&ABR::parse_long, this) },
{ "doub", std::bind(&ABR::parse_doub, this) },
{ "enum", std::bind(&ABR::parse_enum, this) },
{ "tdta", std::bind(&ABR::parse_tdta, this) },
{ "VlLs", std::bind(&SerializedStreamReader::parse_vlls, this) },
{ "TEXT", std::bind(&SerializedStreamReader::parse_text, this) },
{ "Objc", std::bind(&SerializedStreamReader::parse_objc, this) },
{ "UntF", std::bind(&SerializedStreamReader::parse_untf, this) },
{ "bool", std::bind(&SerializedStreamReader::parse_bool, this) },
{ "long", std::bind(&SerializedStreamReader::parse_long, this) },
{ "doub", std::bind(&SerializedStreamReader::parse_doub, this) },
{ "enum", std::bind(&SerializedStreamReader::parse_enum, this) },
{ "tdta", std::bind(&SerializedStreamReader::parse_tdta, this) },
};
}
@@ -532,7 +532,7 @@ bool ABR::open(const std::string& path)
Asset asset;
if (asset.open(path.c_str()))
{
init(asset.read_all(), asset.m_len, BinaryStream::ByteOrder::BigEndian);
init(asset.read_all(), asset.m_len, BinaryStreamReader::ByteOrder::BigEndian);
auto version_major = ru16();
auto version_minor = ru16();
LOG("ABR %d.%d\n", version_major, version_minor);