本文整理汇总了C++中AttributeList::setAutoDelete方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeList::setAutoDelete方法的具体用法?C++ AttributeList::setAutoDelete怎么用?C++ AttributeList::setAutoDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeList
的用法示例。
在下文中一共展示了AttributeList::setAutoDelete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveElement
void saveElement(xmlElementPtr elem, xmlBufferPtr buf)
{
Q_UNUSED(buf);
if (elem)
{
QString elemName = QString((const char*)elem->name);
QFile file( DTD::dirName + elemName + ".tag" );
if ( file.open( IO_WriteOnly ) )
{
QTextStream stream( &file );
stream.setEncoding(QTextStream::UnicodeUTF8);
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
stream << "<!DOCTYPE TAGS>" << endl
<< "<TAGS>" << endl
<< "<tag name=\"" << elemName << "\">" << endl << endl;
xmlElementPtr el_ptr; /* Pointer to an element description */
xmlAttributePtr at_ptr;
el_ptr = xmlGetDtdElementDesc(DTD::dtd_ptr, elem->name);
AttributeList attributes;
attributes.setAutoDelete(true);
if (el_ptr)
{
at_ptr = el_ptr->attributes;
while (at_ptr) {
Attribute *attr = new Attribute;
attr->name = QString((const char*)at_ptr->name);
switch (at_ptr->def) {
case 1: {attr->status = "optional"; break;} //NONE
case 2: {attr->status = "required"; break;} //REQUIRED
case 3: {attr->status = "implied"; break;} //IMPLIED
case 4: {attr->status = "fixed"; break;} //FIXED
}
attr->defaultValue = QString((const char*)at_ptr->defaultValue);
xmlEnumerationPtr enum_ptr;
enum_ptr = at_ptr->tree;
while (enum_ptr) {
attr->values += QString((const char*)enum_ptr->name);
enum_ptr = enum_ptr->next;
}
QString attrtype;
switch (at_ptr->atype) {
case 9: {attrtype = "list"; break;}
default: {attrtype = "input"; break;} //TODO handle the rest of types
}
attr->type = attrtype;
attributes.append(attr);
at_ptr = at_ptr->nexth;
}
}
if (!attributes.isEmpty())
stream << QuantaCommon::xmlFromAttributes(&attributes);
const xmlChar *list_ptr[MAX_CHILD_ELEMENTS];
int childNum = 0;
childNum = xmlValidGetPotentialChildren(el_ptr->content, list_ptr,
&childNum, MAX_CHILD_ELEMENTS);
if (childNum > 0)
{
stream << "<children>" << endl;
for( int i = 0; i < childNum; i++ )
{
stream << " <child name=\"" << QString((const char*)list_ptr[i]) << "\"";
xmlElementPtr child_ptr = xmlGetDtdElementDesc(DTD::dtd_ptr, list_ptr[i]);
if (child_ptr && child_ptr->content && child_ptr->content->ocur)
{
//if (child_ptr->content->ocur == XML_ELEMENT_CONTENT_PLUS)
//{
// stream << " usage=\"required\"";
// }
QString ocur;
switch (child_ptr->content->ocur)
{
case 1: {ocur = "once"; break;}
case 2: {ocur = "opt"; break;}
case 3: {ocur = "mult"; break;}
case 4: {ocur = "plus"; break;}
}
stream << " usage=\"" << ocur << "\"";
QString name = QString((const char*)child_ptr->content->name);
if (name == "#PCDATA")
name == "#text";
stream << " name2=\"" << name << "\"";
}
stream << " />" << endl;
}
stream << "</children>" << endl;
stream << endl;
}
/*
xmlElementContentPtr content_ptr = el_ptr->content;
if (content_ptr)
{
stream << "<children>" << endl;
while (content_ptr)
{
if (!QString((const char*)content_ptr->name).isEmpty())
{
stream << " <child name=\"" << QString((const char*)content_ptr->name) << "\"";
//.........这里部分代码省略.........