Sorry, two more questions
Code:#ifndef PERFECTSIM_PARSER #define PERFECTSIM_PARSER #include <string> #include <d3dx9.h> #include <sstream> #include <iostream> #include "tinyxml\tinyxml.h" using namespace std; template<class T> class GetValue { protected: virtual T get(TiXmlNode* pParent); virtual T get_attribs(TiXmlNode* pParent) = 0; }; class GetVector3 : public GetValue<D3DXVECTOR3> { public: virtual D3DXVECTOR3 get(TiXmlNode* pParent); virtual D3DXVECTOR3 get_attribs(TiXmlElement *element); D3DXVECTOR3 get_vector3(TiXmlElement *element); }; template<class T> T GetValue<T>::get(TiXmlNode* pParent) { T attr; if ( !pParent ) return attr; TiXmlNode* pChild; TiXmlText* pText; int t = pParent->Type(); switch ( t ) { case TiXmlNode::TINYXML_DOCUMENT: break; case TiXmlNode::TINYXML_ELEMENT: attr =get_attribs(pParent->ToElement()); break; case TiXmlNode::TINYXML_COMMENT: break; case TiXmlNode::TINYXML_UNKNOWN: break; case TiXmlNode::TINYXML_TEXT: pText = pParent->ToText(); break; case TiXmlNode::TINYXML_DECLARATION: break; default: break; } for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) { get( pChild ); } return attr; } #endif1) Can't instantiate abstract class of GetVector3.Code:// tutorial demo program #include "stdafx.h" #include "Parser.h" ///////////////////////////////////// /// D3DXVECTOR3 GetVector3::get(TiXmlNode* pNode) { return GetValue::get(pNode); } D3DXVECTOR3 GetVector3::get_vector3(TiXmlElement* pElement) { return get_attribs(pElement); } D3DXVECTOR3 GetVector3::get_attribs(TiXmlElement* pElement) { if ( !pElement ) return D3DXVECTOR3(); GetValue::get(pElement); D3DXVECTOR3 v; pElement->QueryFloatAttribute("X", &v.x); pElement->QueryFloatAttribute("Y", &v.y); pElement->QueryFloatAttribute("Z", &v.z); return v; }
2) Don't you think the coding is very redundant ?
Any help please?
Thanks
Jack


Reply With Quote
Bookmarks