本文整理汇总了C++中QXmlStreamAttributes类的典型用法代码示例。如果您正苦于以下问题:C++ QXmlStreamAttributes类的具体用法?C++ QXmlStreamAttributes怎么用?C++ QXmlStreamAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QXmlStreamAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
ViewItem* ArrowItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
ArrowItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
if (xml.isStartElement()) {
if (!rc && xml.name().toString() == "arrow") {
Q_ASSERT(!rc);
rc = new ArrowItem(view);
if (parent) {
rc->setParentViewItem(parent);
}
QXmlStreamAttributes attrs = xml.attributes();
QStringRef av;
av = attrs.value("startarrowhead");
if (!av.isNull()) {
rc->setStartArrowHead(QVariant(av.toString()).toBool());
}
av = attrs.value("endarrowhead");
if (!av.isNull()) {
rc->setEndArrowHead(QVariant(av.toString()).toBool());
}
av = attrs.value("startarrowheadscale");
if (!av.isNull()) {
rc->setStartArrowScale(QVariant(av.toString()).toDouble());
}
av = attrs.value("endarrowheadscale");
if (!av.isNull()) {
rc->setEndArrowScale(QVariant(av.toString()).toDouble());
}
// Add any new specialized ArrowItem Properties here.
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
}
} else if (xml.isEndElement()) {
if (xml.name().toString() == "arrow") {
break;
} else {
validTag = false;
}
}
if (!validTag) {
qDebug("invalid Tag\n");
Debug::self()->log(QObject::tr("Error creating arrow object from Kst file."), Debug::Warning);
delete rc;
return 0;
}
xml.readNext();
}
return rc;
}
示例2: Q_ASSERT
QPoint DrawingAnchor::loadXmlPos(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("pos"));
QPoint pos;
QXmlStreamAttributes attrs = reader.attributes();
pos.setX(attrs.value(QLatin1String("x")).toString().toInt());
pos.setY(attrs.value(QLatin1String("y")).toString().toInt());
return pos;
}
示例3: optional_assign
bool optional_assign(const QXmlStreamAttributes &attr, const char *key, T &v, const QXmlStreamReader &reader) {
if ( attr.hasAttribute(XmlUtil::XML_NS, key) ) {
v = checked_convert<T>(attr.value(XmlUtil::XML_NS, key).toString(), key, reader);
return true;
} else if ( attr.hasAttribute("", key) ) {
v = checked_convert<T>(attr.value("", key).toString(), key, reader);
return true;
}
return false;
}
示例4: i18n
/*!
Loads from XML.
*/
bool BinaryFilter::load(XmlStreamReader* reader) {
if(!reader->isStartElement() || reader->name() != "binaryFilter"){
reader->raiseError(i18n("no binary filter element found"));
return false;
}
QString attributeWarning = i18n("Attribute '%1' missing or empty, default value is used");
QXmlStreamAttributes attribs = reader->attributes();
// read attributes
QString str = attribs.value("vectors").toString();
if(str.isEmpty())
reader->raiseWarning(attributeWarning.arg("'vectors'"));
else
d->vectors = str.toInt();
str = attribs.value("dataType").toString();
if(str.isEmpty())
reader->raiseWarning(attributeWarning.arg("'dataType'"));
else
d->dataType = (BinaryFilter::DataType) str.toInt();
str = attribs.value("byteOrder").toString();
if(str.isEmpty())
reader->raiseWarning(attributeWarning.arg("'byteOrder'"));
else
d->byteOrder = (BinaryFilter::ByteOrder) str.toInt();
str = attribs.value("autoMode").toString();
if(str.isEmpty())
reader->raiseWarning(attributeWarning.arg("'autoMode'"));
else
d->autoModeEnabled = str.toInt();
str = attribs.value("startRow").toString();
if(str.isEmpty())
reader->raiseWarning(attributeWarning.arg("'startRow'"));
else
d->startRow = str.toInt();
str = attribs.value("endRow").toString();
if(str.isEmpty())
reader->raiseWarning(attributeWarning.arg("'endRow'"));
else
d->endRow = str.toInt();
str = attribs.value("skipStartBytes").toString();
if(str.isEmpty())
reader->raiseWarning(attributeWarning.arg("'skipStartBytes'"));
else
d->skipStartBytes = str.toInt();
str = attribs.value("skipBytes").toString();
if(str.isEmpty())
reader->raiseWarning(attributeWarning.arg("'skipBytes'"));
else
d->skipBytes = str.toInt();
return true;
}
示例5: LOG4CPP_INFO_S
void DocumentModelPointMatch::loadXml(QXmlStreamReader &reader)
{
LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelPointMatch::loadXml";
bool success = true;
QXmlStreamAttributes attributes = reader.attributes();
if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE) &&
attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED) &&
attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE) &&
attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED)) {
setMaxPointSize (attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE).toDouble());
setPaletteColorAccepted ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED).toInt());
setPaletteColorCandidate ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE).toInt());
setPaletteColorRejected ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED).toInt());
// Read until end of this subtree
while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
(reader.name() != DOCUMENT_SERIALIZE_POINT_MATCH)){
loadNextFromReader(reader);
if (reader.atEnd()) {
success = false;
break;
}
}
}
if (!success) {
reader.raiseError (QObject::tr ("Cannot read point match data"));
}
}
示例6: while
void GeneratorBMRC::Generate()
{
writer->setAutoFormatting(true);
writer->writeStartDocument("1.0");
writer->writeStartElement("Station");
writer->writeAttribute("STEP_GRID", QString::number(MainElement::GetStepGrid()));
writer->writeAttribute("RadContact", QString::number(MainElement::getRad()));
writer->writeAttribute("widthLinesElements", QString::number(MainElement::getWidthLinesElements()));
writer->writeAttribute("widthLinesContacts", QString::number(MainElement::getWidthLinesContacts()));
QVector<int> posx, posy;
while(!reader->atEnd() && !reader->hasError())
{
QXmlStreamReader::TokenType token = reader->readNext();
if(token == QXmlStreamReader::StartElement)
{
if(reader->name() == "Chain")
{
QXmlStreamAttributes attrib = reader->attributes();
int idChain;
if(attrib.hasAttribute("id"))
idChain = attrib.value("id").toInt();
ReadOneChain(reader, posx, posy);
}
}
}
for(int i=0;i<element.size();i++)
{
element[i]->SaveToXml(*writer);
}
writer->writeEndElement();//Station
writer->writeEndDocument();
reader->clear();
}
示例7: CmdPointChangeBase
CmdAddPointGraph::CmdAddPointGraph (MainWindow &mainWindow,
Document &document,
const QString &cmdDescription,
QXmlStreamReader &reader) :
CmdPointChangeBase (mainWindow,
document,
cmdDescription)
{
LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph";
QXmlStreamAttributes attributes = reader.attributes();
if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_X) ||
!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_Y) ||
!attributes.hasAttribute(DOCUMENT_SERIALIZE_CURVE_NAME) ||
!attributes.hasAttribute(DOCUMENT_SERIALIZE_ORDINAL) ||
!attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER)) {
xmlExitWithError (reader,
QString ("Missing attribute(s) %1, %2, %3, %4 and/or %5")
.arg (DOCUMENT_SERIALIZE_SCREEN_X)
.arg (DOCUMENT_SERIALIZE_SCREEN_Y)
.arg (DOCUMENT_SERIALIZE_CURVE_NAME)
.arg (DOCUMENT_SERIALIZE_ORDINAL)
.arg (DOCUMENT_SERIALIZE_IDENTIFIER));
}
m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
m_curveName = attributes.value(DOCUMENT_SERIALIZE_CURVE_NAME).toString();
m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
}
示例8: Q_UNUSED
/**
* Called when the webview finished loading a new page
*/
void PhoneGap::loadFinished( bool ok ) {
Q_UNUSED(ok)
// Change into the xml-directory
QDir xmlDir( m_workingDir );
xmlDir.cd( "xml" );
// Try to open the plugins configuration
QFile pluginsXml( xmlDir.filePath("plugins.xml") );
if( !pluginsXml.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
qDebug() << "Error loading plugins config!";
return;
}
// Start reading the file as a stream
QXmlStreamReader plugins;
plugins.setDevice( &pluginsXml );
// Get a reference to the current main-frame
QWebFrame *webFrame = m_webView->page()->mainFrame();
// Iterate over plugins-configuration and load all according plugins
while(!plugins.atEnd()) {
if( plugins.readNext() == QXmlStreamReader::StartElement ) {
// Check if we have a plugin element
if( plugins.name() == "plugin" ) {
QXmlStreamAttributes attribs = plugins.attributes();
// Check for name & value attributes
if( attribs.hasAttribute("name") && attribs.hasAttribute("value") ) {
// Construct object & attribute names
QString attribName = attribs.value( "name" ).toString();
QString attribValue = attribs.value( "value" ).toString();
QString objectName = attribName + "_native";
qDebug() << "Adding Plugin " << attribName << " with " << attribValue;
// Check for such a plugin
PGPlugin *currPlugin = PluginRegistry::getRegistry()->getPlugin( attribValue );
if( currPlugin != NULL ) {
currPlugin->setWebFrame( webFrame );
webFrame->addToJavaScriptWindowObject( objectName, currPlugin );
webFrame->evaluateJavaScript( "PhoneGap.Qt.registerObject( '" + attribValue + "', " + objectName + " )" );
webFrame->evaluateJavaScript( "PhoneGap.enablePlugin( '" + attribValue + "' )" );
}
else {
qDebug() << "Unknown Plugin " << attribName;
}
}
}
}
}
// Device is now ready to rumble
webFrame->evaluateJavaScript( "PhoneGap.deviceready();" );
}
示例9: QLatin1String
bool CeSdkHandler::parse()
{
// look at the file at %VCInstallDir%/vcpackages/WCE.VCPlatform.config
// and scan through all installed sdks...
m_list.clear();
VCInstallDir = QString::fromLatin1(qgetenv("VCInstallDir"));
VCInstallDir += QLatin1String("\\");
VSInstallDir = QString::fromLatin1(qgetenv("VSInstallDir"));
VSInstallDir += QLatin1String("\\");
if (VCInstallDir.isEmpty() || VSInstallDir.isEmpty())
return false;
QDir vStudioDir(VCInstallDir);
if (!vStudioDir.cd(QLatin1String("vcpackages")))
return false;
QFile configFile(vStudioDir.absoluteFilePath(QLatin1String("WCE.VCPlatform.config")));
if (!configFile.exists() || !configFile.open(QIODevice::ReadOnly))
return false;
QString currentElement;
CeSdkInfo currentItem;
QXmlStreamReader xml(&configFile);
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
currentElement = xml.name().toString();
if (currentElement == QLatin1String("Platform"))
currentItem = CeSdkInfo();
else if (currentElement == QLatin1String("Directories")) {
QXmlStreamAttributes attr = xml.attributes();
currentItem.m_include = fixPaths(attr.value(QLatin1String("Include")).toString());
currentItem.m_lib = fixPaths(attr.value(QLatin1String("Library")).toString());
currentItem.m_bin = fixPaths(attr.value(QLatin1String("Path")).toString());
}
} else if (xml.isEndElement()) {
if (xml.name().toString() == QLatin1String("Platform"))
m_list.append(currentItem);
} else if (xml.isCharacters() && !xml.isWhitespace()) {
if (currentElement == QLatin1String("PlatformName"))
currentItem.m_name = xml.text().toString();
else if (currentElement == QLatin1String("OSMajorVersion"))
currentItem.m_major = xml.text().toString().toInt();
else if (currentElement == QLatin1String("OSMinorVersion"))
currentItem.m_minor = xml.text().toString().toInt();
}
}
if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString();
return false;
}
return m_list.size() > 0 ? true : false;
}
示例10: QObject
// Constructor for parser function
Message::Message(XmlStreamReader& xml)
: QObject(),
m_timeStamp(),
m_timeStampPresent( false ),
m_code( 0 ),
m_codePresent( false ),
m_version( "1.0.0" ), // initialize fixed value
m_versionPresent( true ),
m_changed(true)
{
QXmlStreamAttributes attr = xml.attributes();
if ( attr.hasAttribute( "TimeStamp" ) )
{
if ( !setTimeStamp( QDateTime::fromString(attr.value( "TimeStamp" ).toString(), Qt::ISODate)) )
xml.validationError( "error set TimeStamp = " + attr.value( "TimeStamp" ).toString() );
}
if ( attr.hasAttribute( "Code" ) )
{
if ( !setCode( attr.value( "Code" ).toString().toInt() ) )
xml.validationError( "error set Code = " + attr.value( "Code" ).toString() );
}
if ( attr.hasAttribute( "Version" ) )
{
if ( !setVersion( attr.value( "Version" ).toString() ) )
xml.validationError( "error set Version = " + attr.value( "Version" ).toString() );
}
bool stop(false);
while(!xml.atEnd() && !stop)
{
QXmlStreamReader::TokenType token = xml.readNext();
switch ( token )
{
case QXmlStreamReader::EndElement:
if ( xml.name() == "Message" )
stop = true;
break;
case QXmlStreamReader::StartElement:
if ( xml.name() == "Argument" )
{
QString val = xml.readElementText();
if ( xml.name() != "Argument" )
xml.raiseError( "tag mismatch Argument" );
else if ( !addArgument( val ) )
xml.validationError( "error add Argument" );
}
else
{
xml.validationError( "unexpected element " + xml.name().toString() );
}
break;
default:
break;
}
}
}
示例11: handleStanza
bool handleStanza(const QXmlStreamAttributes &attributes)
{
if (!attributes.hasAttribute("branch"))
return false;
if (!attributes.hasAttribute("tip"))
return false;
data->branch = attributes.value("branch").toString();
data->tip = attributes.value("tip").toString();
return true;
}
示例12: if
DriOptionInfo::DriOptionInfo(QXmlStreamReader *xml)
{
QXmlStreamAttributes attributes = xml->attributes();
if (attributes.hasAttribute("name"))
name = attributes.value("name").toString();
else
throw "Missing name element to option info";
if (attributes.hasAttribute("type")) {
QString type_string = attributes.value("type").toString();
if (type_string == "bool")
type = OptionBool;
else if (type_string == "int")
type = OptionInt;
else if (type_string == "enum")
type = OptionEnum;
else if (type_string == "string")
type = OptionString;
else
throw "Unknown type element to option info";
} else
throw "Missing type element to option info";
if (attributes.hasAttribute("default"))
default_value = attributes.value("default").toString();
else
default_value.clear();
if (type == OptionEnum) {
if (!attributes.hasAttribute("valid"))
throw "Missing valid element to option info with enum";
QString valid_string = attributes.value("valid").toString();
QStringList valid_string_list = valid_string.split(':');
bool ok = 0;
if (!valid_string_list.count() == 2)
throw "Invalid valid element to option info with enum";
min_valid = valid_string_list[0].toInt(&ok);
if (!ok)
throw "Invalid valid element to option info with enum";
max_valid = valid_string_list[1].toInt(&ok);
if (!ok || min_valid > max_valid)
throw "Invalid valid element to option info with enum";
}
descriptions.clear();
if (!xml->readNextStartElement()) {
return;
}
do {
if (xml->name() == "description")
descriptions.append(new DescriptionLangInfo(xml));
else
xml->skipCurrentElement();
} while (xml->readNextStartElement());
}
示例13: parseStateChangedArgs
void CStateMachine::parseStateChangedArgs(QXmlStreamReader* reader)
{
m_state = e_state_changed;
QXmlStreamAttributes att = reader->attributes();
QStringRef stateStrRef = att.value(QString(), QString("state"));
bool ok;
m_sessionState = stateStrRef.toString().toInt(&ok);
if(!ok) m_sessionState = e_stopped;
}
示例14: getListWordFromDict
//------------------------------------------------------------------------------
void getListWordFromDict(const QString f_path, QMap<QString, QString>* f_map)
{
f_map->clear();
QFile* xmlFile = new QFile(f_path);
if (!xmlFile->open(QIODevice::ReadOnly | QIODevice::Text))
{
return;
}
QXmlStreamReader* xmlReader = new QXmlStreamReader(xmlFile);
//Parse the XML until we reach end of it
while(!xmlReader->atEnd() && !xmlReader->hasError())
{
// Read next element
QXmlStreamReader::TokenType token = xmlReader->readNext();
//If token is just StartDocument - go to next
if(token == QXmlStreamReader::StartDocument)
{
continue;
}
//If token is StartElement - read it
if(token == QXmlStreamReader::StartElement)
{
if(xmlReader->name() == "word")
{
QXmlStreamAttributes attrs = xmlReader->attributes();
QStringList t_list;
QString t_text;
t_list << xmlReader->readElementText().split("\n");
removeEmptyQStringFromQStringList(&t_list);
for (int i = 0; i < t_list.size(); i++)
{
t_text.append(QString(t_list.at(i)).replace(" ", "") + "\n");
}
f_map->insert(attrs.value("name").toString(), t_text);
}
}
}
if(xmlReader->hasError())
{
return;
}
//close reader and flush file
xmlReader->clear();
xmlFile->close();
}
示例15: addNode
void OsmDataManager::addNode(QXmlStreamReader& xml){
QXmlStreamAttributes attr = xml.attributes();
QString id = attr.value("id").toString();
float lat = attr.value("lat").toString().toFloat();
float lon = attr.value("lon").toString().toFloat();
QList<float> nodes;
nodes.append(lat);
nodes.append(lon);
m_nodes[id] = nodes;
xml.skipCurrentElement();
}