Exemplo n.º 1
0
void ObjectBase::Serialize( ticpp::Document* serializedDocument )
{
	ticpp::Document document( "document" );

  #if wxUSE_UNICODE
	ticpp::Declaration dec( "1.0", "UTF-8", "yes" );
	#else
	ticpp::Declaration dec( "1.0", "ISO-8859-13", "yes" );
	#endif
	document.LinkEndChild( &dec );

	ticpp::Element root( "wxFormBuilder_Project" );

	ticpp::Element fileVersion( "FileVersion" );
	fileVersion.SetAttribute( "major", AppData()->m_fbpVerMajor );
	fileVersion.SetAttribute( "minor", AppData()->m_fbpVerMinor );

	root.LinkEndChild( &fileVersion );

	ticpp::Element element;
	SerializeObject( &element );

	root.LinkEndChild( &element );
	document.LinkEndChild( &root );

	*serializedDocument = document;
}
Exemplo n.º 2
0
void Serializer::Serialize( const QObject *pObject, const QString &_sName )
{
    QString sName = _sName;

    if (sName.isEmpty())
        sName = pObject->objectName();

    if (sName.isEmpty())
    {
        sName = pObject->metaObject()->className();

        sName = sName.section( ":", -1 );

        if ((sName.length() > 0) && (sName.at(0) == 'Q'))
            sName = sName.mid( 1 );
    }

    // ---------------------------------------------------------------

    m_hash.reset();

    BeginSerialize( sName );

    SerializeObject( pObject, sName );

    EndSerialize();

}
HRESULT Library_spot_update_native_Microsoft_SPOT_MFUpdate_MFNativeUpdate::SerializeParameter___STATIC__SZARRAY_U1__OBJECT( CLR_RT_StackFrame& stack )
{
    TINYCLR_HEADER();
    CLR_INT32 offset = 0, size = 0;
    CLR_RT_HeapBlock &ref = stack.PushValueAndClear();
    CLR_UINT8* pData;

    CLR_RT_HeapBlock& obj = stack.Arg0();

    if(!SerializeObject( &obj, NULL, offset, size ) || size <= 0) TINYCLR_SET_AND_LEAVE(CLR_E_FAIL);

    TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(ref, size, g_CLR_RT_WellKnownTypes.m_UInt8));

    pData = (CLR_UINT8*)ref.DereferenceArray()->GetFirstElement();

    offset = 0;

    if(!SerializeObject( &obj, pData, offset, size )) TINYCLR_SET_AND_LEAVE(CLR_E_FAIL);

    TINYCLR_NOCLEANUP();
}
Exemplo n.º 4
0
	bool Scene::SerializeObject(GameObjectPtr pObj, DataStream* pStream)
	{
		const std::string& name = pObj->GetName();
		pStream->WriteString(name);

		const math::Matrix44& local = pObj->GetLocalTransform();
		pStream->Write((void*)&local, sizeof(local));

		uint16 nCom = pObj->GetComponentCount();
		pStream->WriteInt16(nCom - 1);

		for(int i = 0; i < nCom; ++i)
		{
			GameObjectComponentPtr pCom = pObj->GetComponent(i);
			
			
			pStream->WriteString(pCom->GetName());
			
			if(false == pCom->Serialize(pStream))
			{
				logger() << "failed to save component: " << pCom->GetName() << "\n";
				return false;
			}
		}

		uint16 nChild = 0;

		GameObjectPtr pChild = pObj->GetFirstChild();

		while(pChild)
		{
			++nChild;
			pChild = pChild->GetNextNode();
		}

		pStream->WriteInt16(nChild);

		pChild = pObj->GetFirstChild();

		while(pChild)
		{
			if(false == SerializeObject(pChild, pStream))
			{
				return false;
			}
			pChild = pChild->GetNextNode();
		}

		return true;
	}
Exemplo n.º 5
0
	bool Scene::Serialize(DataStream* pStream)
	{
		pStream->WriteInt32(g_scene_file_version.AsUInt32());

		if(false == SerializeObject(m_pRoot, pStream))
		{
			return false;
		}

		EventPtr pEvent = alloc_object<Event, uint32>(EV_SCENE_SAVED);
		m_pObjectManager->DispatchEvent(pEvent);

		return true;
	}
Exemplo n.º 6
0
bool CNodeSystemTest::TestCreateNode()
{
	bool result = true;
	bool subResult = false;

	CHashString hszNodeName(_T("Node1"));
	CHashString hszNodeType(_T("CNode"));

	m_dialogEditControl->ReplaceSel(_T("  Testing Creation of Node 1 - \n"));
	CreateObject( &hszNodeName, NULL, &hszNodeType );

	InitializeObject( &hszNodeName );

	m_dialogEditControl->ReplaceSel(_T("    Created node found in engine: "));

	subResult = FindObject( &hszNodeName );
	SUBREPORT( subResult );
	result = result && subResult;

	m_dialogEditControl->ReplaceSel(_T("    Verify default values: "));
	IArchive *archive = CreateMemoryArchive();
	SerializeObject( &hszNodeName, archive, true );

	float fVersion;
	float fX;
	float fY;
	float fZ;
	archive->SetIsWriting( false );
	archive->Read( fVersion );
	archive->Read( fX );
	archive->Read( fY );
	archive->Read( fZ );
	archive->Close();

	subResult = fVersion == 1.0f;
	subResult = subResult && fX == 0.0f;
	subResult = subResult && fY == 0.0f;
	subResult = subResult && fZ == 0.0f;
	SUBREPORT( subResult );

	result = result && subResult;

	DeleteObject( &hszNodeName );

	m_dialogEditControl->ReplaceSel(_T("  TestCreateNode overall: "));
	return result;
}
Exemplo n.º 7
0
bool CNodeSystemTest::TestCreateNodeConnection()
{
	bool result = true;
	bool subResult = false;

	CHashString hszNodeConnectionName(_T("NodeConnection1"));
	CHashString hszNodeConnectionType(_T("CNodeConnection"));

	m_dialogEditControl->ReplaceSel(_T("  Testing Creation of Node Connection 1 - \n"));
	CreateObject( &hszNodeConnectionName, NULL, &hszNodeConnectionType );

	InitializeObject( &hszNodeConnectionName );

	m_dialogEditControl->ReplaceSel(_T("    Created node found in engine: "));

	subResult = FindObject( &hszNodeConnectionName );
	SUBREPORT( subResult );
	result = result && subResult;

	m_dialogEditControl->ReplaceSel(_T("    Verify default values: "));
	IArchive *archive = CreateMemoryArchive();
	SerializeObject( &hszNodeConnectionName, archive, true );

	float fVersion;
	StdString szNode1;
	StdString szNode2;
	archive->SetIsWriting( false );
	archive->Read( fVersion );
	archive->Read( szNode1 );
	archive->Read( szNode2 );
	archive->Close();

	subResult = fVersion == 1.0f;
	subResult = subResult && szNode1 == "";
	subResult = subResult && szNode2 == "";
	SUBREPORT( subResult );

	result = result && subResult;

	DeleteObject( &hszNodeConnectionName );
	m_dialogEditControl->ReplaceSel(_T("  TestCreateNodeConnection overall: "));
	return result;
}
Exemplo n.º 8
0
TiXmlDocument* ObjectBase::Serialize()
{
	TiXmlDocument *document = new TiXmlDocument("document");

	TiXmlDeclaration* dec = new TiXmlDeclaration("1.0", "UTF-8", "yes");
	document->LinkEndChild( dec );

	TiXmlElement* root = new TiXmlElement( "wxFormBuilder_Project" );

	TiXmlElement* fileVersion = new TiXmlElement( "FileVersion" );
	fileVersion->SetAttribute( "major", AppData()->m_fbpVerMajor );
	fileVersion->SetAttribute( "minor", AppData()->m_fbpVerMinor );

	root->LinkEndChild( fileVersion );

	TiXmlElement *element = SerializeObject();
	root->LinkEndChild(element);
	document->LinkEndChild(root);
	return document;
}
Exemplo n.º 9
0
void cfile_serialize(XFILE *fp, int flag)
{
	int	i;
	int	highest_object_index = 0, highest_ship_index = 0, highest_ai_index = 0;

	Assert((flag == 0) || (flag == 1));

//	fp = cfopen(filename, flag ? "wb" : "rb");
//	if (!fp)
//		MessageBox(NULL, strerror(errno), "File Open Error!", MB_ICONSTOP);

	//	Find highest used object if writing.
	if (flag == 1) {
		for (i=MAX_OBJECTS-1; i>0; i--)
			if (Objects[i].type != OBJ_NONE) {
				highest_object_index = i;
				break;
			}
	}

	if (flag == 0) {
		num_ships = 0;
		num_objects = 0;
	}

	SerializeInt(fp, flag, highest_object_index);

	for (i=1; i<=highest_object_index; i++) {
		SerializeObject(fp, flag, &Objects[i]);
		if (flag == 0)
			if (Objects[i].type != OBJ_NONE)
				num_objects++;
	}

	//	Read/write ships
	if (flag == 1) {
		for (i=MAX_SHIPS-1; i>0; i--)
			if (Ships[i].objnum) {
				highest_ship_index = i;
				break;
			}
	}

	SerializeInt(fp, flag, highest_ship_index);

	for (i=1; i<=highest_ship_index; i++) {
		SerializeShip(fp, flag, &Ships[i]);
		if (flag == 0)
			if (Ships[i].objnum)
				num_ships++;
	}

	// Read/write AI info
	if (flag == 1) {
		for (i=MAX_AI_INFO-1; i>0; i--)
			if (Ai_info[i].shipnum) {
				highest_ai_index = i;
				break;
			}
	}

	SerializeInt(fp, flag, highest_ai_index);
	
	for (i=1; i<=highest_ai_index; i++)
		SerializeAI(fp, flag, &Ai_info[i]);
}
Exemplo n.º 10
0
bool CNodeSystemTest::TestCreateNodeSystem()
{
	bool result = true;
	bool subResult = false;

	CHashString hszNodeSystemName(_T("NodeSystem1"));
	CHashString hszNodeSystemType(_T("CNodeSystem"));

	m_dialogEditControl->ReplaceSel(_T("  Testing Creation of Node System 1 - \n"));
	CreateObject( &hszNodeSystemName, NULL, &hszNodeSystemType );

	InitializeObject( &hszNodeSystemName );

	m_dialogEditControl->ReplaceSel(_T("    Created node system found in engine: "));

	subResult = FindObject( &hszNodeSystemName );
	SUBREPORT( subResult );
	result = result && subResult;

	CHashString hszNodeName(_T("Node1"));
	CHashString hszNodeType(_T("CNode"));

	CreateObject( &hszNodeName, &hszNodeSystemName, &hszNodeType );

	InitializeObject( &hszNodeName );
	IArchive *archive = CreateMemoryArchive();
	archive->SetIsWriting( true );
	archive->Write( 1.0f, _T("Version") );
	archive->Write( 0.0f, _T("X") );
	archive->Write( 0.0f, _T("Y") );
	archive->Write( 0.0f, _T("Z") );
	archive->SetIsWriting( false );

	SerializeObject( &hszNodeName, archive, false );
	archive->Close();

	CHashString hszNodeConnectionName(_T("NodeConnection1"));
	CHashString hszNodeConnectionType(_T("CNodeConnection"));

	CreateObject( &hszNodeConnectionName, &hszNodeSystemName, &hszNodeConnectionType );

	InitializeObject( &hszNodeConnectionName );
	archive = CreateMemoryArchive();
	archive->SetIsWriting( true );
	archive->Write( 1.0f, _T("Version") );
	archive->Write( "", _T("Node1") );
	archive->Write( "", _T("Node2") );
	archive->SetIsWriting( false );

	SerializeObject( &hszNodeConnectionName, archive, false );
	archive->Close();

	archive = CreateMemoryArchive();
	archive->SetIsWriting( true );
	SerializeObject( &hszNodeSystemName, archive, true );
	float fVersion;
	int iNumNodes;
	int iNumConnections;

	archive->SetIsWriting( false );
	archive->Read( fVersion );
	archive->Read( iNumNodes );
	archive->Read( iNumConnections );
	archive->Close();

	m_dialogEditControl->ReplaceSel(_T("    Verify values: "));
	subResult = fVersion == 1.0f;
	subResult = subResult && iNumNodes == 1;
	subResult = subResult && iNumConnections == 1;
	SUBREPORT( subResult );
	result = result && subResult;

	DeleteObject( &hszNodeSystemName );

	m_dialogEditControl->ReplaceSel(_T("    Objects properly deleted: "));
	subResult = !FindObject( &hszNodeSystemName );
	subResult = subResult && !FindObject( &hszNodeName );
	subResult = subResult && !FindObject( &hszNodeConnectionName );
	SUBREPORT( subResult );
	result = result && subResult;

	m_dialogEditControl->ReplaceSel(_T("  TestCreateNodeSystem overall: "));
	return result;
}
static bool SerializeObject(CLR_RT_HeapBlock* pObj, CLR_UINT8* serData, CLR_INT32& serOffset, CLR_INT32& serSize )
{
    if(pObj == NULL)
    {
        return false;
    }

    switch(pObj->DataType())
    {
        case DATATYPE_OBJECT:
            if(!SerializeObject(pObj->Dereference(), serData, serOffset, serSize)) return false;
            break;
            
        case DATATYPE_CLASS:
        case DATATYPE_VALUETYPE:
            {
                CLR_RT_TypeDef_Instance cls; cls.InitializeFromIndex( pObj->ObjectCls() );
                int                    totFields = cls.CrossReference().m_totalFields;

                while(totFields-- > 0)
                {
                    if(!SerializeObject( ++pObj, serData, serOffset, serSize )) return false;
                }
            }
            break;

        case DATATYPE_SZARRAY:
            {
                CLR_RT_HeapBlock_Array* array = (CLR_RT_HeapBlock_Array*)pObj;
                int cnt = array->m_numOfElements;

                CLR_UINT8* pData;

                if(array->m_typeOfElement <= DATATYPE_LAST_NONPOINTER && cnt < 256)
                {
                    pData = (CLR_UINT8*)array->GetFirstElement();

                    while(cnt--)
                    {
                        if(!SerializeIntrinsicType( (CLR_DataType)array->m_typeOfElement, pData, serData, serOffset, serSize )) return false;

                        pData += array->m_sizeOfElement;
                    }
                }
                else
                {
                    return false;
                }
            }
            break;

        default:
            {
                CLR_UINT64 data = (CLR_UINT64)pObj->NumericByRef().u8;
                
                if(!SerializeIntrinsicType(pObj->DataType(), (CLR_UINT8*)&data, serData, serOffset, serSize)) return false;
            }
            break;               
    }

    return true;
}