Exemplo n.º 1
0
std::auto_ptr<Project> ProjectFileParser::Parse(std::string file)
{
    std::auto_ptr<Project> ret;
    try
    {
        rapidxml::file<> xmlFile(file.c_str());
        rapidxml::xml_document<> doc;
        doc.parse<0>(xmlFile.data());
        rapidxml::xml_node<>* projNode = doc.first_node();
        if (projNode == NULL) return ret;
        if (std::string(projNode->name()) != "Project") return ret;

        ret.reset(new Project());
        m_project = ret.get();

        rapidxml::xml_node<>* node = projNode->first_node();
        while (node)
        {
            switch (GetNodeType(node))
            {
                case eItemGroup:
                    ReadItemGroup(node);
                    break;
                case ePropertyGroup:
                    ReadPropertyGroup(node);
                    break;
                case eImportGroup:
                    ReadImportGroup(node);
                    break;
                case eImport:
                    ReadImport(node);
                    break;
                case eItemDefinitionGroup:
                    ReadItemDefinitionGroup(node);
                    break;
                case eUnknown:
                    break;
                default:
                    // any node at this level should be handled
                    break;
            }
            node = node->next_sibling();
        }
    }
    catch (...)
    {
        ret.reset();
    }
    m_project = NULL;
    return ret;
}
Exemplo n.º 2
0
void ObjReadImports (FILE* F, unsigned long Pos, ObjData* O)
/* Read the imports from a file at the given position */
{
    unsigned I;

    /* Seek to the correct position */
    FileSetPos (F, Pos);

    /* Read the data */
    O->ImportCount = ReadVar (F);
    O->Imports     = xmalloc (O->ImportCount * sizeof (O->Imports[0]));
    for (I = 0; I < O->ImportCount; ++I) {
        O->Imports [I] = ReadImport (F, O);
    }
}
Exemplo n.º 3
0
bool CG3DBinaryLoader::InitFile(const char* filename)
{
	m_CurrFile = new BinaryFile(filename);

	OpenFile(m_CurrFile, 0);
	if (!m_CurrFP->IsLoaded())
		return Error("Cannot find file");
	
	if (m_CurrFP->m_Ident == IDENT('W','D','3','G'))
		return Error("This platform is big endian, contact the developers!");
	else if (m_CurrFP->m_Ident != IDENT('G','3','D','W'))
		return Error("File does not have the correct header");

	m_CurrFile->m_Header.m_Version = m_CurrFP->ReadUInt16();
	m_CurrFile->m_Header.m_Num = m_CurrFP->ReadUInt16();
	m_CurrFile->m_Header.m_Table = m_CurrFP->ReadUInt32();
	m_CurrFile->m_Header.m_Import = m_CurrFP->ReadUInt32();
	m_CurrFile->m_Header.m_Reloc = m_CurrFP->ReadUInt32();

	if (m_CurrFile->m_Header.m_Import != 0)
		if (!ReadImport())
			return false;
	
	OpenFile(m_CurrFile, m_CurrFile->m_Header.m_Table);
	for (int i=0; i<m_CurrFile->m_Header.m_Num; i++)
	{
		if (!ReadTable())
			return false;
		if (!NextFile())
			return Error("failed to find all tables");
	}

	CloseFile();
	m_CurrFile->Release();

	return true;
}