QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxDump.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32#ifndef _QX_DUMP_H_
33#define _QX_DUMP_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
46#include <QxCommon/QxConfig.h>
47
51
53
54#ifdef _QX_ENABLE_BOOST_SERIALIZATION
55
56namespace qx {
57
62template <class T>
63void dump(const T & t, bool bJsonFormat = false)
64{
65 QString sDump;
66
67 if (bJsonFormat)
68 {
69#ifndef _QX_NO_JSON
71#else // _QX_NO_JSON
72 sDump = "Unable to dump element in JSON format : you must work with Qt5 and not define _QX_NO_JSON compilation option in 'QxOrm.pri' configuration file";
73#endif // _QX_NO_JSON
74 }
75 else
76 {
77#if _QX_SERIALIZE_POLYMORPHIC
78 sDump = qx::serialization::polymorphic_xml::to_string(t);
79#elif _QX_SERIALIZE_XML
80 sDump = qx::serialization::xml::to_string(t);
81#elif _QX_SERIALIZE_WIDE_XML
82 sDump = qx::serialization::wide::xml::to_string(t);
83#else // _QX_SERIALIZE_POLYMORPHIC
84 sDump = "Unable to dump element : you must define '_QX_ENABLE_BOOST_SERIALIZATION' and '_QX_ENABLE_BOOST_SERIALIZATION_XML' (or '_QX_ENABLE_BOOST_SERIALIZATION_WIDE_XML') compilation options in 'QxOrm.pri' configuration file";
85#endif // _QX_SERIALIZE_POLYMORPHIC
86 }
87
88 QString sName = qx::QxClassName<T>::get();
89 qDebug("[QxOrm] start dump '%s'", qPrintable(sName));
90 qDebug("%s", qPrintable(sDump));
91 qDebug("[QxOrm] end dump '%s'", qPrintable(sName));
92}
93
94} // namespace qx
95
96#else // _QX_ENABLE_BOOST_SERIALIZATION
97
98namespace qx {
99
100template <class T>
101void dump(const T & t, bool bJsonFormat = true)
102{
103#ifdef _QX_NO_JSON
104 qDebug("[QxOrm] qx::dump() : %s", "not implemented when _QX_ENABLE_BOOST_SERIALIZATION compilation option is not defined (XML format) and _QX_NO_JSON compilation option is defined (JSON format)");
105 Q_UNUSED(t); Q_UNUSED(bJsonFormat);
106#else // _QX_NO_JSON
107 if (! bJsonFormat) { return; }
108 QString sDump = qx::serialization::json::to_string(t);
109 QString sName = qx::QxClassName<T>::get();
110 qDebug("[QxOrm] start dump '%s'", qPrintable(sName));
111 qDebug("%s", qPrintable(sDump));
112 qDebug("[QxOrm] end dump '%s'", qPrintable(sName));
113#endif // _QX_NO_JSON
114}
115
116} // namespace qx
117
118#endif // _QX_ENABLE_BOOST_SERIALIZATION
119#endif // _QX_DUMP_H_
Provide some tools to serialize a class registered into QxOrm context into/from binary/XML archive (f...
Provide a class helper to retrieve the class name under const char * format.
List of parameters to compile and build QxOrm library.
Provide a serialization engine with Qt QJson classes (this feature requires Qt5)
static const char * get()
Definition QxClassName.h:63
void dump(const T &t, bool bJsonFormat=false)
qx::dump(const T & t, bool bJsonFormat) : dump class of type T registered into QxOrm context using XM...
Definition QxDump.h:63
QString to_string(const T &obj, unsigned int flags=1, const QString &format=QString())
Root namespace for all QxOrm library features.