Exemplo n.º 1
0
bool wxsEnumProperty::XmlWrite(wxsPropertyContainer* Object,TiXmlElement* Element)
{
    if ( VALUE != Default )
    {
        if ( UseNamesInXml )
        {
            // searching for name of this value
            int i = 0;
            for ( const wxChar** Ptr = Names; *Ptr; Ptr++, i++ )
            {
                if ( VALUE == Values[i] )
                {
                    Element->InsertEndChild(TiXmlText(cbU2C(*Ptr)));
                    return true;
                }
            }

            // Did not found value, storing as integer
        }

        Element->InsertEndChild(TiXmlText(cbU2C(wxString::Format(_T("%ld"),VALUE))));
        return true;
    }
    return false;
}
Exemplo n.º 2
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()->InsertEndChild(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->InsertEndChild(TiXmlText(utf8));

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

	delete [] utf8;
}
void GridRenderComponent::CreateInheritedXmlElements(TiXmlElement* pBaseElement)
{
	TiXmlElement* pTextureNode = CB_NEW TiXmlElement("Texture");
	TiXmlText* pTextureText = CB_NEW TiXmlText(m_TextureResource.c_str());
	pTextureNode->LinkEndChild(pTextureText);
	pBaseElement->LinkEndChild(pTextureNode);

	TiXmlElement* pDivisionNode = CB_NEW TiXmlElement("Division");
	TiXmlText* pDivisionText = CB_NEW TiXmlText(ToStr(m_Squares).c_str());
	pDivisionNode->LinkEndChild(pDivisionText);
	pBaseElement->LinkEndChild(pDivisionNode);
}
Exemplo n.º 4
0
void GupExtraOptions::writeProxyInfo(const char *fn, const char *proxySrv, long port)
{
	TiXmlDocument newProxySettings(fn);
	TiXmlNode *root = newProxySettings.InsertEndChild(TiXmlElement("GUPOptions"));
	TiXmlNode *proxy = root->InsertEndChild(TiXmlElement("Proxy"));
	TiXmlNode *server = proxy->InsertEndChild(TiXmlElement("server"));
	server->InsertEndChild(TiXmlText(proxySrv));
	TiXmlNode *portNode = proxy->InsertEndChild(TiXmlElement("port"));
	char portStr[10];
	sprintf(portStr, "%d", port);
	portNode->InsertEndChild(TiXmlText(portStr));

	newProxySettings.SaveFile();
}
Exemplo n.º 5
0
TiXmlElement* PhysicsComponent::VGenerateXml(void)
{
    TiXmlElement* pBaseElement = GCC_NEW TiXmlElement(VGetName());

    // shape
	TiXmlElement* pShape = GCC_NEW TiXmlElement("Shape");
    TiXmlText* pShapeText = GCC_NEW TiXmlText(m_shape.c_str());
    pShape->LinkEndChild(pShapeText);
	pBaseElement->LinkEndChild(pShape);

    // density
    TiXmlElement* pDensity = GCC_NEW TiXmlElement("Density");
    TiXmlText* pDensityText = GCC_NEW TiXmlText(m_density.c_str());
    pDensity->LinkEndChild(pDensityText);
    pBaseElement->LinkEndChild(pDensity);

    // material
    TiXmlElement* pMaterial = GCC_NEW TiXmlElement("Material");
    TiXmlText* pMaterialText = GCC_NEW TiXmlText(m_material.c_str());
    pMaterial->LinkEndChild(pMaterialText);
    pBaseElement->LinkEndChild(pMaterial);

    // rigid body transform
    TiXmlElement* pInitialTransform = GCC_NEW TiXmlElement("RigidBodyTransform");

    // initial transform -> position
    TiXmlElement* pPosition = GCC_NEW TiXmlElement("Position");
    pPosition->SetAttribute("x", ToStr(m_RigidBodyLocation.x).c_str());
    pPosition->SetAttribute("y", ToStr(m_RigidBodyLocation.y).c_str());
    pPosition->SetAttribute("z", ToStr(m_RigidBodyLocation.z).c_str());
    pInitialTransform->LinkEndChild(pPosition);

    // initial transform -> orientation
    TiXmlElement* pOrientation = GCC_NEW TiXmlElement("Orientation");
    pOrientation->SetAttribute("yaw", ToStr(m_RigidBodyOrientation.x).c_str());
    pOrientation->SetAttribute("pitch", ToStr(m_RigidBodyOrientation.y).c_str());
    pOrientation->SetAttribute("roll", ToStr(m_RigidBodyOrientation.z).c_str());
    pInitialTransform->LinkEndChild(pOrientation);

	// initial transform -> scale 
    TiXmlElement* pScale = GCC_NEW TiXmlElement("Scale");
    pScale->SetAttribute("x", ToStr(m_RigidBodyScale.x).c_str());
    pScale->SetAttribute("y", ToStr(m_RigidBodyScale.y).c_str());
    pScale->SetAttribute("z", ToStr(m_RigidBodyScale.z).c_str());
    pInitialTransform->LinkEndChild(pScale);

    pBaseElement->LinkEndChild(pInitialTransform);

    return pBaseElement;
}
Exemplo n.º 6
0
bool wxsCustomWidget::OnXmlWrite(TiXmlElement* Element,bool IsXRC,bool IsExtra)
{
    bool Ret = wxsItem::OnXmlWrite(Element,IsXRC,IsExtra);

    if ( IsXRC )
    {
        if ( !(GetPropertiesFlags() & flSource) )
        {
            Element->SetAttribute("class",cbU2C(GetUserClass()));
            Element->RemoveAttribute("subclass");
            Element->InsertEndChild(TiXmlElement("style"))->InsertEndChild(TiXmlText(cbU2C(m_Style)));

            for ( TiXmlElement* Child = m_XmlDataDoc.FirstChildElement(); Child; Child = Child->NextSiblingElement() )
            {
                // Skipping all standard elements
                wxString Name = cbC2U(Child->Value());
                if ( Name != _T("pos") &&
                     Name != _T("size") &&
                     Name != _T("style") &&
                     Name != _T("enabled") &&
                     Name != _T("focused") &&
                     Name != _T("hidden") &&
                     Name != _T("fg") &&
                     Name != _T("bg") &&
                     Name != _T("font") &&
                     Name != _T("handler") )
                {
                    Element->InsertEndChild(*Child);
                }
            }
        }
    }

    return Ret;
}
/*! \brief Write XML data.
 *
 * \param Object wxsPropertyContainer*
 * \param Element TiXmlElement*
 * \return bool
 *
 */
bool wxsEditEnumProperty::XmlWrite(wxsPropertyContainer *Object, TiXmlElement *Element)
{
    if(XmlStoreEmpty || (VALUE != Default))
    {
        wxString Base = VALUE;
        wxString Result;
        for(const wxChar *Ch = Base.c_str(); *Ch; Ch++)
        {
            switch(*Ch)
            {
                case _T('_'):
                    Result << _T("__");
                    break;       // TODO: This is NOT compatible with xrc file when there's no version entry or version is less than 2.3.0.1
                    //case _T('&'):  Result << _T('_');  break;     // We could leave this to be translated into &amp; but this looks nicer ;)
                case _T('\\'):
                    Result << _T("\\\\");
                    break;
                    // We could handle \n and \r here too but this is not necessary since XRC loading
                    // routines also handle \n and \r chars
                default:
                    Result << *Ch;
            }
        }
        // TODO: Use proper encoding
        Element->InsertEndChild(TiXmlText(cbU2C(Result)));
        return true;
    }
    return false;
}
void SkyRenderComponent::CreateInheritedXmlElements(TiXmlElement* pBaseElement)
{
	TiXmlElement* pTextureNode = CB_NEW TiXmlElement("Texture");
	TiXmlText* pTextureText = CB_NEW TiXmlText(m_TextureResource.c_str());
	pTextureNode->LinkEndChild(pTextureText);
	
	pBaseElement->LinkEndChild(pTextureNode);
}
Exemplo n.º 9
0
void Profile::read_from_configuration (Configuration* configuration)
{
    TiXmlNode* node = 0;

    // insert initial mandatory declaration if not present
    TiXmlNode* decl = 0;
    for (TiXmlNode* child = xmlProfileDoc->FirstChild();
	 child && !decl; child = child->NextSibling() ) {
	decl = child->ToDeclaration ();
    }
    if (! decl) {
	node = xmlProfileDoc->InsertEndChild( TiXmlDeclaration( "1.0", "UTF-8", "no" ) );
	assert (node);
    }

    // for each configuration variable in configuration
    for (std::map<std::string, Variable*>::const_iterator conf_it = configuration->begin();
	 conf_it != configuration->end();
	 conf_it ++) {

	// start from root of DOM
	node = xmlProfileDoc;

	// get the variable name and break it up in its component vector
	std::string variable_name = conf_it->second->get_name ();
	std::vector<std::string> variable_name_vector = Variable::string_to_vector (variable_name);

	// for each component in variable name vector
	for (size_t i = 0; i < variable_name_vector.size(); i++) {

	    // check if component element exists
	    TiXmlElement* existing = node->FirstChildElement (variable_name_vector[i].c_str());
	    if (existing) {
		// carry on with existing component
		node = existing;

	    } else {
		// create missing component element and carry on with new component
		node = node->InsertEndChild (TiXmlElement (variable_name_vector[i].c_str()));
		assert (node);
	    }
	}

	// check if a text node for element exists
	TiXmlText* text = 0;
	for(TiXmlNode* child = node->FirstChild(); child && !text; child = child->NextSibling() ) {
	    text = child->ToText ();
	}
	if (text) {
	    // text child already exists, so remove it to set new value
	    node->RemoveChild (text);
	}
	node = node->InsertEndChild (TiXmlText (conf_it->second->get_value ().c_str ()));
	assert (node);
    
    }
}
Exemplo n.º 10
0
bool wxsFloatProperty::XmlWrite(wxsPropertyContainer* Object,TiXmlElement* Element)
{
    if ( VALUE != Default )
    {
        Element->InsertEndChild(TiXmlText(cbU2C(wxString::Format(_T("%lf"),VALUE))));
        return true;
    }
    return false;
}
Exemplo n.º 11
0
void ConfigManager::Write(const wxString& name, const ISerializable& object)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlElement *obj = GetUniqElement(e, key);

    TiXmlElement *s = GetUniqElement(obj, _T("obj"));
    SetNodeText(s, TiXmlText(cbU2C(wxBase64::Encode(object.SerializeOut()))));
}
Exemplo n.º 12
0
bool wxsBoolProperty::XmlWrite(cb_unused wxsPropertyContainer* Object,
                               TiXmlElement* Element)
{
    if ( VALUE != Default )
    {
        Element->InsertEndChild(TiXmlText(VALUE?"1":"0"));
        return true;
    }
    return false;
}
Exemplo n.º 13
0
bool wxsPositionSizeProperty::XmlWrite(wxsPropertyContainer* Object,TiXmlElement* Element)
{
    if ( !DEFVALUE )
    {
        wxString Str;
        Str.Printf(_T("%ld,%ld%s"),XVALUE,YVALUE,DUVALUE ? _T("d") : wxEmptyString);
        Element->InsertEndChild(TiXmlText(cbU2C(Str)));
        return true;
    }
    return false;
}
Exemplo n.º 14
0
static int _Encode( TiXmlNode *pNode, sqbind::CSqMulti *pData, int bIndexed, int nDepth = 0 )
{_STT();
	if ( !pNode || !pData )
		return 0;

	// For each element
	for ( sqbind::CSqMulti::iterator it = pData->list().begin(); it != pData->list().end(); it++ )
	{
		// Key name?
		if ( it->first == oexT( "$" ) )
			; // Ignore

		else
		{
			// Is it just an attribute
			if ( nDepth && !it->second.size() )
			{
				((TiXmlElement*)pNode)->SetAttribute( oexStrToMbPtr( it->first.c_str() ), oexStrToMbPtr( it->second.str().c_str() ) );

			} // end else if

			// Handle nested tag
			else
			{
				TiXmlNode *pItem = oexNULL;

				if ( !bIndexed )
				{	if ( it->first.length() )
						pItem = pNode->InsertEndChild( TiXmlElement( oexStrToMbPtr( it->first.c_str() ) ) );
				} // end if

				else if ( it->second.isset( oexT( "$" ) ) && it->second[ oexT( "$" ) ].str().length() )
					pItem = pNode->InsertEndChild( TiXmlElement( oexStrToMbPtr( it->second[ oexT( "$" ) ].str().c_str() ) ) );

				// Did we get an item?
				if ( pItem )
				{
					// Default value?
					if ( it->second.str().length() )
						pItem->InsertEndChild( TiXmlText( oexStrToMbPtr( it->second.str().c_str() ) ) );

					// Encode sub items
					_Encode( pItem, &it->second, bIndexed, nDepth + 1 );

				} // end if

			} // end else if

		} // end if

	} // end for

	return 1;
}
Exemplo n.º 15
0
void ConfigManager::WriteBinary(const wxString& name,  const wxString& source)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlElement *str = GetUniqElement(e, key);

    TiXmlElement *s = GetUniqElement(str, _T("bin"));
    s->SetAttribute("crc", wxCrc32::FromString(source));
    SetNodeText(s, TiXmlText(wxBase64::Encode(source).mb_str(wxConvUTF8)));
}
bool wxsDimensionProperty::XmlWrite(wxsPropertyContainer* Object,TiXmlElement* Element)
{
    if ( VALUE != DefaultValue || UNITS != DefaultDialogUnits )
    {
        wxString Buffer = wxString::Format(_T("%ld"),VALUE);
        if ( UNITS )
        {
            Buffer.Append(_T("d"));
        }

        Element->InsertEndChild(TiXmlText(cbU2C(Buffer)));
        return true;
    }
    return false;
}
Exemplo n.º 17
0
void AddTextElement(TiXmlElement* node, const char* name, const wxString& value)
{
	wxASSERT(node);

	TiXmlElement element(name);

	char* utf8 = ConvUTF8(value);
	if (!utf8)
		return;
	
    element.InsertEndChild(TiXmlText(utf8));
	delete [] utf8;

	node->InsertEndChild(element);
}
Exemplo n.º 18
0
 void SetText( TiXmlElement* element, const char * value)
 {
     if ( element->NoChildren() )
     {
         element->LinkEndChild( new TiXmlText( value ) );
     }
     else
     {
         if ( 0 == element->GetText() )
         {
             element->InsertBeforeChild( element->FirstChild(), TiXmlText( value ) );
         }
         else
         {
             // There already is text, so change it
             element->FirstChild()->SetValue( value );
         }
     }
 }
Exemplo n.º 19
0
void ConfigManager::Write(const wxString& name, const ConfigManagerContainer::SerializableObjectMap* map)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlElement *leaf = GetUniqElement(e, key);

    TiXmlElement *mNode;
    mNode = GetUniqElement(leaf, _T("objmap"));
    leaf->RemoveChild(mNode);
    mNode = GetUniqElement(leaf, _T("objmap"));

    for (ConfigManagerContainer::SerializableObjectMap::const_iterator it = map->begin(); it != map->end(); ++it)
    {
        TiXmlElement s(cbU2C(it->first));
        s.InsertEndChild(TiXmlText(cbU2C(wxBase64::Encode(it->second->SerializeOut()))));
        mNode->InsertEndChild(s);
    }
}
Exemplo n.º 20
0
void AddTextElement(TiXmlElement* node, const wxString& value)
{
	wxASSERT(node);

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

	for (TiXmlNode* pChild = node->FirstChild(); pChild; pChild = pChild->NextSibling())
	{
		if (!pChild->ToText())
			continue;

		node->RemoveChild(pChild);
		break;
	}
	
    node->InsertEndChild(TiXmlText(utf8));
	delete [] utf8;
}
void XMLModelDefinitionSerializer::exportViews(ModelDefinitionPtr modelDef, TiXmlElement& modelElem)
{
	TiXmlElement viewsElem("views");

	for (ViewDefinitionStore::const_iterator I = modelDef->getViewDefinitions().begin(); I != modelDef->getViewDefinitions().end(); ++I) {
		TiXmlElement viewElem("view");
		viewElem.SetAttribute("name", I->second->Name.c_str());

		TiXmlElement distanceElem("distance");
		std::stringstream ss;
		ss << I->second->Distance;
		distanceElem.InsertEndChild(TiXmlText(ss.str().c_str()));
		viewElem.InsertEndChild(distanceElem);

		TiXmlElement rotation("rotation");
		XMLHelper::fillElementFromQuaternion(rotation, I->second->Rotation);
		viewElem.InsertEndChild(rotation);

		viewsElem.InsertEndChild(viewElem);
	}
	modelElem.InsertEndChild(viewsElem);
}
Exemplo n.º 22
0
TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
{
	TiXmlNode* returnNode = 0;

	p = SkipWhiteSpace( p, encoding );
	if( !p || !*p || *p != '<' )
	{
		return 0;
	}

	p = SkipWhiteSpace( p, encoding );

	if ( !p || !*p )
	{
		return 0;
	}

	// What is this thing? 
	// - Elements start with a letter or underscore, but xml is reserved.
	// - Comments: <!--
	// - Decleration: <?xml
	// - Everthing else is unknown to tinyxml.
	//

	const char* xmlHeader = { "<?xml" };
	const char* commentHeader = { "<!--" };
	const char* dtdHeader = { "<!" };
	const char* cdataHeader = { "<![CDATA[" };

	if ( StringEqual( p, xmlHeader, true, encoding ) )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Declaration\n" );
		#endif
		returnNode = NEW TiXmlDeclaration();
	}
	else if ( StringEqual( p, commentHeader, false, encoding ) )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Comment\n" );
		#endif
		returnNode = NEW TiXmlComment();
	}
	else if ( StringEqual( p, cdataHeader, false, encoding ) )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing CDATA\n" );
		#endif
		TiXmlText* text = NEW TiXmlText( "" );
		text->SetCDATA( true );
		returnNode = text;
	}
	else if ( StringEqual( p, dtdHeader, false, encoding ) )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Unknown(1)\n" );
		#endif
		returnNode = NEW TiXmlUnknown();
	}
	else if (    IsAlpha( *(p+1), encoding )
			  || *(p+1) == '_' )
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Element\n" );
		#endif
		returnNode = NEW TiXmlElement( "" );
	}
	else
	{
		#ifdef DEBUG_PARSER
			TIXML_LOG( "XML parsing Unknown(2)\n" );
		#endif
		returnNode = NEW TiXmlUnknown();
	}

	if ( returnNode )
	{
		// Set the parent, so it can report errors
		returnNode->parent = this;
	}
	return returnNode;
}
Exemplo n.º 23
0
const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
{
	TiXmlDocument* document = GetDocument();

	// Read in text and elements in any order.
	const char* pWithWhiteSpace = p;
	p = SkipWhiteSpace( p, encoding );

	while ( p && *p )
	{
		if ( *p != '<' )
		{
			// Take what we have, make a text element.
			TiXmlText* textNode = NEW TiXmlText( "" );

			if ( !textNode )
			{
			    return 0;
			}

			if ( TiXmlBase::IsWhiteSpaceCondensed() )
			{
				p = textNode->Parse( p, data, encoding );
			}
			else
			{
				// Special case: we want to keep the white space
				// so that leading spaces aren't removed.
				p = textNode->Parse( pWithWhiteSpace, data, encoding );
			}

			if ( !textNode->Blank() )
				LinkEndChild( textNode );
			else
				DEL( textNode );
		} 
		else 
		{
			// We hit a '<'
			// Have we hit a new element or an end tag? This could also be
			// a TiXmlText in the "CDATA" style.
			if ( StringEqual( p, "</", false, encoding ) )
			{
				return p;
			}
			else
			{
				TiXmlNode* node = Identify( p, encoding );
				if ( node )
				{
					p = node->Parse( p, data, encoding );
					LinkEndChild( node );
				}				
				else
				{
					return 0;
				}
			}
		}
		pWithWhiteSpace = p;
		p = SkipWhiteSpace( p, encoding );
	}

	if ( !p )
	{
		if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
	}	
	return p;
}
void XMLModelDefinitionSerializer::exportActions(ModelDefinitionPtr modelDef, TiXmlElement& modelElem)
{
	TiXmlElement actionsElem("actions");

	for (ActionDefinitionsStore::const_iterator I = modelDef->getActionDefinitions().begin(); I != modelDef->getActionDefinitions().end(); ++I) {
		TiXmlElement actionElem("action");
		actionElem.SetAttribute("name", (*I)->getName().c_str());
		actionElem.SetDoubleAttribute("speed", (*I)->getAnimationSpeed());


		TiXmlElement activationsElem("activations");
		for (ActivationDefinitionStore::const_iterator J = (*I)->getActivationDefinitions().begin(); J != (*I)->getActivationDefinitions().end(); ++J) {
			TiXmlElement activationElem("activation");
			std::string type;
			switch ((*J)->type) {
			case ActivationDefinition::MOVEMENT:
				type = "movement";
				break;
			case ActivationDefinition::ACTION:
				type = "action";
				break;
			case ActivationDefinition::TASK:
				type = "task";
				break;
			}
			activationElem.SetAttribute("type", type);
			activationElem.InsertEndChild(TiXmlText((*J)->trigger));
			activationsElem.InsertEndChild(activationElem);
		}
		actionElem.InsertEndChild(activationsElem);

		if ((*I)->getAnimationDefinitions().size() > 0) {
			TiXmlElement animationsElem("animations");
			for (AnimationDefinitionsStore::const_iterator J = (*I)->getAnimationDefinitions().begin(); J != (*I)->getAnimationDefinitions().end(); ++J) {
				TiXmlElement animationElem("animation");
				animationElem.SetAttribute("iterations", (*J)->getIterations());

				for (AnimationPartDefinitionsStore::const_iterator K = (*J)->getAnimationPartDefinitions().begin(); K != (*J)->getAnimationPartDefinitions().end(); ++K) {
					TiXmlElement animationPartElem("animationpart");
					animationPartElem.SetAttribute("name", (*K)->Name.c_str());
					for (std::vector<BoneGroupRefDefinition>::const_iterator L = (*K)->BoneGroupRefs.begin(); L != (*K)->BoneGroupRefs.end(); ++L) {
						TiXmlElement boneGroupRefElem("bonegroupref");
						boneGroupRefElem.SetAttribute("name", L->Name.c_str());
						if (L->Weight != 1.0f) {
							boneGroupRefElem.SetAttribute("weight", L->Weight);
						}
						animationPartElem.InsertEndChild(boneGroupRefElem);
					}
					animationElem.InsertEndChild(animationPartElem);
				}

				animationsElem.InsertEndChild(animationElem);
			}
			actionElem.InsertEndChild(animationsElem);
		}

		//for now, only allow one sound
		if ((*I)->getSoundDefinitions().size() > 0)
		{
			TiXmlElement soundsElem("sounds");

			for (SoundDefinitionsStore::const_iterator J = (*I)->getSoundDefinitions().begin(); J != (*I)->getSoundDefinitions().end(); ++J) {
				TiXmlElement soundElem("sound");
				soundElem.SetAttribute("groupName", (*J)->groupName);
				soundElem.SetAttribute("playOrder", (*J)->playOrder);
				soundsElem.InsertEndChild(soundElem);
			}
		}
		actionsElem.InsertEndChild(actionElem);
	}
	modelElem.InsertEndChild(actionsElem);
}
Exemplo n.º 25
0
bool CDVDStateSerializer::DVDToXMLState( std::string &xmlstate, const dvd_state_t *state )
{
    char buffer[256];
    TiXmlDocument xmlDoc("navstate");

    TiXmlElement eRoot("navstate");
    eRoot.SetAttribute("version", 1);


    {   TiXmlElement eRegisters("registers");

        for( int i = 0; i < 24; i++ )
        {

            if( state->registers.SPRM[i] )
            {   TiXmlElement eReg("sprm");
                eReg.SetAttribute("index", i);

                {   TiXmlElement eValue("value");
                    sprintf(buffer, "0x%hx", state->registers.SPRM[i]);
                    eValue.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eValue);
                }

                eRegisters.InsertEndChild(eReg);
            }
        }

        for( int i = 0; i < 16; i++ )
        {
            if( state->registers.GPRM[i] || state->registers.GPRM_mode[i] || state->registers.GPRM_time[i].tv_sec || state->registers.GPRM_time[i].tv_usec )
            {   TiXmlElement eReg("gprm");
                eReg.SetAttribute("index", i);

                {   TiXmlElement eValue("value");
                    sprintf(buffer, "0x%hx", state->registers.GPRM[i]);
                    eValue.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eValue);
                }

                {   TiXmlElement eMode("mode");
                    sprintf(buffer, "0x%c", state->registers.GPRM_mode[i]);
                    eMode.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eMode);
                }

                {   TiXmlElement eTime("time");
                    {   TiXmlElement eValue("tv_sec");
                        sprintf(buffer, "%ld", state->registers.GPRM_time[i].tv_sec);
                        eValue.InsertEndChild( TiXmlText( buffer ) );
                        eTime.InsertEndChild( eValue ) ;
                    }

                    {   TiXmlElement eValue("tv_usec");
                        sprintf(buffer, "%ld", (long int)state->registers.GPRM_time[i].tv_usec);
                        eValue.InsertEndChild( TiXmlText( buffer ) );
                        eTime.InsertEndChild( eValue ) ;
                    }
                    eReg.InsertEndChild(eTime);
                }
                eRegisters.InsertEndChild(eReg);
            }
        }
        eRoot.InsertEndChild(eRegisters);
    }

    {   TiXmlElement element("domain");
        sprintf(buffer, "%d", state->domain);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("vtsn");
        sprintf(buffer, "%d", state->vtsN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("pgcn");
        sprintf(buffer, "%d", state->pgcN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("pgn");
        sprintf(buffer, "%d", state->pgN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("celln");
        sprintf(buffer, "%d", state->cellN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("cell_restart");
        sprintf(buffer, "%d", state->cell_restart);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("blockn");
        sprintf(buffer, "%d", state->blockN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement rsm("rsm");

        {   TiXmlElement element("vtsn");
            sprintf(buffer, "%d", state->rsm_vtsN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("blockn");
            sprintf(buffer, "%d", state->rsm_blockN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("pgcn");
            sprintf(buffer, "%d", state->rsm_pgcN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("celln");
            sprintf(buffer, "%d", state->rsm_cellN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement regs("registers");

            for( int i = 0; i < 5; i++ )
            {
                TiXmlElement reg("sprm");
                reg.SetAttribute("index", i);

                {   TiXmlElement element("value");
                    sprintf(buffer, "0x%hx", state->rsm_regs[i]);
                    element.InsertEndChild( TiXmlText(buffer) );
                    reg.InsertEndChild(element);
                }

                regs.InsertEndChild(reg);
            }
            rsm.InsertEndChild(regs);
        }
        eRoot.InsertEndChild(rsm);
    }


    xmlDoc.InsertEndChild(eRoot);

    std::stringstream stream;
    stream << xmlDoc;
    xmlstate = stream.str();
    return true;
}
Exemplo n.º 26
0
int main(){
    //______________________________________________________________________  
    // Read information from xml file.  
      
    // define xml file path, as follow , we use relative path,  
    // but you can use absolute path also.  
    const char* filepath = "phonebookdata.xml";  
    TiXmlDocument doc(filepath);  
    bool loadOkay = doc.LoadFile();  
    // faile to load 'phonebookdata.xml'.  
    if (!loadOkay) {      
        printf( "Could not load test file %s. Error='%s'. Exiting.\n", filepath,doc.ErrorDesc() );  
        exit( 1 );  
    }  
      
    // get dom root of 'phonebookdata.xml', here root should be 'phonebook'.  
    TiXmlElement* root = doc.RootElement();  
      
    printf("_______________________________________\n\n");  
    printf("     contacted person information      \n\n");  
    // trace every items below root.  
    for( TiXmlNode*  item = root->FirstChild( "item" );  
             item;  
             item = item->NextSibling( "item" ) ) {  
        printf("_______________________________________\n");  
      
        // read name.  
        TiXmlNode* child = item->FirstChild();  
        const char* name = child->ToElement()->GetText();  
        if (name) {  
            printf("name:%s\n",name);  
        } else {  
            printf("name:\n");  
        }  
      
        // read address.  
        child = item->IterateChildren(child);  
        const char* addr = child->ToElement()->GetText();  
        if (addr) {  
            printf("addr:%s\n",addr);  
        } else {  
            printf("addr:\n");  
        }  
      
      
        // read telephone no.  
        child = item->IterateChildren(child);  
        const char* tel = child->ToElement()->GetText();  
            if (tel) {  
            printf("tel:%s\n",tel);  
        } else {  
            printf("tel:\n");  
        }  
      
        // read e-mail.  
        child = item->IterateChildren(child);  
        const char* email = child->ToElement()->GetText();  
        if(email) {  
            printf("email:%s\n",email);  
        } else {  
            printf("email:\n");  
        }  
          
        printf("\n");  
      
    }  
    //______________________________________________________________________  
      
      
    //______________________________________________________________________  
    // Add information to xml file and save it.  
    TiXmlElement* writeRoot = doc.RootElement();  
    TiXmlNode* newNode = new TiXmlElement("item");  
      
       const TiXmlNode* name4NewNode = new TiXmlElement("name");  
    newNode->InsertEndChild(*name4NewNode)->InsertEndChild(TiXmlText("pipi"));  
      
    const TiXmlNode* addr4NewNode = new TiXmlElement("addr");  
    newNode->InsertEndChild(*addr4NewNode)->InsertEndChild(TiXmlText("Shaanxi Xianyang"));  
      
    const TiXmlNode* tel4NewNode = new TiXmlElement("tel");  
    newNode->InsertEndChild(*tel4NewNode)->InsertEndChild(TiXmlText("02937310627"));  
      
    const TiXmlNode* email4NewNode = new TiXmlElement("email");  
    newNode->InsertEndChild(*email4NewNode)->InsertEndChild(TiXmlText("[email protected]"));  
      
    writeRoot->InsertEndChild(*newNode);  
    doc.SaveFile();  
    //______________________________________________________________________  

}
Exemplo n.º 27
0
bool wxsMenuItem::OnXmlWrite(TiXmlElement* Element,bool IsXRC,bool IsExtra)
{
    bool Ret = wxsParent::OnXmlWrite(Element,IsXRC,IsExtra);

    if ( IsXRC )
    {
        // Type information is stored differently
        switch ( m_Type )
        {
            case Separator:
                Element->SetAttribute("class","separator");
                break;

            case Break:
                Element->SetAttribute("class","break");
                break;

            case Radio:
                Element->InsertEndChild(TiXmlElement("radio"))->ToElement()->InsertEndChild(TiXmlText("1"));
                break;

            case Check:
                Element->InsertEndChild(TiXmlElement("checkable"))->ToElement()->InsertEndChild(TiXmlText("1"));
                break;

            case Normal:
                break;
        }
    }

    return Ret;
}
Exemplo n.º 28
0
bool wxsToolBarItem::OnXmlWrite(TiXmlElement* Element,bool IsXRC,bool IsExtra)
{
    bool Ret = wxsParent::OnXmlWrite(Element,IsXRC,IsExtra);

    if ( IsXRC )
    {
        Element->SetAttribute("class","tool");

        switch ( m_Type )
        {
            case Separator:
                Element->SetAttribute("class","separator");
                break;

            case Radio:
                Element->InsertEndChild(TiXmlElement("radio"))->ToElement()->InsertEndChild(TiXmlText("1"));
                break;

            case Check:
                Element->InsertEndChild(TiXmlElement("check"))->ToElement()->InsertEndChild(TiXmlText("1"));
                break;

            case Normal:
                break;
        }
    }

    return Ret;
}
Exemplo n.º 29
0
ResNickMan::ResNickMan() {
    ReservedNicks = NULL;

	TiXmlDocument doc;
#ifdef _WIN32
	if(doc.LoadFile((PATH+"\\cfg\\ReservedNicks.xml").c_str()) == false) {
		TiXmlDocument doc((PATH+"\\cfg\\ReservedNicks.xml").c_str());
#else
	if(doc.LoadFile((PATH+"/cfg/ReservedNicks.xml").c_str()) == false) {
		TiXmlDocument doc((PATH+"/cfg/ReservedNicks.xml").c_str());
#endif
		doc.InsertEndChild(TiXmlDeclaration("1.0", "windows-1252", "yes"));
		TiXmlElement reservednicks("ReservedNicks");
		const char* Nicks[] = { "Hub-Security", "Admin", "Client", "PtokaX", "OpChat" };
		for(uint8_t ui8i = 0; ui8i < 5; ui8i++) {
			AddReservedNick(Nicks[ui8i]);
			TiXmlElement reservednick("ReservedNick");
			reservednick.InsertEndChild(TiXmlText(Nicks[ui8i]));

			reservednicks.InsertEndChild(reservednick);
		}
		doc.InsertEndChild(reservednicks);
		doc.SaveFile();
    }

#ifdef _WIN32
	if(doc.LoadFile((PATH+"\\cfg\\ReservedNicks.xml").c_str())) {
#else
	if(doc.LoadFile((PATH+"/cfg/ReservedNicks.xml").c_str())) {
#endif
		TiXmlHandle cfg(&doc);
		TiXmlNode *reservednicks = cfg.FirstChild("ReservedNicks").Node();
		if(reservednicks != NULL) {
			TiXmlNode *child = NULL;
			while((child = reservednicks->IterateChildren(child)) != NULL) {
				TiXmlNode *reservednick = child->FirstChild();
                    
				if(reservednick == NULL) {
					continue;
				}

				char *sNick = (char *)reservednick->Value();
                    
				AddReservedNick(sNick);
			}
        }
    }
}
//---------------------------------------------------------------------------
	
ResNickMan::~ResNickMan() {
    ReservedNick *next = ReservedNicks;

    while(next != NULL) {
        ReservedNick *cur = next;
        next = cur->next;

        delete cur;
    }
}
//---------------------------------------------------------------------------

// Check for reserved nicks true = reserved
bool ResNickMan::CheckReserved(const char * sNick, const uint32_t &hash) const {
    ReservedNick *next = ReservedNicks;

    while(next != NULL) {
        ReservedNick *cur = next;
        next = cur->next;

		if(cur->ui32Hash == hash && strcasecmp(cur->sNick, sNick) == 0) {
            return true;
        }
    }

    return false;
}
Exemplo n.º 30
0
/** Create new profile with default values.
 *
 */
void ProfileManager::buildProfile(const std::string p)
{
    TiXmlNode* root;
    TiXmlNode* node;
    TiXmlNode* module;
    TiXmlNode* element;
	

    // Create document
    delete xmlProfileDoc;
    xmlProfileDoc = new TiXmlDocument(p.c_str());

    // Insert initial mandatory declaration
    node = xmlProfileDoc->InsertEndChild( TiXmlDeclaration( "1.0", "UTF-8", "no" ) );
    assert( node );

    // Insert root element
    root = xmlProfileDoc->InsertEndChild( TiXmlElement( "Presage" ) );
    assert( root );

    // PluginRegistry module
    module = root->InsertEndChild( TiXmlElement( "PluginRegistry" ) );
    assert( module );
    if( module ) {
        element = module->InsertEndChild(TiXmlElement("LOGGER"));
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_LOGGER_LEVEL;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }

        element = module->InsertEndChild( TiXmlElement( "PLUGINS" ) );
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_PLUGINS;
            node = element->InsertEndChild(TiXmlText( ss.str().c_str() ));
            assert( node );
        }
    }

    // ContextTracker module
    module = root->InsertEndChild( TiXmlElement( "ContextTracker" ) );
    assert( module );
    if( module ) {
        element = module->InsertEndChild(TiXmlElement("LOGGER"));
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_LOGGER_LEVEL;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }

        element = module->InsertEndChild( TiXmlElement( "SLIDING_WINDOW_SIZE" ) );
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_SLIDING_WINDOW_SIZE;
            node = element->InsertEndChild(TiXmlText( ss.str().c_str() ));
            assert( node );
        }
    }
	
    // Selector module
    module = root->InsertEndChild( TiXmlElement( "Selector" ) );
    assert( module );
    if( module ) {
        element = module->InsertEndChild(TiXmlElement("LOGGER"));
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_LOGGER_LEVEL;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }

        element = module->InsertEndChild(TiXmlElement("SUGGESTIONS"));
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_SUGGESTIONS;
            node = element->InsertEndChild(TiXmlText( ss.str().c_str() ));
            assert( node );
        }
		
        element = module->InsertEndChild( TiXmlElement( "REPEAT_SUGGESTIONS" ) );
        assert( element );
        if( element ) {
            node = element->InsertEndChild( TiXmlText( "no" ) );
            assert( node );
        }
		
        element = module->InsertEndChild( TiXmlElement( "GREEDY_SUGGESTION_THRESHOLD" ) );
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_GREEDY_SUGGESTION_THRESHOLD;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }
    }

    // PredictorActivator module
    module = root->InsertEndChild( TiXmlElement( "PredictorActivator" ) );
    assert( module );
    if( module ) {
        element = module->InsertEndChild(TiXmlElement("LOGGER"));
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_LOGGER_LEVEL;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }

        element = module->InsertEndChild(TiXmlElement("PREDICT_TIME"));
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_PREDICT_TIME;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }

        element = module->InsertEndChild(TiXmlElement("MAX_PARTIAL_PREDICTION_SIZE"));
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_MAX_PARTIAL_PREDICTION_SIZE;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }

        element = module->InsertEndChild( TiXmlElement( "COMBINATION_POLICY" ) );
        assert( element );
        if( element ) {
            std::stringstream ss;
            ss << DEFAULT_COMBINATION_POLICY;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }

        element = module->InsertEndChild( TiXmlElement( "PLUGINS" ) );
        assert( element );
        if( element ) {
            std::stringstream ss;
            ss << DEFAULT_PREDICTIVE_PLUGINS;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }
    }

    // ProfileManager module
    module = root->InsertEndChild( TiXmlElement( "ProfileManager" ) );
    assert( module );
    if( module ) {
        element = module->InsertEndChild(TiXmlElement("LOGGER"));
        assert( element );
        if( element ) {
            std::ostringstream ss;
            ss << DEFAULT_LOGGER_LEVEL;
            node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
            assert( node );
        }
    }

    //PLUMP
    /*
    // PluginManager module
    module = root->InsertEndChild( TiXmlElement( "PluginManager" ) );
    assert( module );
    if( module ) {
    element = module->InsertEndChild( TiXmlElement( "PLUGIN_PATH" ) );
    assert( element );
    if( element ) {
    std::stringstream ss;
    ss << DEFAULT_PLUGIN_PATH;
    node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
    assert( node );
    }

    element = module->InsertEndChild( TiXmlElement( "PLUGIN_SUFFIX" ) );
    assert( element );
    if( element ) {
    std::stringstream ss;
    ss << DEFAULT_PLUGIN_SUFFIX;
    node = element->InsertEndChild( TiXmlText( ss.str().c_str() ) );
    assert( node );
    }
    }
    */

    // Plugin modules
    module = root->InsertEndChild( TiXmlElement( "Plugins" ) );
    assert( module );
    if( module ) {

        // handled by PluginManager object
        //PLUMP		pluginManager.createProfile( module );


    }

    // print out doc for debug purposes
    // result.Print();

}