Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit d038b698 authored by EXT Arnaud Clère's avatar EXT Arnaud Clère
Browse files

small XML changes

parent eaf20d83
......@@ -49,11 +49,15 @@
// QBind<T,QXmlStreamWriter> support
//! \warning Since XML has no standard way of encoding data structures, we choose a rather implicit one
//! based on the fact that XML elements are implicit data structures unless they contain text without elements.
//! based on the fact that XML elements are implicit data structures unless they contain text without elements,
//! in which case it is customary to let the reader interpret XML text representation as specific data types.
//! \li sequence : element named after outer item or metaData[qmName] or "sequence"
//! \li record : element named after outer item or metaData[qmName] or "record"
//! \li null : empty element named after outer item or metaData[qmName] or "item"
//! \li BindNative: text element named after outer item or metaData[qmName] or "item", containing the default text representation
//! \li null : empty element named after outer item or metaData[qmName] or "null"
//! \li BindNative: text element named after outer item or metaData[qmName] or XSD typename, containing the default text representation
//! \see https://www.w3.org/TR/xmlschema-2/#built-in-datatypes
//! \note Selecting heterogeneous sequence items reliably can still be made using XPath "*[i]"
//! \note A more explicit encoding variant could add implicit type information as an attribute to enable roundtrips to/from other generic data structures at the expense of space
class QXmlWriter : public IWriter
{
Q_DISABLE_COPY(QXmlWriter)
......@@ -71,8 +75,14 @@ public:
protected:
bool _sequence(quint32* =nullptr) { io->writeStartElement(tag("sequence") ); att(); return true; }
bool _record (quint32* =nullptr) { io->writeStartElement(tag("record" ) ); att(); return true; }
bool _null ( ) { io->writeEmptyElement(tag("item" ) ); att(); return true; }
bool _bind ( const char* s) { io->writeTextElement (tag("item" ),s); att(); return true; }
bool _null ( ) { io->writeEmptyElement(tag("null" ) ); att(); return true; }
bool _bind ( const char* s) { io->writeTextElement (tag("string" ),s); att(); return true; }
bool _bind ( bool&& s) { io->writeTextElement (tag("boolean" ),s ? "true" : "false"); att(); return true; }
bool _bind ( qint64&& n) { const int s=66; char c[s]; io->writeTextElement(tag("integer"), qlltoa2(c+s, n)); att(); return true; }
bool _bind ( quint64&& n) { const int s=66; char c[s]; io->writeTextElement(tag("integer"),qulltoa2(c+s, n)); att(); return true; }
bool _bind ( float&& n) { static QUtf8String s; s.setNum(double(n),'g',std::numeric_limits< float>::max_digits10); io->writeTextElement(tag("decimal"),s.constData()); att(); return true; } // with specific precision
bool _bind ( double&& n) { static QUtf8String s; s.setNum( n ,'g',std::numeric_limits< double>::max_digits10); io->writeTextElement(tag("decimal"),s.constData()); att(); return true; } // with specific precision
bool _bind ( QByteArray&& s) { QUtf8String hex(s.size()*2+2+1,'\0'); hex.append("0x"); hex.append(s.toHex().toUpper()); io->writeTextElement(tag("hexBinary"),hex.constData()); att(); return true; }
bool _isOk() noexcept { return !io->hasError(); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment