void XmlSync::processEntryType05(QDomElement &parentNode, QByteArray *data) { QDomElement entryNode = parentNode.firstChildElement(); QTextCodec *codec = QTextCodec::codecForName("Shift-JIS"); while(!entryNode.isNull()) { if(entryNode.tagName() == QString("text")) { QDomElement originalNode; QString originalText; GET_NODE(entryNode, "original", originalNode); GET_NODE_TEXT(originalNode, originalText); data->append(codec->fromUnicode(originalText)); } else if (entryNode.tagName() == QString("ctrl")) { QString ctrlString; ATTRIBUTE_TO_STRING_NOT_EMPTY(entryNode, "value", ctrlString); data->append(ctrlString); } else { fatalExit("Unknown tag (not 'text' or 'ctrl')"); } entryNode = entryNode.nextSiblingElement(); } }
void XmlSync::load(QString path, quint32 order) { QFile structFile(path); QXmlSimpleReader simpleread; QXmlInputSource input; QDomDocument *xmlData; QDomElement *root; if(!structFile.open(QIODevice::ReadOnly | QIODevice::Text)) { fatalExit("Failed to open input file!"); } if (order == 0) //Input file { xmlData = &xmlData_in; root = &root_in; } else //Template file { xmlData = &xmlData_out; root = &root_out; } //Use QXmlSimpleReader to read document since the default kills whitespace nodes which are needed. simpleread.setFeature(QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData"), true); input.setData(structFile.readAll()); xmlData->setContent(&input, &simpleread); structFile.close(); // Get root *root = xmlData->documentElement(); if(root->isNull()) { fatalExit("Root of the input XML file was not detected!"); } }
void XmlSync::saveXml(QString path) { QFile outFile(path); if( !outFile.open(QIODevice::WriteOnly)) { fatalExit("Cannot open output file!"); } QTextStream xmlOutStream(&outFile); xmlData_out.save(xmlOutStream, 2); xmlOutStream.flush(); outFile.close(); }
/** * @copydoc OptionalImplBase<T>::value */ T value() { if (!m_value) fatalExit("tried to retrieve value of Optional without value"); return *m_value; }
/** * @brief Gets the constant value. * @copydetails value */ const T& value() const { if (!m_hasValue) fatalExit("tried to retrieve value of Optional without value"); return *ptr(); }