Example #1
0
//-----------------------------------------------------------------------------
// <Group::WriteXML>
// Write ourselves to an XML document
//-----------------------------------------------------------------------------
void Group::WriteXML
(
	TiXmlElement* _groupElement
)
{
	char str[16];

	snprintf( str, 16, "%d", m_groupIdx );
	_groupElement->SetAttribute( "index", str );

	snprintf( str, 16, "%d", m_maxAssociations );
	_groupElement->SetAttribute( "max_associations", str );

	_groupElement->SetAttribute( "label", m_label.c_str() );
	_groupElement->SetAttribute( "auto", m_auto ? "true" : "false" );
	if( m_multiInstance )
	{
		_groupElement->SetAttribute( "multiInstance", m_multiInstance ? "true" : "false" );
	}
	
	for( map<InstanceAssociation,AssociationCommandVec,classcomp>::iterator it = m_associations.begin(); it != m_associations.end(); ++it )
	{
		TiXmlElement* associationElement = new TiXmlElement( "Node" );
		
		snprintf( str, 16, "%d", it->first.m_nodeId );
		associationElement->SetAttribute( "id", str );
		if (it->first.m_instance != 0)
		{
			snprintf( str, 16, "%d", it->first.m_instance );
			associationElement->SetAttribute( "instance", str );
		}

		_groupElement->LinkEndChild( associationElement );
	}
}
Example #2
0
//-----------------------------------------------------------------------------
// <ValueList::WriteXML>
// Write ourselves to an XML document
//-----------------------------------------------------------------------------
void ValueList::WriteXML
(
	TiXmlElement* _valueElement
)
{
	Value::WriteXML( _valueElement );

	char str[16];
	snprintf( str, sizeof(str), "%d", m_valueIdx );
	_valueElement->SetAttribute( "vindex", str );

	snprintf( str, sizeof(str), "%d", m_size );
	_valueElement->SetAttribute( "size", str );

	for( vector<Item>::iterator it = m_items.begin(); it != m_items.end(); ++it )
	{
		TiXmlElement* pItemElement = new TiXmlElement( "Item" );
		pItemElement->SetAttribute( "label", (*it).m_label.c_str() );

		snprintf( str, sizeof(str), "%d", (*it).m_value );
		pItemElement->SetAttribute( "value", str );

		_valueElement->LinkEndChild( pItemElement );
	}
}
//-----------------------------------------------------------------------------
// <ThermostatMode::WriteXML>
// Save the supported modes
//-----------------------------------------------------------------------------
void ThermostatMode::WriteXML
(
	TiXmlElement* _ccElement
)
{
	if( m_supportedModes.empty() )
	{
		return;
	}

	CommandClass::WriteXML( _ccElement );

	if( GetNodeUnsafe() )
	{
		TiXmlElement* supportedModesElement = new TiXmlElement( "SupportedModes" );
		_ccElement->LinkEndChild( supportedModesElement );

		for( vector<ValueList::Item>::iterator it = m_supportedModes.begin(); it != m_supportedModes.end(); ++it )
		{
			ValueList::Item const& item = *it;

			TiXmlElement* modeElement = new TiXmlElement( "Mode" );
			supportedModesElement->LinkEndChild( modeElement );

			char str[8];
			snprintf( str, 8, "%d", item.m_value );
			modeElement->SetAttribute( "index", str );
			modeElement->SetAttribute( "label", item.m_label.c_str() );
		}
	}
}
void dRigidbodyNodeInfo::Serialize (TiXmlElement* const rootNode) const
{
	SerialiseBase(dNodeInfo, rootNode);

	char tmp[1024];

	TiXmlElement* dataNode = new TiXmlElement ("transform");
	rootNode->LinkEndChild(dataNode);

	dataNode = new TiXmlElement ("centerOfMass");
	rootNode->LinkEndChild(dataNode);
	dFloatArrayToString (&m_centerOfMass[0], 4, tmp, sizeof (tmp));
	dataNode->SetAttribute("float4", tmp);

	dataNode = new TiXmlElement ("massMatrix");
	rootNode->LinkEndChild(dataNode);
	dFloatArrayToString (&m_massMatrix[0], 4, tmp, sizeof (tmp));
	dataNode->SetAttribute("float4", tmp);

	dataNode = new TiXmlElement ("velocity");
	rootNode->LinkEndChild(dataNode);
	dFloatArrayToString (&m_velocity[0], 4, tmp, sizeof (tmp));
	dataNode->SetAttribute("float4", tmp);

	dataNode = new TiXmlElement ("omega");
	rootNode->LinkEndChild(dataNode);
	dFloatArrayToString (&m_omega[0], 4, tmp, sizeof (tmp));
	dataNode->SetAttribute("float4", tmp);

	dataNode = new TiXmlElement ("internalDamp");
	rootNode->LinkEndChild(dataNode);
	dFloatArrayToString (&m_internalDamp[0], 4, tmp, sizeof (tmp));
	dataNode->SetAttribute("float4", tmp);
}
void wxsItemResData::SaveExtraDataReq(wxsItem* Item,TiXmlElement* Node)
{
    if ( Item->GetPropertiesFlags() && flId )
    {
        wxString Id = Item->GetIdName();
        if ( !Id.empty() )
        {
            TiXmlElement* Object = Node->InsertEndChild(TiXmlElement("object"))->ToElement();
            if ( Item!=m_RootItem )
            {
                Object->SetAttribute("name",cbU2C(Id));
                Object->SetAttribute("class",cbU2C(Item->GetClassName()));
            }
            else
            {
                // TOP-level items have different attributes in extra node
                Object->SetAttribute("root","1");
            }
            Item->XmlWrite(Object,false,true);
        }
    }

    wxsParent* AsParent = Item->ConvertToParent();
    if ( AsParent )
    {
        for ( int i=0; i<AsParent->GetChildCount(); i++ )
        {
            SaveExtraDataReq(AsParent->GetChild(i),Node);
        }
    }
}
TiXmlElement* SceneScaleNode::getSceneNodeTransformValueAsXmlElement() {
	TiXmlElement* element = new TiXmlElement("Scale");
	element->SetAttribute("x", xValue);
	element->SetAttribute("y", yValue);
	element->SetAttribute("z", zValue);
	return element;
}
//----------------------------------------------------------------------------
void saveUserData(OgitorsCustomPropertySet *set, TiXmlElement *pParent)
{
    if(!set || !pParent)
        return;

    OgitorsPropertyVector vec = set->getPropertyVector();

    if(vec.size() < 1)
        return;

    TiXmlElement *pNode = pParent->InsertEndChild(TiXmlElement("userData"))->ToElement();

    for(unsigned int i = 0; i < vec.size(); i++)
    {
        OgitorsPropertyBase *property = vec[i];
        const OgitorsPropertyDef *def = property->getDefinition();
        OgitorsPropertyValue value;
        value.propType = property->getType();
        value.val = property->getValue();

        TiXmlElement *pProp = pNode->InsertEndChild(TiXmlElement("property"))->ToElement();
        pProp->SetAttribute("type", Ogre::StringConverter::toString(value.propType).c_str());
        pProp->SetAttribute("name", property->getName().c_str());
        pProp->SetAttribute("data", OgitorsUtils::GetValueString(value).c_str());
    }
}
TiXmlElement* SceneRotateNode::getSceneNodeTransformValueAsXmlElement() {
	TiXmlElement* element = new TiXmlElement("Rotate");
	element->SetAttribute("angle", angleValue);
	element->SetAttribute("x", xValue);
	element->SetAttribute("y", yValue);
	element->SetAttribute("z", zValue);
	return element;
}
void printModule(PMODULEENTRY32 entry, TiXmlElement* process)
{
    TiXmlElement* node = new TiXmlElement("module");

	TiXmlElement* item = new TiXmlElement("HANDLE");
	item->SetAttribute("value", (DWORD)entry->hModule);
	node->LinkEndChild(item);

	item = new TiXmlElement("Address");
	char szBuffer[1024] = {0};
	sprintf(szBuffer, "0x%08X", entry->modBaseAddr);
	item->SetAttribute("value", szBuffer);
	node->LinkEndChild(item);

	item = new TiXmlElement("Size");
	item->SetAttribute("value", entry->modBaseSize);
	node->LinkEndChild(item);

	item = new TiXmlElement("Name");
	memset(szBuffer, 0, 1024);
	if (WideCharToMultiByte(
		CP_ACP,
		NULL,
		entry->szModule,
		wcslen(entry->szModule),
		szBuffer,
		1024,
		NULL,
		NULL) > 0)
	{
		item->SetAttribute("value", szBuffer);
		node->LinkEndChild(item);
	}
	else
		delete item;

	item = new TiXmlElement("Path");
	memset(szBuffer, 0, 1024);
	if (WideCharToMultiByte(
		CP_ACP,
		NULL,
		entry->szExePath,
		wcslen(entry->szExePath),
		szBuffer,
		1024,
		NULL,
		NULL) > 0)
	{
		item->SetAttribute("value", szBuffer);
		node->LinkEndChild(item);
	}
	else
		delete item;

	process->LinkEndChild(node);
}
Example #10
0
	void EMMMaterial::writeXML(TiXmlElement *root) {
		TiXmlElement* materialRoot = new TiXmlElement("EMMMaterial");
		materialRoot->SetAttribute("name", ToString(name));
		materialRoot->SetAttribute("shader_name", ToString(shader_name));

		for (size_t i = 0; i < parameters.size(); i++) {
			parameters[i]->writeXML(materialRoot);
		}

		root->LinkEndChild(materialRoot);
	}
void COrientationModifierParams::WriteXMLAttributes(TiXmlNode *root)
{
	TiXmlElement * element;
	element = new TiXmlElement( "params" );
	root->LinkEndChild( element );

	element->SetAttribute("m_spacing", int(m_spacing));
	element->SetAttribute("m_number_of_rotations", int(m_number_of_rotations));
	element->SetAttribute("m_sketch_rotates_text", m_sketch_rotates_text);
	element->SetAttribute("m_justification", int(m_justification));
}
  TiXmlElement* GeneticMaxAmountMutation::toXmlElement() {
    TiXmlElement* element;
    element = new TiXmlElement("MaxAmountMutation");

    element->SetDoubleAttribute("Min",min);
    element->SetDoubleAttribute("Max",max);
    element->SetDoubleAttribute("Maxstep",maxstep);
    element->SetDoubleAttribute("Probability",prob);
    element->SetAttribute("Description",description);
    element->SetAttribute("ChemicalName",chemName);

    return element;
  };
bool wxsItemResData::RebuildXrcFile()
{
    // First - opening file
    TiXmlDocument Doc;
    TiXmlElement* Resources = nullptr;
    TiXmlElement* Object = nullptr;

    if ( TinyXML::LoadDocument(m_XrcFileName,&Doc) )
    {
        Resources = Doc.FirstChildElement("resource");
    }

    if ( !Resources )
    {
        Doc.Clear();
        Doc.InsertEndChild(TiXmlDeclaration("1.0","utf-8",""));
        Resources = Doc.InsertEndChild(TiXmlElement("resource"))->ToElement();
        Resources->SetAttribute("xmlns","http://www.wxwidgets.org/wxxrc");
    }

    // Searching for object representing this resource
    for ( Object = Resources->FirstChildElement("object"); Object; Object = Object->NextSiblingElement("object") )
    {
        if ( cbC2U(Object->Attribute("name")) == m_ClassName )
        {
            Object->Clear();
            while ( Object->FirstAttribute() )
            {
                Object->RemoveAttribute(Object->FirstAttribute()->Name());
            }
            break;
        }
    }

    if ( !Object )
    {
        Object = Resources->InsertEndChild(TiXmlElement("object"))->ToElement();
    }

    // The only things left are: to dump item into object ...
    m_RootItem->XmlWrite(Object,true,false);
    Object->SetAttribute("name",cbU2C(m_ClassName));
    for ( int i=0; i<GetToolsCount(); i++ )
    {
        TiXmlElement* ToolElement = Object->InsertEndChild(TiXmlElement("object"))->ToElement();
        m_Tools[i]->XmlWrite(ToolElement,true,false);
    }

    // ... and save back the file
    return TinyXML::SaveDocument(m_XrcFileName,&Doc);
}
Example #14
0
bool ETHEntity::WriteToXMLFile(TiXmlElement *pHeadRoot) const
{
	TiXmlElement *pEntity = new TiXmlElement(GS_L("Entity"));
	pHeadRoot->LinkEndChild(pEntity);

	TiXmlElement *pElement;

	// if it has a specific name, save it
	if (m_properties.entityName != GS_L(""))
	{
		pElement = new TiXmlElement(GS_L("EntityName"));
		pElement->LinkEndChild(new TiXmlText(m_properties.entityName));
		pEntity->LinkEndChild(pElement);
	}

	if (m_v4Color != ETH_DEFAULT_COLOR)
	{
		pElement = new TiXmlElement(GS_L("Color"));
		pEntity->LinkEndChild(pElement); 
		pElement->SetDoubleAttribute(GS_L("r"), m_v4Color.x);
		pElement->SetDoubleAttribute(GS_L("g"), m_v4Color.y);
		pElement->SetDoubleAttribute(GS_L("b"), m_v4Color.z);
		pElement->SetDoubleAttribute(GS_L("a"), m_v4Color.w);
	}

	pElement = new TiXmlElement(GS_L("Position"));
	pEntity->LinkEndChild(pElement);
	{
		const Vector3 pos(m_controller->GetPos());
		pElement->SetDoubleAttribute(GS_L("x"), pos.x);
		pElement->SetDoubleAttribute(GS_L("y"), pos.y);
		pElement->SetDoubleAttribute(GS_L("z"), pos.z);
		pElement->SetDoubleAttribute(GS_L("angle"), m_controller->GetAngle());
		
	}
	pEntity->SetAttribute(GS_L("id"), m_id);
	pEntity->SetAttribute(GS_L("spriteFrame"), m_spriteFrame);

	if (m_spriteFrame > 0)
		pEntity->SetDoubleAttribute(GS_L("spriteFrame"), m_spriteFrame);

	if (m_properties.castShadow)
		pEntity->SetDoubleAttribute(GS_L("shadowZ"), m_shadowZ);

	if (m_hide != ETH_FALSE)
		pEntity->SetAttribute(GS_L("hide"), m_hide);

	m_properties.WriteToXMLFile(pEntity);
	return true;
}
Example #15
0
void CWrapEngine::SetWidthToCache(const char* name, int width)
{
	if (!m_use_cache)
		return;

	if (!name || !*name)
		return;

	// We have to synchronize access to layout.xml so that multiple processed don't write
	// to the same file or one is reading while the other one writes.
	CInterProcessMutex mutex(MUTEX_LAYOUT);

	wxFileName file(COptions::Get()->GetOption(OPTION_DEFAULT_SETTINGSDIR), _T("layout.xml"));
	TiXmlElement* pDocument = GetXmlFile(file);

	if (!pDocument)
		return;

	TiXmlElement* pElement = pDocument->FirstChildElement("Layout");
	if (!pElement)
	{
		delete pDocument->GetDocument();
		return;
	}

	wxString language = wxGetApp().GetCurrentLanguageCode();
	if (language.empty())
		language = _T("default");

	TiXmlElement* pLanguage = FindElementWithAttribute(pElement, "Language", "id", language.mb_str());
	if (!pLanguage)
	{
		delete pDocument->GetDocument();
		return;
	}

	TiXmlElement* pDialog = FindElementWithAttribute(pLanguage, "Dialog", "name", name);
	if (!pDialog)
	{
		pDialog = pLanguage->LinkEndChild(new TiXmlElement("Dialog"))->ToElement();
		pDialog->SetAttribute("name", name);
	}

	pDialog->SetAttribute("width", width);
	wxString error;
	SaveXmlFile(file, pDocument, &error);

	delete pDocument->GetDocument();
}
bool CBusStopConfig::SaveBusStop(TiXmlElement* pElement)
{
	for (TiXmlElement* pChiled = pElement->FirstChildElement(); pChiled != NULL; pChiled = pChiled->NextSiblingElement())
	{
		const char* szValue = pChiled->Value();
// 		if(strcmp(Layout, szValue) == 0)
// 		{
// 			string strLeft = pChiled->Attribute(Left);
// 			string strRight = pChiled->Attribute(Right);
// 			string strTop = pChiled->Attribute(Top);
// 			string strBottom = pChiled->Attribute(Bottom);
// 
// 			m_size.left = atoi(strLeft.c_str());
// 			m_size.right = atoi(strRight.c_str());
// 			m_size.top = atoi(strTop.c_str());
// 			m_size.bottom = atoi(strBottom.c_str());
// 		}
		if(strcmp(Static, szValue) == 0)
		{
			for (TiXmlElement* pStatic = pChiled->FirstChildElement(); pStatic != NULL; pStatic = pStatic->NextSiblingElement())
			{
				const char* szStaticValue = pStatic->Value();
				if(strcmp(City, szStaticValue) == 0)
				{
					pStatic->SetAttribute(ID, m_strCityCode.c_str());
				}
				else if(strcmp(CurStop, szStaticValue) == 0)
				{
					pStatic->SetAttribute(ID, m_strStopID.c_str());
					pStatic->SetAttribute(Name, m_strStopName.c_str());
				}
// 				else if(strcmp(Attrib, szStaticValue) == 0)
// 				{
// 					string strLineCount = pStatic->Attribute(LineCount);
// 					string strOneBord = pStatic->Attribute(OneBord);
// 					m_nLineCount = atoi(strLineCount.c_str());
// 					m_nOneBord = atoi(strOneBord.c_str());
// 				}
				else if(strcmp(StaticData, szStaticValue) == 0)
				{
					pStatic->SetAttribute(Dir, m_strStaticData.c_str());
				}
			}
		}
	}

	return true;
}
Example #17
0
bool CreateXmlFile(std::string& szFileName)
{//创建xml文件,szFilePath为文件保存的路径,若创建成功返回true,否则false
	try
	{
		//创建一个XML的文档对象。
		TiXmlDocument *myDocument = new TiXmlDocument();
		//创建一个根元素并连接。
		TiXmlElement *RootElement = new TiXmlElement("Persons");
		myDocument->LinkEndChild(RootElement);
		//创建一个Person元素并连接。
		TiXmlElement *PersonElement = new TiXmlElement("Person");
		RootElement->LinkEndChild(PersonElement);
		//设置Person元素的属性。
		PersonElement->SetAttribute("ID", "1");
		//创建name元素、age元素并连接。
		TiXmlElement *NameElement = new TiXmlElement("name");
		TiXmlElement *AgeElement = new TiXmlElement("age");
		PersonElement->LinkEndChild(NameElement);
		PersonElement->LinkEndChild(AgeElement);
		//设置name元素和age元素的内容并连接。
		TiXmlText *NameContent = new TiXmlText("周星星");
		TiXmlText *AgeContent = new TiXmlText("22");
		NameElement->LinkEndChild(NameContent);
		AgeElement->LinkEndChild(AgeContent);
		std::string fullPath = GetAppPath();
		fullPath += "\\";
		fullPath += szFileName;
		myDocument->SaveFile(fullPath.c_str());//保存到文件
	}
	catch (std::string& e)
	{
		return false;
	}
	return true;
}
Example #18
0
void COptions::SetXmlValue(unsigned int nID, wxString value)
{
	if (!m_pXmlFile)
		return;

	// No checks are made about the validity of the value, that's done in SetOption

	char *utf8 = ConvUTF8(value);
	if (!utf8)
		return;

	TiXmlElement *settings = m_pXmlFile->GetElement()->FirstChildElement("Settings");
	if (!settings)
	{
		TiXmlNode *node = m_pXmlFile->GetElement()->LinkEndChild(new TiXmlElement("Settings"));
		if (!node)
		{
			delete [] utf8;
			return;
		}
		settings = node->ToElement();
		if (!settings)
		{
			delete [] utf8;
			return;
		}
	}
	else
	{
		TiXmlNode *node = 0;
		while ((node = settings->IterateChildren("Setting", node)))
		{
			TiXmlElement *setting = node->ToElement();
			if (!setting)
				continue;

			const char *attribute = setting->Attribute("name");
			if (!attribute)
				continue;
			if (strcmp(attribute, options[nID].name))
				continue;

			//setting->RemoveAttribute("type");
			setting->Clear();
			//setting->SetAttribute("type", (options[nID].type == string) ? "string" : "number");
			setting->LinkEndChild(new TiXmlText(utf8));

			delete [] utf8;
			return;
		}
	}
	wxASSERT(options[nID].name[0]);
	TiXmlElement *setting = new TiXmlElement("Setting");
	setting->SetAttribute("name", options[nID].name);
	//setting->SetAttribute("type", (options[nID].type == string) ? "string" : "number");
	setting->LinkEndChild(new TiXmlText(utf8));
	settings->LinkEndChild(setting);

	delete [] utf8;
}
Example #19
0
TiXmlElement* ObjectBase::SerializeObject()
{
	TiXmlElement *element = new TiXmlElement("object");
	element->SetAttribute("class", _STDSTR( GetClassName() ));

	for (unsigned int i=0; i< GetPropertyCount(); i++)
	{
		shared_ptr<Property> prop = GetProperty(i);
		TiXmlElement *prop_element = new TiXmlElement("property");
		prop_element->SetAttribute("name", _STDSTR(prop->GetName() ));

		TiXmlText* prop_value = new TiXmlText( _STDSTR(prop->GetValue()));
		prop_element->LinkEndChild(prop_value);
		element->LinkEndChild(prop_element);
	}

	for (unsigned int i=0 ; i < GetChildCount() ; i++)
	{
		shared_ptr<ObjectBase> child = GetChild(i);
		TiXmlElement * child_element = child->SerializeObject();
		element->LinkEndChild(child_element);
	}

	return element;
}
int CFieldDataXML::ChangeFieldInfo(FieldInfo& info)
{
	if (!m_bInit)
	{
		if (!myDocument.LoadFile(m_strXML.GetBuffer()))
		{
			return ERROR_OPEN_FILE;
		}
		m_bInit = TRUE;
	}

	//获得根元素
	TiXmlElement *RootElement = myDocument.RootElement();
	//获得第一个field节点。
	TiXmlElement *field = RootElement->FirstChildElement();

	int i=0;
	while(field)
	{
		CString strID = field->Attribute("id");
		if (strID == info.m_strFieldID)
		{
			break;
		}
		field = field->NextSiblingElement("field");
	}

	ASSERT(field);

	field->SetAttribute("name", info.m_strFieldName);
	return ERROR_OK;
}
Example #21
0
int em::EmXml::AppendRootChildList( const char* szChildName, EmVecMapStr &rVecMapStr )
{
	std::string strResult;
	bool bUpdated = false;
	int iResult = 0;
	int i = 0;

	TiXmlElement *pElemRoot = m_pDoc->RootElement();
	if(pElemRoot == NULL)
	{
		return 0;
	}
	
	if(rVecMapStr.size() == 0)
	{
		return 0;
	}
	
	for(i = 0; i < rVecMapStr.size(); i++)
	{
		TiXmlElement *pElemChildNew = new TiXmlElement(szChildName);
		EmMapStr::const_iterator iterMap;
		for(iterMap = rVecMapStr[i].begin(); iterMap != rVecMapStr[i].end(); iterMap++)
		{
			pElemChildNew->SetAttribute(iterMap->first,iterMap->second);
		}
		
		pElemRoot->LinkEndChild(pElemChildNew);
	}

	m_bUpdated = true;
	return iResult;
}
Example #22
0
TiXmlNode* TiXmlElement::Clone() const
{
    TiXmlElement* clone = new TiXmlElement( Value() );

    if ( !clone )
        return 0;

    CopyToClone( clone );

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

    TiXmlNode* node = 0;
    for ( node = firstChild; node; node = node->NextSibling() )
    {
        clone->LinkEndChild( node->Clone() );
    }
    return clone;
}
TiXmlElement* SceneTransformNode::getSceneNodeValueAsXmlElement() {
	//SceneNode::getSceneNodeAsXmlElement();
	TiXmlElement* element = new TiXmlElement("TransformNode");
	element->SetAttribute("Type",  getType());
	element->LinkEndChild(getSceneNodeTransformValueAsXmlElement());
	return element;
}
Example #24
0
bool exportMaterial(Material &material, TiXmlElement *xml)
{
  TiXmlElement *material_xml = new TiXmlElement("material");
  material_xml->SetAttribute("name", material.name);

  TiXmlElement* texture = new TiXmlElement("texture");
  if (!material.texture_filename.empty())
    texture->SetAttribute("filename", material.texture_filename);
  material_xml->LinkEndChild(texture);

  TiXmlElement* color = new TiXmlElement("color");
  color->SetAttribute("rgba", urdf_export_helpers::values2str(material.color));
  material_xml->LinkEndChild(color);
  xml->LinkEndChild(material_xml);
  return true;
}
Example #25
0
string strMiscWarning;
bool fTestNet = false;
bool fNoListen = false;
bool fLogTimestamps = false;
CMedianFilter<int64> vTimeOffsets(200,0);
bool fReopenDebugLog = false;

// Init openssl library multithreading support
static CCriticalSection** ppmutexOpenSSL;
void locking_callback(int mode, int i, const char* file, int line)
{
    if (mode & CRYPTO_LOCK) {
        ENTER_CRITICAL_SECTION(*ppmutexOpenSSL[i]);
    } else {
        LEAVE_CRITICAL_SECTION(*ppmutexOpenSSL[i]);
    }
}

// Init
class CInit
{
public:
    CInit()
    {
        // Init openssl library multithreading support
        ppmutexOpenSSL = (CCriticalSection**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(CCriticalSection*));
        for (int i = 0; i < CRYPTO_num_locks(); i++)
            ppmutexOpenSSL[i] = new CCriticalSection();
        CRYPTO_set_locking_callback(locking_callback);

#ifdef WIN32
        // Seed random number generator with screen scrape and other hardware sources
        RAND_screen();
#endif
Example #26
0
void wxWidgetsGUI::OnWriteConfig(TiXmlElement* element)
{
    element->SetAttribute("src",cbU2C(m_AppFile));
    element->SetAttribute("main",cbU2C(m_MainResource));
    if ( m_CallInitAll && m_CallInitAllNecessary )
    {
        element->SetAttribute("init_handlers","necessary");
    }
    else if ( m_CallInitAll )
    {
        element->SetAttribute("init_handlers","always");
    }
    else
    {
        element->SetAttribute("init_handlers","never");
    }

    element->SetAttribute("language",cbU2C(wxsCodeMarks::Name(m_AppLanguage)));

    for ( size_t i=0; i<m_LoadedResources.GetCount(); ++i )
    {
        TiXmlElement* LoadRes = element->InsertEndChild(TiXmlElement("load_resource"))->ToElement();
        LoadRes->SetAttribute("file",cbU2C(m_LoadedResources[i]));
    }
}
TiXmlElement* BaseScriptComponent::VGenerateXml(void)
{
    TiXmlElement* pBaseElement = GCC_NEW TiXmlElement(VGetName());

    // ScriptObject
    TiXmlElement* pScriptObjectElement = GCC_NEW TiXmlElement("ScriptObject");
    if (!m_scriptObjectName.empty())
        pScriptObjectElement->SetAttribute("var", m_scriptObjectName.c_str());
    if (!m_constructorName.empty())
        pScriptObjectElement->SetAttribute("constructor", m_constructorName.c_str());
    if (!m_destructorName.empty())
        pScriptObjectElement->SetAttribute("destructor", m_destructorName.c_str());
    pBaseElement->LinkEndChild(pScriptObjectElement);

    return pBaseElement;
}
Example #28
0
void User::Save(bool force) {
  if (!force) {
    // If no save operation is scheduled, exit now
    if (!scheduledSaveTimer_) return;
    if (!scheduledSaveTimer_->IsRunning()) return;
  }

  settings_->Save();
  wxGetApp().GetPluginManager()->Save();

  TiXmlDocument doc;
  doc.LinkEndChild(new TiXmlDeclaration("1.0", "UTF-8", ""));

  TiXmlElement* xmlRoot = new TiXmlElement("FolderItems");
  xmlRoot->SetAttribute("version", "1.0");
  doc.LinkEndChild(xmlRoot);

  for (int i = 0; i < autoAddExclusions_.size(); i++) {
    XmlUtil::AppendTextElement(xmlRoot, "ExcludedPath", autoAddExclusions_[i]);
  }

  FolderItemVector folderItems = rootFolderItem_->GetChildren();
  for (int i = 0; i < folderItems.size(); i++) {
    FolderItem* folderItem = folderItems.at(i);
    xmlRoot->LinkEndChild(folderItem->ToXml());   
  }

  FilePaths::CreateSettingsDirectory();
  bool saved = doc.SaveFile(FilePaths::GetFolderItemsFile().mb_str());
  if (!saved) ELOG(_T("Could not save file"));
}
Example #29
0
void gen_catfee_xml(std::vector<FeeCatXML*>& feeCat)
{
	// Make xml: <?xml ..><Hello>World</Hello>
	TiXmlDocument doc;
	TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "", "");
	TiXmlElement * element = new TiXmlElement("import");

	//TiXmlText * text = new TiXmlText("World");
	element->SetAttribute("mode", "synchronize");
	doc.LinkEndChild(decl);
	doc.LinkEndChild(element);

	{
		
		for (std::vector < FeeCatXML* >::iterator iter = feeCat.begin();
			iter != feeCat.end(); iter++) {
			TiXmlElement * feescats = new TiXmlElement("clientfeecat");
			element->LinkEndChild(feescats);
			FeeCatXML *feeCat =  *iter;

			TiXmlElement * id = new TiXmlElement("id");
			TiXmlElement * name = new TiXmlElement("name");
		
			feescats->LinkEndChild(id);
			feescats->LinkEndChild(name);
		
			id->LinkEndChild(new TiXmlText((feeCat->id).c_str() ));
			name->LinkEndChild(new TiXmlText( (feeCat->name).c_str() ));

		}


		doc.SaveFile("BSBFeeCat.xml");
	}
}
Example #30
0
bool Utils::set_config_option(std::string key, std::string value)
{
    TiXmlDocument document(getConfigFile(LOCAL_CONFIG).c_str());

    if (!document.LoadFile())
    {
        cError() <<  "There was an exception in XML parsing.";
        cError() <<  "Parse error: " << document.ErrorDesc();
        cError() <<  "In file " << getConfigFile(LOCAL_CONFIG) << " At line " << document.ErrorRow();

        return false;
    }

    TiXmlHandle docHandle(&document);
    bool found = false;

    TiXmlElement *key_node = docHandle.FirstChildElement("calaos:config").FirstChildElement().ToElement();
    if (key_node)
    {
        for(; key_node; key_node = key_node->NextSiblingElement())
        {
            if (key_node->ValueStr() == "calaos:option" &&
                key_node->Attribute("name") &&
                key_node->Attribute("name") == key)
            {
                key_node->SetAttribute("value", value);
                found = true;
                break;
            }
        }

        //the option was not found, we create it
        if (!found)
        {
            TiXmlElement *element = new TiXmlElement("calaos:option");
            element->SetAttribute("name", key);
            element->SetAttribute("value", value);
            docHandle.FirstChild("calaos:config").ToElement()->LinkEndChild(element);
        }

        document.SaveFile();
    }

    return true;
}