Modified script serialization to use a sequence of scripts instead of a map
This commit is contained in:
parent
4f177bc455
commit
cfed342f9c
|
@ -497,7 +497,7 @@ namespace SHADE
|
|||
return true;
|
||||
|
||||
// Serialise each script
|
||||
//yamlNode->SetStyle(YAML::EmitterStyle::Block);
|
||||
yamlNode->SetStyle(YAML::EmitterStyle::Block);
|
||||
System::Collections::Generic::List<Script^>^ scriptList = scripts[entity];
|
||||
for each (Script^ script in scriptList)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,11 @@ if (iter != jsonValue.MemberEnd()) \
|
|||
vec.MEMBER = iter->value.GetDouble(); \
|
||||
} \
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
/* File-Level Constants */
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
static const std::string_view SCRIPT_TYPE_YAMLTAG = "Type";
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
/* Function Definitions */
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
|
@ -61,12 +66,14 @@ namespace SHADE
|
|||
/*---------------------------------------------------------------------------------*/
|
||||
/* Serialisation Functions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
void ReflectionUtilities::Serialise(System::Object^ object, YAML::Node& yamlNode)
|
||||
void ReflectionUtilities::Serialise(System::Object^ object, YAML::Node& scriptListNode)
|
||||
{
|
||||
using namespace System::Reflection;
|
||||
|
||||
// Create YAML object
|
||||
YAML::Node scriptNode;
|
||||
scriptNode.SetStyle(YAML::EmitterStyle::Block);
|
||||
scriptNode[SCRIPT_TYPE_YAMLTAG] = Convert::ToNative(object->GetType()->FullName);
|
||||
|
||||
// Get all fields
|
||||
System::Collections::Generic::IEnumerable<FieldInfo^>^ fields = GetInstanceFields(object);
|
||||
|
@ -80,7 +87,7 @@ namespace SHADE
|
|||
writeFieldIntoYaml(field, object, scriptNode);
|
||||
}
|
||||
|
||||
yamlNode[Convert::ToNative(object->GetType()->FullName)] = scriptNode;
|
||||
scriptListNode.push_back(scriptNode);
|
||||
}
|
||||
void ReflectionUtilities::Deserialise(Object^ object, YAML::Node& yamlNode)
|
||||
{
|
||||
|
@ -120,8 +127,6 @@ namespace SHADE
|
|||
{
|
||||
// Field YAML Node
|
||||
YAML::Node fieldNode;
|
||||
fieldNode.SetStyle(YAML::EmitterStyle::Block);
|
||||
fieldNode["Name"] = Convert::ToNative(fieldInfo->Name);
|
||||
|
||||
// Retrieve string for the YAML
|
||||
if (fieldInsertYaml<System::Int16> (fieldInfo, object, fieldNode) ||
|
||||
|
@ -172,7 +177,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
// Store the field into YAML
|
||||
yamlNode.push_back(fieldNode);
|
||||
yamlNode[Convert::ToNative(fieldInfo->Name)] = fieldNode;
|
||||
}
|
||||
|
||||
void ReflectionUtilities::writeYamlIntoField(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node)
|
||||
|
|
|
@ -64,6 +64,8 @@ namespace SHADE
|
|||
/// <param name="object">The object to copy deserialised data into.</param>
|
||||
static void Deserialise(System::Object^ object, YAML::Node& yamlNode);
|
||||
|
||||
|
||||
private:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Serialization Helper Functions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in New Issue