本文整理汇总了C++中XmlAttribute类的典型用法代码示例。如果您正苦于以下问题:C++ XmlAttribute类的具体用法?C++ XmlAttribute怎么用?C++ XmlAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XmlAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetAttribute
void XmlElement::SetAttribute( const char * cname, const char * cvalue )
{
XmlAttribute* attrib = attributeSet.FindOrCreate( cname );
if ( attrib ) {
attrib->SetValue( cvalue );
}
}
示例2: Asset
//===========================================
// PauseMenu::PauseMenu
//===========================================
PauseMenu::PauseMenu(const XmlNode data)
: Asset(internString("PauseMenu")),
Entity(data.firstChild().firstChild().firstChild()),
Menu(data.firstChild()) {
try {
AssetManager assetManager;
XML_NODE_CHECK(data, PauseMenu);
XmlNode node = data.nthChild(1);
XML_NODE_CHECK(node, flare);
XmlAttribute attr = node.firstAttribute();
XML_ATTR_CHECK(attr, ptr);
long id = attr.getLong();
m_flare = boost::dynamic_pointer_cast<CSprite>(assetManager.getAssetPointer(id));
if (!m_flare)
throw XmlException("Bad asset id for flare item", __FILE__, __LINE__);
m_flare->addToWorld();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class PauseMenu; ");
throw;
}
}
示例3: Asset
//===========================================
// Animation::Animation
//===========================================
Animation::Animation(const XmlNode data)
: Asset(internString("Animation")),
m_state(STOPPED),
m_frameReady(false) {
try {
XML_NODE_CHECK(data, Animation);
XmlAttribute attr = data.firstAttribute();
XML_ATTR_CHECK(attr, name);
m_name = internString(attr.getString());
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, duration);
m_duration = attr.getFloat();
uint_t f = 0;
XmlNode node = data.firstChild();
while (!node.isNull() && node.name() == "AnimFrame") {
AnimFrame frame(node);
frame.number = f;
m_frames.push_back(frame);
++f;
node = node.nextSibling();
}
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class Animation; ");
throw;
}
}
示例4: SetDoubleAttribute
void XmlElement::SetDoubleAttribute( const std::string& name, double val )
{
XmlAttribute* attrib = attributeSet.FindOrCreate( name );
if ( attrib ) {
attrib->SetDoubleValue( val );
}
}
示例5: SetNodeAttribute
bool CXmlDocument::SetNodeAttribute(const CXmlNode& node, const CString& attributeName, const CString& value)
{
if(node.GetNode() == NULL)
return FALSE;
XmlAttribute pAttr;
HRESULT hr = m_pDoc->createAttribute((_bstr_t)attributeName, &pAttr);
if ( FAILED(hr) )
return FALSE;
hr = pAttr->put_text((_bstr_t)value);
if( FAILED(hr) )
return FALSE;
XmlMap pNodeMap;
hr = node.GetNode()->get_attributes(&pNodeMap);
if ( FAILED(hr) )
return FALSE;
XmlNode pNamedItem;
hr = pNodeMap->setNamedItem(pAttr, &pNamedItem);
if ( FAILED(hr) )
return FALSE;
return TRUE;
}
示例6: Asset
//===========================================
// CreditsMenu::CreditsMenu
//===========================================
CreditsMenu::CreditsMenu(const XmlNode data)
: Asset(internString("CreditsMenu")),
Entity(data.firstChild().firstChild().firstChild()),
Menu(data.firstChild()) {
try {
AssetManager assetManager;
XML_NODE_CHECK(data, CreditsMenu);
XmlNode node = data.nthChild(1);
XML_NODE_CHECK(node, font);
XmlAttribute attr = node.firstAttribute();
XML_ATTR_CHECK(attr, ptr);
long id = attr.getLong();
m_font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(id));
if (!m_font)
throw XmlException("Bad font asset id", __FILE__, __LINE__);
node = node.nextSibling();
XML_NODE_CHECK(node, fadeInTime);
m_fadeInTime = node.getFloat();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class CreditsMenu; ");
throw;
}
init();
}
示例7: testEmpty
void XmlAttributeUnitTests::testEmpty()
{
XmlAttribute attr;
CPPUNIT_ASSERT(attr.GetValue().empty());
CPPUNIT_ASSERT(false == attr.GetBoolValue(false));
CPPUNIT_ASSERT(true == attr.GetBoolValue(true));
}
示例8: assert
void XmlSchema::addSimpleVector(const XmlNode* child, String& structDefinition, size_t typeWidth,
String& readingFunction, String& writingFunction) const
{
assert(child != NULL);
XmlAttribute* type = child->findAttribute(ATTR_TYPE);
if (type == NULL)
{
return;
}
String typeString = T("std::vector<");
typeString += getSimpleTypeString(type);
typeString += T(">");
size_t thisWidth = typeString.size();
assert(thisWidth < typeWidth + 1);
for (size_t i = 0; i < typeWidth + 1 - thisWidth; ++i)
{
typeString += T(" ");
}
structDefinition += T(" ");
structDefinition += typeString;
structDefinition += getPluralName(child->getName());
structDefinition += T(";\r\n");
readingFunction += T("\r\n childNode = node->findFirstChild(");
readingFunction += LEFT_QUOTE;
readingFunction += child->getName();
readingFunction += T("\", iter);\r\n while (childNode != NULL)\r\n {\r\n ");
readingFunction += getPluralName(child->getName());
readingFunction += T(".resize(");
readingFunction += getPluralName(child->getName());
readingFunction += T(".size() + 1);\r\n ");
readingFunction += getPluralName(child->getName());
readingFunction += T(".back() = childNode->get");
String typeName = type->getString();
typeName[0] -= 32;
readingFunction += typeName;
readingFunction += T("();\r\n childNode = node->findNextChild(");
readingFunction += LEFT_QUOTE;
readingFunction += child->getName();
readingFunction += T("\", iter);\r\n }\r\n");
writingFunction += T("\r\n for (std::vector<");
writingFunction += getSimpleTypeString(type);
writingFunction += T(">::const_iterator iter = ");
writingFunction += getPluralName(child->getName());
writingFunction += T(".begin();\r\n iter != ");
writingFunction += getPluralName(child->getName());
writingFunction += T(".end();\r\n ++iter)\r\n {\r\n const ");
writingFunction += getSimpleTypeString(type);
writingFunction += T("& value = *iter;\r\n");
writingFunction += T(" childNode = node->addChild(");
writingFunction += LEFT_QUOTE;
writingFunction += child->getName();
writingFunction += T("\");\r\n childNode->set");
writingFunction += typeName;
writingFunction += T("(value);\r\n }\r\n");
}
示例9: Find
XmlAttribute *XmlElement::XmlAttributeSet::FindOrCreate(const String &sName)
{
XmlAttribute *pAttribute = Find(sName);
if (!pAttribute) {
pAttribute = new XmlAttribute();
Add(*pAttribute);
pAttribute->SetName(sName);
}
return pAttribute;
}
示例10: Find
XmlAttribute* XmlAttributeSet::FindOrCreate( const char* _name )
{
XmlAttribute* attrib = Find( _name );
if ( !attrib ) {
attrib = new XmlAttribute();
Add( attrib );
attrib->SetName( _name );
}
return attrib;
}
示例11: XML_NODE_CHECK
//===========================================
// Item::Item
//===========================================
Item::Item(const XmlNode data) {
try {
XML_NODE_CHECK(data, Item);
XmlAttribute attr = data.firstAttribute();
XML_ATTR_CHECK(attr, solid);
m_solid = attr.getBool();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class Item; ");
throw;
}
}
示例12: EntityPhysics
//===========================================
// Box2dPhysics::Box2dPhysics
//===========================================
Box2dPhysics::Box2dPhysics(Entity* entity, const XmlNode data)
: EntityPhysics(entity, data),
m_init(false),
m_entity(entity),
m_body(NULL),
m_opts(false, false, 1.f, 0.3f) {
init();
try {
XML_NODE_CHECK(data, Box2dPhysics);
XmlAttribute attr = data.firstAttribute();
XML_ATTR_CHECK(attr, dynamic);
m_opts.dynamic = attr.getBool();
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, fixedAngle);
m_opts.fixedAngle = attr.getBool();
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, density);
m_opts.density = attr.getFloat();
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, friction);
m_opts.friction = attr.getFloat();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class Box2dPhysics; ");
throw;
}
}
示例13: XML_NODE_CHECK
//===========================================
// Vec2i::Vec2i
//===========================================
Vec2i::Vec2i(const XmlNode data) {
try {
XML_NODE_CHECK(data, Vec2i);
XmlAttribute attr = data.firstAttribute();
XML_ATTR_CHECK(attr, x);
x = attr.getInt();
attr = attr.nextAttribute();
XML_ATTR_CHECK(attr, y);
y = attr.getInt();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class Vec2i; ");
throw;
}
}
示例14: getNodeMemberTypeWidth
size_t XmlSchema::getNodeMemberTypeWidth(const XmlNode* node) const
{
size_t maxWidth = 0;
size_t width = 0;
NodeIterator iter;
for (const XmlNode* child = node->getFirstChild(iter);
child != NULL;
child = node->getNextChild(iter))
{
XmlAttribute* multiple = child->findAttribute(ATTR_MULTIPLE);
if (child->isEmpty())
{
//simple type
XmlAttribute* type = child->findAttribute(ATTR_TYPE);
if (type == NULL)
{
continue;
}
width = getSimpleTypeString(type).size();
if (multiple != NULL && multiple->getBool())
{
width += Strlen(T("std::vector<>"));
}
}
else
{
//struct type
width = Strlen(child->getName());
if (multiple != NULL && multiple->getBool())
{
width += Strlen(T("std::vector<>"));
}
}
if (width > maxWidth)
{
maxWidth = width;
}
}
return maxWidth;
}
示例15: _readNodeCallback
bool LibreOfficeInspector::_readNodeCallback(XmlNode node, void *data)
{
vector <XmlAttribute>* attributes;
bool bIsItem;
if (g_parsing_state == PropUILocale && node.GetName().compare(L"value")==0)
{
wstring* lang_found = (wstring *) data;
*lang_found = node.GetText();
g_parsing_state = ItemOther;
return false;
}
bIsItem = node.GetName().compare(L"item") == 0;
if (bIsItem && g_parsing_state != ItemOther)
{
g_parsing_state = ItemOther;
}
attributes = node.GetAttributes();
for (unsigned int i = 0; i < attributes->size(); i++)
{
XmlAttribute attribute;
attribute = attributes->at(i);
if (g_parsing_state == ItemOther && bIsItem && attribute.GetName() == L"oor:path" && attribute.GetValue() == L"/org.openoffice.Office.Linguistic/General")
{
g_parsing_state = ItemLinguisticGeneral;
}
if (g_parsing_state == ItemLinguisticGeneral && attribute.GetName() == L"oor:name" && attribute.GetValue() == L"UILocale")
{
g_parsing_state = PropUILocale;
}
}
return true;
}