Пример #1
0
bool BaseScriptComponent::VInit(TiXmlElement* pData)
{
    LuaStateManager* pStateMgr = LuaStateManager::Get();
    GCC_ASSERT(pStateMgr);

    // load the <ScriptObject> tag and validate it
    TiXmlElement* pScriptObjectElement = pData->FirstChildElement("ScriptObject");
    if (!pScriptObjectElement)
    {
        GCC_ERROR("No <ScriptObject> tag in XML.  This won't be a very useful script component.");
        return true;  // technically it succeeded even though it won't be accessible
    }

    // read all the attributes
    const char* temp = NULL;
    temp = pScriptObjectElement->Attribute("var");
    if (temp)
        m_scriptObjectName = temp;

    temp = pScriptObjectElement->Attribute("constructor");
    if (temp)
        m_constructorName = temp;

    temp = pScriptObjectElement->Attribute("destructor");
    if (temp)
        m_destructorName = temp;

    // Having a var attribute will export the instance of this object to that name.
    if (!m_scriptObjectName.empty())
    {
        m_scriptObject = pStateMgr->CreatePath(m_scriptObjectName.c_str());

        if (!m_scriptObject.IsNil())
        {
            CreateScriptObject();
        }
	}

    // The scriptConstructor attribute will also cause a Lua object to be created if one wasn't created in 
    // the previous step.  The scriptConstructor string is treated as a function of the form f(scriptObject) 
    // and is called.
    if (!m_constructorName.empty())
    {
        m_scriptConstructor = pStateMgr->GetGlobalVars().Lookup(m_constructorName.c_str());
        if (m_scriptConstructor.IsFunction())
        {
			// m_scriptObject could be nil if there was no scriptObject attribute.  If this is the case, 
            // the Lua object is created here.
			if (m_scriptObject.IsNil())
			{
				m_scriptObject.AssignNewTable(pStateMgr->GetLuaState());
				CreateScriptObject();
			}
		}
    }

    // The scriptDestructor attribute is treated as a function in the form of f(scriptObject) and is called
    // when the C++ ScriptObject instance is destroyed.
    if (!m_destructorName.empty())
    {
        m_scriptDestructor = pStateMgr->GetGlobalVars().Lookup(m_destructorName.c_str());
	}

    // read the <ScriptData> tag
    TiXmlElement* pScriptDataElement = pData->FirstChildElement("ScriptData");
    if (pScriptDataElement)
    {
        if (m_scriptObject.IsNil())
        {
            GCC_ERROR("m_scriptObject cannot be nil when ScriptData has been defined");
            return false;
        }

        for (TiXmlAttribute* pAttribute = pScriptDataElement->FirstAttribute(); pAttribute != NULL; pAttribute = pAttribute->Next())
        {
            m_scriptObject.SetString(pAttribute->Name(), pAttribute->Value());
        }
    }

	return true;
}
MutualFund::MutualFund(TiXmlNode* xmlNode)
: UnderlyingAsset(xmlNode)
{
    #ifdef ConsolePrint
        std::string initialtap_ = FileManager::instance().tap_;
        FileManager::instance().tap_.append("   ");
    #endif 
   //openEndedFundNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* openEndedFundNode = xmlNode->FirstChildElement("openEndedFund");

   if(openEndedFundNode){openEndedFundIsNull_ = false;}
   else{openEndedFundIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- openEndedFundNode , address : " << openEndedFundNode << std::endl;
   #endif
   if(openEndedFundNode)
   {
      if(openEndedFundNode->Attribute("href") || openEndedFundNode->Attribute("id"))
      {
          if(openEndedFundNode->Attribute("id"))
          {
             openEndedFundIDRef_ = openEndedFundNode->Attribute("id");
             openEndedFund_ = boost::shared_ptr<XsdTypeBoolean>(new XsdTypeBoolean(openEndedFundNode));
             openEndedFund_->setID(openEndedFundIDRef_);
             IDManager::instance().setID(openEndedFundIDRef_,openEndedFund_);
          }
          else if(openEndedFundNode->Attribute("href")) { openEndedFundIDRef_ = openEndedFundNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { openEndedFund_ = boost::shared_ptr<XsdTypeBoolean>(new XsdTypeBoolean(openEndedFundNode));}
   }

   //fundManagerNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* fundManagerNode = xmlNode->FirstChildElement("fundManager");

   if(fundManagerNode){fundManagerIsNull_ = false;}
   else{fundManagerIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- fundManagerNode , address : " << fundManagerNode << std::endl;
   #endif
   if(fundManagerNode)
   {
      if(fundManagerNode->Attribute("href") || fundManagerNode->Attribute("id"))
      {
          if(fundManagerNode->Attribute("id"))
          {
             fundManagerIDRef_ = fundManagerNode->Attribute("id");
             fundManager_ = boost::shared_ptr<XsdTypeString>(new XsdTypeString(fundManagerNode));
             fundManager_->setID(fundManagerIDRef_);
             IDManager::instance().setID(fundManagerIDRef_,fundManager_);
          }
          else if(fundManagerNode->Attribute("href")) { fundManagerIDRef_ = fundManagerNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { fundManager_ = boost::shared_ptr<XsdTypeString>(new XsdTypeString(fundManagerNode));}
   }

    #ifdef ConsolePrint
        FileManager::instance().tap_ = initialtap_;
    #endif 
}
Пример #3
0
int CXGseScd::ParseIEDs(TiXmlNode *pRootNode)
{
    TiXmlNode *pIEDNode = pRootNode->FirstChild("IED");
    std::string ied_name;
    TiXmlElement *pIEDElement = NULL;
    while (pIEDNode != NULL)//IED
    {
        ied_name = pIEDNode->ToElement()->Attribute("name");
        TiXmlNode *pAPNode = pIEDNode->FirstChildElement("AccessPoint");
        while (pAPNode != NULL)//G1
        {
            TiXmlNode *pLDNode = NULL;
            if (GES_MEMCMP(pAPNode->ToElement()->Attribute("name"), GSE_TYPE_TAG))
            {
                pLDNode = pAPNode->FirstChild("Server")->FirstChild("LDevice");
                std::string ld_inst;
                TiXmlNode *pLN0Node = NULL;
                while (pLDNode != NULL)//LDevice
                {
                    ld_inst = pLDNode->ToElement()->Attribute("inst");
                    pLN0Node = pLDNode->FirstChild("LN0");
                    //TiXmlNode *pDataSetNode = NULL;
                    TiXmlNode *pGSECtrlNode = NULL;
                    if (pLN0Node != NULL)
                    {
                        std::string gocb_name;
                        std::string datset_name;
                        pGSECtrlNode = pLN0Node->FirstChild("GSEControl");
                        while (pGSECtrlNode != NULL)
                        {
                            TiXmlElement *pGSECtrlElement = pGSECtrlNode->ToElement();
                            gocb_name = pGSECtrlElement->Attribute("name");
                            datset_name = pGSECtrlElement->Attribute("datSet");
							printf("%s\n", datset_name.c_str());

                            //生成一条记录
                            u_int32_t appid = 0;
                            //查找对应的APPID
                            if (FindAppid(ied_name, ld_inst, gocb_name, appid) != J_OK)
                            {
                                //没有对应的APPID
                                printf("CXGseScd::ParseIEDs %s Is not a GOOSE IED\n", ied_name.c_str());
                                pGSECtrlNode = pGSECtrlNode->NextSibling();
                                continue;

                            }
							
							if (appid == 1328)
							{
								printf("%d\n", appid);
							}
                            GSE_DataSetInfo *pDataSetInfo = new GSE_DataSetInfo;
                            if (MakeDataSetInfo(pLN0Node, datset_name, pDataSetInfo) != J_OK)
                            {
                                //数据解析有错误
                                assert(false);
                            }
                            m_gocbMap[appid] = pDataSetInfo;

                            pGSECtrlNode = pGSECtrlNode->NextSibling("GSEControl");
                        }
                    }
                    pLDNode = pLDNode->NextSibling();
                }
            }
            pAPNode = pAPNode->NextSibling();
        }
        pIEDNode = pIEDNode->NextSibling("IED");
    }
    return J_OK;
}
Пример #4
0
void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, std::map<std::string, PeripheralDeviceSetting> &settings)
{
  TiXmlElement *currentNode = xmlNode->FirstChildElement("setting");
  int iMaxOrder = 0;

  while (currentNode)
  {
    CSetting *setting = nullptr;
    std::string strKey = XMLUtils::GetAttribute(currentNode, "key");
    if (strKey.empty())
      continue;

    std::string strSettingsType = XMLUtils::GetAttribute(currentNode, "type");
    int iLabelId = currentNode->Attribute("label") ? atoi(currentNode->Attribute("label")) : -1;
    const std::string config = XMLUtils::GetAttribute(currentNode, "configurable");
    bool bConfigurable = (config.empty() || (config != "no" && config != "false" && config != "0"));
    if (strSettingsType == "bool")
    {
      const std::string value = XMLUtils::GetAttribute(currentNode, "value");
      bool bValue = (value != "no" && value != "false" && value != "0");
      setting = new CSettingBool(strKey, iLabelId, bValue);
    }
    else if (strSettingsType == "int")
    {
      int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0;
      int iMin   = currentNode->Attribute("min") ? atoi(currentNode->Attribute("min")) : 0;
      int iStep  = currentNode->Attribute("step") ? atoi(currentNode->Attribute("step")) : 1;
      int iMax   = currentNode->Attribute("max") ? atoi(currentNode->Attribute("max")) : 255;
      setting = new CSettingInt(strKey, iLabelId, iValue, iMin, iStep, iMax);
    }
    else if (strSettingsType == "float")
    {
      float fValue = currentNode->Attribute("value") ? (float) atof(currentNode->Attribute("value")) : 0;
      float fMin   = currentNode->Attribute("min") ? (float) atof(currentNode->Attribute("min")) : 0;
      float fStep  = currentNode->Attribute("step") ? (float) atof(currentNode->Attribute("step")) : 0;
      float fMax   = currentNode->Attribute("max") ? (float) atof(currentNode->Attribute("max")) : 0;
      setting = new CSettingNumber(strKey, iLabelId, fValue, fMin, fStep, fMax);
    }
    else if (StringUtils::EqualsNoCase(strSettingsType, "enum"))
    {
      std::string strEnums = XMLUtils::GetAttribute(currentNode, "lvalues");
      if (!strEnums.empty())
      {
        std::vector< std::pair<int,int> > enums;
        std::vector<std::string> valuesVec;
        StringUtils::Tokenize(strEnums, valuesVec, "|");
        for (unsigned int i = 0; i < valuesVec.size(); i++)
          enums.push_back(std::make_pair(atoi(valuesVec[i].c_str()), atoi(valuesVec[i].c_str())));
        int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0;
        setting = new CSettingInt(strKey, iLabelId, iValue, enums);
      }
    }
    else
    {
      std::string strValue = XMLUtils::GetAttribute(currentNode, "value");
      setting = new CSettingString(strKey, iLabelId, strValue);
    }

    if (setting)
    {
      //! @todo add more types if needed

      /* set the visibility */
      setting->SetVisible(bConfigurable);

      /* set the order */
      int iOrder = 0;
      currentNode->Attribute("order", &iOrder);
      /* if the order attribute is invalid or 0, then the setting will be added at the end */
      if (iOrder < 0)
        iOrder = 0;
      if (iOrder > iMaxOrder)
       iMaxOrder = iOrder;

      /* and add this new setting */
      PeripheralDeviceSetting deviceSetting = { setting, iOrder };
      settings[strKey] = deviceSetting;
    }

    currentNode = currentNode->NextSiblingElement("setting");
  }

  /* add the settings without an order attribute or an invalid order attribute set at the end */
  for (auto& it : settings)
  {
    if (it.second.m_order == 0)
      it.second.m_order = ++iMaxOrder;
  }
}
Пример #5
0
bool CConfigManager::AnalyseConfigFile()
{
	TiXmlDocument doc;
	doc.LoadFile(m_strConfigFile.c_str());
	
	TiXmlElement* pRoot = doc.RootElement();
	const char* szRoot = pRoot->Value();
	if(strcmp("system", szRoot) != 0)
		return false;


	for (TiXmlElement* pChiled = pRoot->FirstChildElement(); pChiled != NULL; pChiled = pChiled->NextSiblingElement())
	{
		const char* szValue = pChiled->Value();
		if(strcmp(Software, szValue) == 0)
		{
			m_strAppVer = pChiled->Attribute(Ver);
			m_strSotfUrl = pChiled->Attribute(URL);
		}
		else if(strcmp(Configur, szValue) == 0)
		{
			m_strConfigVer = pChiled->Attribute(Ver);
		}
		else if(strcmp(Globle, szValue) == 0)
		{
			m_strHeight = pChiled->Attribute(Height);
			m_strWidth = pChiled->Attribute(Width);
			string strAdverCount = pChiled->Attribute(AdverCount);
			m_nAdverCount = atoi(strAdverCount.c_str());
		}
		else if(strcmp(Sever, szValue) == 0)
		{
			m_strIp = pChiled->Attribute(IP);
			m_strPort = pChiled->Attribute(Port);
		}
		else if(strcmp(Notice, szValue) == 0)
		{
			m_strNoticeDir = pChiled->Attribute(Dir);
		}
		else if(strcmp(Template, szValue) == 0)
		{
			m_strTempVer = pChiled->Attribute(Ver);
			m_strTemplatePath = pChiled->Attribute(Dir);
		}
		else if(strcmp(Adver, szValue) == 0)
		{
			m_Adver.AnalyseAdver(pChiled);
		}
		else if(strcmp(BusStop, szValue) == 0)
		{
			m_Busstop.AnalyseBusStop(pChiled);
		}
		else if(strcmp(Picture, szValue) == 0)
		{
			m_strPictrueDir = pChiled->Attribute(Dir);
		}
		else if(strcmp(Default, szValue) == 0)
		{
			m_strDefaultPath = pChiled->Attribute(Dir);
		}
		else if(strcmp(Volume, szValue) == 0)
		{
			m_strVolumeDir = pChiled->Attribute(Dir);
		}
	}

	return true;
}
Пример #6
0
bool XMLScene::parseAppearences() {

	printf("Processing appearences...\n\n");

	bool valid_nr_appear = false;
	char tmp_str[MAX_STRING_LEN], app_id[MAX_STRING_LEN], app_text_ref[MAX_STRING_LEN];
	double app_emiss_r = 0, app_emiss_g = 0, app_emiss_b = 0, app_emiss_a = 0, app_amb_r = 0, app_amb_g = 0, app_amb_b =
			0, app_amb_a = 0, app_dif_r = 0, app_dif_g = 0, app_dif_b = 0, app_dif_a = 0, app_spec_r = 0,
			app_spec_g = 0, app_spec_b = 0, app_spec_a = 0, app_shin = 0, app_text_len_s = 0, app_text_len_t = 0;
	TiXmlElement * app = NULL;
	if ((app = appearencesElement->FirstChildElement("appearance")) != NULL) {
		valid_nr_appear = true;
		do {
			if (strdup(app_id, app->Attribute("id")) == NULL) {
				printf("Error in \"id\" attribute!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, app->Attribute("emissive")) == NULL) {
				printf("Error in \"emissive\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &app_emiss_r, &app_emiss_g, &app_emiss_b, &app_emiss_a) != 4) {
				printf("Error parsing \"emissive\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, app->Attribute("ambient")) == NULL) {
				printf("Error in \"ambient\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &app_amb_r, &app_amb_g, &app_amb_b, &app_amb_a) != 4) {
				printf("Error parsing \"ambient\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, app->Attribute("diffuse")) == NULL) {
				printf("Error in \"diffuse\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &app_dif_r, &app_dif_g, &app_dif_b, &app_dif_a) != 4) {
				printf("Error parsing \"diffuse\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, app->Attribute("specular")) == NULL) {
				printf("Error in \"specular\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &app_spec_r, &app_spec_g, &app_spec_b, &app_spec_a) != 4) {
				printf("Error parsing \"specular\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			if (app->Attribute("shininess", &app_shin) == NULL) {
				printf("Error parsing \"shininess\" attribute of %s appearence!\n", app_id);
				throw InvalidXMLException();
			}

			Appearance *new_app = new Appearance(app_id);
			new_app->setEmissivity(app_emiss_r, app_emiss_g, app_emiss_b, app_emiss_a);
			new_app->setAmbient(app_amb_r, app_amb_g, app_amb_b, app_amb_a);
			new_app->setDiffuse(app_dif_r, app_dif_g, app_dif_b, app_dif_a);
			new_app->setSpecular(app_spec_r, app_spec_g, app_spec_b, app_spec_a);

			if (strdup(app_text_ref, app->Attribute("textureref")) != NULL) {
				if (strcmp(app_text_ref, "") != 0) {
					if (app->Attribute("texlength_s", &app_text_len_s) == NULL) {
						printf("Error parsing \"texlength_s\" attribute of %s appearence!\n", app_id);
						throw InvalidXMLException();
					}

					if (app->Attribute("texlength_t", &app_text_len_t) == NULL) {
						printf("Error parsing \"texlength_t\" attribute of %s appearence!\n", app_id);
						throw InvalidXMLException();
					}

					new_app->setTextProp(app_text_ref, app_text_len_s, app_text_len_t);
				} else {
					strdup(app_text_ref, "none");
					app_text_len_s = 0.0;
					app_text_len_t = 0.0;
				}
			} else {
				strdup(app_text_ref, "none");
				app_text_len_s = 0.0;
				app_text_len_t = 0.0;
			}

			Scene::getInstance()->addAppearance(app_id, new_app);

			printf(
					"id: %s\nemissive: (%f,%f,%f,%f)\nambient: (%f,%f,%f,%f)\ndiffuse: (%f,%f,%f,%f)\nspecular: (%f,%f,%f,%f)\nshininess: %f\ntextureref: %s\ntexlength_s: %f\ntextlength_t: %f\n\n",
					app_id, app_emiss_r, app_emiss_g, app_emiss_b, app_emiss_a, app_amb_r, app_amb_g, app_amb_b,
					app_amb_a, app_dif_r, app_dif_g, app_dif_b, app_dif_a, app_spec_r, app_spec_g, app_spec_b,
					app_spec_a, app_shin, app_text_ref, app_text_len_s, app_text_len_t);

		} while ((app = app->NextSiblingElement("appearance")) != NULL);
	}
	if (!valid_nr_appear) {
		printf("There are no defined appearences!\nPlease define at least one\n");
		throw InvalidXMLException();
	}
	return true;
}
Пример #7
0
bool XMLScene::parseNode(TiXmlElement *curr_node, bool is_inside_dl) {

	char node_id[MAX_STRING_LEN];

	if (strdup(node_id, curr_node->Attribute("id")) == NULL) {
		printf("Error reading \"id\" attribute!\n");
		throw InvalidXMLException();
	}

	printf("id: %s\n", node_id);

	bool is_dl = false;
	string dl_node_id;
	if (curr_node->QueryBoolAttribute("displaylist", &is_dl) != TIXML_SUCCESS) {
		printf("No \"displaylist\" attribute\n");
	}

	if (is_dl) {
		printf("Node \"%s\" defined as a display list.\n", node_id);
		dl_node_id = Scene::getInstance()->findNextNameAvail(node_id);
		printf("dl_node_id: %s\n", dl_node_id.c_str());
	}

	Node *n;

	if (is_dl) {
		n = new DisplayList(dl_node_id);
	} else {
		n = new Node(node_id);
	}

	nodes_being_processed.push_back(node_id);

	printf("Processing transformations...\n");

	TiXmlElement *transf_block = NULL;
	if ((transf_block = curr_node->FirstChildElement("transforms")) == NULL) {
		printf("Could not find \"transforms\" block on %s node!\n", node_id);
		throw InvalidXMLException();
	}

	TiXmlElement *transf = NULL;
	while ((transf = (TiXmlElement*) transf_block->IterateChildren(transf))) {
		char t_type[MAX_STRING_LEN];
		if (strdup(t_type, transf->Value()) == NULL) {
			printf("Invalid transformation on node %s\n", node_id);
			throw InvalidXMLException();
		}
		if (strcmp(t_type, "translate") == 0) {
			char tmp_str[MAX_STRING_LEN];
			double t_x = 0, t_y = 0, t_z = 0;

			if (strdup(tmp_str, transf->Attribute("to")) == NULL) {
				printf("Error on translate transformation on node %s!\n", node_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf", &t_x, &t_y, &t_z) != 3) {
				printf("Error parsing translate transformation on node %s!\n", node_id);
				throw InvalidXMLException();
			}

			n->addTranslate(t_x, t_y, t_z);

			printf("Translate\nto: (%f %f %f)\n", t_x, t_y, t_z);

		} else if (strcmp(t_type, "rotate") == 0) {
			char tmp_str[2];
			char r_axis = '\0';
			double r_angle;
			if (strdup(tmp_str, transf->Attribute("axis")) == NULL) {
				printf("Error on rotate transformation on node %s!\n", node_id);
				throw InvalidXMLException();
			}
			r_axis = tmp_str[0];

			if (transf->QueryDoubleAttribute("angle", &r_angle)) {
				printf("Error parsing rotate transformation on node %s!\n", node_id);
				throw InvalidXMLException();
			}

			n->addRotation(r_angle, r_axis);

			printf("Rotate\naxis: %c\nangle: %f\n", r_axis, r_angle);

		} else if (strcmp(t_type, "scale") == 0) {
			char tmp_str[MAX_STRING_LEN];
			double f_x = 0, f_y = 0, f_z = 0;

			if (strdup(tmp_str, transf->Attribute("factor")) == NULL) {
				printf("Error on scale transformation on node %s!\n", node_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf", &f_x, &f_y, &f_z) != 3) {
				printf("Error parsing scale transformation on node %s!\n", node_id);
				throw InvalidXMLException();
			}

			n->addScale(f_x, f_y, f_z);

			printf("Scale\nfactor: (%f %f %f)\n", f_x, f_y, f_z);

		} else {
			printf("Invalid transformation on node %s\n", node_id);
			throw InvalidXMLException();
		}
	}

	TiXmlElement *appearance = NULL;
	if ((appearance = curr_node->FirstChildElement("appearanceref"))) {
		char app_id[MAX_STRING_LEN];
		if (strdup(app_id, appearance->Attribute("id")) == NULL) {
			printf("Error on \"appearanceref\" block on node %s!\n", node_id);
			throw InvalidXMLException();
		}

		n->setAppearance(app_id);
		app_stck.push(app_id);

		printf("Appearance\nid: %s\n", app_id);
	} else {
		app_stck.push(app_stck.top());
	}

	TiXmlElement *animation = NULL;
	if ((animation = curr_node->FirstChildElement("animationref"))) {
		if (is_inside_dl || is_dl) {
			printf("Animation defined in \"%s\" is inside a display list!\n", node_id);
			throw InvalidXMLException();
		}

		char ani_id[MAX_STRING_LEN];
		if (strdup(ani_id, animation->Attribute("id")) == NULL) {
			printf("Error on \"animationref\" block on node %s!\n", node_id);
			throw InvalidXMLException();
		}

		n->setAnimation(ani_id);

		printf("Animation\nid: %s\n", ani_id);
	} else {
		printf("No animation defined on node \"%s\".\n", node_id);
	}

	printf("Processing children...\n");

	TiXmlElement *children = NULL;

	if ((children = curr_node->FirstChildElement("children")) == NULL) {
		printf("Block \"children\" not found!\n");
		throw InvalidXMLException();
	}

	TiXmlElement *child = NULL;
	while ((child = (TiXmlElement *) children->IterateChildren(child))) {
		char child_type[MAX_STRING_LEN];
		strdup(child_type, child->Value());

		if (strcmp(child_type, "rectangle") == 0) {
			char tmp_str[MAX_STRING_LEN];
			double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
			if (strdup(tmp_str, child->Attribute("xy1")) == NULL) {
				printf("Error reading \"xy1\" attribute!\n");
				throw InvalidXMLException();
			}
			if (sscanf(tmp_str, "%lf %lf", &x1, &y1) != 2) {
				printf("Error parsing \"xy1\" attribute!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, child->Attribute("xy2")) == NULL) {
				printf("Error reading \"xy2\" attribute!\n");
				throw InvalidXMLException();
			}
			if (sscanf(tmp_str, "%lf %lf", &x2, &y2) != 2) {
				printf("Error parsing \"xy2\" attribute!\n");
				throw InvalidXMLException();
			}

			MyRectangle *rect = new MyRectangle(x1, y1, x2, y2);
			n->addPrimitive(rect);

			printf("Rectangle\nxy1: (%f,%f)\nxy2: (%f,%f)\n", x1, y1, x2, y2);

		} else if (strcmp(child_type, "triangle") == 0) {
			char tmp_str[MAX_STRING_LEN];
			double x1 = 0, x2 = 0, x3 = 0, y1 = 0, y2 = 0, y3 = 0, z1 = 0, z2 = 0, z3 = 0;
			if (strdup(tmp_str, child->Attribute("xyz1")) == NULL) {
				printf("Error reading \"xyz1\" attribute!\n");
				throw InvalidXMLException();
			}
			if (sscanf(tmp_str, "%lf %lf %lf", &x1, &y1, &z1) != 3) {
				printf("Error parsing \"xyz1\" attribute!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, child->Attribute("xyz2")) == NULL) {
				printf("Error reading \"xyz2\" attribute!\n");
				throw InvalidXMLException();
			}
			if (sscanf(tmp_str, "%lf %lf %lf", &x2, &y2, &z2) != 3) {
				printf("Error parsing \"xyz2\" attribute!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, child->Attribute("xyz3")) == NULL) {
				printf("Error reading \"xyz3\" attribute!\n");
				throw InvalidXMLException();
			}
			if (sscanf(tmp_str, "%lf %lf %lf", &x3, &y3, &z3) != 3) {
				printf("Error parsing \"xyz3\" attribute!\n");
				throw InvalidXMLException();
			}

			MyTriangle *tri = new MyTriangle(x1, y1, z1, x2, y2, z2, x3, y3, z3);
			n->addPrimitive(tri);

			printf("Triangle\nxyz1: (%f,%f,%f)\nxyz2: (%f,%f,%f)\nxyz3: (%f,%f,%f)\n", x1, y1, z1, x2, y2, z2, x3, y3,
					z3);

		} else if (strcmp(child_type, "cylinder") == 0) {
			double cyl_base = 0, cyl_top = 0, cyl_height = 0;
			unsigned int cyl_slices = 0, cyl_stacks = 0;

			if (child->QueryDoubleAttribute("base", &cyl_base) != TIXML_SUCCESS) {
				printf("Error parsing base attribute!\n");
				throw InvalidXMLException();
			}

			if (child->QueryDoubleAttribute("top", &cyl_top) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
				throw InvalidXMLException();
			}

			if (child->QueryDoubleAttribute("height", &cyl_height) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
				throw InvalidXMLException();
			}

			if (child->QueryUnsignedAttribute("slices", &cyl_slices) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
				throw InvalidXMLException();
			}

			if (child->QueryUnsignedAttribute("stacks", &cyl_stacks) != TIXML_SUCCESS) {
				printf("Error parsing stacks attribute!\n");
				throw InvalidXMLException();
			}

			MyCylinder *cyl = new MyCylinder(cyl_base, cyl_top, cyl_height, cyl_slices, cyl_stacks);
			n->addPrimitive(cyl);

			printf("Cylinder\nbase: %f\ntop: %f\nheight: %f\nslices: %d\nstacks: %d\n", cyl_base, cyl_top, cyl_height,
					cyl_slices, cyl_stacks);

		} else if (strcmp(child_type, "sphere") == 0) {
			double sph_rad = 0;
			unsigned int sph_slices = 0, sph_stacks = 0;

			if (child->QueryDoubleAttribute("radius", &sph_rad) != TIXML_SUCCESS) {
				printf("Error parsing radius attribute!\n");
			}

			if (child->QueryUnsignedAttribute("slices", &sph_slices) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
			}

			if (child->QueryUnsignedAttribute("stacks", &sph_stacks) != TIXML_SUCCESS) {
				printf("Error parsing stacks attribute!\n");
			}

			MySphere *sph = new MySphere(sph_rad, sph_slices, sph_stacks);
			n->addPrimitive(sph);

			printf("Sphere\nradius: %f\nslices: %d\nstacks: %d\n", sph_rad, sph_slices, sph_stacks);

		} else if (strcmp(child_type, "torus") == 0) {
			double tor_inner = 0, tor_out = 0;
			unsigned int tor_slices = 0, tor_loops = 0;

			if (child->QueryDoubleAttribute("inner", &tor_inner) != TIXML_SUCCESS) {
				printf("Error parsing inner attribute!\n");
			}

			if (child->QueryDoubleAttribute("outer", &tor_out) != TIXML_SUCCESS) {
				printf("Error parsing outer attribute!\n");
			}

			if (child->QueryUnsignedAttribute("slices", &tor_slices) != TIXML_SUCCESS) {
				printf("Error parsing slices attribute!\n");
			}

			if (child->QueryUnsignedAttribute("loops", &tor_loops) != TIXML_SUCCESS) {
				printf("Error parsing loops attribute!\n");
			}

			MyTorus *tor = new MyTorus(tor_inner, tor_out, tor_slices, tor_loops);
			n->addPrimitive(tor);

			printf("Torus\ninner: %f\nouter: %f\nslices: %d\nloops: %d\n", tor_inner, tor_out, tor_slices, tor_loops);
		} else if (strcmp(child_type, "plane") == 0) {
			int parts = 0;

			if (child->QueryIntAttribute("parts", &parts) != TIXML_SUCCESS) {
				printf("Error parsing \"parts\" attribute on plane!\n");
				throw InvalidXMLException();
			}

			if (parts <= 0) {
				printf("Invalid value on parts attribute of plane!\n");
				throw InvalidXMLException();
			}

			printf("Plane\nparts: %i\n", parts);

			Plane *p = new Plane(parts);
			n->addPrimitive(p);
		} else if (strcmp(child_type, "patch") == 0) {
			int order = 0;
			int parts_u = 0;
			int parts_v = 0;
			char compute[MAX_STRING_LEN];

			if (child->QueryIntAttribute("order", &order) != TIXML_SUCCESS) {
				printf("Error parsing \"order\" attribute on patch!\n");
				throw InvalidXMLException();
			}

			if (child->QueryIntAttribute("partsU", &parts_u) != TIXML_SUCCESS) {
				printf("Error parsing \"partsU\" attribute on patch!\n");
				throw InvalidXMLException();
			}

			if (child->QueryIntAttribute("partsV", &parts_v) != TIXML_SUCCESS) {
				printf("Error parsing \"partsV\" attribute on patch!\n");
				throw InvalidXMLException();
			}

			if (strdup(compute, child->Attribute("compute")) == NULL) {
				printf("Error parsing \"compute\" attribute on patch!\n");
				throw InvalidXMLException();
			}

			printf("Patch\norder: %d\npartsU: %d\npartsV: %d\ncompute: %s\n", order, parts_u, parts_v, compute);

			MyPatch *patch = new MyPatch(order, parts_u, parts_v, compute);
			n->addPrimitive(patch);

			TiXmlElement *ctrl_p = child->FirstChildElement("controlpoint");
			do {
				float x = 0;
				float y = 0;
				float z = 0;

				if (ctrl_p->QueryFloatAttribute("x", &x) != TIXML_SUCCESS) {
					printf("Error parsing \"x\" attribute on patch!\n");
					throw InvalidXMLException();
				}

				if (ctrl_p->QueryFloatAttribute("y", &y) != TIXML_SUCCESS) {
					printf("Error parsing \"y\" attribute on patch!\n");
					throw InvalidXMLException();
				}
				if (ctrl_p->QueryFloatAttribute("z", &z) != TIXML_SUCCESS) {
					printf("Error parsing \"z\" attribute on patch!\n");
					throw InvalidXMLException();
				}

				printf("controlpoint: (%f %f %f)\n", x, y, z);

				patch->addControlPoint(x, y, z);

			} while ((ctrl_p = ctrl_p->NextSiblingElement("controlpoint")) != NULL);
		} else if (strcmp(child_type, "waterline") == 0) {
			char heightmap[MAX_STRING_LEN];
			char texturemap[MAX_STRING_LEN];
			char vert_shader[MAX_STRING_LEN];
			char frag_shader[MAX_STRING_LEN];

			if (is_inside_dl || is_dl) {
				printf("Waterline defined in \"%s\" is inside a display list!\n", node_id);
				throw InvalidXMLException();
			}

			if (strdup(heightmap, child->Attribute("heightmap")) == NULL) {
				printf("Error parsing \"heightmap\" attribute of waterline!");
				throw InvalidXMLException();
			}

			if (strdup(texturemap, child->Attribute("texturemap")) == NULL) {
				printf("Error parsing \"texturemap\" attribute of waterline!");
				throw InvalidXMLException();
			}

			if (strdup(frag_shader, child->Attribute("fragmentshader")) == NULL) {
				printf("Error parsing \"fragmentshader\" attribute of waterline!");
				throw InvalidXMLException();
			}

			if (strdup(vert_shader, child->Attribute("vertexshader")) == NULL) {
				printf("Error parsing \"vertexshader\" attribute of waterline!");
				throw InvalidXMLException();
			}

			MyWaterLine *wl = new MyWaterLine(heightmap, texturemap, vert_shader, frag_shader);
			n->addPrimitive(wl);

		} else if (strcmp(child_type, "vehicle") == 0) {
			MyVehicle *v = new MyVehicle();
			n->addPrimitive(v);

		} else if (strcmp(child_type, "noderef") == 0) {
			char next_node_id[MAX_STRING_LEN];
			if (strdup(next_node_id, child->Attribute("id")) == NULL) {
				printf("Error reading noderef's id!\n");
				throw InvalidXMLException();
			}
			if (find(nodes_being_processed.begin(), nodes_being_processed.end(), next_node_id)
					!= nodes_being_processed.end()) {
				if (find(nodes_finished_processing.begin(), nodes_finished_processing.end(), next_node_id)
						!= nodes_finished_processing.end()) {
					printf("Node has already been processed.\n");
					string last_node_name = Scene::getInstance()->findLastNameAvail(next_node_id);
					if (Scene::getInstance()->getNode(last_node_name)->getType() != DISPLAY_LIST) { // normal node
						n->addRef(next_node_id);
					} else {
						TiXmlElement *next_node = NULL;
						if ((next_node = findChildByAttribute(graphElement, "id", next_node_id))) {
							printf("\n\n");
							parseNode(next_node, is_dl || is_inside_dl);
							n->addRef(Scene::getInstance()->findLastNameAvail(next_node_id));
						}
					}
					continue;
				} else {
					printf("Cyclic definition found in node \"%s\"", next_node_id);
					throw InvalidXMLException();
				}
			} else {
				TiXmlElement *next_node = NULL;
				if ((next_node = findChildByAttribute(graphElement, "id", next_node_id))) {
					printf("\n\n");
					parseNode(next_node, is_dl || is_inside_dl);
					string last_node_name = Scene::getInstance()->findLastNameAvail(next_node_id);
					if (Scene::getInstance()->getNode(last_node_name)->getType() == DISPLAY_LIST) {
						n->addRef(last_node_name);
					} else {
						n->addRef(next_node_id);
					}

				} else {
					printf("Node %s does not exist!\n", next_node_id);
					throw InvalidXMLException();
				}
			}
		} else {
			printf("Invalid block inside children of node %s\n", node_id);
			throw InvalidXMLException();
		}
	}
	printf("Finished processing %s node children.\n\n", node_id);

	if (is_dl) {
		Scene::getInstance()->addNode(dl_node_id, n);
	} else {
		Scene::getInstance()->addNode(node_id, n);
	}
	printf("closing %s\n", node_id);
	n->closeDefinition(app_stck);
	printf("closed %s\n", node_id);
	app_stck.pop();
	nodes_finished_processing.push_back(node_id);
	return true;
}
vector<EncodedAttributeInfo*> LoadSavedDataSources::loadCodedAttributes(string dsName,int rowCount,bool limit){
	TiXmlDocument doc_1(this->_fileName.c_str());
	doc_1.LoadFile();
	TiXmlHandle handler(&doc_1);
	TiXmlElement *dsElement = handler.FirstChild("DataSources").ToElement();
	dsElement = dsElement->FirstChildElement("DataSource");
	vector<EncodedAttributeInfo*> codedAtts;
	try
	{
		while (dsElement)
		{
			if (strcmp(dsElement->Attribute("Name"),dsName.c_str()) == 0)
			{
				dsElement = dsElement->FirstChildElement("CodedAttributes")->FirstChildElement("Attribute");
				while (dsElement)
				{
					int attID = dsElement->FirstAttribute()->IntValue();
					int attType = atoi(dsElement->Attribute("Type"));
					string attName = dsElement->Attribute("Name");
					int noVStreams = dsElement->LastAttribute()->IntValue();
					EncodedAttributeInfo* attr;
					switch(attType){
					case 0:
						{
							EncodedIntAttribute *intAtt = new EncodedIntAttribute();
							intAtt->setAttID(attID);
							intAtt->setAttName(attName);
							intAtt->setNoOfVBitStreams(noVStreams,rowCount);
							intAtt->setAttType(getAttType(attType));

							BitStreamInfo** bitStreams = new BitStreamInfo*[noVStreams];
							TiXmlElement *vbs = dsElement->FirstChildElement("VBitStreams")->FirstChildElement("vbitstream");
							for (int k = 0 ; k < noVStreams ; k++)
							{
								BitStreamInfo* bitStr = new VBitStream();
								bitStr->setBitCount(rowCount);
								bitStr->setBitStreamAllocAttID(attID);
								bitStr->setBitStreamAllocAttName(attName);
								string bitStream;
								if (limit)
								{
									bitStream = vbs->GetText();
									long offset = rowCount - this->_rowLimit;
									bitStream = bitStream.substr(offset,this->_rowLimit);
								}
								else bitStream = vbs->GetText();
								dynamic_bitset<> temp(bitStream);
								bitStr->convert(temp);
								bitStreams[k] = bitStr;
								vbs = vbs->NextSiblingElement("vbitstream");
							}
							vector<BitStreamInfo*> tempVB(bitStreams , bitStreams + noVStreams);
							intAtt->setVBitStreams(tempVB);
							attr = intAtt;
							codedAtts.push_back(attr);
							break;
						}
					case 1:
						{
							EncodedDoubleAttribute *doubleAtt = new EncodedDoubleAttribute();
							doubleAtt->setAttID(attID);
							doubleAtt->setAttName(attName);
							doubleAtt->setNoOfVBitStreams(noVStreams,rowCount);
							doubleAtt->setAttType(getAttType(attType));

							BitStreamInfo** bitStreams = new BitStreamInfo*[noVStreams];
							TiXmlElement *vbs = dsElement->FirstChildElement("VBitStreams")->FirstChildElement("vbitstream");
							for (int k = 0 ; k < noVStreams ; k++)
							{
								BitStreamInfo* bitStr = new VBitStream();
								bitStr->setBitCount(rowCount);
								bitStr->setBitStreamAllocAttID(attID);
								bitStr->setBitStreamAllocAttName(attName);
								string bitStream;
								if (limit)
								{
									bitStream = vbs->GetText();
									long offset = rowCount - this->_rowLimit;
									bitStream = bitStream.substr(offset,this->_rowLimit);
								}
								else bitStream = vbs->GetText();
								dynamic_bitset<> temp(bitStream);
								bitStr->convert(temp);
								bitStreams[k] = bitStr;
								vbs = vbs->NextSiblingElement("vbitstream");
							}
							vector<BitStreamInfo*> tempVB(bitStreams , bitStreams + noVStreams);
							doubleAtt->setVBitStreams(tempVB);
							attr = doubleAtt;
							codedAtts.push_back(attr);
							break;
						}
					case 3:
						{
							EncodedMultiCatAttribute *catAtt = new EncodedMultiCatAttribute();
							catAtt->setAttID(attID);
							catAtt->setAttName(attName);
							catAtt->setAttType(getAttType(attType));
							catAtt->setNoOfVBitStreams(noVStreams,rowCount);

							BitStreamInfo** bitStreams = new BitStreamInfo*[noVStreams];
							TiXmlElement *vbs = dsElement->FirstChildElement("VBitStreams")->FirstChildElement("vbitstream");
							for (int k = 0 ; k < noVStreams ; k++)
							{
								BitStreamInfo* bitStr = new VBitStream();
								bitStr->setBitCount(rowCount);
								bitStr->setBitStreamAllocAttID(attID);
								bitStr->setBitStreamAllocAttName(attName);
								string bitStream;
								if (limit)
								{
									bitStream = vbs->GetText();
									long offset = rowCount - this->_rowLimit;
									bitStream = bitStream.substr(offset,this->_rowLimit);
								}
								else bitStream = vbs->GetText();
								dynamic_bitset<> temp(bitStream);
								bitStr->convert(temp);
								bitStreams[k] = bitStr;
								vbs = vbs->NextSiblingElement("vbitstream");
							}
							vector<BitStreamInfo*> tempVB(bitStreams , bitStreams + noVStreams);
							catAtt->setVBitStreams(tempVB);
							attr = catAtt;
							codedAtts.push_back(attr);
							break;
						}

					}

					dsElement = dsElement->NextSiblingElement("Attribute");
				}
			}
			else{
				dsElement = dsElement->NextSiblingElement("DataSource");
				continue;
			}
		}
	}
	catch(...)
	{
		error_loading_encoded_data ex;
		ex << error_message(ExceptionReader::GetError(SM1017));
		ex << error_code(SM1017);
		BOOST_THROW_EXCEPTION(ex);
	}
	return codedAtts;
}
vector<EncodedAttributeInfo*> LoadSavedDataSources::loadCodedAttributesFromMultipleFiles( string dsName,int rowCount,bool limit )
{
	vector<EncodedAttributeInfo*> codedAtts;
	try
	{
		for (int j = 0 ; j < this->saved_file_names.size() ; j++)
		{
			this->_fileName = ConfigurationReader::ReadConfiguration(ConfigurationReader::configutation::SAVE_DATA_FOLDER) + this->_saved_folder + "\\" + this->saved_file_names[j];
			TiXmlDocument *doc_1 = new TiXmlDocument(this->_fileName.c_str());
			doc_1->LoadFile();
			TiXmlHandle handler(doc_1);
			TiXmlElement *dsElement = handler.FirstChild("DataSources").ToElement();
			dsElement = dsElement->FirstChildElement("DataSource");
			if (strcmp(dsElement->Attribute("Name"),dsName.c_str()) == 0)
			{
				dsElement = dsElement->FirstChildElement("CodedAttribute");
				int attID = dsElement->FirstAttribute()->IntValue();
				int attType = atoi(dsElement->Attribute("Type"));
				string attName = dsElement->Attribute("Name");
				int noVStreams = dsElement->LastAttribute()->IntValue();
				EncodedAttributeInfo* attr;
				switch(attType){
					case 0:
						{
							EncodedIntAttribute *intAtt = new EncodedIntAttribute();
							intAtt->setAttID(attID);
							intAtt->setAttName(attName);
							intAtt->setNoOfVBitStreams(noVStreams,rowCount);
							intAtt->setAttType(getAttType(attType));

							BitStreamInfo** bitStreams = new BitStreamInfo*[noVStreams];
							TiXmlElement *vbs = dsElement->FirstChildElement("VBitStreams")->FirstChildElement("vbitstream");
							for (int k = 0 ; k < noVStreams ; k++)
							{
								BitStreamInfo* bitStr = new VBitStream();
								bitStr->setBitCount(rowCount);
								bitStr->setBitStreamAllocAttID(attID);
								bitStr->setBitStreamAllocAttName(attName);
								string bitStream;
								if (limit)
								{
									bitStream = vbs->GetText();
									long offset = rowCount - this->_rowLimit;
									bitStream = bitStream.substr(offset,this->_rowLimit);
								}
								else bitStream = vbs->GetText();
								dynamic_bitset<> temp(bitStream);
								bitStr->convert(temp);
								bitStreams[k] = bitStr;
								vbs = vbs->NextSiblingElement("vbitstream");
							}
							vector<BitStreamInfo*> tempVB(bitStreams , bitStreams + noVStreams);
							intAtt->setVBitStreams(tempVB);
							attr = intAtt;
							codedAtts.push_back(attr);
							break;
						}
					case 1:
						{
							EncodedDoubleAttribute *doubleAtt = new EncodedDoubleAttribute();
							doubleAtt->setAttID(attID);
							doubleAtt->setAttName(attName);
							doubleAtt->setNoOfVBitStreams(noVStreams,rowCount);
							doubleAtt->setAttType(getAttType(attType));

							BitStreamInfo** bitStreams = new BitStreamInfo*[noVStreams];
							TiXmlElement *vbs = dsElement->FirstChildElement("VBitStreams")->FirstChildElement("vbitstream");
							for (int k = 0 ; k < noVStreams ; k++)
							{
								BitStreamInfo* bitStr = new VBitStream();
								bitStr->setBitCount(rowCount);
								bitStr->setBitStreamAllocAttID(attID);
								bitStr->setBitStreamAllocAttName(attName);
								string bitStream;
								if (limit)
								{
									bitStream = vbs->GetText();
									long offset = rowCount - this->_rowLimit;
									bitStream = bitStream.substr(offset,this->_rowLimit);
								}
								else bitStream = vbs->GetText();
								dynamic_bitset<> temp(bitStream);
								bitStr->convert(temp);
								bitStreams[k] = bitStr;
								vbs = vbs->NextSiblingElement("vbitstream");
							}
							vector<BitStreamInfo*> tempVB(bitStreams , bitStreams + noVStreams);
							doubleAtt->setVBitStreams(tempVB);
							attr = doubleAtt;
							codedAtts.push_back(attr);
							break;
						}
					case 3:
						{
							EncodedMultiCatAttribute *catAtt = new EncodedMultiCatAttribute();
							catAtt->setAttID(attID);
							catAtt->setAttName(attName);
							catAtt->setAttType(getAttType(attType));
							catAtt->setNoOfVBitStreams(noVStreams,rowCount);

							BitStreamInfo** bitStreams = new BitStreamInfo*[noVStreams];
							TiXmlElement *vbs = dsElement->FirstChildElement("VBitStreams")->FirstChildElement("vbitstream");
							for (int k = 0 ; k < noVStreams ; k++)
							{
								BitStreamInfo* bitStr = new VBitStream();
								bitStr->setBitCount(rowCount);
								bitStr->setBitStreamAllocAttID(attID);
								bitStr->setBitStreamAllocAttName(attName);
								string bitStream;
								if (limit)
								{
									bitStream = vbs->GetText();
									long offset = rowCount - this->_rowLimit;
									bitStream = bitStream.substr(offset,this->_rowLimit);
								}
								else bitStream = vbs->GetText();
								dynamic_bitset<> temp(bitStream);
								bitStr->convert(temp);
								bitStreams[k] = bitStr;
								vbs = vbs->NextSiblingElement("vbitstream");
							}
							vector<BitStreamInfo*> tempVB(bitStreams , bitStreams + noVStreams);
							catAtt->setVBitStreams(tempVB);
							attr = catAtt;
							codedAtts.push_back(attr);
							break;
						}
				}
			}
			delete doc_1;
		}
	}
	catch(...)
	{
		error_loading_encoded_data ex;
		string err = ExceptionReader::GetError(SM1017);
		err += "-> Try to load from a multiple attribute data files";
		ex << error_message(err);
		ex << error_code(SM1017);
		BOOST_THROW_EXCEPTION(ex);
	}
	return codedAtts;
}
PrevailingTime::PrevailingTime(TiXmlNode* xmlNode)
: ISerialized(xmlNode)
{
    #ifdef ConsolePrint
        std::string initialtap_ = FileManager::instance().tap_;
        FileManager::instance().tap_.append("   ");
    #endif 
   //hourMinuteTimeNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* hourMinuteTimeNode = xmlNode->FirstChildElement("hourMinuteTime");

   if(hourMinuteTimeNode){hourMinuteTimeIsNull_ = false;}
   else{hourMinuteTimeIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- hourMinuteTimeNode , address : " << hourMinuteTimeNode << std::endl;
   #endif
   if(hourMinuteTimeNode)
   {
      if(hourMinuteTimeNode->Attribute("href") || hourMinuteTimeNode->Attribute("id"))
      {
          if(hourMinuteTimeNode->Attribute("id"))
          {
             hourMinuteTimeIDRef_ = hourMinuteTimeNode->Attribute("id");
             hourMinuteTime_ = boost::shared_ptr<HourMinuteTime>(new HourMinuteTime(hourMinuteTimeNode));
             hourMinuteTime_->setID(hourMinuteTimeIDRef_);
             IDManager::instance().setID(hourMinuteTimeIDRef_,hourMinuteTime_);
          }
          else if(hourMinuteTimeNode->Attribute("href")) { hourMinuteTimeIDRef_ = hourMinuteTimeNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { hourMinuteTime_ = boost::shared_ptr<HourMinuteTime>(new HourMinuteTime(hourMinuteTimeNode));}
   }

   //locationNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* locationNode = xmlNode->FirstChildElement("location");

   if(locationNode){locationIsNull_ = false;}
   else{locationIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- locationNode , address : " << locationNode << std::endl;
   #endif
   if(locationNode)
   {
      if(locationNode->Attribute("href") || locationNode->Attribute("id"))
      {
          if(locationNode->Attribute("id"))
          {
             locationIDRef_ = locationNode->Attribute("id");
             location_ = boost::shared_ptr<TimezoneLocation>(new TimezoneLocation(locationNode));
             location_->setID(locationIDRef_);
             IDManager::instance().setID(locationIDRef_,location_);
          }
          else if(locationNode->Attribute("href")) { locationIDRef_ = locationNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { location_ = boost::shared_ptr<TimezoneLocation>(new TimezoneLocation(locationNode));}
   }

    #ifdef ConsolePrint
        FileManager::instance().tap_ = initialtap_;
    #endif 
}
PortfolioReference::PortfolioReference(TiXmlNode* xmlNode)
: PortfolioReferenceBase(xmlNode)
{
    #ifdef ConsolePrint
        std::string initialtap_ = FileManager::instance().tap_;
        FileManager::instance().tap_.append("   ");
    #endif 
   //sequenceNumberNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* sequenceNumberNode = xmlNode->FirstChildElement("sequenceNumber");

   if(sequenceNumberNode){sequenceNumberIsNull_ = false;}
   else{sequenceNumberIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- sequenceNumberNode , address : " << sequenceNumberNode << std::endl;
   #endif
   if(sequenceNumberNode)
   {
      if(sequenceNumberNode->Attribute("href") || sequenceNumberNode->Attribute("id"))
      {
          if(sequenceNumberNode->Attribute("id"))
          {
             sequenceNumberIDRef_ = sequenceNumberNode->Attribute("id");
             sequenceNumber_ = boost::shared_ptr<XsdTypePositiveInteger>(new XsdTypePositiveInteger(sequenceNumberNode));
             sequenceNumber_->setID(sequenceNumberIDRef_);
             IDManager::instance().setID(sequenceNumberIDRef_,sequenceNumber_);
          }
          else if(sequenceNumberNode->Attribute("href")) { sequenceNumberIDRef_ = sequenceNumberNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { sequenceNumber_ = boost::shared_ptr<XsdTypePositiveInteger>(new XsdTypePositiveInteger(sequenceNumberNode));}
   }

   //submissionsCompleteNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* submissionsCompleteNode = xmlNode->FirstChildElement("submissionsComplete");

   if(submissionsCompleteNode){submissionsCompleteIsNull_ = false;}
   else{submissionsCompleteIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- submissionsCompleteNode , address : " << submissionsCompleteNode << std::endl;
   #endif
   if(submissionsCompleteNode)
   {
      if(submissionsCompleteNode->Attribute("href") || submissionsCompleteNode->Attribute("id"))
      {
          if(submissionsCompleteNode->Attribute("id"))
          {
             submissionsCompleteIDRef_ = submissionsCompleteNode->Attribute("id");
             submissionsComplete_ = boost::shared_ptr<XsdTypeBoolean>(new XsdTypeBoolean(submissionsCompleteNode));
             submissionsComplete_->setID(submissionsCompleteIDRef_);
             IDManager::instance().setID(submissionsCompleteIDRef_,submissionsComplete_);
          }
          else if(submissionsCompleteNode->Attribute("href")) { submissionsCompleteIDRef_ = submissionsCompleteNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { submissionsComplete_ = boost::shared_ptr<XsdTypeBoolean>(new XsdTypeBoolean(submissionsCompleteNode));}
   }

    #ifdef ConsolePrint
        FileManager::instance().tap_ = initialtap_;
    #endif 
}
Пример #12
0
void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
{
  CXBMCTinyXML advancedXML;
  if (!CFile::Exists(file))
  {
    CLog::Log(LOGNOTICE, "No settings file to load (%s)", file.c_str());
    return;
  }

  if (!advancedXML.LoadFile(file))
  {
    CLog::Log(LOGERROR, "Error loading %s, Line %d\n%s", file.c_str(), advancedXML.ErrorRow(), advancedXML.ErrorDesc());
    return;
  }

  TiXmlElement *pRootElement = advancedXML.RootElement();
  if (!pRootElement || strcmpi(pRootElement->Value(),"advancedsettings") != 0)
  {
    CLog::Log(LOGERROR, "Error loading %s, no <advancedsettings> node", file.c_str());
    return;
  }

  // succeeded - tell the user it worked
  CLog::Log(LOGNOTICE, "Loaded settings file from %s", file.c_str());

  // Dump contents of AS.xml to debug log
  TiXmlPrinter printer;
  printer.SetLineBreak("\n");
  printer.SetIndent("  ");
  advancedXML.Accept(&printer);
  CLog::Log(LOGNOTICE, "Contents of %s are...\n%s", file.c_str(), printer.CStr());

  TiXmlElement *pElement = pRootElement->FirstChildElement("audio");
  if (pElement)
  {
    XMLUtils::GetFloat(pElement, "ac3downmixgain", m_ac3Gain, -96.0f, 96.0f);
    XMLUtils::GetInt(pElement, "headroom", m_audioHeadRoom, 0, 12);
    XMLUtils::GetString(pElement, "defaultplayer", m_audioDefaultPlayer);
    // 101 on purpose - can be used to never automark as watched
    XMLUtils::GetFloat(pElement, "playcountminimumpercent", m_audioPlayCountMinimumPercent, 0.0f, 101.0f);

    XMLUtils::GetBoolean(pElement, "usetimeseeking", m_musicUseTimeSeeking);
    XMLUtils::GetInt(pElement, "timeseekforward", m_musicTimeSeekForward, 0, 6000);
    XMLUtils::GetInt(pElement, "timeseekbackward", m_musicTimeSeekBackward, -6000, 0);
    XMLUtils::GetInt(pElement, "timeseekforwardbig", m_musicTimeSeekForwardBig, 0, 6000);
    XMLUtils::GetInt(pElement, "timeseekbackwardbig", m_musicTimeSeekBackwardBig, -6000, 0);

    XMLUtils::GetInt(pElement, "percentseekforward", m_musicPercentSeekForward, 0, 100);
    XMLUtils::GetInt(pElement, "percentseekbackward", m_musicPercentSeekBackward, -100, 0);
    XMLUtils::GetInt(pElement, "percentseekforwardbig", m_musicPercentSeekForwardBig, 0, 100);
    XMLUtils::GetInt(pElement, "percentseekbackwardbig", m_musicPercentSeekBackwardBig, -100, 0);

    XMLUtils::GetInt(pElement, "resample", m_audioResample, 0, 192000);
    XMLUtils::GetBoolean(pElement, "allowtranscode44100", m_allowTranscode44100);
    XMLUtils::GetBoolean(pElement, "forceDirectSound", m_audioForceDirectSound);
    XMLUtils::GetBoolean(pElement, "audiophile", m_audioAudiophile);
    XMLUtils::GetBoolean(pElement, "allchannelstereo", m_allChannelStereo);
    XMLUtils::GetString(pElement, "transcodeto", m_audioTranscodeTo);
    XMLUtils::GetInt(pElement, "audiosinkbufferdurationmsec", m_audioSinkBufferDurationMsec);

    TiXmlElement* pAudioExcludes = pElement->FirstChildElement("excludefromlisting");
    if (pAudioExcludes)
      GetCustomRegexps(pAudioExcludes, m_audioExcludeFromListingRegExps);

    pAudioExcludes = pElement->FirstChildElement("excludefromscan");
    if (pAudioExcludes)
      GetCustomRegexps(pAudioExcludes, m_audioExcludeFromScanRegExps);

    XMLUtils::GetString(pElement, "audiohost", m_audioHost);
    XMLUtils::GetBoolean(pElement, "applydrc", m_audioApplyDrc);
    XMLUtils::GetBoolean(pElement, "dvdplayerignoredtsinwav", m_dvdplayerIgnoreDTSinWAV);

    XMLUtils::GetFloat(pElement, "limiterhold", m_limiterHold, 0.0f, 100.0f);
    XMLUtils::GetFloat(pElement, "limiterrelease", m_limiterRelease, 0.001f, 100.0f);
  }

  pElement = pRootElement->FirstChildElement("karaoke");
  if (pElement)
  {
    XMLUtils::GetFloat(pElement, "syncdelaycdg", m_karaokeSyncDelayCDG, -3.0f, 3.0f); // keep the old name for comp
    XMLUtils::GetFloat(pElement, "syncdelaylrc", m_karaokeSyncDelayLRC, -3.0f, 3.0f);
    XMLUtils::GetBoolean(pElement, "alwaysreplacegenre", m_karaokeChangeGenreForKaraokeSongs );
    XMLUtils::GetBoolean(pElement, "storedelay", m_karaokeKeepDelay );
    XMLUtils::GetInt(pElement, "autoassignstartfrom", m_karaokeStartIndex, 1, 2000000000);
    XMLUtils::GetBoolean(pElement, "nocdgbackground", m_karaokeAlwaysEmptyOnCdgs );
    XMLUtils::GetBoolean(pElement, "lookupsongbackground", m_karaokeUseSongSpecificBackground );

    TiXmlElement* pKaraokeBackground = pElement->FirstChildElement("defaultbackground");
    if (pKaraokeBackground)
    {
      const char* attr = pKaraokeBackground->Attribute("type");
      if ( attr )
        m_karaokeDefaultBackgroundType = attr;

      attr = pKaraokeBackground->Attribute("path");
      if ( attr )
        m_karaokeDefaultBackgroundFilePath = attr;
    }
  }

  pElement = pRootElement->FirstChildElement("video");
  if (pElement)
  {
    XMLUtils::GetFloat(pElement, "subsdelayrange", m_videoSubsDelayRange, 10, 600);
    XMLUtils::GetFloat(pElement, "audiodelayrange", m_videoAudioDelayRange, 10, 600);
    XMLUtils::GetInt(pElement, "blackbarcolour", m_videoBlackBarColour, 0, 255);
    XMLUtils::GetString(pElement, "defaultplayer", m_videoDefaultPlayer);
    XMLUtils::GetString(pElement, "defaultdvdplayer", m_videoDefaultDVDPlayer);
    XMLUtils::GetBoolean(pElement, "fullscreenonmoviestart", m_fullScreenOnMovieStart);
    // 101 on purpose - can be used to never automark as watched
    XMLUtils::GetFloat(pElement, "playcountminimumpercent", m_videoPlayCountMinimumPercent, 0.0f, 101.0f);
    XMLUtils::GetInt(pElement, "ignoresecondsatstart", m_videoIgnoreSecondsAtStart, 0, 900);
    XMLUtils::GetFloat(pElement, "ignorepercentatend", m_videoIgnorePercentAtEnd, 0, 100.0f);

    XMLUtils::GetInt(pElement, "smallstepbackseconds", m_videoSmallStepBackSeconds, 1, INT_MAX);
    XMLUtils::GetInt(pElement, "smallstepbacktries", m_videoSmallStepBackTries, 1, 10);
    XMLUtils::GetInt(pElement, "smallstepbackdelay", m_videoSmallStepBackDelay, 100, 5000); //MS

    XMLUtils::GetBoolean(pElement, "usetimeseeking", m_videoUseTimeSeeking);
    XMLUtils::GetInt(pElement, "timeseekforward", m_videoTimeSeekForward, 0, 6000);
    XMLUtils::GetInt(pElement, "timeseekbackward", m_videoTimeSeekBackward, -6000, 0);
    XMLUtils::GetInt(pElement, "timeseekforwardbig", m_videoTimeSeekForwardBig, 0, 6000);
    XMLUtils::GetInt(pElement, "timeseekbackwardbig", m_videoTimeSeekBackwardBig, -6000, 0);

    XMLUtils::GetInt(pElement, "percentseekforward", m_videoPercentSeekForward, 0, 100);
    XMLUtils::GetInt(pElement, "percentseekbackward", m_videoPercentSeekBackward, -100, 0);
    XMLUtils::GetInt(pElement, "percentseekforwardbig", m_videoPercentSeekForwardBig, 0, 100);
    XMLUtils::GetInt(pElement, "percentseekbackwardbig", m_videoPercentSeekBackwardBig, -100, 0);

    TiXmlElement* pVideoExcludes = pElement->FirstChildElement("excludefromlisting");
    if (pVideoExcludes)
      GetCustomRegexps(pVideoExcludes, m_videoExcludeFromListingRegExps);

    pVideoExcludes = pElement->FirstChildElement("excludefromscan");
    if (pVideoExcludes)
      GetCustomRegexps(pVideoExcludes, m_moviesExcludeFromScanRegExps);

    pVideoExcludes = pElement->FirstChildElement("excludetvshowsfromscan");
    if (pVideoExcludes)
      GetCustomRegexps(pVideoExcludes, m_tvshowExcludeFromScanRegExps);

    pVideoExcludes = pElement->FirstChildElement("cleanstrings");
    if (pVideoExcludes)
      GetCustomRegexps(pVideoExcludes, m_videoCleanStringRegExps);

    XMLUtils::GetString(pElement,"cleandatetime", m_videoCleanDateTimeRegExp);
    XMLUtils::GetString(pElement,"ppffmpegdeinterlacing",m_videoPPFFmpegDeint);
    XMLUtils::GetString(pElement,"ppffmpegpostprocessing",m_videoPPFFmpegPostProc);
    XMLUtils::GetBoolean(pElement,"vdpauscaling",m_videoVDPAUScaling);
    XMLUtils::GetFloat(pElement, "nonlinearstretchratio", m_videoNonLinStretchRatio, 0.01f, 1.0f);
    XMLUtils::GetBoolean(pElement,"enablehighqualityhwscalers", m_videoEnableHighQualityHwScalers);
    XMLUtils::GetFloat(pElement,"autoscalemaxfps",m_videoAutoScaleMaxFps, 0.0f, 1000.0f);
    XMLUtils::GetBoolean(pElement,"allowmpeg4vdpau",m_videoAllowMpeg4VDPAU);
    XMLUtils::GetBoolean(pElement,"allowmpeg4vaapi",m_videoAllowMpeg4VAAPI);    
    XMLUtils::GetBoolean(pElement, "disablebackgrounddeinterlace", m_videoDisableBackgroundDeinterlace);
    XMLUtils::GetInt(pElement, "useocclusionquery", m_videoCaptureUseOcclusionQuery, -1, 1);

    TiXmlElement* pAdjustRefreshrate = pElement->FirstChildElement("adjustrefreshrate");
    if (pAdjustRefreshrate)
    {
      TiXmlElement* pRefreshOverride = pAdjustRefreshrate->FirstChildElement("override");
      while (pRefreshOverride)
      {
        RefreshOverride override = {0};

        float fps;
        if (XMLUtils::GetFloat(pRefreshOverride, "fps", fps))
        {
          override.fpsmin = fps - 0.01f;
          override.fpsmax = fps + 0.01f;
        }

        float fpsmin, fpsmax;
        if (XMLUtils::GetFloat(pRefreshOverride, "fpsmin", fpsmin) &&
            XMLUtils::GetFloat(pRefreshOverride, "fpsmax", fpsmax))
        {
          override.fpsmin = fpsmin;
          override.fpsmax = fpsmax;
        }

        float refresh;
        if (XMLUtils::GetFloat(pRefreshOverride, "refresh", refresh))
        {
          override.refreshmin = refresh - 0.01f;
          override.refreshmax = refresh + 0.01f;
Пример #13
0
//This function loads a map from the specified .tmx file
void Game::LoadMap(string filename)
{
	//Create our Root Document handle and open it up
	TiXmlDocument Root(filename.c_str());
	if (!Root.LoadFile()) throw std::runtime_error(string("Failed to open level file: ") + filename);

	//Get a handle to our first set of 'layer' data in the map. This could be anything from a tile/object layer to tileset info,
	//so we need to check what it is before we do anything with it.
	TiXmlElement *Layer = Root.FirstChildElement("map")->FirstChildElement();

	//Clear out any existing object data
	GameStorage->ClearAll();

	//Loop through all layers we can find in the map data
	while (Layer)
	{
		//Check for an object layer that has child elements. Currently this is the only kind we're interested in.
		if (string(Layer->Value()) == "objectgroup" && !Layer->NoChildren())
		{
			//Get our first object in this layer
			TiXmlElement *Object = Layer->FirstChildElement();
			//Get the name of our layer
			string name(Layer->Attribute("name"));
			ColourType colour;

			//Convert name to lower-case
			for (int i = 0; i < name.length(); i++)
			{
				name[i] = tolower(name[i]);
			}

			//Loop through all objects
			while (Object)
			{
				string type((Object->Attribute("type") != NULL) ? Object->Attribute("type") : "");

				//Depending on the type of this layer, spawn a certain type of object
				if (name == "red")
				{
					colour = COLOUR_RED;
				}
				else if (name == "blue")
				{
					colour = COLOUR_BLUE;
				}
				else if (name == "yellow")
				{
					colour = COLOUR_YELLOW;
				}
				else if (name == "white")
				{
					colour = COLOUR_WHITE;
				}
				else if (name == "player")
				{
					player.ReadPosition(Object);
				}
				else if (name == "exit")
				{
					exit.ReadPosition(Object);
				}

				if (name != "player" && name != "exit")
				{
					if (type == "" || type == "normal")
					{
						GameStorage->AddObject(GameObjectPointer(new ColourBox(Object, colour)));
					}
					else if (type == "moveable")
					{

					}
					else if (type == "moving")
					{
						GameStorage->AddObject(GameObjectPointer(new MovingColourBlock(Object, colour)));
					}
				}

				Object = Object->NextSiblingElement();
			}
		}

		Layer = Layer->NextSiblingElement();
	}

	ColouredObject::SetCurrentColour(COLOUR_RED);
}
Пример #14
0
bool CGUIWindow::Load(TiXmlElement *pRootElement)
{
  if (!pRootElement)
    return false;

  // set the scaling resolution so that any control creation or initialisation can
  // be done with respect to the correct aspect ratio
  CServiceBroker::GetWinSystem()->GetGfxContext().SetScalingResolution(m_coordsRes, m_needsScaling);

  // now load in the skin file
  SetDefaults();

  CGUIControlFactory::GetInfoColor(pRootElement, "backgroundcolor", m_clearBackground, GetID());
  CGUIControlFactory::GetActions(pRootElement, "onload", m_loadActions);
  CGUIControlFactory::GetActions(pRootElement, "onunload", m_unloadActions);
  CRect parentRect(0, 0, static_cast<float>(m_coordsRes.iWidth), static_cast<float>(m_coordsRes.iHeight));
  CGUIControlFactory::GetHitRect(pRootElement, m_hitRect, parentRect);

  TiXmlElement *pChild = pRootElement->FirstChildElement();
  while (pChild)
  {
    std::string strValue = pChild->Value();
    if (strValue == "previouswindow" && pChild->FirstChild())
    {
      m_previousWindow = CWindowTranslator::TranslateWindow(pChild->FirstChild()->Value());
    }
    else if (strValue == "defaultcontrol" && pChild->FirstChild())
    {
      const char *always = pChild->Attribute("always");
      if (always && StringUtils::EqualsNoCase(always, "true"))
        m_defaultAlways = true;
      m_defaultControl = atoi(pChild->FirstChild()->Value());
    }
    else if(strValue == "menucontrol" && pChild->FirstChild())
    {
      m_menuControlID = atoi(pChild->FirstChild()->Value());
    }
    else if (strValue == "visible" && pChild->FirstChild())
    {
      std::string condition;
      CGUIControlFactory::GetConditionalVisibility(pRootElement, condition);
      m_visibleCondition = CServiceBroker::GetGUI()->GetInfoManager().Register(condition, GetID());
    }
    else if (strValue == "animation" && pChild->FirstChild())
    {
      CRect rect(0, 0, static_cast<float>(m_coordsRes.iWidth), static_cast<float>(m_coordsRes.iHeight));
      CAnimation anim;
      anim.Create(pChild, rect, GetID());
      m_animations.push_back(anim);
    }
    else if (strValue == "zorder" && pChild->FirstChild())
    {
      m_renderOrder = atoi(pChild->FirstChild()->Value());
    }
    else if (strValue == "coordinates")
    {
      XMLUtils::GetFloat(pChild, "posx", m_posX);
      XMLUtils::GetFloat(pChild, "posy", m_posY);
      XMLUtils::GetFloat(pChild, "left", m_posX);
      XMLUtils::GetFloat(pChild, "top", m_posY);

      TiXmlElement *originElement = pChild->FirstChildElement("origin");
      while (originElement)
      {
        COrigin origin;
        origin.x = CGUIControlFactory::ParsePosition(originElement->Attribute("x"), static_cast<float>(m_coordsRes.iWidth));
        origin.y = CGUIControlFactory::ParsePosition(originElement->Attribute("y"), static_cast<float>(m_coordsRes.iHeight));
        if (originElement->FirstChild())
          origin.condition = CServiceBroker::GetGUI()->GetInfoManager().Register(originElement->FirstChild()->Value(), GetID());
        m_origins.push_back(origin);
        originElement = originElement->NextSiblingElement("origin");
      }
    }
    else if (strValue == "camera")
    { // z is fixed
      m_camera.x = CGUIControlFactory::ParsePosition(pChild->Attribute("x"), static_cast<float>(m_coordsRes.iWidth));
      m_camera.y = CGUIControlFactory::ParsePosition(pChild->Attribute("y"), static_cast<float>(m_coordsRes.iHeight));
      m_hasCamera = true;
    }
    else if (strValue == "depth" && pChild->FirstChild())
    { 
      float stereo = static_cast<float>(atof(pChild->FirstChild()->Value()));
      m_stereo = std::max(-1.f, std::min(1.f, stereo));
    }
    else if (strValue == "controls")
    {
      TiXmlElement *pControl = pChild->FirstChildElement();
      while (pControl)
      {
        if (StringUtils::EqualsNoCase(pControl->Value(), "control"))
        {
          LoadControl(pControl, nullptr, CRect(0, 0, static_cast<float>(m_coordsRes.iWidth), static_cast<float>(m_coordsRes.iHeight)));
        }
        pControl = pControl->NextSiblingElement();
      }
    }

    pChild = pChild->NextSiblingElement();
  }

  return true;
}
Пример #15
0
int _tmain(int argc, _TCHAR* argv[])
{
  std::string input = "svn_log.xml";
  std::string output = "Changelog.txt";
  int limit = 0;

  if (argc < 2)
  {
    // output help information
    printf("usage:\n");
    printf("\n");
    printf("  Changelog input <output> <limit>\n");
    printf("\n");
    printf("  input    : input .xml file generated from SVN (using svn log --xml)\n");
    printf("             DOWNLOAD to download direct from XBMC SVN\n");
    printf("  <output> : output .txt file for the changelog (defaults to Changelog.txt)\n");
    printf("  <limit>  : the number of log entries for svn to fetch. (defaults to no limit)");
    printf("\n");
    return 0;
  }
  input = argv[1];
  if (argc > 2)
    output = argv[2];
  FILE *file = fopen(output.c_str(), "wb");
  if (!file)
    return 1;
  fprintf(file, header);
  if (input.compare("download") == 0)
  {
    if(argc > 3)
      limit = atoi(argv[3]);
    // download our input file
    std::string command = "svn log -r 'HEAD':8638 ";
    if (limit > 0)
    {
      command += "--limit ";
      command += argv[3]; // the limit as a string
      command += " ";
    }
#ifndef _LINUX
    command += "--xml https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/XBMC > svn_log.xml";
#else
    command += "--xml https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/linuxport/XBMC > svn_log.xml";
#endif
    printf("Downloading changelog from SVN - this will take some time (around 1MB to download with no limit)\n");
    system(command.c_str());
    input = "svn_log.xml";
    printf("Downloading done - processing\n");
  }
  TiXmlDocument doc;
  if (!doc.LoadFile(input.c_str()))
  {
    return 1;
  }

  TiXmlElement *root = doc.RootElement();
  if (!root) return 1;

  TiXmlElement *logitem = root->FirstChildElement("logentry");
  while (logitem)
  {
    int revision;
    logitem->Attribute("revision", &revision);
    TiXmlNode *date = logitem->FirstChild("date");
    std::string dateString;
    if (date && date->FirstChild())
      dateString = date->FirstChild()->Value();
    TiXmlNode *msg = logitem->FirstChild("msg");
    if (msg && msg->FirstChild())
    {
      // filter the message a bit
      std::string message = FilterMessage(msg->FirstChild()->Value());
      if (message.size())
        fprintf(file, "%s  %4i  %s\r\n", dateString.substr(0,10).c_str(), revision, message.c_str());
      else
        int breakhere = 1;
    }
    logitem = logitem->NextSiblingElement("logentry");
  }
  fclose(file);
  printf("Changelog saved as: %s\n", output.c_str());
  return 0;
}
Пример #16
0
//! 读取配置
BOOL NetSetup::LoadSetup(const char *pXmlFilename)
{
	if(NULL == pXmlFilename)
		return FALSE;

	TiXmlNode *pNode = NULL; 		

	TiXmlDocument* m_Tdoc = new TiXmlDocument(pXmlFilename);
	if(!m_Tdoc->LoadFile())
		return FALSE;

	pNode = m_Tdoc->FirstChild("NetSetup");

	if (pNode == NULL)
	{
		SAFE_DELETE(m_Tdoc);
		return FALSE;
	}

	TiXmlElement* pNetSetup = pNode->ToElement();//获取node 的指针

	if (pNetSetup == NULL)
	{
		SAFE_DELETE(m_Tdoc);
		return FALSE;
	}

	////////////////////////////////////////////
	m_bIsReady = FALSE;
	m_mapServerSetup.clear();

	m_MemSetup.dwDataBlockNum	= atoi(pNetSetup->Attribute("DataBlockNum"));
	m_MemSetup.dwDataBlockSize	= atoi(pNetSetup->Attribute("DataBlockSize"));
	m_MemSetup.dwFreeMsgNum		= atoi(pNetSetup->Attribute("FreeMsgNum"));

	TiXmlElement* pServerSetup = pNetSetup->FirstChildElement("ServerSetup");
	for (; pServerSetup != NULL; pServerSetup = pServerSetup->NextSiblingElement("ServerSetup"))
	{
		tagServerSetup ServerSetup;
		LONG lID = atoi(pServerSetup->Attribute("ID"));

		ServerSetup.dwListenOrConnectPort		= atoi(pServerSetup->Attribute("ListenOrConnectPort"));		// 侦听或者连接端口
		ServerSetup.dwFreeSockOperNum			= atoi(pServerSetup->Attribute("FreeSockOperNum"));			// 网络命令操作预分配数量
		ServerSetup.dwFreeIOOperNum				= atoi(pServerSetup->Attribute("FreeIOOperNum"));			// 完成端口上IO操作预分配数量
		ServerSetup.dwIOOperDataBufNum			= atoi(pServerSetup->Attribute("IOOperDataBufNum"));		// 默认IO操作的DataBuf数量

		ServerSetup.dwCheckNet					= atoi(pServerSetup->Attribute("CheckNet"));				// 是否对网络进行检测
		ServerSetup.dwBanIPTime					= atoi(pServerSetup->Attribute("BanIPTime"));				// 禁止IP的时间
		ServerSetup.dwMaxMsgLen					= atoi(pServerSetup->Attribute("MaxMsgLen"));				// 允许传输的最大消息长度		
		ServerSetup.dwMaxConnectNum				= atoi(pServerSetup->Attribute("MaxConnectNum"));			// 客户端的最大连接数量
		ServerSetup.dwMaxClientsNum				= atoi(pServerSetup->Attribute("MaxClientsNum"));			// 最大的客户端发送缓冲区大小
		ServerSetup.dwPendingWrBufNum			= atoi(pServerSetup->Attribute("PendingWrBufNum"));			// 最大的发送IO操作Buf总大小
		ServerSetup.dwPendingRdBufNum			= atoi(pServerSetup->Attribute("PendingRdBufNum"));			// 最大的接受IO操作Buf总大小
		ServerSetup.dwMaxSendSizePerSecond		= atoi(pServerSetup->Attribute("MaxSendSizePerSecond"));	// 向客户端每秒发送的最大字节数
		ServerSetup.dwMaxRecvSizePerSecond		= atoi(pServerSetup->Attribute("MaxRecvSizePerSecond"));	// 从客户端接受的每秒最大字节数
		ServerSetup.dwMaxBlockedSendMsgNum		= atoi(pServerSetup->Attribute("MaxBlockedSendMsgNum"));	// 最大阻塞的发送消息数量
		ServerSetup.dwConPendingWrBufNum		= atoi(pServerSetup->Attribute("ConPendingWrBufNum"));		// 客户端最大的发送IO操作Buf总大小
		ServerSetup.dwConPendingRdBufNum		= atoi(pServerSetup->Attribute("ConPendingRdBufNum"));		// 客户端最大的接受IO操作Buf总大小
		ServerSetup.dwConMaxSendSizePerSecond	= atoi(pServerSetup->Attribute("ConMaxSendSizePerSecond"));	// 向服务器发送的每秒最大字节数
		ServerSetup.dwConMaxRecvSizePerSecond	= atoi(pServerSetup->Attribute("ConMaxRecvSizePerSecond"));	// 从服务器接受的每秒最大字节数
		ServerSetup.dwConMaxBlockedSendMsgNum	= atoi(pServerSetup->Attribute("ConMaxBlockedSendMsgNum"));	// 最大阻塞的发送消息数量

		m_mapServerSetup[lID] = ServerSetup;
	}
	
	////////////////////////////////////////////
	m_bIsReady = TRUE;
	SAFE_DELETE(m_Tdoc);
	return TRUE;
}
Пример #17
0
bool XMLScene::parseLighting() {
	unsigned int lights_counter = 0;
	printf("Processing lights...\n\n");
	char tmp_str[MAX_STRING_LEN];
	bool is_doublesided = false, is_local = true, is_enabled = true;
	double light_amb_r = 0, light_amb_g = 0, light_amb_b = 0, light_amb_a = 0;

	if (lightingElement->QueryBoolAttribute("doublesided", &is_doublesided) != TIXML_SUCCESS) {
		printf("Invalid argument of doublesided!\n");
		throw InvalidXMLException();
	}

	if (lightingElement->QueryBoolAttribute("local", &is_local) != TIXML_SUCCESS) {
		printf("Invalid argument of local!\n");
		throw InvalidXMLException();
	}

	if (lightingElement->QueryBoolAttribute("enabled", &is_enabled) != TIXML_SUCCESS) {
		printf("Invalid argument of enabled!\n");
		throw InvalidXMLException();
	}

	if (strdup(tmp_str, lightingElement->Attribute("ambient")) == NULL) {
		printf("Invalid argument of ambient!\n");
		throw InvalidXMLException();
	}

	if (sscanf(tmp_str, "%lf %lf %lf %lf", &light_amb_r, &light_amb_g, &light_amb_b, &light_amb_a) != 4) {
		printf("Invalid argument of ambient!\n");
		throw InvalidXMLException();
	}

	Scene::getInstance()->setGlobalLights(is_doublesided, is_local, is_enabled);
	Scene::getInstance()->setAmb(light_amb_r, light_amb_g, light_amb_b, light_amb_a);

	printf("Global lightign attributes.\ndoublesided: %s\nlocal: %s\nenabled: %s\nambient: (%f,%f,%f,%f)\n\n",
			is_doublesided ? "true" : "false", is_local ? "true" : "false", is_enabled ? "true" : "false", light_amb_r,
			light_amb_g, light_amb_b, light_amb_a);

	TiXmlElement *omni = NULL, *spot = NULL;

	if ((omni = lightingElement->FirstChildElement("omni")) != NULL) {
		do {
			lights_counter++;
			char omni_id[MAX_STRING_LEN], tmp_str[MAX_STRING_LEN];
			bool omni_enabled = false;
			double omni_location_x = 0, omni_location_y = 0, omni_location_z = 0, omni_amb_r = 0, omni_amb_g = 0,
					omni_amb_b = 0, omni_amb_a = 0, omni_dif_r = 0, omni_dif_g = 0, omni_dif_b = 0, omni_dif_a = 0,
					omni_spec_r = 0, omni_spec_g = 0, omni_spec_b = 0, omni_spec_a = 0;
			if (strdup(omni_id, omni->Attribute("id")) == NULL) {
				printf("Invalid id argument!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, omni->Attribute("enabled")) == NULL) {
				printf("Error on atribute \"enabled\" of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			if (strcmp(tmp_str, "true") == 0) {
				omni_enabled = true;
			} else if (strcmp(tmp_str, "false") == 0) {
				omni_enabled = false;
			} else {
				printf("Invalid argument of local!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, omni->Attribute("location")) == NULL) {
				printf("No attribute \"location\" of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf", &omni_location_x, &omni_location_y, &omni_location_z) != 3) {
				printf("Invalid location argument of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, omni->Attribute("ambient")) == NULL) {
				printf("No attribute \"ambient\" of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &omni_amb_r, &omni_amb_g, &omni_amb_b, &omni_amb_a) != 4) {
				printf("Invalid ambient argument of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, omni->Attribute("diffuse")) == NULL) {
				printf("No attribute \"diffuse\" of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &omni_dif_r, &omni_dif_g, &omni_dif_b, &omni_dif_a) != 4) {
				printf("Invalid diffuse argument of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, omni->Attribute("specular")) == NULL) {
				printf("No attribute \"specular\" of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &omni_spec_r, &omni_spec_g, &omni_spec_b, &omni_spec_a) != 4) {
				printf("Invalid specular argument of %s light!\n", omni_id);
				throw InvalidXMLException();
			}

			Light *omni_light = new Omnilight(omni_id, omni_enabled);
			((Omnilight *) omni_light)->setLocation(omni_location_x, omni_location_y, omni_location_z);
			((Omnilight *) omni_light)->setAmbient(omni_amb_r, omni_amb_g, omni_amb_b, omni_amb_a);
			((Omnilight *) omni_light)->setDiffuse(omni_dif_r, omni_dif_g, omni_dif_b, omni_dif_a);
			((Omnilight *) omni_light)->setSpecular(omni_spec_r, omni_spec_g, omni_spec_b, omni_spec_a);

			Scene::getInstance()->addLight(omni_light);

			printf(
					"Omni light.\nid: %s\nenabled: %s\nlocation: (%f,%f,%f)\nambient: (%f,%f,%f,%f)\ndiffuse: (%f,%f,%f,%f)\nspecular: (%f,%f,%f,%f)\n\n",
					omni_id, omni_enabled ? "true" : "false", omni_location_x, omni_location_y, omni_location_z,
					omni_amb_r, omni_amb_g, omni_amb_b, omni_amb_a, omni_dif_r, omni_dif_g, omni_dif_b, omni_dif_a,
					omni_spec_r, omni_spec_g, omni_spec_b, omni_spec_a);
		} while ((omni = omni->NextSiblingElement("omni")) != NULL);
	} else {
		printf("There are no omni lights.\n");
	}

	if ((spot = lightingElement->FirstChildElement("spot")) != NULL) {
		do {
			lights_counter++;
			char spot_id[MAX_STRING_LEN], tmp_str[MAX_STRING_LEN];
			bool spot_enabled = false;
			double spot_location_x = 0, spot_location_y = 0, spot_location_z = 0, spot_amb_r = 0, spot_amb_g = 0,
					spot_amb_b = 0, spot_amb_a = 0, spot_dif_r = 0, spot_dif_g = 0, spot_dif_b = 0, spot_dif_a = 0,
					spot_spec_r = 0, spot_spec_g = 0, spot_spec_b = 0, spot_spec_a = 0, spot_angle = 0, spot_exp = 0,
					spot_dir_x = 0, spot_dir_y = 0, spot_dir_z = 0;

			if (strdup(spot_id, spot->Attribute("id")) == NULL) {
				printf("Invalid id argument!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, spot->Attribute("enabled")) == NULL) {
				printf("Error on atribute \"enabled\" of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (strcmp(tmp_str, "true") == 0) {
				spot_enabled = true;
			} else if (strcmp(tmp_str, "false") == 0) {
				spot_enabled = false;
			} else {
				printf("Invalid argument of local!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, spot->Attribute("location")) == NULL) {
				printf("No attribute \"location\" of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf", &spot_location_x, &spot_location_y, &spot_location_z) != 3) {
				printf("Invalid location argument of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, spot->Attribute("ambient")) == NULL) {
				printf("No attribute \"ambient\" of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &spot_amb_r, &spot_amb_g, &spot_amb_b, &spot_amb_a) != 4) {
				printf("Invalid ambient argument of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, spot->Attribute("diffuse")) == NULL) {
				printf("No attribute \"diffuse\" of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &spot_dif_r, &spot_dif_g, &spot_dif_b, &spot_dif_a) != 4) {
				printf("Invalid diffuse argument of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, spot->Attribute("specular")) == NULL) {
				printf("No attribute \"specular\" of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf %lf", &spot_spec_r, &spot_spec_g, &spot_spec_b, &spot_spec_a) != 4) {
				printf("Invalid specular argument of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (spot->Attribute("angle", &spot_angle) == NULL) {
				printf("Invalid angle atribute of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (spot->Attribute("exponent", &spot_exp) == NULL) {
				printf("Invalid exponent atribute of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, spot->Attribute("direction")) == NULL) {
				printf("No attribute \"direction\" of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf %lf %lf", &spot_dir_x, &spot_dir_y, &spot_dir_z) != 3) {
				printf("Invalid location argument of %s light!\n", spot_id);
				throw InvalidXMLException();
			}

			Light *spot_light = new Spotlight(spot_id, spot_enabled);
			((Spotlight *) spot_light)->setLocation(spot_location_x, spot_location_y, spot_location_z);
			((Spotlight *) spot_light)->setAmbient(spot_amb_r, spot_amb_g, spot_amb_b, spot_amb_a);
			((Spotlight *) spot_light)->setDiffuse(spot_dif_r, spot_dif_g, spot_dif_b, spot_dif_a);
			((Spotlight *) spot_light)->setSpecular(spot_spec_r, spot_spec_g, spot_spec_b, spot_spec_a);
			((Spotlight *) spot_light)->setAngle(spot_angle);
			((Spotlight *) spot_light)->setExponent(spot_exp);
			((Spotlight *) spot_light)->setDir(spot_dir_x, spot_dir_y, spot_dir_z);

			Scene::getInstance()->addLight(spot_light);

			printf(
					"Spot light.\nid: %s\nenabled: %s\nlocation: (%f,%f,%f)\nambient: (%f,%f,%f,%f)\ndiffuse: (%f,%f,%f,%f)\nspec: (%f,%f,%f,%f)\nangle: %f\nexponent: %f\ndirection: (%f,%f,%f)\n\n",
					spot_id, spot_enabled ? "true" : "false", spot_location_x, spot_location_y, spot_location_z,
					spot_amb_r, spot_amb_g, spot_amb_b, spot_amb_a, spot_dif_r, spot_dif_g, spot_dif_b, spot_dif_a,
					spot_spec_r, spot_spec_g, spot_spec_b, spot_spec_a, spot_angle, spot_exp, spot_dir_x, spot_dir_y,
					spot_dir_z);
		} while ((spot = spot->NextSiblingElement("spot")) != NULL);
	} else {
		printf("There are no omni lights.\n");
	}

	if (lights_counter > 8 || lights_counter < 1) {
		printf("There are more lights than the ones that can be used. Exiting...\n");
		throw InvalidXMLException();
	}
	return true;
}
SettlementInstruction::SettlementInstruction(TiXmlNode* xmlNode)
: ISerialized(xmlNode)
{
    #ifdef ConsolePrint
        std::string initialtap_ = FileManager::instance().tap_;
        FileManager::instance().tap_.append("   ");
    #endif 
   //settlementMethodNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* settlementMethodNode = xmlNode->FirstChildElement("settlementMethod");

   if(settlementMethodNode){settlementMethodIsNull_ = false;}
   else{settlementMethodIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- settlementMethodNode , address : " << settlementMethodNode << std::endl;
   #endif
   if(settlementMethodNode)
   {
      if(settlementMethodNode->Attribute("href") || settlementMethodNode->Attribute("id"))
      {
          if(settlementMethodNode->Attribute("id"))
          {
             settlementMethodIDRef_ = settlementMethodNode->Attribute("id");
             settlementMethod_ = boost::shared_ptr<SettlementMethod>(new SettlementMethod(settlementMethodNode));
             settlementMethod_->setID(settlementMethodIDRef_);
             IDManager::instance().setID(settlementMethodIDRef_,settlementMethod_);
          }
          else if(settlementMethodNode->Attribute("href")) { settlementMethodIDRef_ = settlementMethodNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { settlementMethod_ = boost::shared_ptr<SettlementMethod>(new SettlementMethod(settlementMethodNode));}
   }

   //correspondentInformationNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* correspondentInformationNode = xmlNode->FirstChildElement("correspondentInformation");

   if(correspondentInformationNode){correspondentInformationIsNull_ = false;}
   else{correspondentInformationIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- correspondentInformationNode , address : " << correspondentInformationNode << std::endl;
   #endif
   if(correspondentInformationNode)
   {
      if(correspondentInformationNode->Attribute("href") || correspondentInformationNode->Attribute("id"))
      {
          if(correspondentInformationNode->Attribute("id"))
          {
             correspondentInformationIDRef_ = correspondentInformationNode->Attribute("id");
             correspondentInformation_ = boost::shared_ptr<CorrespondentInformation>(new CorrespondentInformation(correspondentInformationNode));
             correspondentInformation_->setID(correspondentInformationIDRef_);
             IDManager::instance().setID(correspondentInformationIDRef_,correspondentInformation_);
          }
          else if(correspondentInformationNode->Attribute("href")) { correspondentInformationIDRef_ = correspondentInformationNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { correspondentInformation_ = boost::shared_ptr<CorrespondentInformation>(new CorrespondentInformation(correspondentInformationNode));}
   }

   //intermediaryInformationNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* intermediaryInformationNode = xmlNode->FirstChildElement("intermediaryInformation");

   if(intermediaryInformationNode){intermediaryInformationIsNull_ = false;}
   else{intermediaryInformationIsNull_ = true;}

   if(intermediaryInformationNode)
   {
      for(intermediaryInformationNode; intermediaryInformationNode; intermediaryInformationNode = intermediaryInformationNode->NextSiblingElement("intermediaryInformation")){
          #ifdef ConsolePrint
              FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- intermediaryInformationNode , address : " << intermediaryInformationNode << std::endl;
          #endif
          if(intermediaryInformationNode->Attribute("href") || intermediaryInformationNode->Attribute("id"))
          {
              if(intermediaryInformationNode->Attribute("id"))
              {
                  intermediaryInformationIDRef_ = intermediaryInformationNode->Attribute("id");
                  intermediaryInformation_.push_back(boost::shared_ptr<IntermediaryInformation>(new IntermediaryInformation(intermediaryInformationNode)));
                  intermediaryInformation_.back()->setID(intermediaryInformationIDRef_);
                  IDManager::instance().setID(intermediaryInformationIDRef_, intermediaryInformation_.back());
              }
              else if(intermediaryInformationNode->Attribute("href")) { intermediaryInformationIDRef_ = intermediaryInformationNode->Attribute("href");}
              else { QL_FAIL("id or href error"); }
          }
          else { intermediaryInformation_.push_back(boost::shared_ptr<IntermediaryInformation>(new IntermediaryInformation(intermediaryInformationNode)));}
      }
   }
   else {
       #ifdef ConsolePrint
           FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- intermediaryInformationNode , address : " << intermediaryInformationNode << std::endl;
       #endif
   }

   //beneficiaryBankNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* beneficiaryBankNode = xmlNode->FirstChildElement("beneficiaryBank");

   if(beneficiaryBankNode){beneficiaryBankIsNull_ = false;}
   else{beneficiaryBankIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- beneficiaryBankNode , address : " << beneficiaryBankNode << std::endl;
   #endif
   if(beneficiaryBankNode)
   {
      if(beneficiaryBankNode->Attribute("href") || beneficiaryBankNode->Attribute("id"))
      {
          if(beneficiaryBankNode->Attribute("id"))
          {
             beneficiaryBankIDRef_ = beneficiaryBankNode->Attribute("id");
             beneficiaryBank_ = boost::shared_ptr<Beneficiary>(new Beneficiary(beneficiaryBankNode));
             beneficiaryBank_->setID(beneficiaryBankIDRef_);
             IDManager::instance().setID(beneficiaryBankIDRef_,beneficiaryBank_);
          }
          else if(beneficiaryBankNode->Attribute("href")) { beneficiaryBankIDRef_ = beneficiaryBankNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { beneficiaryBank_ = boost::shared_ptr<Beneficiary>(new Beneficiary(beneficiaryBankNode));}
   }

   //beneficiaryNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* beneficiaryNode = xmlNode->FirstChildElement("beneficiary");

   if(beneficiaryNode){beneficiaryIsNull_ = false;}
   else{beneficiaryIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- beneficiaryNode , address : " << beneficiaryNode << std::endl;
   #endif
   if(beneficiaryNode)
   {
      if(beneficiaryNode->Attribute("href") || beneficiaryNode->Attribute("id"))
      {
          if(beneficiaryNode->Attribute("id"))
          {
             beneficiaryIDRef_ = beneficiaryNode->Attribute("id");
             beneficiary_ = boost::shared_ptr<Beneficiary>(new Beneficiary(beneficiaryNode));
             beneficiary_->setID(beneficiaryIDRef_);
             IDManager::instance().setID(beneficiaryIDRef_,beneficiary_);
          }
          else if(beneficiaryNode->Attribute("href")) { beneficiaryIDRef_ = beneficiaryNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { beneficiary_ = boost::shared_ptr<Beneficiary>(new Beneficiary(beneficiaryNode));}
   }

   //depositoryPartyReferenceNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* depositoryPartyReferenceNode = xmlNode->FirstChildElement("depositoryPartyReference");

   if(depositoryPartyReferenceNode){depositoryPartyReferenceIsNull_ = false;}
   else{depositoryPartyReferenceIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- depositoryPartyReferenceNode , address : " << depositoryPartyReferenceNode << std::endl;
   #endif
   if(depositoryPartyReferenceNode)
   {
      if(depositoryPartyReferenceNode->Attribute("href") || depositoryPartyReferenceNode->Attribute("id"))
      {
          if(depositoryPartyReferenceNode->Attribute("id"))
          {
             depositoryPartyReferenceIDRef_ = depositoryPartyReferenceNode->Attribute("id");
             depositoryPartyReference_ = boost::shared_ptr<PartyReference>(new PartyReference(depositoryPartyReferenceNode));
             depositoryPartyReference_->setID(depositoryPartyReferenceIDRef_);
             IDManager::instance().setID(depositoryPartyReferenceIDRef_,depositoryPartyReference_);
          }
          else if(depositoryPartyReferenceNode->Attribute("href")) { depositoryPartyReferenceIDRef_ = depositoryPartyReferenceNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { depositoryPartyReference_ = boost::shared_ptr<PartyReference>(new PartyReference(depositoryPartyReferenceNode));}
   }

   //splitSettlementNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* splitSettlementNode = xmlNode->FirstChildElement("splitSettlement");

   if(splitSettlementNode){splitSettlementIsNull_ = false;}
   else{splitSettlementIsNull_ = true;}

   if(splitSettlementNode)
   {
      for(splitSettlementNode; splitSettlementNode; splitSettlementNode = splitSettlementNode->NextSiblingElement("splitSettlement")){
          #ifdef ConsolePrint
              FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- splitSettlementNode , address : " << splitSettlementNode << std::endl;
          #endif
          if(splitSettlementNode->Attribute("href") || splitSettlementNode->Attribute("id"))
          {
              if(splitSettlementNode->Attribute("id"))
              {
                  splitSettlementIDRef_ = splitSettlementNode->Attribute("id");
                  splitSettlement_.push_back(boost::shared_ptr<SplitSettlement>(new SplitSettlement(splitSettlementNode)));
                  splitSettlement_.back()->setID(splitSettlementIDRef_);
                  IDManager::instance().setID(splitSettlementIDRef_, splitSettlement_.back());
              }
              else if(splitSettlementNode->Attribute("href")) { splitSettlementIDRef_ = splitSettlementNode->Attribute("href");}
              else { QL_FAIL("id or href error"); }
          }
          else { splitSettlement_.push_back(boost::shared_ptr<SplitSettlement>(new SplitSettlement(splitSettlementNode)));}
      }
   }
   else {
       #ifdef ConsolePrint
           FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- splitSettlementNode , address : " << splitSettlementNode << std::endl;
       #endif
   }

    #ifdef ConsolePrint
        FileManager::instance().tap_ = initialtap_;
    #endif 
}
Пример #19
0
bool XMLScene::parseAnimations() {

	printf("Processing animations...\n\n");

	char ani_id[MAX_STRING_LEN], tmp_str[MAX_STRING_LEN];
	char ani_type[MAX_STRING_LEN];
	double ani_span;
	TiXmlElement * ani = NULL;
	if ((ani = animationsElement->FirstChildElement("animation")) != NULL) {
		do {
			if (strdup(ani_id, ani->Attribute("id")) == NULL) {
				printf("Error in \"id\" attribute!\n");
				throw InvalidXMLException();
			}

			if (strdup(tmp_str, ani->Attribute("span")) == NULL) {
				printf("Error in \"span\" attribute of %s animation!\n", ani_id);
				throw InvalidXMLException();
			}

			if (sscanf(tmp_str, "%lf", &ani_span) != 1) {
				printf("Error parsing \"span\" attribute of %s animation!\n", ani_id);
				throw InvalidXMLException();
			}

			if (strdup(ani_type, ani->Attribute("type")) == NULL) {
				printf("Error in \"type\" attribute of %s animation!\n", ani_id);
				throw InvalidXMLException();
			}
			Animation *animation = new Animation(ani_id, ani_span, ani_type);
			TiXmlElement *ctrl_point = NULL;

			if ((ctrl_point = ani->FirstChildElement("controlpoint")) == NULL) {
				printf("Block \"controlpoint\" not found!\n");
				throw InvalidXMLException();
			}

			double xx, yy, zz;
			int num_pt = 0;
			do {
				if (strdup(tmp_str, ctrl_point->Attribute("xx")) == NULL) {
					printf("Error in \"xx\" attribute of %s animation!\n", ani_id);
					throw InvalidXMLException();
				}

				if (sscanf(tmp_str, "%lf", &xx) != 1) {
					printf("Error parsing \"xx\" attribute of %s animation!\n", ani_id);
					throw InvalidXMLException();
				}

				if (strdup(tmp_str, ctrl_point->Attribute("yy")) == NULL) {
					printf("Error in \"yy\" attribute of %s animation!\n", ani_id);
					throw InvalidXMLException();
				}

				if (sscanf(tmp_str, "%lf", &yy) != 1) {
					printf("Error parsing \"yy\" attribute of %s animation!\n", ani_id);
					throw InvalidXMLException();
				}

				if (strdup(tmp_str, ctrl_point->Attribute("zz")) == NULL) {
					printf("Error in \"zz\" attribute of %s animation!\n", ani_id);
					throw InvalidXMLException();
				}

				if (sscanf(tmp_str, "%lf", &zz) != 1) {
					printf("Error parsing \"zz\" attribute of %s animation!\n", ani_id);
					throw InvalidXMLException();
				}

				animation->addPoint(xx, yy, zz);
				num_pt++;
			} while ((ctrl_point = ctrl_point->NextSiblingElement("controlpoint")) != NULL);

			if (num_pt >= 2) {
				animation->calculateDelta();
				printf("delta\n");
				Scene::getInstance()->addAnimation(ani_id, animation);
			} else {
				printf("Error! Animation %s doesn't have enought control points!", ani_id);
				throw InvalidXMLException();
			}

		} while ((ani = ani->NextSiblingElement("animation")) != NULL);
	}

	return true;
}
Пример #20
0
/*
Find function in XML structure and parse it
*/
bool FunctionCallTip::loadFunction()
{
	reset();	//set everything back to 0
	//The functions should be ordered, but linear search because we cant access like array
	_curFunction = NULL;
	//Iterate through all keywords and find the correct function keyword
	TiXmlElement *funcNode = _pXmlKeyword;
	
	for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")))
	{
		const TCHAR * name = NULL;
		name = funcNode->Attribute(TEXT("name"));
		if (!name)		//malformed node
			continue;
		int compVal = 0;
		if (_ignoreCase)
			compVal = testNameNoCase(name, _funcName);	//lstrcmpi doesnt work in this case
		else
			compVal = lstrcmp(name, _funcName);
		if (!compVal) 	//found it!
        {
			const TCHAR * val = funcNode->Attribute(TEXT("func"));
			if (val)
			{
				if (!lstrcmp(val, TEXT("yes"))) 
                {
					//what we've been looking for
					_curFunction = funcNode;
					break;
				}
				else 
                {
					//name matches, but not a function, abort the entire procedure
					return false;
				}
			}
		}
	}

	//Nothing found
	if (!_curFunction)
		return false;

	stringVec paramVec;

	TiXmlElement *overloadNode = _curFunction->FirstChildElement(TEXT("Overload"));
	TiXmlElement *paramNode = NULL;
	for (; overloadNode ; overloadNode = overloadNode->NextSiblingElement(TEXT("Overload")) ) {
		const TCHAR * retVal = overloadNode->Attribute(TEXT("retVal"));
		if (!retVal)
			continue;	//malformed node
		_retVals.push_back(retVal);

		const TCHAR * description = overloadNode->Attribute(TEXT("descr"));
		if (description)
			_descriptions.push_back(description);
		else
			_descriptions.push_back(TEXT(""));	//"no description available"

		paramNode = overloadNode->FirstChildElement(TEXT("Param"));
		for (; paramNode ; paramNode = paramNode->NextSiblingElement(TEXT("Param")) ) {
			const TCHAR * param = paramNode->Attribute(TEXT("name"));
			if (!param)
				continue;	//malformed node
			paramVec.push_back(param);
		}
		_overloads.push_back(paramVec);
		paramVec.clear();

		++_currentNrOverloads;
	}

	_currentNrOverloads = _overloads.size();

	if (_currentNrOverloads == 0)	//malformed node
		return false;

	return true;
}
Пример #21
0
bool SQRGUIStyle::Initialize(void)
{
	if(!m_isLoad)
	{
		ipkgstream iXML;
		TiXmlDocument XmlDoc;
		UIString Str = m_strStylePath + "Config.xml";
		if (iXML.open(GUI_PATH_ALIAS_GUI.c_str(), Str.c_str()))
			return false;

		iXML>>XmlDoc;

		TiXmlNode* pStyle = XmlDoc.FirstChild("Style");

		for( TiXmlNode* pNode = pStyle->FirstChild("GUI");pNode; pNode = pNode->NextSibling("GUI") )
		{
			TiXmlElement* pElement = pNode->ToElement();
			if (!pElement)
				continue;
			StyleStruct* pStyle = SetStyleStruct(pElement->Attribute("Name"),StyleStruct());

			pStyle->m_TexString =  pElement->Attribute("Texture");
			Str = m_strTexture + pStyle->m_TexString;
			if(pStyle->m_TexString.size()>0)
				CGraphic::GetInst()->CreateTexture(GUI_PATH_ALIAS_GUITEX.c_str(), Str.c_str(), &(pStyle->pTexture));

			for( TiXmlNode* pElemNode = pNode->FirstChild("Elem"); pElemNode; pElemNode = pElemNode->NextSibling("Elem") )
			{
				TiXmlElement* pElem  = pElemNode->ToElement();
				if(!pElem)
					continue;
				int		Type;
				pElem->QueryIntAttribute("EventState",&Type);
				BLOCK_POOL& BlockPool = pStyle->m_vecPool[static_cast<EventStateMask>(Type)];

				for( TiXmlNode* pBlockPoolNode = pElemNode->FirstChild("BlockPool"); pBlockPoolNode; pBlockPoolNode = pBlockPoolNode->NextSibling("BlockPool") )
				{
					TiXmlElement* pElemBlockPool  = pBlockPoolNode->ToElement();
					if (!pElemBlockPool)
						continue;
					int Index;
					pElemBlockPool->QueryIntAttribute("Index",&Index);
					if( static_cast<UINT>(Index)>BLOCK_POOL::MAX_BLOCK_NUM || Index < 1)
						continue;

					GUI_BLOCK& Block = BlockPool.InitBlock(Index);
					for( TiXmlNode* pBlockNode = pElemBlockPool->FirstChild("Block"); pBlockNode; pBlockNode = pBlockNode->NextSibling("Block") )
					{
						CFRect	Rect;
						int		BlockMask;
						TiXmlElement* pElemBlock  = pBlockNode->ToElement();
						if (!pElemBlock)
							continue;
						pElemBlock->QueryIntAttribute("BlockMask",&BlockMask);
						pElemBlock->QueryFloatAttribute("Top",&(Rect.top));
						pElemBlock->QueryFloatAttribute("Left",&(Rect.left));
						pElemBlock->QueryFloatAttribute("Right",&(Rect.right));
						pElemBlock->QueryFloatAttribute("Bottom",&(Rect.bottom));
						Block[BlockMask] = Rect;
					}

					TiXmlNode* pFontNode = pElemBlockPool->FirstChild("Font");
					if ( pFontNode )
					{
						// 有font信息
						TiXmlElement* pElemFont = pFontNode->ToElement();
						if (!pElemFont)
							continue;

						if (pStyle->m_vecFont.find(Index) == pStyle->m_vecFont.end())
							pStyle->m_vecFont[Index] = new GUI_FONT();
						GUI_FONT* GuiFont = pStyle->m_vecFont[Index];


						std::string winFontId = pElemFont->Attribute(GUILayoutHandler::PropertyNameFont.c_str());
						int32 fontid;
						integer(winFontId,fontid);
						GuiFont->m_nFontID			= fontid;

						std::string winFontSize = pElemFont->Attribute(GUILayoutHandler::PropertyNameFontSize.c_str());
						uint32 FontSize;
						uinteger(winFontSize,FontSize);
						GuiFont->m_FontSize = uint32(FontSize);

						

						std::string winFGCol = pElemFont->Attribute(GUILayoutHandler::PropertyNameFontGCol.c_str());
						uint32 tempCol;
						uinteger(winFGCol, tempCol);
						GuiFont->m_uFontGradualColor = (uint32)tempCol;

						std::string winFGEff = pElemFont->Attribute(GUILayoutHandler::PropertyNameFontEffe.c_str());
						uint32 tempeff;
						uinteger(winFGEff, tempeff);
						GuiFont->m_uFontEffectMask = (uint32)tempeff;
					}
					TiXmlNode* pEvtFontNode = pElemBlockPool->FirstChild("EvtFont");
					if (pEvtFontNode)
					{
						TiXmlElement* pElemFont = pEvtFontNode->ToElement();
						if (!pElemFont)
							continue;
						// 有这类结点
						if (pStyle->m_vecFont.find(Index) != pStyle->m_vecFont.end())
						{
							// 只有创建过的才去读
							GUI_FONT* GuiFont = pStyle->m_vecFont[Index];
							if (GuiFont)
							{
								// 字体颜色
								std::string sStateCol = pElemFont->Attribute(GUILayoutHandler::PropertyStateColor.c_str());
								uint32 iStateCol;
								uinteger(sStateCol, iStateCol);
								GuiFont->m_EventFont[static_cast<EventStateMask>(Type)].m_FontColor =  (uint32)iStateCol;

								std::string sRimCol = pElemFont->Attribute(GUILayoutHandler::PropertyRimColor.c_str());
								uint32 iRimCol;
								uinteger(sRimCol, iRimCol);
								GuiFont->m_EventFont[static_cast<EventStateMask>(Type)].m_uFontBkColor = (uint32)iRimCol;
							}
						}
					}
				}
			}
		}
		m_isLoad = true;
	}
    // ---------------------------------------------------------
    // set positions and orientations.
    void XMLSkeletonSerializer::readBones2(Skeleton* skel, TiXmlElement* mBonesNode)
    {
        LogManager::getSingleton().logMessage("XMLSkeletonSerializer: Reading Bones data...");

        Bone* btmp;
        Quaternion quat;

        for (TiXmlElement* bonElem = mBonesNode->FirstChildElement();
            bonElem != 0; bonElem = bonElem->NextSiblingElement())
        {
            String name = bonElem->Attribute("name");
            //			int id = StringConverter::parseInt(bonElem->Attribute("id"));

            TiXmlElement* posElem = bonElem->FirstChildElement("position");
            TiXmlElement* rotElem = bonElem->FirstChildElement("rotation");
            TiXmlElement* axisElem = rotElem->FirstChildElement("axis");
            TiXmlElement* scaleElem = bonElem->FirstChildElement("scale");

            Vector3 pos;
            Vector3 axis;
            Radian angle;
            Vector3 scale;

            pos.x = StringConverter::parseReal(posElem->Attribute("x"));
            pos.y = StringConverter::parseReal(posElem->Attribute("y"));
            pos.z = StringConverter::parseReal(posElem->Attribute("z"));

            angle = Radian(StringConverter::parseReal(rotElem->Attribute("angle")));

            axis.x = StringConverter::parseReal(axisElem->Attribute("x"));
            axis.y = StringConverter::parseReal(axisElem->Attribute("y"));
            axis.z = StringConverter::parseReal(axisElem->Attribute("z"));

            // Optional scale
            if (scaleElem)
            {
                // Uniform scale or per axis?
                const char* factorAttrib = scaleElem->Attribute("factor");
                if (factorAttrib)
                {
                    // Uniform scale
                    Real factor = StringConverter::parseReal(factorAttrib);
                    scale = Vector3(factor, factor, factor);
                }
                else
                {
                    // axis scale
                    scale = Vector3::UNIT_SCALE;
                    const char* factorString = scaleElem->Attribute("x");
                    if (factorString)
                    {
                        scale.x = StringConverter::parseReal(factorString);
                    }
                    factorString = scaleElem->Attribute("y");
                    if (factorString)
                    {
                        scale.y = StringConverter::parseReal(factorString);
                    }
                    factorString = scaleElem->Attribute("z");
                    if (factorString)
                    {
                        scale.z = StringConverter::parseReal(factorString);
                    }
                }
            }
            else
            {
                scale = Vector3::UNIT_SCALE;
            }

            /*LogManager::getSingleton().logMessage("bone " + name + " : position("
            + StringConverter::toString(pos.x) + "," + StringConverter::toString(pos.y) + "," + StringConverter::toString(pos.z) + ")"
            + " - angle: " + StringConverter::toString(angle) +" - axe: "
            + StringConverter::toString(axis.x) + "," + StringConverter::toString(axis.y) + "," + StringConverter::toString(axis.z) );
            */

            btmp = skel->getBone(name);

            btmp->setPosition(pos);
            quat.FromAngleAxis(angle, axis);
            btmp->setOrientation(quat);
            btmp->setScale(scale);

        } // bones
    }
SensitivitySet::SensitivitySet(TiXmlNode* xmlNode)
: ISerialized(xmlNode)
{
    #ifdef ConsolePrint
        std::string initialtap_ = FileManager::instance().tap_;
        FileManager::instance().tap_.append("   ");
    #endif 
   //nameNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* nameNode = xmlNode->FirstChildElement("name");

   if(nameNode){nameIsNull_ = false;}
   else{nameIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- nameNode , address : " << nameNode << std::endl;
   #endif
   if(nameNode)
   {
      if(nameNode->Attribute("href") || nameNode->Attribute("id"))
      {
          if(nameNode->Attribute("id"))
          {
             nameIDRef_ = nameNode->Attribute("id");
             name_ = boost::shared_ptr<XsdTypeString>(new XsdTypeString(nameNode));
             name_->setID(nameIDRef_);
             IDManager::instance().setID(nameIDRef_,name_);
          }
          else if(nameNode->Attribute("href")) { nameIDRef_ = nameNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { name_ = boost::shared_ptr<XsdTypeString>(new XsdTypeString(nameNode));}
   }

   //definitionReferenceNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* definitionReferenceNode = xmlNode->FirstChildElement("definitionReference");

   if(definitionReferenceNode){definitionReferenceIsNull_ = false;}
   else{definitionReferenceIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- definitionReferenceNode , address : " << definitionReferenceNode << std::endl;
   #endif
   if(definitionReferenceNode)
   {
      if(definitionReferenceNode->Attribute("href") || definitionReferenceNode->Attribute("id"))
      {
          if(definitionReferenceNode->Attribute("id"))
          {
             definitionReferenceIDRef_ = definitionReferenceNode->Attribute("id");
             definitionReference_ = boost::shared_ptr<SensitivitySetDefinitionReference>(new SensitivitySetDefinitionReference(definitionReferenceNode));
             definitionReference_->setID(definitionReferenceIDRef_);
             IDManager::instance().setID(definitionReferenceIDRef_,definitionReference_);
          }
          else if(definitionReferenceNode->Attribute("href")) { definitionReferenceIDRef_ = definitionReferenceNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { definitionReference_ = boost::shared_ptr<SensitivitySetDefinitionReference>(new SensitivitySetDefinitionReference(definitionReferenceNode));}
   }

   //sensitivityNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* sensitivityNode = xmlNode->FirstChildElement("sensitivity");

   if(sensitivityNode){sensitivityIsNull_ = false;}
   else{sensitivityIsNull_ = true;}

   if(sensitivityNode)
   {
      for(sensitivityNode; sensitivityNode; sensitivityNode = sensitivityNode->NextSiblingElement("sensitivity")){
          #ifdef ConsolePrint
              FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- sensitivityNode , address : " << sensitivityNode << std::endl;
          #endif
          if(sensitivityNode->Attribute("href") || sensitivityNode->Attribute("id"))
          {
              if(sensitivityNode->Attribute("id"))
              {
                  sensitivityIDRef_ = sensitivityNode->Attribute("id");
                  sensitivity_.push_back(boost::shared_ptr<Sensitivity>(new Sensitivity(sensitivityNode)));
                  sensitivity_.back()->setID(sensitivityIDRef_);
                  IDManager::instance().setID(sensitivityIDRef_, sensitivity_.back());
              }
              else if(sensitivityNode->Attribute("href")) { sensitivityIDRef_ = sensitivityNode->Attribute("href");}
              else { QL_FAIL("id or href error"); }
          }
          else { sensitivity_.push_back(boost::shared_ptr<Sensitivity>(new Sensitivity(sensitivityNode)));}
      }
   }
   else {
       #ifdef ConsolePrint
           FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- sensitivityNode , address : " << sensitivityNode << std::endl;
       #endif
   }

    #ifdef ConsolePrint
        FileManager::instance().tap_ = initialtap_;
    #endif 
}
    //---------------------------------------------------------------------
    void XMLSkeletonSerializer::readKeyFrames(NodeAnimationTrack* track, TiXmlElement* mKeyfNode) {

        TransformKeyFrame* kf;
        Quaternion q;

        for (TiXmlElement* keyfElem = mKeyfNode->FirstChildElement("keyframe"); keyfElem != 0; keyfElem = keyfElem->NextSiblingElement())
        {
            Vector3 trans;
            Vector3 axis;
            Radian angle;
            Real time;

            // Get time and create keyframe
            time = StringConverter::parseReal(keyfElem->Attribute("time"));
            kf = track->createNodeKeyFrame(time);
            // Optional translate
            TiXmlElement* transElem = keyfElem->FirstChildElement("translate");
            if (transElem)
            {
                trans.x = StringConverter::parseReal(transElem->Attribute("x"));
                trans.y = StringConverter::parseReal(transElem->Attribute("y"));
                trans.z = StringConverter::parseReal(transElem->Attribute("z"));
                kf->setTranslate(trans);
            }
            // Optional rotate
            TiXmlElement* rotElem = keyfElem->FirstChildElement("rotate");
            if (rotElem)
            {
                TiXmlElement* axisElem = rotElem->FirstChildElement("axis");
                if (!axisElem)
                {
                    OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Missing 'axis' element "
                        "expected under parent 'rotate'", "MXLSkeletonSerializer::readKeyFrames");
                }
                angle = Radian(StringConverter::parseReal(rotElem->Attribute("angle")));

                axis.x = StringConverter::parseReal(axisElem->Attribute("x"));
                axis.y = StringConverter::parseReal(axisElem->Attribute("y"));
                axis.z = StringConverter::parseReal(axisElem->Attribute("z"));

                q.FromAngleAxis(angle, axis);
                kf->setRotation(q);

            }
            // Optional scale
            TiXmlElement* scaleElem = keyfElem->FirstChildElement("scale");
            if (scaleElem)
            {
                // Uniform scale or per axis?
                const char* factorAttrib = scaleElem->Attribute("factor");
                if (factorAttrib)
                {
                    // Uniform scale
                    Real factor = StringConverter::parseReal(factorAttrib);
                    kf->setScale(Vector3(factor, factor, factor));
                }
                else
                {
                    // axis scale
                    Real xs = 1.0f, ys = 1.0f, zs = 1.0f;
                    const char* factorString = scaleElem->Attribute("x");
                    if (factorString)
                    {
                        xs = StringConverter::parseReal(factorString);
                    }
                    factorString = scaleElem->Attribute("y");
                    if (factorString)
                    {
                        ys = StringConverter::parseReal(factorString);
                    }
                    factorString = scaleElem->Attribute("z");
                    if (factorString)
                    {
                        zs = StringConverter::parseReal(factorString);
                    }
                    kf->setScale(Vector3(xs, ys, zs));

                }
            }


            /*
            LogManager::getSingleton().logMessage("Keyframe: translation("
            + StringConverter::toString(trans.x) + "," + StringConverter::toString(trans.y) + "," + StringConverter::toString(trans.z) + ")"
            + " - angle: " + StringConverter::toString(angle) +" - axe: "
            + StringConverter::toString(axis.x) + "," + StringConverter::toString(axis.y) + "," + StringConverter::toString(axis.z) );
            */


        }
    }
CreditEventNotice::CreditEventNotice(TiXmlNode* xmlNode)
: ISerialized(xmlNode)
{
    #ifdef ConsolePrint
        std::string initialtap_ = FileManager::instance().tap_;
        FileManager::instance().tap_.append("   ");
    #endif 
   //notifyingPartyNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* notifyingPartyNode = xmlNode->FirstChildElement("notifyingParty");

   if(notifyingPartyNode){notifyingPartyIsNull_ = false;}
   else{notifyingPartyIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- notifyingPartyNode , address : " << notifyingPartyNode << std::endl;
   #endif
   if(notifyingPartyNode)
   {
      if(notifyingPartyNode->Attribute("href") || notifyingPartyNode->Attribute("id"))
      {
          if(notifyingPartyNode->Attribute("id"))
          {
             notifyingPartyIDRef_ = notifyingPartyNode->Attribute("id");
             notifyingParty_ = boost::shared_ptr<NotifyingParty>(new NotifyingParty(notifyingPartyNode));
             notifyingParty_->setID(notifyingPartyIDRef_);
             IDManager::instance().setID(notifyingPartyIDRef_,notifyingParty_);
          }
          else if(notifyingPartyNode->Attribute("href")) { notifyingPartyIDRef_ = notifyingPartyNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { notifyingParty_ = boost::shared_ptr<NotifyingParty>(new NotifyingParty(notifyingPartyNode));}
   }

   //businessCenterNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* businessCenterNode = xmlNode->FirstChildElement("businessCenter");

   if(businessCenterNode){businessCenterIsNull_ = false;}
   else{businessCenterIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- businessCenterNode , address : " << businessCenterNode << std::endl;
   #endif
   if(businessCenterNode)
   {
      if(businessCenterNode->Attribute("href") || businessCenterNode->Attribute("id"))
      {
          if(businessCenterNode->Attribute("id"))
          {
             businessCenterIDRef_ = businessCenterNode->Attribute("id");
             businessCenter_ = boost::shared_ptr<BusinessCenter>(new BusinessCenter(businessCenterNode));
             businessCenter_->setID(businessCenterIDRef_);
             IDManager::instance().setID(businessCenterIDRef_,businessCenter_);
          }
          else if(businessCenterNode->Attribute("href")) { businessCenterIDRef_ = businessCenterNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { businessCenter_ = boost::shared_ptr<BusinessCenter>(new BusinessCenter(businessCenterNode));}
   }

   //publiclyAvailableInformationNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* publiclyAvailableInformationNode = xmlNode->FirstChildElement("publiclyAvailableInformation");

   if(publiclyAvailableInformationNode){publiclyAvailableInformationIsNull_ = false;}
   else{publiclyAvailableInformationIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- publiclyAvailableInformationNode , address : " << publiclyAvailableInformationNode << std::endl;
   #endif
   if(publiclyAvailableInformationNode)
   {
      if(publiclyAvailableInformationNode->Attribute("href") || publiclyAvailableInformationNode->Attribute("id"))
      {
          if(publiclyAvailableInformationNode->Attribute("id"))
          {
             publiclyAvailableInformationIDRef_ = publiclyAvailableInformationNode->Attribute("id");
             publiclyAvailableInformation_ = boost::shared_ptr<PubliclyAvailableInformation>(new PubliclyAvailableInformation(publiclyAvailableInformationNode));
             publiclyAvailableInformation_->setID(publiclyAvailableInformationIDRef_);
             IDManager::instance().setID(publiclyAvailableInformationIDRef_,publiclyAvailableInformation_);
          }
          else if(publiclyAvailableInformationNode->Attribute("href")) { publiclyAvailableInformationIDRef_ = publiclyAvailableInformationNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { publiclyAvailableInformation_ = boost::shared_ptr<PubliclyAvailableInformation>(new PubliclyAvailableInformation(publiclyAvailableInformationNode));}
   }

    #ifdef ConsolePrint
        FileManager::instance().tap_ = initialtap_;
    #endif 
}
LegIdentifier::LegIdentifier(TiXmlNode* xmlNode)
: ISerialized(xmlNode)
{
    #ifdef ConsolePrint
        std::string initialtap_ = FileManager::instance().tap_;
        FileManager::instance().tap_.append("   ");
    #endif 
   //legIdNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* legIdNode = xmlNode->FirstChildElement("legId");

   if(legIdNode){legIdIsNull_ = false;}
   else{legIdIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- legIdNode , address : " << legIdNode << std::endl;
   #endif
   if(legIdNode)
   {
      if(legIdNode->Attribute("href") || legIdNode->Attribute("id"))
      {
          if(legIdNode->Attribute("id"))
          {
             legIdIDRef_ = legIdNode->Attribute("id");
             legId_ = boost::shared_ptr<LegId>(new LegId(legIdNode));
             legId_->setID(legIdIDRef_);
             IDManager::instance().setID(legIdIDRef_,legId_);
          }
          else if(legIdNode->Attribute("href")) { legIdIDRef_ = legIdNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { legId_ = boost::shared_ptr<LegId>(new LegId(legIdNode));}
   }

   //versionNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* versionNode = xmlNode->FirstChildElement("version");

   if(versionNode){versionIsNull_ = false;}
   else{versionIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- versionNode , address : " << versionNode << std::endl;
   #endif
   if(versionNode)
   {
      if(versionNode->Attribute("href") || versionNode->Attribute("id"))
      {
          if(versionNode->Attribute("id"))
          {
             versionIDRef_ = versionNode->Attribute("id");
             version_ = boost::shared_ptr<XsdTypeNonNegativeInteger>(new XsdTypeNonNegativeInteger(versionNode));
             version_->setID(versionIDRef_);
             IDManager::instance().setID(versionIDRef_,version_);
          }
          else if(versionNode->Attribute("href")) { versionIDRef_ = versionNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { version_ = boost::shared_ptr<XsdTypeNonNegativeInteger>(new XsdTypeNonNegativeInteger(versionNode));}
   }

   //effectiveDateNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* effectiveDateNode = xmlNode->FirstChildElement("effectiveDate");

   if(effectiveDateNode){effectiveDateIsNull_ = false;}
   else{effectiveDateIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- effectiveDateNode , address : " << effectiveDateNode << std::endl;
   #endif
   if(effectiveDateNode)
   {
      if(effectiveDateNode->Attribute("href") || effectiveDateNode->Attribute("id"))
      {
          if(effectiveDateNode->Attribute("id"))
          {
             effectiveDateIDRef_ = effectiveDateNode->Attribute("id");
             effectiveDate_ = boost::shared_ptr<IdentifiedDate>(new IdentifiedDate(effectiveDateNode));
             effectiveDate_->setID(effectiveDateIDRef_);
             IDManager::instance().setID(effectiveDateIDRef_,effectiveDate_);
          }
          else if(effectiveDateNode->Attribute("href")) { effectiveDateIDRef_ = effectiveDateNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { effectiveDate_ = boost::shared_ptr<IdentifiedDate>(new IdentifiedDate(effectiveDateNode));}
   }

    #ifdef ConsolePrint
        FileManager::instance().tap_ = initialtap_;
    #endif 
}
Пример #27
0
void CCutscene::Initialize(std::string szFilename)
{
    m_cCameraController = new CCameraController(this);
    if (szFilename == "Test")
    {
        XMFLOAT4X4 f44World = {
            1, 0, 0, 0,
            0, 1, 0, 0,
            0, 0, 1, 0,
            0, 500, 0, 1
        };
        CCameraFrame* pCameraFrame = new CCameraFrame(5.0f, false, f44World);
        m_cCameraController->GetFrames().push_back(pCameraFrame);
        m_fCutsceneTime = 3.0f;
    }
    else
    {
        //Load from XML TODO
        std::string szFullFilepath;
        szFullFilepath = "../Game/Assets/Scripts/Cutscene/" + szFilename;
        TiXmlDocument Doc;
        if (Doc.LoadFile(szFullFilepath.c_str(), TiXmlEncoding::TIXML_ENCODING_UTF8))
        {
            TiXmlElement * root = Doc.RootElement();
            TiXmlElement * CameraFrameElmt = root->FirstChildElement("CameraFrame");
            m_fCutsceneTime = 0.0f;
            while (CameraFrameElmt != nullptr)
            {
                double dLook[3];
                double dPos[3];
                double dFrameTime;
                int nShouldInterpolate;
                CameraFrameElmt->Attribute("lookDirX", &dLook[0]);
                CameraFrameElmt->Attribute("lookDirY", &dLook[1]);
                CameraFrameElmt->Attribute("lookDirZ", &dLook[2]);
                CameraFrameElmt->Attribute("posX", &dPos[0]);
                CameraFrameElmt->Attribute("posY", &dPos[1]);
                CameraFrameElmt->Attribute("posZ", &dPos[2]);
                CameraFrameElmt->Attribute("frameTime", &dFrameTime);
                CameraFrameElmt->Attribute("shouldInterpolate", &nShouldInterpolate);

                //Do Look At Algorithm to find Matrix of Frame

                XMFLOAT4X4 f44WorldMatrix;
                XMVECTOR vecZAxis = { (float)dLook[0], (float)dLook[1], (float)dLook[2], 0 };
                vecZAxis = XMVector3Normalize(vecZAxis);
                XMVECTOR vecUp = { 0, 1, 0, 0 };
                XMVECTOR vecXAxis = XMVector3Cross(vecUp, vecZAxis);
                vecXAxis = XMVector3Normalize(vecXAxis);
                XMVECTOR vecYAxis = XMVector3Cross(vecZAxis, vecXAxis);
                vecYAxis = XMVector2Normalize(vecYAxis);
                f44WorldMatrix.m[0][0] = vecXAxis.m128_f32[0];
                f44WorldMatrix.m[0][1] = vecXAxis.m128_f32[1];
                f44WorldMatrix.m[0][2] = vecXAxis.m128_f32[2];
                f44WorldMatrix.m[0][3] = 0;
                f44WorldMatrix.m[1][0] = vecYAxis.m128_f32[0];
                f44WorldMatrix.m[1][1] = vecYAxis.m128_f32[1];
                f44WorldMatrix.m[1][2] = vecYAxis.m128_f32[2];
                f44WorldMatrix.m[1][3] = 0;
                f44WorldMatrix.m[2][0] = vecZAxis.m128_f32[0];
                f44WorldMatrix.m[2][1] = vecZAxis.m128_f32[1];
                f44WorldMatrix.m[2][2] = vecZAxis.m128_f32[2];
                f44WorldMatrix.m[2][3] = 0;
                f44WorldMatrix.m[3][0] = (float)dPos[0];
                f44WorldMatrix.m[3][1] = (float)dPos[1];
                f44WorldMatrix.m[3][2] = (float)dPos[2];
                f44WorldMatrix.m[3][3] = 1;
                CCameraFrame* pCameraFrame = new CCameraFrame((float)dFrameTime, nShouldInterpolate,f44WorldMatrix);
                m_cCameraController->GetFrames().push_back(pCameraFrame);
                m_fCutsceneTime += (float)dFrameTime;
                CameraFrameElmt = CameraFrameElmt->NextSiblingElement("CameraFrame");
            }
        }
    }
}
CommodityMetalBrand::CommodityMetalBrand(TiXmlNode* xmlNode)
: ISerialized(xmlNode)
{
    #ifdef ConsolePrint
        std::string initialtap_ = FileManager::instance().tap_;
        FileManager::instance().tap_.append("   ");
    #endif 
   //nameNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* nameNode = xmlNode->FirstChildElement("name");

   if(nameNode){nameIsNull_ = false;}
   else{nameIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- nameNode , address : " << nameNode << std::endl;
   #endif
   if(nameNode)
   {
      if(nameNode->Attribute("href") || nameNode->Attribute("id"))
      {
          if(nameNode->Attribute("id"))
          {
             nameIDRef_ = nameNode->Attribute("id");
             name_ = boost::shared_ptr<CommodityMetalBrandName>(new CommodityMetalBrandName(nameNode));
             name_->setID(nameIDRef_);
             IDManager::instance().setID(nameIDRef_,name_);
          }
          else if(nameNode->Attribute("href")) { nameIDRef_ = nameNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { name_ = boost::shared_ptr<CommodityMetalBrandName>(new CommodityMetalBrandName(nameNode));}
   }

   //brandManagerNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* brandManagerNode = xmlNode->FirstChildElement("brandManager");

   if(brandManagerNode){brandManagerIsNull_ = false;}
   else{brandManagerIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- brandManagerNode , address : " << brandManagerNode << std::endl;
   #endif
   if(brandManagerNode)
   {
      if(brandManagerNode->Attribute("href") || brandManagerNode->Attribute("id"))
      {
          if(brandManagerNode->Attribute("id"))
          {
             brandManagerIDRef_ = brandManagerNode->Attribute("id");
             brandManager_ = boost::shared_ptr<CommodityMetalBrandManager>(new CommodityMetalBrandManager(brandManagerNode));
             brandManager_->setID(brandManagerIDRef_);
             IDManager::instance().setID(brandManagerIDRef_,brandManager_);
          }
          else if(brandManagerNode->Attribute("href")) { brandManagerIDRef_ = brandManagerNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { brandManager_ = boost::shared_ptr<CommodityMetalBrandManager>(new CommodityMetalBrandManager(brandManagerNode));}
   }

   //countryNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* countryNode = xmlNode->FirstChildElement("country");

   if(countryNode){countryIsNull_ = false;}
   else{countryIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- countryNode , address : " << countryNode << std::endl;
   #endif
   if(countryNode)
   {
      if(countryNode->Attribute("href") || countryNode->Attribute("id"))
      {
          if(countryNode->Attribute("id"))
          {
             countryIDRef_ = countryNode->Attribute("id");
             country_ = boost::shared_ptr<CountryCode>(new CountryCode(countryNode));
             country_->setID(countryIDRef_);
             IDManager::instance().setID(countryIDRef_,country_);
          }
          else if(countryNode->Attribute("href")) { countryIDRef_ = countryNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { country_ = boost::shared_ptr<CountryCode>(new CountryCode(countryNode));}
   }

   //producerNode ----------------------------------------------------------------------------------------------------------------------
   TiXmlElement* producerNode = xmlNode->FirstChildElement("producer");

   if(producerNode){producerIsNull_ = false;}
   else{producerIsNull_ = true;}

   #ifdef ConsolePrint
      FileManager::instance().outFile_ << FileManager::instance().tap_.c_str() << "- producerNode , address : " << producerNode << std::endl;
   #endif
   if(producerNode)
   {
      if(producerNode->Attribute("href") || producerNode->Attribute("id"))
      {
          if(producerNode->Attribute("id"))
          {
             producerIDRef_ = producerNode->Attribute("id");
             producer_ = boost::shared_ptr<CommodityMetalProducer>(new CommodityMetalProducer(producerNode));
             producer_->setID(producerIDRef_);
             IDManager::instance().setID(producerIDRef_,producer_);
          }
          else if(producerNode->Attribute("href")) { producerIDRef_ = producerNode->Attribute("href");}
          else { QL_FAIL("id or href error"); }
      }
      else { producer_ = boost::shared_ptr<CommodityMetalProducer>(new CommodityMetalProducer(producerNode));}
   }

    #ifdef ConsolePrint
        FileManager::instance().tap_ = initialtap_;
    #endif 
}
Пример #29
0
void CMusicInfoScraper::FindAlbumInfo()
{
  CStdString strAlbum=m_strAlbum;
  CStdString strHTML;
  m_vecAlbums.erase(m_vecAlbums.begin(), m_vecAlbums.end());

  if (!m_scraper->Load() || !m_scraper->GetParser().HasFunction("CreateAlbumSearchUrl"))
    return;

  CLog::Log(LOGDEBUG, "%s: Searching for '%s - %s' using %s scraper (path: '%s', content: '%s', version: '%s')",
    __FUNCTION__, m_strArtist.c_str(), strAlbum.c_str(), m_scraper->Name().c_str(), m_scraper->Path().c_str(),
    ADDON::TranslateContent(m_scraper->Content()).c_str(), m_scraper->Version().c_str());
  
  vector<CStdString> extras;
  extras.push_back(strAlbum);
  extras.push_back(m_strArtist);
  g_charsetConverter.utf8To(m_scraper->GetParser().GetSearchStringEncoding(), strAlbum, extras[0]);
  g_charsetConverter.utf8To(m_scraper->GetParser().GetSearchStringEncoding(), m_strArtist, extras[1]);
  CURL::Encode(extras[0]);
  CURL::Encode(extras[1]);

  CScraperUrl scrURL;
  vector<CStdString> url = m_scraper->Run("CreateAlbumSearchUrl",scrURL,m_http,&extras);
  if (url.empty())
    return;
  scrURL.ParseString(url[0]);
  vector<CStdString> xml = m_scraper->Run("GetAlbumSearchResults",scrURL,m_http);

  for (vector<CStdString>::iterator it  = xml.begin();
                                    it != xml.end(); ++it)
  {
    // ok, now parse the xml file
    TiXmlDocument doc;
    doc.Parse(it->c_str(),0,TIXML_ENCODING_UTF8);
    TiXmlHandle docHandle( &doc );
    TiXmlElement* album = docHandle.FirstChild( "results" ).FirstChild( "entity" ).Element();

    while (album)
    {
      TiXmlNode* title = album->FirstChild("title");
      TiXmlElement* link = album->FirstChildElement("url");
      TiXmlNode* artist = album->FirstChild("artist");
      TiXmlNode* year = album->FirstChild("year");
      TiXmlElement* relevance = album->FirstChildElement("relevance");
      if (title && title->FirstChild())
      {
        CStdString strTitle = title->FirstChild()->Value();
        CStdString strArtist;
        CStdString strAlbumName;

        if (artist && artist->FirstChild())
        {
          strArtist = artist->FirstChild()->Value();
          strAlbumName.Format("%s - %s",strArtist.c_str(),strTitle.c_str());
        }
        else
          strAlbumName = strTitle;

        if (year && year->FirstChild())
          strAlbumName.Format("%s (%s)",strAlbumName.c_str(),year->FirstChild()->Value());

        CScraperUrl url;
        if (!link)
          url.ParseString(scrURL.m_xml);

        while (link && link->FirstChild())
        {
          url.ParseElement(link);
          link = link->NextSiblingElement("url");
        }
        CMusicAlbumInfo newAlbum(strTitle, strArtist, strAlbumName, url);
        if (relevance && relevance->FirstChild())
        {
          float scale=1;
          const char* newscale = relevance->Attribute("scale");
          if (newscale)
            scale = (float)atof(newscale);
          newAlbum.SetRelevance((float)atof(relevance->FirstChild()->Value())/scale);
        }
        m_vecAlbums.push_back(newAlbum);
      }
      album = album->NextSiblingElement();
    }
  }

  if (m_vecAlbums.size()>0)
    m_bSucceeded=true;

  return;
}
Пример #30
0
TiXmlElement* wxsVersionConverter::ConvertFromOldConfig(TiXmlElement* ConfigNode,TiXmlDocument* Doc,wxsProject* Project) const
{
    if ( cbMessageBox(_("This project uses old wxSmith configuration format\n"
                        "Would you like me to convert to new one?\n"),
                      _("wxSmith: Converting from old format"),
                      wxYES_NO) != wxID_YES ) return 0;

    TiXmlElement* NewConfig = Doc->InsertEndChild(TiXmlElement("wxSmith"))->ToElement();
    TiXmlElement* Resources = NewConfig->InsertEndChild(TiXmlElement("resources"))->ToElement();
    NewConfig->SetAttribute("version",CurrentVersionStr);
    for ( TiXmlElement* Node = ConfigNode->FirstChildElement(); Node; Node = Node->NextSiblingElement() )
    {
        wxString NodeName = cbC2U(Node->Value());
        if ( NodeName == _T("configuration") )
        {
            const char* AppSrc  = Node->Attribute("app_src_file");
            const char* Main    = Node->Attribute("main_resource");
            const char* InitAll = Node->Attribute("init_all_handlers");

            if ( AppSrc )
            {
                TiXmlElement* GUINode = NewConfig->InsertEndChild(TiXmlElement("gui"))->ToElement();
                GUINode->SetAttribute("name","wxWidgets");
                GUINode->SetAttribute("src",AppSrc);
                GUINode->SetAttribute("main",Main?Main:"");
                GUINode->SetAttribute("init_handlers",InitAll?InitAll:"necessary");
                GUINode->SetAttribute("language","CPP");
            }
        }
        else
        {
            if ( NodeName == _T("dialog") ||
                 NodeName == _T("frame") ||
                 NodeName == _T("panel") )
            {
                const char* Wxs   = Node->Attribute("wxs_file");
                const char* Class = Node->Attribute("class");
                const char* Src   = Node->Attribute("src_file");
                const char* Hdr   = Node->Attribute("header_file");
                const char* Xrc   = Node->Attribute("xrc_file");
                const char* Mode  = Node->Attribute("edit_mode");

                if ( Wxs && Class && Src && Hdr && Mode )
                {
                    if ( cbC2U(Mode) == _T("Source") ) Xrc = 0;
                    TiXmlElement* Res = Resources->InsertEndChild(TiXmlElement(
                        NodeName == _T("dialog") ? "wxDialog" :
                        NodeName == _T("frame")  ? "wxFrame" :
                                                   "wxPanel" ))->ToElement();

                    Res->SetAttribute("wxs",cbU2C(_T("wxsmith/")+cbC2U(Wxs)));
                    Res->SetAttribute("src",Src);
                    Res->SetAttribute("hdr",Hdr);
                    if ( Xrc ) Res->SetAttribute("xrc",Xrc);
                    Res->SetAttribute("name",Class);
                    Res->SetAttribute("language","CPP");

                    ConvertOldWxsFile(Project->GetProjectPath()+_T("wxsmith/")+cbC2U(Wxs),Xrc!=0);
                    AdoptOldSourceFile(Project->GetProjectPath()+cbC2U(Src),cbC2U(Class));
                }
            }
        }
    }
    return NewConfig;
}