35#include <QDomDocument>
43#include "klfdatautil_p.h"
46static inline bool klf_is_hex_char(
char c)
48 return (
'0' <= c && c <=
'9') || (
'a' <= c && c <=
'f') || (
'A' <= c && c <=
'F');
53#define KLF_BRUSH_STYLE(sty) \
54 { Qt::sty##Pattern, #sty }
57 { Qt::NoBrush,
"NoBrush" },
58 { Qt::SolidPattern,
"" },
59 { Qt::SolidPattern,
"Solid" },
78#define KLF_TEXT_FORMAT_FORMAT(fmt) \
79 { QTextFormat::fmt##Format, #fmt "Format" }
81static struct {
int formatId;
const char *
format; } klf_text_format_formats[] = {
93#define KLF_TEXT_FORMAT_PROP(p, type) \
94 { QTextFormat::p, #p, #type }
96static struct {
int propId;
const char *
key;
const char *
type; } klf_text_format_props[] = {
105 { QTextFormat::ForegroundBrush,
"FG",
"QBrush" },
106 { QTextFormat::BackgroundBrush,
"BG",
"QBrush" },
112 {
"NORMALWEIGHT", QTextFormat::FontWeight,
QVariant(QFont::Normal) },
113 {
"BOLD", QTextFormat::FontWeight,
QVariant(QFont::Bold) },
114 {
"NORMALSTYLE", QTextFormat::FontItalic,
QVariant(
false) },
115 {
"ITALIC", QTextFormat::FontItalic,
QVariant(
true) },
127 klfDbg(
"len="<<value_ba.
size()<<
" , data=`"<<value_ba<<
"' escapechar="<<
klfFmtCC(
"'\\x%02X'", (
int)escapechar));
131 for (k = 0; k < value_ba.
size(); ++k) {
133 if (value_ba[k] >= 32 && value_ba[k] <= 126 && value_ba[k] != escapechar) {
136 }
else if (value_ba[k] == escapechar) {
151 klfDbg(
"data=`"<<data<<
"', escapechar="<<
klfFmtCC(
"'\\x%02X'", (
int)escapechar));
157 while (k < data.
size()) {
158 if (data[k] != escapechar) {
164 if (data[k] == escapechar && k+1 >= data.
size()) {
165 value_ba += escapechar;
170 if (data[k+1] !=
'x') {
173 if (data[k+1] ==
'n')
175 if (data[k+1] ==
'0')
177 if (data[k+1] ==
't')
179 if (data[k+1] ==
'a')
181 if (data[k+1] ==
'b')
183 if (data[k+1] ==
'f')
185 if (data[k+1] ==
'r')
187 if (data[k+1] ==
'v')
190 value_ba += data[k+1];
195 if (k+3 >= data.
size() || !klf_is_hex_char(data[k+2]) || !klf_is_hex_char(data[k+3])) {
197 klfDbg(
"ignoring invalid escape sequence `"<<data.
mid(k,4)<<
"'") ;
203 uchar cval = data.
mid(k+2, 2).
toUInt(&convertOk, 16);
204 value_ba += (char)cval;
214 for (
int k = 0; k < list.
size(); ++k) {
221 if (k < list.
size()-1)
233 bool first_item =
true;
235 for (k = 0; k < sections.size(); ++k) {
243 key.replace(
"\\",
"\\\\");
244 key.replace(
";",
"\\;");
245 key.replace(
"=",
"\\=");
248 if (val.
isEmpty() && ignore_empty_values)
251 data +=
key +
"=" + val;
260 klfDbg(
"decaps_list, data="<<ba_data);
270 while (k < data.
size()) {
271 if (data[k] ==
';') {
278 if (data[k] ==
'\\') {
279 if (k+1 < data.
size()) {
288 if (data[k] ==
']') {
305 klfDbg(
"sections="<<sections);
325 while (k < data.
size()) {
326 if (data[k] ==
';') {
328 if (!allow_empty_values && curChunk == &chunkkey)
329 qWarning()<<KLF_FUNC_NAME<<
": no '=' in pair at pos "<<k<<
" in string: "<<data<<
"";
330 sections << QPair<QByteArray,QByteArray>(chunkkey, chunkvalue);
334 curChunk = &chunkkey;
337 if (data[k] ==
'\\') {
338 if (k+1 < data.
size()) {
339 *curChunk += data[k+1];
342 *curChunk += data[k];
347 if (curChunk == &chunkkey && data[k] ==
'=') {
349 curChunk = &chunkvalue;
353 if (data[k] ==
'}') {
356 if (!allow_empty_values && curChunk == &chunkkey)
357 qWarning()<<
"klfLoadVariantFromText: no '=' in pair at pos "<<k<<
" in string: "<<data<<
"";
358 sections << QPair<QByteArray,QByteArray>(chunkkey, chunkvalue);
362 *curChunk += data[k];
382 bool result = xmldoc.setContent(xmldata);
388 "Wrong XML root node in wrapper for klfLoadVariantFromText(): "
403 klfDbg(
"saving null variant.");
404 if (savedType != NULL)
410 switch ((
int)value.
type()) {
411 case QMetaType::Bool:
412 data = value.
toBool() ?
"true" :
"false";
415 case QMetaType::UInt:
416 case QMetaType::Short:
417 case QMetaType::UShort:
418 case QMetaType::Long:
419 case QMetaType::ULong:
420 case QMetaType::LongLong:
421 case QMetaType::ULongLong:
422 case QMetaType::Double:
425 case QMetaType::Char:
427 char c = value.
value<
char>();
428 if (c >= 32 && c <= 126 && c !=
'\\') {
430 }
else if (c ==
'\\') {
437 case QMetaType::QChar:
442 }
else if (c ==
'\\') {
449 case QMetaType::QString:
458 for (k = 0; k < s.
length(); ++k) {
468 case QMetaType::QStringList:
473 for (k = 0; k < list.
size(); ++k) {
476 data = encaps_list(sections);
479 case QMetaType::QUrl:
481 case QMetaType::QByteArray:
486 case QMetaType::QDate:
487 data = value.
value<
QDate>().toString(Qt::SystemLocaleShortDate).toLocal8Bit();
break;
488 case QMetaType::QTime:
489 data = value.
value<
QTime>().toString(Qt::SystemLocaleShortDate).toLocal8Bit();
break;
490 case QMetaType::QDateTime:
491 data = value.
value<
QDateTime>().toString(Qt::SystemLocaleShortDate).toLocal8Bit();
break;
492 case QMetaType::QSize:
497 case QMetaType::QPoint:
502 case QMetaType::QRect:
507 case QMetaType::QColor:
509 klfDbg(
"Saving color "<<c<<
": alpha="<<c.
alpha()) ;
510 if (c.
alpha() == 255)
516 case QMetaType::QFont:
520 case QFont::Light: data +=
" Light";
break;
521 case QFont::Normal:
break;
522 case QFont::DemiBold: data +=
" DemiBold";
break;
523 case QFont::Bold: data +=
" Bold";
break;
524 case QFont::Black: data +=
" Black";
break;
528 case QFont::StyleNormal:
break;
529 case QFont::StyleItalic: data +=
" Italic";
break;
530 case QFont::StyleOblique: data +=
" Oblique";
break;
537 case QMetaType::QBrush:
541 int bstyle = b.
style();
544 bool found_style =
false;
545 for (k = 0; klf_brush_styles[k].brushStyle >= 0 && klf_brush_styles[k].style != NULL; ++k) {
546 if (klf_brush_styles[k].
brushStyle == bstyle) {
557 data += klf_brush_styles[k].style;
558 if (strlen(klf_brush_styles[k].
style))
565 case QMetaType::QTextFormat:
574 for (k = 0; klf_text_format_formats[k].format != NULL; ++k)
577 if (klf_text_format_formats[k].
format == NULL) {
584 sections << QPair<QByteArray,QByteArray>(klf_text_format_formats[k].
format,
QByteArray());
587 for (it = props.begin(); it != props.end(); ++it) {
593 for (k = 0; klf_text_format_keywords[k].keyword != NULL; ++k)
595 klf_text_format_keywords[k].
fixed_value == propValue)
597 const char *kw = klf_text_format_keywords[k].keyword;
601 sections << QPair<QByteArray,QByteArray>(kw,
QByteArray());
606 for (k = 0; klf_text_format_props[k].key != NULL; ++k)
609 if (klf_text_format_props[k].
key != NULL) {
611 if ( !strcmp(klf_text_format_props[k].
type, propValue.
typeName()) ) {
615 sections << QPair<QByteArray,QByteArray>(
key, value);
618 qWarning()<<KLF_FUNC_NAME<<
": QTextFormat property "<<klf_text_format_props[k].key
619 <<
" 's type is `"<<propValue.
typeName()<<
"' which is not the known type: "
620 <<klf_text_format_props[k].type;
629 data = encaps_map(sections,
true);
632 case QMetaType::QVariantList:
636 if (saveListAndMapsAsXML) {
643 for (k = 0; k < list.
size(); ++k) {
645 innertype = list[k].typeName();
646 if (innertype != list[k].typeName()) {
647 klfWarning(
"saving list: not all inner QVariants have same type. Found a "<<innertype
648 <<
" along with a "<<list[k].typeName());
652 if (savedListOrMapType != NULL)
653 *savedListOrMapType = innertype;
654 data = encaps_list(sections);
658 case QMetaType::QVariantMap:
662 if (saveListAndMapsAsXML) {
667 klfDbg(
"saved XML: data="<<data) ;
671 bool firstround =
true;
675 thistype = it.value().typeName();
677 innertype = thistype;
680 if (innertype != thistype) {
681 klfWarning(
"saving map: not all inner QVariants have same type. Found a "<<innertype
682 <<
" along with a "<<thistype);
684 sections << QPair<QByteArray,QByteArray>(k, v);
686 if (savedListOrMapType != NULL)
687 *savedListOrMapType = innertype;
688 data = encaps_map(sections);
706 if (savedType != NULL) {
707 *savedType = typeName +
"/" + typeSpec;
710 if (savedType != NULL)
711 *savedType = typeName;
714 if (typeName ==
"KLFEnumType") {
727 if (!hasfixedtypes) {
731 QVariantMap propstexts;
732 for (QVariantMap::const_iterator it = props.begin(); it != props.end(); ++it) {
734 klfDbg(
"Saving property "<<it.key()<<
" to text, value = "<<propstexts[it.key()]) ;
759 qDebug(
"\tVariant value is %s, len=%d", vdata.
constData(), vdata.
size());
764 klfDbg(
"klfSaveVariantToText("<<value<<
"): saved data (len="<<data.
size()<<
") : "<<data ) ;
772 const char *listOrMapDataTypeName)
778#define RX_INT "-?\\d+"
779#define RX_COORD_SEP "\\s*(?:[,;]|\\s)\\s*"
780#define RX_SIZE_SEP "\\s*(?:[,;x]|\\s)\\s*"
784 static const int V2RX_X = 1, V2RX_Y = 2;
788 static const int SZRX_W = 1, SZRX_H = 2;
796 static const int RECTRX_X1 = 1, RECTRX_Y1 = 2, RECTRX_MIDDLESEP_PLUS = 3,
797 RECTRX_X2orW = 4, RECTRX_LASTSEP_X = 5, RECTRX_Y2orH = 6;
802 "(" RX_COORD_SEP "(\\d+))?\\s*\\)?", Qt::CaseInsensitive);
803 static const int COLRX_R = 1, COLRX_G = 2, COLRX_B = 3, COLRX_MAYBE_ALPHA = 4, COLRX_A = 5;
809 static const int BRUSHRX_STYLE = 1, BRUSHRX_R = 2, BRUSHRX_G = 3, BRUSHRX_B = 4, BRUSHRX_A = 6;
812 QRegExp fontrx(
"^([\"']?)\\s*(.+)\\s*\\1"
814 "(\\s+(Light|Normal|DemiBold|Bold|Black|Wgt\\s*=\\s*(\\d+)))?"
816 "(\\s+(Normal|Italic|Oblique))?(\\s+(\\d+))?$");
818 static const int FONTRX_FAMILY = 2, FONTRX_WEIGHT_TEXT = 4, FONTRX_WEIGHT_VALUE = 5,
819 FONTRX_STYLE_TEXT = 7, FONTRX_POINTSIZE = 9;
827 if (dataTypeName == NULL || *dataTypeName == 0) {
828 klfDbg(
"loading null variant.");
836 klfDbg(
"\tAbout to read raw variant from datastr="<<vdata_esc<<
", ie. from data len="<<vdata.
size() ) ;
845 klfDbg(
"Will start loading a `"<<dataTypeName<<
"' from data (len="<<data.
size()<<
") : "<<data ) ;
852 if ((idslash = tname.
indexOf(
'/')) >= 0) {
853 tspecification = tname.
mid(idslash+1);
854 tname = tname.
left(idslash);
855 klfDbg(
"tspecification="<<tspecification<<
", tname="<<tname) ;
861 bool convertOk =
false;
864 case QMetaType::Bool:
875 int i = data.
toInt(&convertOk);
880 case QMetaType::UInt:
883 uint i = data.
toUInt(&convertOk);
888 case QMetaType::Short:
891 short i = data.
toShort(&convertOk);
896 case QMetaType::UShort:
899 ushort i = data.
toUShort(&convertOk);
904 case QMetaType::Long:
907 long i = data.
toLong(&convertOk);
912 case QMetaType::ULong:
915 ulong i = data.
toULong(&convertOk);
920 case QMetaType::LongLong:
928 case QMetaType::ULongLong:
936 case QMetaType::Double:
939 double val = data.
toDouble(&convertOk);
944 case QMetaType::Char:
947 if (data[0] ==
'\\') {
954 uint c = data.
mid(1).
toUInt(&convertOk, 16);
964 case QMetaType::QChar:
967 if (data[0] ==
'\\') {
974 uint c = data.
mid(1).
toUInt(&convertOk, 16);
984 case QMetaType::QString:
990 while (k < data.
size()) {
991 if (data[k] !=
'\\') {
996 if (data[k] ==
'\\' && k+1 >= data.
size()) {
1002 if (data[k+1] !=
'x') {
1010 if (k+5 < data.
size() && klf_is_hex_char(data[k+2]) && klf_is_hex_char(data[k+3])
1011 && klf_is_hex_char(data[k+4]) && klf_is_hex_char(data[k+5])) {
1014 if (k+3 < data.
size() && klf_is_hex_char(data[k+2]) && klf_is_hex_char(data[k+3])) {
1024 ushort cval = data.
mid(k+2, nlen).
toUShort(&convertOk, 16);
1038 case QMetaType::QStringList:
1045 for (k = 0; k < sections.
size(); ++k) {
1051 case QMetaType::QUrl:
1056 case QMetaType::QByteArray:
1062 case QMetaType::QDate:
1082 case QMetaType::QTime:
1103 case QMetaType::QDateTime:
1127 case QMetaType::QSize:
1136 case QMetaType::QPoint:
1145 case QMetaType::QRect:
1152 if (vals[RECTRX_MIDDLESEP_PLUS] ==
"+" || vals[RECTRX_LASTSEP_X] ==
"x") {
1154 QSize(vals[RECTRX_X2orW].toInt(), vals[RECTRX_Y2orH].toInt()) ));
1157 QPoint(vals[RECTRX_X2orW].toInt(), vals[RECTRX_Y2orH].toInt()) ));
1159 case QMetaType::QColor:
1164 if (colrx.
indexIn(colstr) < 0) {
1165 klfDbg(
"color "<<colstr<<
" does not match regexp="<<colrx.
pattern()<<
", trying named...") ;
1175 QColor color =
QColor(vals[COLRX_R].toInt(), vals[COLRX_G].toInt(), vals[COLRX_B].toInt(), 255);
1176 if (!vals[COLRX_MAYBE_ALPHA].isEmpty())
1177 color.
setAlpha(vals[COLRX_A].toInt());
1180 case QMetaType::QFont:
1184 klfDbg(
"malformed font: "<<data);
1188 klfDbg(
"parsing font: data="<<data<<
"; captured texts are: "<<vals );
1190 QString family = vals[FONTRX_FAMILY].trimmed();
1191 QString weighttxt = vals[FONTRX_WEIGHT_TEXT];
1192 QString weightval = vals[FONTRX_WEIGHT_VALUE];
1193 QString styletxt = vals[FONTRX_STYLE_TEXT];
1194 QString ptsval = vals[FONTRX_POINTSIZE];
1196 int weight = QFont::Normal;
1197 if (weighttxt ==
"Light") weight = QFont::Light;
1198 else if (weighttxt ==
"Normal") weight = QFont::Normal;
1199 else if (weighttxt ==
"DemiBold") weight = QFont::DemiBold;
1200 else if (weighttxt ==
"Bold") weight = QFont::Bold;
1201 else if (weighttxt ==
"Black") weight = QFont::Black;
1205 QFont::Style
style = QFont::StyleNormal;
1206 if (styletxt ==
"Normal")
style = QFont::StyleNormal;
1207 else if (styletxt ==
"Italic")
style = QFont::StyleItalic;
1208 else if (styletxt ==
"Oblique")
style = QFont::StyleOblique;
1212 pt = ptsval.
toInt();
1214 QFont font(family, pt, weight);
1218 case QMetaType::QBrush:
1222 klfDbg(
"malformed brush text: "<<data) ;
1229 bool style_found =
false;
1230 for (k = 0; klf_brush_styles[k].brushStyle >= 0 && klf_brush_styles[k].style != NULL; ++k) {
1237 klfDbg(
"Can't find style"<<
style<<
" in brush style list!");
1240 int qbrush_style = klf_brush_styles[k].brushStyle;
1242 QColor c =
QColor(vals[BRUSHRX_R].toInt(), vals[BRUSHRX_G].toInt(),
1243 vals[BRUSHRX_B].toInt());
1244 if (!vals[BRUSHRX_A].isEmpty())
1245 c.
setAlpha(vals[BRUSHRX_A].toInt());
1246 return QBrush(c,
static_cast<Qt::BrushStyle
>(qbrush_style));
1248 case QMetaType::QTextFormat:
1254 klfDbg(
"Invalid QTextFormat data.") ;
1260 for (k = 0; klf_text_format_formats[k].format != NULL; ++k)
1262 Qt::CaseInsensitive) == 0)
1264 if (klf_text_format_formats[k].
format == NULL) {
1265 klfDbg(
"QTextFormat: Invalid format type: "<<fmttype) ;
1268 int qtextformat_type = klf_text_format_formats[k].formatId;
1273 for (it = sections.
begin(); it != sections.
end(); ++it) {
1276 klfDbg(
"QTextFormat: considering property pair key="<<
key<<
"; value="<<value) ;
1278 for (k = 0; klf_text_format_keywords[k].keyword != NULL; ++k)
1280 key, Qt::CaseInsensitive) == 0)
1282 if (klf_text_format_keywords[k].
keyword != NULL) {
1284 klfDbg(
"QTextFormat: is keyword, propId="<<klf_text_format_keywords[k].
propId<<
", fixed_value="
1291 for (k = 0; klf_text_format_props[k].key != NULL; ++k)
1293 key, Qt::CaseInsensitive) == 0)
1295 if (klf_text_format_props[k].
key != NULL) {
1296 klfDbg(
"QTextFormat: is known property of type "<<klf_text_format_props[k].
type) ;
1304 bool tointok =
true;
1305 int propid =
key.toInt(&tointok);
1307 qWarning()<<KLF_FUNC_NAME<<
": QTextFormat bad format for general property key=value pair; "
1308 <<
"key is not a numerical property ID, nor is it a known property name.";
1311 klfDbg(
"QTextFormat: property is not a known one. propid="<<propid) ;
1314 while (value.
size() &&
QChar(value[0]).isSpace())
1318 qWarning().nospace()<<KLF_FUNC_NAME<<
": QTextFormat bad format for general property, value does "
1319 <<
"not begin with \"[type-name]\".";
1325 klfDbg(
"setting generalized property "<<propid<<
" to value "<<vval) ;
1330 case QMetaType::QVariantList:
1332 klfDbg(
"qvariantlist!") ;
1334 QDomElement el = parse_xml_wrapper(data,
"variant-list");
1341 for (k = 0; k < sections.
size(); ++k) {
1349 case QMetaType::QVariantMap:
1353 QDomElement el = parse_xml_wrapper(data,
"variant-map");
1359 for (it = sections.
begin(); it != sections.
end(); ++it) {
1371 if (tname ==
"KLFEnumType") {
1379 klfDbg(
"other type or failed to load the good type!") ;
1388 if (tspecification.
size()) {
1396 klfDbg(
"loading an abstr.prop.obj: "<<obj) ;
1397 klfDbg(
"obj is of type "<<obj->
objectKind()<<
", fixedtypes="<<hasfixedtypes) ;
1400 if (!hasfixedtypes) {
1405 QVariantMap propsconverted;
1406 for (QVariantMap::const_iterator it = props.begin(); it != props.end(); ++it) {
1414 klfDbg(
"Loading property "<<it.key()<<
" from saved text, value = "<<propsconverted[it.key()]) ;
1416 props = propsconverted;
1421 qWarning(
"klfLoadVariantFromText: Can't load a %s from %s !", dataTypeName, stringdata.
constData());
1441 for (QVariantMap::const_iterator it = vmap.begin(); it != vmap.end(); ++it) {
1454 if (vtype ==
"QVariantMap") {
1457 }
else if (vtype ==
"QVariantList") {
1513 if (valuetype ==
"QVariantMap") {
1515 }
else if (valuetype ==
"QVariantList") {
1531 for (QVariantList::const_iterator it = vlist.begin(); it != vlist.end(); ++it) {
1537 if (vtype ==
"QVariantMap") {
1540 }
else if (vtype ==
"QVariantList") {
1569 qWarning(
"%s: ignoring unexpected tag `%s'!\n", KLF_FUNC_NAME, qPrintable(e.
nodeName()));
1658 KLF_ASSERT_NOT_NULL(saver,
"Can't find object saver for format="<<f<<
" !",
return false; ) ;
1659 return saver->
load(data, obj, f);
An abstract object characterized by properties.
virtual bool hasFixedTypes() const
virtual QByteArray typeNameFor(const QString &property) const
Corresonding type for the given property.
virtual QString objectKind() const =0
A string representing this object type.
virtual bool setAllProperties(const QMap< QString, QVariant > &data)
Convenience function to load a set of property values.
virtual QByteArray typeSpecificationFor(const QString &property) const
A type specification for the given property.
virtual QMap< QString, QVariant > allProperties() const
Convenience function to retrieve all properties.
Inherit this class to implement a custom saver for KLFAbstractPropertizedObjects.
virtual QString recognizeDataFormat(const QByteArray &data) const =0
virtual ~KLFAbstractPropertizedObjectSaver()
virtual bool load(const QByteArray &data, KLFAbstractPropertizedObject *obj, const QString &format)=0
KLFAbstractPropertizedObjectSaver()
static KLFAbstractPropertizedObjectSaver * findSaverFor(const QString &format)
static KLFAbstractPropertizedObjectSaver * findRecognizedFormat(const QByteArray &data, QString *format=NULL)
virtual QByteArray save(const KLFAbstractPropertizedObject *obj, const QString &format)=0
bool setSpecification(const QByteArray &data)
KLFFactoryBase(KLFFactoryManager *factoryManager)
A base abstract factory manager class.
static bool isRegistered(const char *name)
static bool isRegistered(const char *name)
virtual bool setSpecification(const QByteArray &data)=0
virtual QByteArray specification() const =0
KLFBaseFormatsPropertizedObjectSaver __klf_baseformats_pobj_saver
#define KLF_BRUSH_STYLE(sty)
KLF_EXPORT QByteArray klfEscapedToData(const QByteArray &data, char escapechar)
#define KLF_TEXT_FORMAT_PROP(p, type)
KLF_EXPORT QDomElement klfSaveVariantListToXML(const QVariantList &vlist, QDomElement baseNode)
Lossless save of full list to XML with type information.
KLF_EXPORT QDomElement klfSaveVariantMapToXML(const QVariantMap &vmap, QDomElement baseNode)
Lossless save of full map to XML with type information.
KLF_EXPORT QVariant klfLoadVariantFromText(const QByteArray &stringdata, const char *dataTypeName, const char *listOrMapDataTypeName)
KLF_EXPORT bool klfLoad(const QByteArray &data, KLFAbstractPropertizedObject *obj, const QString &format)
KLF_EXPORT QByteArray klfDataToEscaped(const QByteArray &value_ba, char escapechar)
KLF_EXPORT QByteArray klfSaveVariantToText(const QVariant &value, bool saveListAndMapsAsXML, QByteArray *savedType, QByteArray *savedListOrMapType)
KLF_EXPORT QVariantMap klfLoadVariantMapFromXML(const QDomElement &xmlNode)
Load a map saved with klfSaveVariantMapToXML()
KLF_EXPORT QVariantList klfLoadVariantListFromXML(const QDomElement &xmlNode)
Load a list saved with klfSaveVariantListToXML()
KLF_EXPORT QByteArray klfSave(const KLFAbstractPropertizedObject *obj, const QString &format)
#define KLF_TEXT_FORMAT_FORMAT(fmt)
#define KLF_DEBUG_TIME_BLOCK(msg)
Utility to time the execution of a block.
#define klfWarning(streamableItems)
#define KLF_DEBUG_BLOCK(msg)
Utility to debug the execution of a block.
#define KLF_ASSERT_NOT_NULL(ptr, msg, failaction)
Asserting Non-NULL pointers (NON-FATAL)
#define KLF_ASSERT_CONDITION(expr, msg, failaction)
Asserting Conditions (NON-FATAL)
#define klfDbg(streamableItems)
print debug stream items
Base declarations for klatexformula and some utilities.
const QColor & color() const
const QMatrix & matrix() const
Qt::BrushStyle style() const
const char * constData() const
bool contains(char ch) const
int indexOf(char ch, int from) const
QByteArray left(int len) const
QByteArray mid(int pos, int len) const
QByteArray number(int n, int base)
QByteArray & remove(int pos, int len)
QByteArray & replace(int pos, int len, const char *after)
bool startsWith(const QByteArray &ba) const
double toDouble(bool *ok) const
int toInt(bool *ok, int base) const
long toLong(bool *ok, int base) const
qlonglong toLongLong(bool *ok, int base) const
QByteArray toLower() const
short toShort(bool *ok, int base) const
uint toUInt(bool *ok, int base) const
ulong toULong(bool *ok, int base) const
qulonglong toULongLong(bool *ok, int base) const
ushort toUShort(bool *ok, int base) const
QByteArray trimmed() const
void setNamedColor(const QString &name)
QDate fromString(const QString &string, Qt::DateFormat format)
QDateTime fromString(const QString &string, Qt::DateFormat format)
QDomElement createElement(const QString &tagName)
QDomText createTextNode(const QString &value)
QByteArray toByteArray(int indent) const
QString attribute(const QString &name, const QString &defValue) const
void setAttribute(const QString &name, const QString &value)
QDomNode appendChild(const QDomNode &newChild)
QDomNode firstChild() const
QDomNode nextSibling() const
NodeType nodeType() const
QDomDocument ownerDocument() const
QDomElement toElement() const
void setStyle(Style style)
void append(const T &value)
QStringList capturedTexts() const
int indexIn(const QString &str, int offset, CaretMode caretMode) const
void setMinimal(bool minimal)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const
int compare(const QString &other, Qt::CaseSensitivity cs) const
QString fromLatin1(const char *str, int size)
QString fromLocal8Bit(const char *str, int size)
QString fromUtf8(const char *str, int size)
QString mid(int position, int n) const
QString number(int n, int base)
QString & replace(int position, int n, QChar after)
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
int toInt(bool *ok, int base) const
QByteArray toLatin1() const
QByteArray toLocal8Bit() const
QByteArray toUtf8() const
bool canEncode(QChar ch) const
QTextCodec * codecForLocale()
QByteArray fromUnicode(const QString &str) const
QMap< int, QVariant > properties() const
void setProperty(int propertyId, const QVariant &value)
QTime fromString(const QString &string, Qt::DateFormat format)
QByteArray toEncoded(FormattingOptions options) const
QVariant fromValue(const T &value)
QList< QVariant > toList() const
QMap< QString, QVariant > toMap() const
QStringList toStringList() const
const char * typeName() const