void TiXmlElement::CopyTo( TiXmlElement* target ) const
{
	// superclass:
	TiXmlNode::CopyTo( target );

	// Element class: 
	// Clone the attributes, then clone the children.
	TiXmlAttribute* attribute = 0;
	for(	attribute = attributeSet.First();
	attribute;
	attribute = attribute->Next() )
	{
		target->SetAttribute( attribute->Name(), attribute->Value() );
	}

	TiXmlNode* node = 0;
	for ( node = firstChild; node; node = node->NextSibling() )
	{
		target->LinkEndChild( node->Clone() );
	}
}
示例#2
0
daeElementRef daeTinyXMLPlugin::readElement(TiXmlElement* tinyXmlElement, daeElement* parentElement) {
    std::vector<attrPair> attributes;
    for (TiXmlAttribute* attrib = tinyXmlElement->FirstAttribute(); attrib != NULL; attrib = attrib->Next())
        attributes.push_back(attrPair(attrib->Name(), attrib->Value()));

    daeElementRef element = beginReadElement(parentElement, tinyXmlElement->Value(),
                                             attributes, getCurrentLineNumber(tinyXmlElement));
    if (!element) {
        // We couldn't create the element. beginReadElement already printed an error message.
        return NULL;
    }

    if (tinyXmlElement->GetText() != NULL)
        readElementText(element, tinyXmlElement->GetText(), getCurrentLineNumber(tinyXmlElement));

    // Recurse children
    for (TiXmlElement* child = tinyXmlElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
        element->placeElement(readElement(child, element));

    return element;
}
void CRedisProxyCfg::getVipAttr(const TiXmlElement* vidNode) {
    TiXmlAttribute *addrAttr = (TiXmlAttribute *)vidNode->FirstAttribute();
    for (; addrAttr != NULL; addrAttr = addrAttr->Next()) {
        const char* name = addrAttr->Name();
        const char* value = addrAttr->Value();
        if (value == NULL) value = "";
        if (0 == strcasecmp(name, "if_alias_name")) {
            strcpy(m_vip.if_alias_name, value);
            continue;
        }
        if (0 == strcasecmp(name, "vip_address")) {
            strcpy(m_vip.vip_address, value);
            continue;
        }
        if (0 == strcasecmp(name, "enable")) {
            if(strcasecmp(value, "0") != 0 && strcasecmp(value, "") != 0 ) {
                m_vip.enable = true;
            }
        }
    }
}
示例#4
0
bool CConverToMK::ParseFilterInVCProjectFile( TiXmlElement* pkElement,
											 StringVector& kVector)
{
	if (0 == pkElement)
	{
		return false;
	}

	TiXmlElement* pkFilter = pkElement->FirstChildElement();

	if (0 == pkFilter)
	{
		return false;
	}

	do
	{
		TiXmlAttribute* pkAttr = pkFilter->FirstAttribute();

		string strType = pkFilter->Value();

		if (strcmp("Filter",strType.c_str()) == 0)
		{
			ParseFilterInVCProjectFile(pkFilter,kVector);
		}
		else if (strcmp("File",strType.c_str()) == 0)
		{
			string strName = pkAttr->Value();

			if (!IsFilterWord(strName.c_str()))
			{
				continue;
			}

			kVector.push_back(strName);
		}
	} while (pkFilter = pkFilter->NextSiblingElement());

	return true;
}
示例#5
0
bool CButtonTranslator::LoadLircMap()
{
  // load our xml file, and fill up our mapping tables
  TiXmlDocument xmlDoc;

  // Load the config file
  CStdString lircmapPath = g_settings.GetUserDataItem("Lircmap.xml");
  CLog::Log(LOGINFO, "Loading %s", lircmapPath.c_str());
  if (!xmlDoc.LoadFile(lircmapPath))
  {
    g_LoadErrorStr.Format("%s, Line %d\n%s", lircmapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
    return true; // This is so people who don't have the file won't fail, just warn
  }

  lircRemotesMap.clear();
  TiXmlElement* pRoot = xmlDoc.RootElement();
  CStdString strValue = pRoot->Value();
  if (strValue != "lircmap")
  {
    g_LoadErrorStr.Format("%sl Doesn't contain <lircmap>", lircmapPath.c_str());
    return false;
  }

  // run through our window groups
  TiXmlNode* pRemote = pRoot->FirstChild();
  while (pRemote)
  {
    const char *szRemote = pRemote->Value();
    if (szRemote)
    {
      TiXmlAttribute* pAttr = pRemote->ToElement()->FirstAttribute();
      const char* szDeviceName = pAttr->Value();
      MapRemote(pRemote, szDeviceName);
    }
    pRemote = pRemote->NextSibling();
  }
  
  return true;
}
示例#6
0
int dump_attribs_to_stdout(TiXmlElement* pElement, unsigned int indent)
{
	if (!pElement) return 0;

	TiXmlAttribute* pAttrib = pElement->FirstAttribute();
	int i = 0;
	int ival;
	double dval;
	const char* pIndent = getIndent(indent);
	printf("\n");
	while (pAttrib)
	{
		printf("%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value());

		if (pAttrib->QueryIntValue(&ival) == TIXML_SUCCESS)    printf(" int=%d", ival);
		if (pAttrib->QueryDoubleValue(&dval) == TIXML_SUCCESS) printf(" d=%1.1f", dval);
		printf("\n");
		i++;
		pAttrib = pAttrib->Next();
	}
	return i;
}
示例#7
0
void SE_ShaderHandler::handle(SE_Element* parent, TiXmlElement* xmlElement, unsigned int indent)
{
    if(!xmlElement)
        return;
    TiXmlAttribute* pAttribute = xmlElement->FirstAttribute();
    SE_ResourceManager* resourceManager = SE_Application::getInstance()->getResourceManager();
    std::string vertexShaderFilePath;
    std::string fragmentShaderFilePath;
    while(pAttribute)
    {
        const char* name = pAttribute->Name();
        const char* value = pAttribute->Value();
        if(!strcmp(name , "VertexShader"))
        {
            vertexShaderFilePath = std::string(resourceManager->getDataPath()) + SE_SEP + value;
        }
        else if(!strcmp(name, "FragmentShader"))
        {
            fragmentShaderFilePath = std::string(resourceManager->getDataPath()) + SE_SEP + value;
        }
        pAttribute = pAttribute->Next();
    }
    char* vertexShader;
    char* fragmentShader;
    int vertexShaderLen =0;
    int fragmentShaderLen = 0;
    SE_IO::readFileAll(vertexShaderFilePath.c_str(), vertexShader, vertexShaderLen);
    SE_IO::readFileAll(fragmentShaderFilePath.c_str(), fragmentShader, fragmentShaderLen);
    char* vs = new char[vertexShaderLen + 1];
    char* fs = new char[fragmentShaderLen + 1];
    memset(vs, 0, vertexShaderLen + 1);
    memset(fs, 0, fragmentShaderLen + 1);
    memcpy(vs, vertexShader, vertexShaderLen);
    memcpy(fs, fragmentShader, fragmentShaderLen);
    SE_ProgramDataID id("main_vertex_shader");
    //resourceManager->setShaderProgram(id, vs, fs);
    delete[] vertexShader;
    delete[] fragmentShader;
}
void CRedisProxyCfg::setKeyMappingNode(TiXmlElement* pNode) {
    TiXmlElement* pNext = pNode->FirstChildElement();
    for (; pNext != NULL; pNext = pNext->NextSiblingElement()) {
        CKeyMapping hashMap;
        if (0 == strcasecmp(pNext->Value(), "key")) {
            TiXmlAttribute *addrAttr = pNext->FirstAttribute();
            for (; addrAttr != NULL; addrAttr = addrAttr->Next()) {
                const char* name = addrAttr->Name();
                const char* value = addrAttr->Value();
                if (value == NULL) value = "";
                if (0 == strcasecmp(name, "key_name")) {
                    strcpy(hashMap.key, value);
                    continue;
                }
                if (0 == strcasecmp(name, "group_name")) {
                    strcpy(hashMap.group_name, value);
                }
            }
            m_keyMappingList->push_back(hashMap);
        }
    }
}
示例#9
0
View* XmlParser::parse_element(TiXmlElement *e, View *parent /* = NULL */)
{
	if (!e)
	{
		return NULL;
	}
	View *view = ResourceCreator::instance().get_view(e->Value());
	if (!view)
	{
		return NULL;
	}
	if (parent)
	{
		view->set_parent(parent);
		parent->push_child(view);
	}
	TiXmlAttribute *a = e->FirstAttribute();
	PropMap props;
	while(a)
	{
		props.insert(make_pair(a->Name(), a->Value()));
		a = a->Next();
	}
	view->parse(props);

	TiXmlNode *node = e->FirstChild();
	if (!node)
	{
		return view;
	}
	TiXmlElement *sub = node->ToElement();
	while (sub)
	{
		View* sv = parse_element(sub, view);
		sub = sub->NextSiblingElement();
	}
	return view;
}
示例#10
0
inline bool TamlXmlParser::parseAttributes( TiXmlElement* pXmlElement, TamlVisitor& visitor )
{
    // Debug Profiling.
    PROFILE_SCOPE(TamlXmlParser_ParseAttribute);

    // Calculate if element is at the root or not.
    const bool isRoot = pXmlElement->GetDocument()->RootElement() == pXmlElement;

    // Create a visitor property state.
    TamlVisitor::PropertyState propertyState;
    propertyState.setObjectName( pXmlElement->Value(), isRoot );

    // Iterate attributes.
    for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
    {
        // Configure property state.
        propertyState.setProperty( pAttribute->Name(), pAttribute->Value() );

        // Visit this attribute.
        const bool visitStatus = visitor.visit( *this, propertyState );

        // Was the property value changed?
        if ( propertyState.getPropertyValueDirty() )
        {
            // Yes, so update the attribute.
            pAttribute->SetValue( propertyState.getPropertyValue() );

            // Flag the document as dirty.
            mDocumentDirty = true;
        }

        // Finish if requested.
        if ( !visitStatus )
            return false;
    }

    return true;
}
示例#11
0
int em::EmXml::ReadRootAttrMap( EmMapStr &rMapStr )
{
	int iResult = 0;
	rMapStr.clear();

	TiXmlElement *pElemRoot = m_pDoc->RootElement();
	if(pElemRoot == NULL)
	{
		return 0;
	}
	TiXmlAttribute *pAttr = pElemRoot->FirstAttribute();
	while(true)
	{
		if(pAttr == NULL)
		{
			break;
		}
		rMapStr[  pAttr->Name() ] =  pAttr->Value() ;
		pAttr = pAttr->Next();
	}
	iResult = rMapStr.size();
	return iResult;
}
示例#12
0
void CALLBACK CUICommandHistory::UIModify(TiXmlNode* pNode)
{
	TiXmlElement* pElement = pNode->ToElement();
	CStringA strName = pElement->Attribute("name");
	pElement->RemoveAttribute("name");
	if(strName.IsEmpty())
		return;

	CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager();
	CControlUI* pControl = pManager->FindControl(StringConvertor::Utf8ToWide(strName));
	TiXmlAttribute* pAttrib = pElement->FirstAttribute();
	if(pControl == NULL)
		return;

	while(pAttrib)
	{
		pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name())
			, StringConvertor::Utf8ToWide(pAttrib->Value()));
		pAttrib = pAttrib->Next();
	}
	CControlUI* pParent = pControl->GetParent();
	pParent->SetPos(pParent->GetPos());
}
示例#13
0
/*!
*  /brief 通过节点查询。
*
*  /param XmlFile   xml文件全路径。
*  /param strNodeName  要查询的节点名
*  /param AttMap      要查询的属性值,这是一个map,前一个为属性名,后一个为属性值
*  /return 是否成功。true为成功,false表示失败。
*/
bool xml_QueryNode_Attribute(TiXmlElement *pRootEle, std::string strNodeName,
        std::map<std::string, std::string> &AttMap)
{
    // 定义一个TiXmlDocument类指针
    typedef std::pair<std::string, std::string> String_Pair;
    if (NULL == pRootEle) {
        return false;
    }
    TiXmlElement *pNode = NULL;
    xml_GetNodePointerByName(pRootEle, strNodeName, pNode);
    if (NULL != pNode) {
        TiXmlAttribute* pAttr = NULL;
        for (pAttr = pNode->FirstAttribute(); pAttr; pAttr = pAttr->Next()) {
            std::string strAttName = pAttr->Name();
            std::string strAttValue = pAttr->Value();
            AttMap.insert(String_Pair(strAttName, strAttValue));
        }
        return true;
    } else {
        return false;
    }
    return true;
}
/***********************************************************************************************************
 * 程序作者:赵进军
 * 函数功能:获取 XML文件所有的数据
 * 参数说明:null
 * 注意事项:null
 * 修改日期:2015/12/14 23:10:00
 ***********************************************************************************************************/
void OperationProfile_XML::GetXmlDataAll(TiXmlNode* pRootEle, char* groupName)
{
	if (NULL == pRootEle)
		return;

	TiXmlNode* pElement = pRootEle->FirstChild();
	TiXmlElement* element;
	TiXmlAttribute* attr;
	int kl;
	for (; pElement; pElement = pElement->NextSibling())
	{
		int nType = pElement->Type();
		switch (nType)
		{
		case TiXmlNode::TINYXML_ELEMENT:
			element = pElement->ToElement();
			if (element != NULL)
			{
				attr = element->FirstAttribute();
				if (attr != NULL)
					std::cout << attr->Value() << std::endl;
			}
			GetXmlDataAll(pElement, groupName);
			break;

		case TiXmlNode::TINYXML_TEXT:
			std::cout << pElement->Value() << std::endl;
			break;

		case TiXmlNode::TINYXML_DOCUMENT:
			kl = 0;
			break;
		default:
			break;
		}
	}
}
示例#15
0
文件: main.cpp 项目: pfeng90/Myc2xml
void readXml()
{
    TiXmlDocument* myDocument = new TiXmlDocument();
    myDocument->LoadFile("student.xml");
    myDocument->Print();
    TiXmlElement* rootElement = myDocument->RootElement();  //Class    
    TiXmlElement* studentsElement = rootElement->FirstChildElement();  //Students
    TiXmlElement* studentElement = studentsElement->FirstChildElement();  //Students
    //std::cout<<studentElement->GetText() ;    
    while ( studentElement ) 
    {
        TiXmlAttribute* attributeOfStudent = studentElement->FirstAttribute();  //获得student的name属性
        while ( attributeOfStudent ) 
        {
            std::cout << attributeOfStudent->Name() << " : " << attributeOfStudent->Value() << std::endl;
            attributeOfStudent = attributeOfStudent->Next();
        }
        TiXmlElement* phoneElement = studentElement->FirstChildElement();//获得student的phone元素
        std::cout << "phone" << " : " << phoneElement->GetText() << std::endl;
        TiXmlElement* addressElement = phoneElement->NextSiblingElement();
        std::cout << "address" << " : " << phoneElement->GetText() << std::endl;
        studentElement = studentElement->NextSiblingElement();
    }
}
示例#16
0
TiXmlNode* TiXmlElement::Clone() const
{
	TiXmlElement* clone = new TiXmlElement( Value() );
	if ( !clone )
		return 0;

	CopyToClone( clone );

	// Clone the attributes, then clone the children.
	TiXmlAttribute* attribute = 0;
	for(	attribute = attributeSet.First();
	attribute;
	attribute = attribute->Next() )
	{
		clone->SetAttribute( attribute->Name(), attribute->Value() );
	}

	TiXmlNode* node = 0;
	for ( node = firstChild; node; node = node->NextSibling() )
	{
		clone->LinkEndChild( node->Clone() );
	}
	return clone;
}
示例#17
0
void XMLMenuLabel::ReadFromXML( TiXmlElement* element )
{
    TiXmlAttribute* attrib = element->FirstAttribute();

    while( attrib )
    {
        if( strcmp( attrib->Name(), "text_id" ) == 0 )
        {
            m_textID = const_cast< char* >( attrib->Value() );
        }
        else if( strcmp( attrib->Name(), "underlined" ) == 0 )
        {
            m_underlined = XMLMenuHelper::charToBool( const_cast< char* >( attrib->Value() ) );
        }
        else if( strcmp( attrib->Name(), "back_button" ) == 0 )
        {
            m_backButton = XMLMenuHelper::charToBool( const_cast< char* >( attrib->Value() ) );
        }
        else if( strcmp( attrib->Name(), "fontsize" ) == 0 )
        {
            sscanf( attrib->Value(), "%d", &m_fontSize );
        }
        else if( strcmp( attrib->Name(), "alignment" ) == 0 )
        {
            m_alignment = XMLMenuHelper::convertAlignmentStrToInt( attrib->Value() );
        }
        else if( strcmp( attrib->Name(), "inputtextbox" ) == 0 )
        {
            m_isInputBox = XMLMenuHelper::charToBool( const_cast< char* >( attrib->Value() ) );
        }
        else
        {
            setAttribs( attrib->Name(), const_cast< char* >( attrib->Value() ) );
        }

        attrib = attrib->Next();
    }
}
示例#18
0
void EnemyManager::ReadXmlEnemyData(const char* filename)
{
	TiXmlDocument doc;
	if (doc.LoadFile(filename)) {
		doc.Print();
	} else {
		MyLog::put(__LINE__, __FILE__, "can not parse xml file.\n");
		return;
	}

	TiXmlElement* rootElement = doc.RootElement();
	TiXmlElement* keyElement = rootElement->FirstChildElement();

	while (keyElement) {
		EnemyData ed;
		TiXmlElement* ele = keyElement->FirstChildElement();
		TiXmlAttribute* coord = ele->FirstAttribute();
		ed.x = atoi(coord->Value());
		coord = coord->Next();
		ed.y = atoi(coord->Value());
		coord = coord->Next();
		ed.z = atoi(coord->Value());

		ele = ele->NextSiblingElement();
		TiXmlElement* cmdEle = ele->FirstChildElement();
		while (cmdEle) {
			TiXmlAttribute* cmdName = cmdEle->FirstAttribute();
			if (strcmp(cmdName->Value(), "MovingForward") == 0) {
				ed.vCmd.push_back(Job::eMovingForward);
			} else if (strcmp(cmdName->Value(), "TurningLeft") == 0) {
				ed.vCmd.push_back(Job::eTurningLeft);
			} else if (strcmp(cmdName->Value(), "TurningRight") == 0) {
				ed.vCmd.push_back(Job::eTurningRight);
			}
			cmdEle = cmdEle->NextSiblingElement();
		}

		vData.push_back(ed);
		keyElement = keyElement->NextSiblingElement();
	}
}
示例#19
0
void CPacketDlg::OnBnClickedButton6()
{
	m_pBaseDataLogic->ClearRandomPacket();

	//读取XML文件
	TiXmlDocument * pDocument = new TiXmlDocument(PACKETDATA_FILENAME);//tstl可以为文件路径或文件名
	pDocument->LoadFile();

	if(NULL == pDocument)
	{
		MessageBox(_T("读取顺序数据包xml文件失败"), _T("提示信息"), MB_OK);
		return;
	}

	TiXmlElement *Root = pDocument->RootElement();//获取根节点<Particls>
	TiXmlElement *Particl = NULL;

	int nLen        = 0;
	int nType       = 0;
	int nRecvLength = 0;

	for(Particl = Root->FirstChildElement();Particl != NULL;Particl = Particl->NextSiblingElement())
	{
		//得到文档内容
		const char *sztext = Particl->GetText();

		//得到文档属性
		TiXmlAttribute* pAddrAttr = Particl->FirstAttribute();
		if(strcmp(pAddrAttr->Name(), "Len") == 0)
		{
			nLen = atoi(pAddrAttr->Value());
		}
		else if(strcmp(pAddrAttr->Name(), "Type") == 0)
		{
			nType = atoi(pAddrAttr->Value());
		}
		else
		{
			nRecvLength = atoi(pAddrAttr->Value());
		}

		TiXmlAttribute *pAttr1 = pAddrAttr->Next();
		if(strcmp(pAttr1->Name(), "Len") == 0)
		{
			nLen = atoi(pAttr1->Value());
		}
		else if(strcmp(pAttr1->Name(), "Type") == 0)
		{
			nType = atoi(pAttr1->Value());
		}
		else
		{
			nRecvLength = atoi(pAttr1->Value());
		}

		TiXmlAttribute * pAttr2 = pAttr1->Next();
		if(strcmp(pAttr2->Name(), "Len") == 0)
		{
			nLen = atoi(pAttr2->Value());
		}
		else if(strcmp(pAttr2->Name(), "Type") == 0)
		{
			nType = atoi(pAttr2->Value());
		}
		else
		{
			nRecvLength = atoi(pAttr2->Value());
		}

		//添加类型
		m_pBaseDataLogic->InsertRandomPacket(sztext, nLen, nRecvLength, nType);
	}

	ShowPacketList();

	delete pDocument;
}
示例#20
0
const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data )
{
    p = SkipWhiteSpace( p );
    TiXmlDocument* document = GetDocument();

    if ( !p || !*p )
    {
        if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0 );
        return 0;
    }

//	TiXmlParsingData data( p, prevData );
    if ( data )
    {
        data->Stamp( p );
        location = data->Cursor();
    }

    if ( *p != '<' )
    {
        if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data );
        return 0;
    }

    p = SkipWhiteSpace( p+1 );

    // Read the name.
    const char* pErr = p;

    p = ReadName( p, &value );
    if ( !p || !*p )
    {
        if ( document )	document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data );
        return 0;
    }

    TIXML_STRING endTag ("</");
    endTag += value;
    endTag += ">";

    // Check for and read attributes. Also look for an empty
    // tag or an end tag.
    while ( p && *p )
    {
        pErr = p;
        p = SkipWhiteSpace( p );
        if ( !p || !*p )
        {
            if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data );
            return 0;
        }
        if ( *p == '/' )
        {
            ++p;
            // Empty tag.
            if ( *p  != '>' )
            {
                if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data );
                return 0;
            }
            return (p+1);
        }
        else if ( *p == '>' )
        {
            // Done with attributes (if there were any.)
            // Read the value -- which can include other
            // elements -- read the end tag, and return.
            ++p;
            p = ReadValue( p, data );		// Note this is an Element method, and will set the error if one happens.
            if ( !p || !*p )
                return 0;

            // We should find the end tag now
            if ( StringEqual( p, endTag.c_str(), false ) )
            {
                p += endTag.length();
                return p;
            }
            else
            {
                if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data );
                return 0;
            }
        }
        else
        {
            // Try to read an attribute:
            TiXmlAttribute* attrib = new TiXmlAttribute();
            if ( !attrib )
            {
                if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data );
                return 0;
            }

            attrib->SetDocument( document );
            const char* pErr = p;
            p = attrib->Parse( p, data );

            if ( !p || !*p )
            {
                if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data );
                delete attrib;
                return 0;
            }

            // Handle the strange case of double attributes:
            TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
            if ( node )
            {
                node->SetValue( attrib->Value() );
                delete attrib;
                return 0;
            }

            attributeSet.Add( attrib );
        }
    }
    return p;
}
示例#21
0
BOOL CProcessMgr::Open(CString sProcessFilePath)
{
	ZTools::WriteZToolsFormatLog("开始打开设计过程");
/*
建目录
解压
存工作路径变量
打开建模页面
*/
	if (sProcessFilePath.IsEmpty())
	{
		return FALSE;
	}

	//创建临时目录
	CString sWorkPath = GetExecDir() + "\\Data\\" + ReslibMgr::GuidToString(ReslibMgr::CreateGuid()).c_str();

	if (!MakeSureDirectoryPathExists(sWorkPath + "\\"))
	{
		ZTools::WriteZToolsFormatLog("创建工作目录失败:%s", sWorkPath);
		return FALSE;
	}

	//解压
	if (!ZipTool::Unzip((LPCTSTR)sProcessFilePath, (LPCTSTR)sWorkPath))
	{
		ZTools::WriteZToolsFormatLog("unzip file failed: %s", sProcessFilePath);
		return FALSE;
	}

	//打开建模页面
	CMainFrame * pMainFrame = reinterpret_cast< CMainFrame * > ( theApp.m_pMainWnd );
	if (!pMainFrame)
	{
		return FALSE;
	}
	pMainFrame->OnMenuModuleOpenjianmo();

	CDlgSvg * pSvg = GetSvgDilogPtr();
	if ( pSvg == NULL ) return FALSE;

	//设置当前设计过程的变量
	Clear();
	m_sProcessFilePath = sProcessFilePath;
	m_sWorkPath = sWorkPath;
	
	{//打开时同样添加历史记录
		CString strHistoryPath = m_sWorkPath + "\\main.xpdl";
		if ( !IsAccessibleFile( strHistoryPath ) )
		{
			return FALSE;
		}

		TiXmlBase::SetCondenseWhiteSpace(false);
		TiXmlDocument doc;
		doc.LoadFile(strHistoryPath, TIXML_ENCODING_UTF8);
		if (doc.Error())
		{
			ZTools::WriteZToolsFormatLog("解析main.xpdl出错");
			return FALSE;
		}
		TiXmlElement* rootElement = doc.RootElement();//Package
		if (rootElement)
		{
			std::string strName;
			std::string strValue;
			//rootElement->QueryStringAttribute("name", &strName);
			TiXmlAttribute* pAb;
			pAb = rootElement->FirstAttribute();
			while (pAb)
			{
				strName = pAb->Name();
				strValue = pAb->Value();
				ZTools::UTF8ToMB(strName);
				ZTools::UTF8ToMB(strValue);
				if(strName == "Name")
				{
					AddToHistory(strValue.c_str(), m_sProcessFilePath);//添加到历史
					theApp.GetMainWnd()->SetTimer( TIMER_MAINFRAME_RECENTLYMENU, TIMER_MAINFRAME_RECENTLYMENU_TIMEOUT, 0);
					break;
				}
				pAb = pAb->Next();
			}			
		}
	}

	ZTools::WriteZToolsFormatLog("工作路径准备完成,开始加载静态页面");
	pSvg->Navigate( theGlobalConfig.m_strSvgUrl );
	return TRUE;
}
示例#22
0
const char* TiXmlElement::Parse( const char* p )
{
	p = SkipWhiteSpace( p );
	TiXmlDocument* document = GetDocument();

	if ( !p || !*p || *p != '<' )
	{
		if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT );
		return false;
	}

	p = SkipWhiteSpace( p+1 );

	// Read the name.
    p = ReadName( p, &value );
	if ( !p || !*p )
	{
		if ( document )	document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME );
		return false;
	}

    TIXML_STRING endTag ("</");
	endTag += value;
	endTag += ">";

	// Check for and read attributes. Also look for an empty
	// tag or an end tag.
	while ( p && *p )
	{
		p = SkipWhiteSpace( p );
		if ( !p || !*p )
		{
			if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES );
			return 0;
		}
		if ( *p == '/' )
		{
			++p;
			// Empty tag.
			if ( *p  != '>' )
			{
				if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY );		
				return 0;
			}
			return (p+1);
		}
		else if ( *p == '>' )
		{
			// Done with attributes (if there were any.)
			// Read the value -- which can include other
			// elements -- read the end tag, and return.
			++p;
			p = ReadValue( p );		// Note this is an Element method, and will set the error if one happens.
			if ( !p || !*p )
				return 0;

			// We should find the end tag now
			if ( StringEqual( p, endTag.c_str(), false ) )
			{
				p += endTag.length();
				return p;
			}
			else
			{
				if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG );
				return 0;
			}
		}
		else
		{
			// Try to read an element:
			TiXmlAttribute attrib;
			attrib.SetDocument( document );
			p = attrib.Parse( p );

			if ( !p || !*p )
			{
				if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT );
				return 0;
			}
			SetAttribute( attrib.Name(), attrib.Value() );
		}
	}
	return p;
}
示例#23
0
bool cResourceManager::loadFromXMLFile(std::string Filename)
{
	TiXmlDocument doc(Filename.c_str());

	if(doc.LoadFile())
	{
		//find topmost resources node in XML file
		TiXmlNode* ResourceTree = doc.FirstChild("resources");

		if(ResourceTree)
		{
			//Enumerate resource objects
			for(TiXmlNode* child = ResourceTree->FirstChild();child; child = child->NextSibling())
			{
				TiXmlElement *Element = child->ToElement();

				if(Element)
				{
					cResource *Resource = NULL;
					cAudioResource* aResource = NULL;

					for(TiXmlAttribute* ElementAttrib = Element->FirstAttribute(); ElementAttrib; ElementAttrib = ElementAttrib->Next())
					{
						//examine our resource object
						std::string AttribName = ElementAttrib->Name();
						std::string AttribValue = ElementAttrib->Value();

						//detect resource type. Graphic, Texture, Audio
						if(AttribName=="type")
						{
							//Allow managers to implement derived versions of cResource.
							//Managers will create resources and pass a cResource point to be
							//added to resource list.  
							if(AttribValue=="graphic")
							{
								//call the render manager to instantiate an instance of render resource
								Resource = g_renderManager->load3DFromXML(Element);
							}

							if(AttribValue=="texture")
							{
								Resource = AudioManager::GetInstance()->loadTResourceFromXML(Element);
								//Resource = g_TextureManager.loadResourceFromXML(Element);  //CTextureResource
							}

							if(AttribValue=="audio")
							{	
								Resource = AudioManager::GetInstance()->loadResourceFromXML(Element);
							}
						}

						if(Resource)
						{
							if(AttribName=="UID")
							{
								Resource->m_ResourceID = atoi(AttribValue.c_str());
							}

							if(AttribName=="filename")
							{
								Resource->m_FileName = AttribValue;
							}

							if(AttribName=="scenescope")
							{
								Resource->m_Scope = atoi(AttribValue.c_str());
							}
						}
					}

					if(Resource)
					{
						//Resources are added to map here
						m_Resources[Resource->m_Scope].push_back(Resource);
						m_ResourceCount++;
					}
					//if(aResource)
					//{
					//	//Resources are added to map here
					//	m_Resources[aResource->m_Scope].push_back(aResource);
					//	m_ResourceCount++;
					//}
				}
			}
			return true;
		}
	}
	return false;
}
示例#24
0
bool CGmResMan::ReadXML_Curves_( CList<CCurvePathBezier3 *> *poLstCurve, TiXmlNode* poParent, unsigned int uiCounter )
{
	if( !poParent )
		return false;
	
	static CCurvePathBezier3 * poCurve_;
	static CCurveBezier3 * poBezier_;
	static unsigned int uiVertex_;
	static char acTxt_[256];
	if( uiCounter == 0 )
	{
		poCurve_ = 0;
		poBezier_ = 0;
		uiVertex_ = 0;
	}
	bool bCurveTag = false;
	bool bBezierTag = false;
	
	switch ( poParent->Type() )
	{
	case TiXmlNode::DOCUMENT:
		LOG( "XML: Document" );
	break;
	case TiXmlNode::ELEMENT:
	{
		const char *pcName = poParent->Value();
		//LOG( "name: %s\n", pcName );
		if( !strcmp( pcName, "curve" ) )
		{
			LOG( "curve:\n" );
			
			poCurve_ = new CCurvePathBezier3;
			poLstCurve->Append( poCurve_ );
			bCurveTag = true;
			
			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					if( !strcmp( pcName, "name" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "name: %s\n", acTxt_ );
						poCurve_->m_oName = acTxt_;
					}
					poAttrib = poAttrib->Next();
				}
			}
		}
		else if( !strcmp( pcName, "bezier" ) )
		{
			LOG( "bezier:\n" );
			poBezier_ = new CCurveBezier3;
			bBezierTag = true;
		}
		else if( !strcmp( pcName, "point" ) && poBezier_ )
		{
			LOG( "point:\n" );
			CCurve::CVertex oVertex;
			
			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					
					if( !strcmp( pcName, "x" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							oVertex.m_oPos[0] = float( dVal );
						}
					}
					else if( !strcmp( pcName, "y" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							oVertex.m_oPos[1] = float( dVal );
						}
					}
					else if( !strcmp( pcName, "z" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							oVertex.m_oPos[2] = float( dVal );
						}
					}
					else if( !strcmp( pcName, "weight" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							oVertex.m_fWeight0 = float( dVal );
						}
					}
					poAttrib = poAttrib->Next();
				}
			}
			poBezier_->m_aoVertex[uiVertex_] = oVertex;
			++uiVertex_;
		}
	}
	break;
	case TiXmlNode::COMMENT:
		//LOG( "XML: Comment: [%s]", poParent->Value());
	break;
	case TiXmlNode::UNKNOWN:
		//LOG( "XML: Unknown" );
	break;
	case TiXmlNode::TEXT:
		//LOG( "XML: Text: [%s]", poParent->ToText()->Value() );
	break;
	case TiXmlNode::DECLARATION:
		//LOG( "XML: Declaration" );
	break;
	default:
	break;
	}
	LOG( "\n" );
	
	++uiCounter;
	
	TiXmlNode* poChild = poParent->FirstChild();
	if( poChild )
	{
		//LOG( "<tag>\n" );
		for( ; poChild != 0; poChild = poChild->NextSibling() ) 
		{
			ReadXML_Curves_( poLstCurve, poChild, uiCounter );
		}
		//LOG( "</tag>\n" );
	}
	
	if( bBezierTag )
	{
		poCurve_->Append( poBezier_ );
		poBezier_ = 0;
		uiVertex_ = 0;
	}
	else if( bCurveTag )
	{
		poCurve_ = 0;
	}
	
	return true;
}
示例#25
0
const char* TiXmlDeclaration::Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding)
{
  p = SkipWhiteSpace(p, _encoding);
  // Find the beginning, find the end, and look for
  // the stuff in-between.
  TiXmlDocument* document = GetDocument();

  if(!p || !*p || !StringEqual(p, "<?xml", true, _encoding))
  {
    if(document)
    {
      document->SetError(TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding);
    }

    return 0;
  }

  if(data)
  {
    data->Stamp(p, _encoding);
    location = data->Cursor();
  }

  p += 5;
  version = "";
  encoding = "";
  standalone = "";

  while(p && *p)
  {
    if(*p == '>')
    {
      ++p;
      return p;
    }

    p = SkipWhiteSpace(p, _encoding);

    if(StringEqual(p, "version", true, _encoding))
    {
      TiXmlAttribute attrib;
      p = attrib.Parse(p, data, _encoding);
      version = attrib.Value();
    }
    else if(StringEqual(p, "encoding", true, _encoding))
    {
      TiXmlAttribute attrib;
      p = attrib.Parse(p, data, _encoding);
      encoding = attrib.Value();
    }
    else if(StringEqual(p, "standalone", true, _encoding))
    {
      TiXmlAttribute attrib;
      p = attrib.Parse(p, data, _encoding);
      standalone = attrib.Value();
    }
    else
    {
      // Read over whatever it is.
      while(p && *p && *p != '>' && !IsWhiteSpace(*p))
      {
        ++p;
      }
    }
  }

  return 0;
}
示例#26
0
bool WorldDB::load_object_attributes(WorldObject *object, TiXmlElement *elmt)
{
    bool result = true;

    TiXmlAttribute *attr = elmt->FirstAttribute();
    while (attr) {
        if (strcmp(attr->Name(), "id") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "location_x") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "location_y") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "location") == 0) {
            object->m_location = std::string(attr->Value());
        }
        else if (strcmp(attr->Name(), "type") == 0) {
            if (strcmp(attr->Value(), "item") == 0) {
                object->m_object_type = Object::TypeItem;
            }
            else if (strcmp(attr->Value(), "collectable") == 0) {
                object->m_object_type = Object::TypeCollectable;
            }
            else if (strcmp(attr->Value(), "curse") == 0) {
                object->m_object_type = Object::TypeCurse;
            }
            else if (strcmp(attr->Value(), "event") == 0) {
                object->m_object_type = Object::TypeEvent;
            }
            else {
                result = false;
                break;
            }
        }
        else if (strcmp(attr->Name(), "name") == 0) {
            object->m_strings[std::string(attr->Name())] =
                std::string(attr->Value());
        }
        else if (strcmp(attr->Name(), "player") == 0) {
            object->m_strings[std::string(attr->Name())] =
                std::string(attr->Value());
        }
        else if (strcmp(attr->Name(), "destination") == 0) {
            object->m_strings[std::string(attr->Name())] =
                std::string(attr->Value());
        }
        else if (strcmp(attr->Name(), "start_x") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "start_y") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "event_type") == 0) {
            if (strcmp(attr->Value(), "area") == 0) {
                object->m_strings[std::string(attr->Name())] =
                    std::string(attr->Value());
            }
            else {
                result = false;
                break;
            }
        }
        else if (strcmp(attr->Name(), "event") == 0) {
            object->m_strings[std::string(attr->Name())] =
                std::string(attr->Value());
        }
        else if (strcmp(attr->Name(), "x") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "y") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "width") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "height") == 0) {
            object->m_integers[std::string(attr->Name())] = atoi(attr->Value());
        }
        else if (strcmp(attr->Name(), "area_type") == 0) {
            object->m_strings[std::string(attr->Name())] =
                std::string(attr->Value());
        }
        else {
            result = false;
            break;
        }

        attr = attr->Next();
    }

    return result;
}
bool CGetResultListBG::ParseResultListXml(const CStdString& strHtml, CFileItemList& items)
{
  TiXmlDocument xmlDoc;
  xmlDoc.Parse(strHtml);

  TiXmlElement *pRootElement = xmlDoc.RootElement();
  if (!pRootElement)
    return false;

  if (strcmpi(pRootElement->Value(), "search") != 0)
  {
    CLog::Log(LOGERROR, "CGetResultListBG::ParseResultListXml, could not parse manual resolution results (manual)");
    return false;
  }

  const TiXmlNode* pTag = 0;
  while ((pTag = pRootElement->IterateChildren(pTag)))
  {
    if (pTag->ValueStr() == "title")
    {
      const TiXmlNode *pValue = pTag->FirstChild();
      CStdString strValue = pValue->ValueStr();

      // Find the id attribute, we do not know its name but we know that there are two attributes and it's not the one called 'year'
      CStdString idAttributeName;
      CStdString idAttributeValue;

      TiXmlAttribute* attribute = ((TiXmlElement*)pTag)->FirstAttribute();
      while (attribute)
      {
        if ((strcmpi(attribute->Name(), "year") != 0) && (strcmpi(attribute->Name(), "type") != 0))
        {
          idAttributeName = attribute->Name();
          idAttributeValue = attribute->Value();
        }
        attribute = attribute->Next();
      }

      if (idAttributeName.IsEmpty() || idAttributeValue.IsEmpty())
      {
        // this should not happen, each search result should have an id
        CLog::Log(LOGERROR, "CGetResultListBG::ParseResultListXml, search result without id, value = %s (manual)", strValue.c_str());
        continue;
      }

      // Get the year
      CStdString strYear = ((TiXmlElement*)pTag)->Attribute("year");

      CStdString strType = ((TiXmlElement*)pTag)->Attribute("type");

      bool bIsMovie = false;
      if (strType == "movie")
      {
        bIsMovie = true;
      }
      else if (strType == "tv")
      {
        bIsMovie = false;
      }
      else
      {
        CLog::Log(LOGERROR, "CGetResultListBG::ParseResultListXml, invalid type = %s (manual)", strType.c_str());
        continue;
      }

      CStdString strMovieTypeLabel = "Movie";
      CStdString strTvTypeLabel = "TV";

      // Format label and create file item
      CStdString strLabel;
      if (strYear.IsEmpty())
        strLabel.Format("%s (%s)", strValue.c_str(), bIsMovie ? strMovieTypeLabel.c_str() : strTvTypeLabel.c_str());
      else
        strLabel.Format("%s (%s) (%s)", strValue.c_str(), strYear.c_str(), bIsMovie ? strMovieTypeLabel.c_str() : strTvTypeLabel.c_str());

      CFileItemPtr resultItem (new CFileItem(strLabel));
      resultItem->SetProperty("type", "msearch");
      resultItem->SetProperty("manualresolve::Title", strValue);
      resultItem->SetProperty("manualresolve::Year", strYear);
      resultItem->SetProperty("manualresolve::idName", idAttributeName);
      resultItem->SetProperty("manualresolve::idValue", idAttributeValue);
      resultItem->SetProperty("manualresolve::isMovie", bIsMovie);
      items.Add(resultItem);

      CLog::Log(LOGDEBUG, "CGetResultListBG::ParseResultListXml, added item, title = %s, type = %s, year = %s, idName = %s, idValue = %s (manual)",
          strValue.c_str(), bIsMovie ? "movie" : "tv", strYear.c_str(), idAttributeName.c_str(), idAttributeValue.c_str());
    }
  }

  return items.Size() > 0;
}
void HoOrionModelParser::ParseRouter(TiXmlNode* pParent) {
	double TmpDouble;
	int TmpInt;
	string Type;
	stringstream Energy;
	stringstream Area;
	int MaxIn = 0;
	int MaxOut = 0;
	TiXmlAttribute* Attribute = ( pParent->ToElement())->FirstAttribute() ;
	while (Attribute ) {
		if (string(Attribute->Name() ) == "type") {
			Type = string(Attribute->Value() ) ;
		} else if (string(Attribute->Name() ) == "maxin") {
			Attribute->QueryIntValue(&TmpInt) ;
			MaxIn = TmpInt ;
		} else if (string(Attribute->Name() ) == "maxout") {
			Attribute->QueryIntValue(&TmpInt) ;
			MaxOut = TmpInt ;
		} else if (string(Attribute->Name() ) == "maxbw") {
			Attribute->QueryDoubleValue(&TmpDouble) ;
			//mModel->RouterMaxBw = TmpDouble ;
		} else if (string(Attribute->Name() ) == "energy") {
			Energy << Attribute->ValueStr() ;
		} else if (string(Attribute->Name() ) == "area") {
			Area << Attribute->ValueStr() ;
		} else {
			cout << "Unknown attribute "<< Attribute->Name() << " for wire"
					<< endl ;
		}
		Attribute = Attribute->Next() ;
	}

	mMaxIn = MaxIn ;
	mMaxOut = MaxOut ;

	if (Type == "r1ch32") {
		mArouter1ch32.resize(MaxIn + 1) ;
		mErouter1ch32.resize(MaxIn + 1) ;
		mErouterLeak1ch32.resize(MaxIn + 1) ;
		mArouter1ch32[0].resize(MaxOut + 1) ;
		mErouter1ch32[0].resize(MaxOut + 1) ;
		mErouterLeak1ch32[0].resize(MaxOut + 1) ;
		for (int i = 1; i <= MaxIn ; i++) {
			mArouter1ch32[i].resize(MaxOut + 1) ;
			mErouter1ch32[i].resize(MaxOut + 1) ;
			mErouterLeak1ch32[i].resize(MaxOut + 1) ;
			for (int j = 1; j <= MaxOut ; j++) {
				Area >> mArouter1ch32[i][j];
				mArouter1ch32[i][j] = mArouter1ch32[i][j]*1e-12;
				Energy >> mErouter1ch32[i][j];
				Energy >> mErouterLeak1ch32[i][j];
			}
		}

		//handle first rows nad first column
		for (int j = 0; j <= MaxOut ; j++) {
			mArouter1ch32[0][j] = 0;
			mErouter1ch32[0][j] = 0;
			mErouterLeak1ch32[0][j] = 0;
		}
		for (int i = 0; i <= MaxIn ; i++) {
			mArouter1ch32[i][0] = 0;
			mErouter1ch32[i][0] = 0;
			mErouterLeak1ch32[i][0] = 0;
		}

	} else if (Type == "r4ch32") {
示例#29
0
bool CGmObjAnim3::ReadXML( TiXmlNode* poParent, unsigned int uiCounter )
{
	if( !poParent )
		return false;
	
	static char acTxt_[256];
	if( uiCounter == 0 )
	{
	}
	
	switch ( poParent->Type() )
	{
	case TiXmlNode::DOCUMENT:
		LOG( "XML: Document" );
	break;
	case TiXmlNode::ELEMENT:
	{
		const char *pcName = poParent->Value();
		//LOG( "name: %s\n", pcName );
		if( !strcmp( pcName, "animation" ) )
		{
			LOG( "animation:\n" );
			
			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				int iIdx;
				CStr oMeshFileName;
				CArray<CStr> oArrAnimFileName;
				
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					if( !strcmp( pcName, "mesh" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						oMeshFileName = acTxt_;
					}
					else if( SSCANF( pcName, "anim_%d", &iIdx ) == 1 )
					{
						LOG( "%s: %d\n", poAttrib->Name(), iIdx );
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						if( iIdx >= int( oArrAnimFileName.GetSize() ) )
							oArrAnimFileName.Resize( iIdx + 1 );
						oArrAnimFileName[iIdx] = acTxt_;
						
					}
					poAttrib = poAttrib->Next();
				}
				
				if( oMeshFileName.GetSize() )
				{
					// Model.
					m_poModel = m_poResMan_->NewModelMD5( oMeshFileName, oArrAnimFileName, false );
					
					const unsigned int uiFrameCountTotal = m_poModel->GetFrameCountTotal();
					const unsigned int uiMeshCount = m_poModel->GetMeshCount();
					const unsigned int uiAnimCount = m_poModel->GetAnimCount();
					
					m_oArrAnim.Resize( uiAnimCount );
					m_oArrAnim.Fill( 0 );
					
					m_poData->SetFrameCount( uiFrameCountTotal );
					unsigned int uiFrameIdx = 0;
					
					for( unsigned int uiAnim=0; uiAnim<uiAnimCount; ++uiAnim )
					{
						//m_poModel->SetAnim( uiAnim );	
						const unsigned int uiFrameCount = m_poModel->GetFrameCount( uiAnim );
						
						CAnim * poAnim = new CAnim;
						m_oArrAnim[uiAnim] = poAnim;
						
						poAnim->SetFrameRate( m_poModel->GetFrameRate( uiAnim ) );
						poAnim->SetFrameCount( uiFrameCount );
						
						for( unsigned int uiFrame=0; uiFrame<uiFrameCount; ++uiFrame )
						{
							CFrame * poFrame = new CFrame;
							m_poData->SetFrame( uiFrameIdx, poFrame );
							poAnim->SetFrameIndex( uiFrame, uiFrameIdx );
							++uiFrameIdx;
							
							poFrame->SetMeshCount( uiMeshCount );

							for( unsigned int uiMesh=0; uiMesh<uiMeshCount; ++uiMesh )
							{
								CGMeshMD5 * poMesh = m_poModel->GetPrecalcMesh( uiMesh, uiFrame, uiAnim );
								ASSERT( poMesh );
								poFrame->SetMesh( uiMesh, poMesh );
							}
						}

						poAnim->Init();
					}
					ASSERT( uiFrameIdx == uiFrameCountTotal );
				}
			}
		}
		else if( m_poModel )
		{
			if( !strcmp( pcName, "action" ) )
			{
				LOG( "action:\n" );
				
				TiXmlElement * poElement = poParent->ToElement();
				if( poElement )
				{
					CAction *poAction = 0;
					
					TiXmlAttribute* poAttrib = poElement->FirstAttribute();
					while( poAttrib )
					{
						const char *pcName = poAttrib->Name();
						if( !strcmp( pcName, "name" ) )
						{
							STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
							LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
							
							poAction = new CAction;
							poAction->m_oName = acTxt_;
							poAction->m_uiIndex = m_oArrAction.GetSize();
							m_oArrAction.Append( poAction );
						}
						else if( !strcmp( pcName, "anim" ) )
						{
							STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
							LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
							
							CStr oIdxSeq( acTxt_ );
							if( oIdxSeq.GetSize() && poAction )
							{
								static const char cDelim_ = ',';
								
								unsigned int i = 0;
								while( true )
								{
									int iIdx;
									if( SSCANF( oIdxSeq.GetData() + i, "%d", &iIdx ) == 1 )
									{
										LOG( "index: %d\n", iIdx );
										poAction->AppendAnimIndex( iIdx );
									}
									const int c = oIdxSeq.Find( i, cDelim_ );
									if( c < 0 )
										break;
									i = c + 1;
								}
								
							}
						}
						else if( !strcmp( pcName, "sound" ) )
						{
							STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
							LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
							
							TWav * poWav = m_poResMan_->NewWav( acTxt_ );
							if( poWav )
							{
								poAction->SetSoundStart( poWav );
							}
						}
						poAttrib = poAttrib->Next();
					}

					poAction->Init();
				}
			}
			/*
			else if( !strcmp( pcName, "joint_tracker" ) )
			{
				LOG( "joint_tracker:\n" );
				
				TiXmlElement * poElement = poParent->ToElement();
				if( poElement )
				{
					CJointTracker *poJointTracker = 0;
					
					TiXmlAttribute* poAttrib = poElement->FirstAttribute();
					while( poAttrib )
					{
						const char *pcName = poAttrib->Name();
						if( !strcmp( pcName, "name" ) )
						{
							STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
							LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
							
							poJointTracker = GetJointTracker( acTxt_ );
							if( !poJointTracker )
							{
								poJointTracker = new CJointTracker;
								poJointTracker->m_oName = acTxt_;
								m_oLstJointTracker.Append( poJointTracker );
							}
						}
						else if( !strcmp( pcName, "joint" ) && poJointTracker )
						{
							STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
							LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
							
							const int iJoint = m_poModel->GetJointIndex( acTxt_ );
							if( iJoint >= 0 )
								poJointTracker->New( iJoint );
						}
						poAttrib = poAttrib->Next();
					}
				}
			}
			*/
		}
	}
	break;
	case TiXmlNode::COMMENT:
		//LOG( "XML: Comment: [%s]", poParent->Value());
	break;
	case TiXmlNode::UNKNOWN:
		//LOG( "XML: Unknown" );
	break;
	case TiXmlNode::TEXT:
		//LOG( "XML: Text: [%s]", poParent->ToText()->Value() );
	break;
	case TiXmlNode::DECLARATION:
		//LOG( "XML: Declaration" );
	break;
	default:
	break;
	}
	LOG( "\n" );
	
	++uiCounter;
	
	for( TiXmlNode* poChild = poParent->FirstChild(); poChild != 0; poChild = poChild->NextSibling() ) 
	{
		ReadXML( poChild, uiCounter );
	}
	
	// Ganz am Schluss...
	if( uiCounter == 1 )
	{
	}
	return true;
}
示例#30
0
bool CGmObjShapeStaticItem::ReadXML( TiXmlNode* poParent, unsigned int uiCounter )
{
	if( !poParent )
		return false;
	
	static char acTxt_[256];
	if( uiCounter == 0 )
	{
	}
	
	switch ( poParent->Type() )
	{
	case TiXmlNode::DOCUMENT:
		LOG( "XML: Document" );
	break;
	case TiXmlNode::ELEMENT:
	{
		const char *pcName = poParent->Value();
		//LOG( "name: %s\n", pcName );
		if( !strcmp( pcName, "item" ) )
		{
			LOG( "item:\n" );
			
			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					if( !strcmp( pcName, "name" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						m_oName = acTxt_;
					}
					if( !strcmp( pcName, "type" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						if( !strcmp( acTxt_, "weapon" ) )
							m_eType = TYPE_WEAPON;
						else if( !strcmp( acTxt_, "energy" ) )
							m_eType = TYPE_ENERGY;
						else if( !strcmp( acTxt_, "ammo" ) )
							m_eType = TYPE_AMMO;
						else if( !strcmp( acTxt_, "key" ) )
							m_eType = TYPE_KEY;
						else
							m_eType = TYPE_UNDEFINED;
					}
					if( !strcmp( pcName, "cycle_duration" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							if( dVal >= 0.0 )
								m_iTickDurCycle = int( dVal / m_dTInteractionInterval_ );
							else
								m_iTickDurCycle = -1;
						}
					}
					if( !strcmp( pcName, "rotation_y_speed" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							m_fRotationYSpeed = float( dVal * 360.0 );
						}
					}
					if( !strcmp( pcName, "weapon_name" )
					 && ( m_eType == TYPE_WEAPON || m_eType == TYPE_AMMO ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						m_oWeaponName = acTxt_;
					}
					if( !strcmp( pcName, "energy" ) && m_eType == TYPE_ENERGY )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							m_fEnergy = float( dVal );
						}
					}
					if( !strcmp( pcName, "ammo" )
					 && ( m_eType == TYPE_WEAPON || m_eType == TYPE_AMMO ) )
					{
						int iVal;
						if( poAttrib->QueryIntValue( &iVal ) == TIXML_SUCCESS
						 && iVal > 0 )
						{
							LOG( "%s: %d\n", poAttrib->Name(), iVal );
							m_uiAmmo = iVal;
						}
					}
					if( !strcmp( pcName, "key" ) && m_eType == TYPE_ENERGY )
					{
						int iVal;
						if( poAttrib->QueryIntValue( &iVal ) == TIXML_SUCCESS
						 && iVal > 0 )
						{
							LOG( "%s: %d\n", poAttrib->Name(), iVal );
							m_uiKey = iVal;
						}
					}
					poAttrib = poAttrib->Next();
				}
			}
		}
		if( !strcmp( pcName, "animation" ) )
		{
			LOG( "animation:\n" );
			
			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					if( !strcmp( pcName, "file_name" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						m_poAnim = m_poResMan_->NewAnim3( CStr( "item/" ) + acTxt_ );
					}
					poAttrib = poAttrib->Next();
				}
			}
		}
		// Gleich wie in GmObjShapeDynamicEnemy.cpp.
		if( !strcmp( pcName, "mesh" ) )
		{
			LOG( "mesh:\n" );

			CStr oFileName, oSubDir;

			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					if( !strcmp( pcName, "sub_dir" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						oSubDir = acTxt_;
					}
					else if( !strcmp( pcName, "file_name" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						oFileName = acTxt_;
					}
					poAttrib = poAttrib->Next();
				}
			}
			if( oFileName.GetSize() )
			{
				CGMesh * poMesh( m_poResMan_->NewMeshObj( oSubDir, oFileName ) ); //, false, false ) );
				if( poMesh )
				{
					m_oLstMesh.Append( poMesh );
				}
			}
		}
	}
	break;
	case TiXmlNode::COMMENT:
		//LOG( "XML: Comment: [%s]", poParent->Value());
	break;
	case TiXmlNode::UNKNOWN:
		//LOG( "XML: Unknown" );
	break;
	case TiXmlNode::TEXT:
		//LOG( "XML: Text: [%s]", poParent->ToText()->Value() );
	break;
	case TiXmlNode::DECLARATION:
		//LOG( "XML: Declaration" );
	break;
	default:
	break;
	}
	LOG( "\n" );

	++uiCounter;

	for( TiXmlNode* poChild = poParent->FirstChild(); poChild != 0; poChild = poChild->NextSibling() )
	{
		ReadXML( poChild, uiCounter );
	}
	
	// Ganz am Schluss...
	if( uiCounter == 1 )
	{
	}
	return true;
}