本文整理汇总了C++中QDomNode::toCDATASection方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::toCDATASection方法的具体用法?C++ QDomNode::toCDATASection怎么用?C++ QDomNode::toCDATASection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::toCDATASection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nodeToVariant
//! function
static bool nodeToVariant(const QDomNode &aNode,QVariant &aValue) {
bool vRetval = false;
QString vType, vValue;
aValue = QVariant();
if(!vRetval && aNode.isCDATASection()) {
vValue = aNode.toCDATASection().data();
vRetval = true;
}
if(!vRetval && aNode.isText()) {
vValue = aNode.toText().data();
vRetval = true;
}
if(!vRetval) return vRetval;
if(vValue.isEmpty()) return false; // ????
const QDomNode vParent = aNode.parentNode();
if(vParent.isElement()) {
vType = vParent.toElement().attribute(QString::fromLatin1("type"));
}
if(vType == QString::fromLatin1("bytearray")) {
aValue = QVariant(vValue.toLatin1());
}
else if(vType == QString::fromLatin1("variant")) {
QByteArray vArray(vValue.toLatin1());
QDataStream vStream(&vArray, QIODevice::ReadOnly);
vStream >> aValue;
}
示例2: QDomCDATASection
QDomCDATASection QDomNodeProto:: toCDATASection() const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->toCDATASection();
return QDomCDATASection();
}
示例3: memset
bool Ersky9xInterface::loadModelDataXML(QDomDocument * qdoc, ModelData *model, int modelNum, int stickMode)
{
T ersky9xModel;
memset(&ersky9xModel, 0, sizeof(ersky9xModel));
//look for MODEL_DATA with modelNum attribute.
//if modelNum = -1 then just pick the first one
QDomNodeList ndl = qdoc->elementsByTagName("MODEL_DATA");
//cycle through nodes to find correct model number
QDomNode k = ndl.at(0);
if (modelNum>=0) {
while(!k.isNull()) {
int a = k.toElement().attribute("number").toInt();
if(a==modelNum)
break;
k = k.nextSibling();
}
}
if (k.isNull()) // couldn't find
return false;
//load cdata into tgen
QDomNode n = k.toElement().elementsByTagName("Data").at(0).firstChild();// get all children in Data
while (!n.isNull()) {
if (n.isCDATASection()) {
QString ds = n.toCDATASection().data();
QByteArray ba = QByteArray::fromBase64(ds.toAscii());
const char * data = ba.data();
memcpy(&ersky9xModel, data, std::min(ba.size(), (int)sizeof(ersky9xModel)));
break;
}
n = n.nextSibling();
}
applyStickModeToModel(ersky9xModel, stickMode);
*model = ersky9xModel;
return true;
}
示例4: while
bool Ersky9xInterface::loadGeneralDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen)
{
//look for "GENERAL_DATA" tag
QDomElement gde = qdoc->elementsByTagName("GENERAL_DATA").at(0).toElement();
if(gde.isNull()) // couldn't find
return false;
//load cdata into tgen
QDomNode n = gde.elementsByTagName("Data").at(0).firstChild();// get all children in Data
while (!n.isNull()) {
if (n.isCDATASection()) {
QString ds = n.toCDATASection().data();
QByteArray ba = QByteArray::fromBase64(ds.toAscii());
const char * data = ba.data();
memcpy(tgen, data, std::min((unsigned int)ba.size(), (unsigned int)sizeof(Ersky9xGeneral)));
break;
}
n = n.nextSibling();
}
//check version?
return true;
}
示例5: loadXmlElement
bool ImageOptions::loadXmlElement(QDomElement element)
{
bool result = false;
auto readStringFromNode = [this](QDomElement element, const QString elementName, QString * result) {
if (element.tagName() == elementName) {
QDomNode dataNode = element.firstChild();
if (dataNode.isCDATASection()) {
QDomCDATASection cdataSection = dataNode.toCDATASection();
QString strValue = cdataSection.data();
*result = this->unescapeEmpty(strValue);
} else {
QString strValue = element.text();
*result = this->unescapeEmpty(strValue);
}
}
};
QDomNode nodeSett = element.firstChild();
while (!nodeSett.isNull()) {
QDomElement e = nodeSett.toElement();
if (e.tagName() == ImageOptions::GroupName) {
break;
}
nodeSett = nodeSett.nextSibling();
}
if (nodeSett.isNull()) {
return result;
}
quint32 uBytesOrder = 0, uBlockSize = 0, uBlockDefaultOnes = 0, uSplitToRows = 0;
quint32 uCompressionRle = 0, uCompressionRleMinLength = 2;
QString sBlockPrefix = "0x", sBlockSuffix, sBlockDelimiter = ", ";
QString sPreviewPrefix, sPreviewSuffix, sPreviewDelimiter, sPreviewLevels;
QDomNode nodeValue = nodeSett.firstChild();
while (!nodeValue.isNull()) {
QDomElement e = nodeValue.toElement();
if (!e.isNull()) {
if (e.tagName() == ImageOptions::FieldBlockSize) {
QString str = e.text();
uBlockSize = str.toUInt(&result);
}
if (e.tagName() == ImageOptions::FieldBytesOrder) {
QString str = e.text();
uBytesOrder = str.toUInt(&result);
}
if (e.tagName() == ImageOptions::FieldSplitToRows) {
QString str = e.text();
uSplitToRows = str.toUInt(&result);
}
if (e.tagName() == ImageOptions::FieldCompressionRle) {
QString str = e.text();
uCompressionRle = str.toUInt(&result);
}
if (e.tagName() == ImageOptions::FieldCompressionRleMinLength) {
QString str = e.text();
uCompressionRleMinLength = str.toUInt(&result);
}
if (e.tagName() == ImageOptions::FieldBlockDefaultOnes) {
QString str = e.text();
uBlockDefaultOnes = str.toUInt(&result);
}
readStringFromNode(e, ImageOptions::FieldBlockPrefix, &sBlockPrefix);
readStringFromNode(e, ImageOptions::FieldBlockSuffix, &sBlockSuffix);
readStringFromNode(e, ImageOptions::FieldBlockDelimiter, &sBlockDelimiter);
readStringFromNode(e, ImageOptions::FieldPreviewPrefix, &sPreviewPrefix);
readStringFromNode(e, ImageOptions::FieldPreviewSuffix, &sPreviewSuffix);
readStringFromNode(e, ImageOptions::FieldPreviewDelimiter, &sPreviewDelimiter);
readStringFromNode(e, ImageOptions::FieldPreviewLevels, &sPreviewLevels);
if (!result) {
break;
}
}
nodeValue = nodeValue.nextSibling();
}
if (result) {
this->setBlockSize((Parsing::Conversion::Options::DataBlockSize)uBlockSize);
this->setBlockDefaultOnes((bool)uBlockDefaultOnes);
this->setBytesOrder((Parsing::Conversion::Options::BytesOrder)uBytesOrder);
this->setSplitToRows((bool)uSplitToRows);
this->setCompressionRle((bool)uCompressionRle);
this->setCompressionRleMinLength(uCompressionRleMinLength);
//.........这里部分代码省略.........