Click here to Skip to main content
15,894,740 members
Articles / Web Development / HTML

QxOrm - C++ ORM (Object Relational Mapping) Library

Rate me:
Please Sign up or sign in to vote.
4.90/5 (61 votes)
24 Apr 2019GPL326 min read 141K   321   140  
QxOrm C++ library: Persistence (based on QtSql Qt library) - Serialization (based on boost::serialization library) - Reflection (introspection)
#include "../include/precompiled.h"

#include "../include/CTestAll.h"

#include <QxMemLeak.h>

void CTestAll::init()
{
   m_lId = 56;
   m_oQxBool = qx_bool(true, "qx_bool description");
   m_oStdString = "std::string text";

   m_oQString = "QString text\nwith a new line";
   m_oQDate = QDate::currentDate();
   m_oQDateTime = QDateTime::currentDateTime();
   m_oQTime = QTime::currentTime();
   m_oQColor = QColor(255, 200, 200);
   m_oQFont.setBold(true);
   m_oQFont.setFamily("font family from qx test");
   m_oQPoint = QPoint(8, 11);
   m_oQRect = QRect(QPoint(52, 3), QPoint(574, 1112));
   m_oQSize = QSize(1024, 768);
   m_oQRegExp = QRegExp("qt reg exp");
   m_oQUrl = QUrl("www.qxorm.com");
   m_oQStringList << "str1" << "str2" << "str3" << "str4";
   m_oQByteArray = QByteArray("QByteArray t\0ext\nwith a new line\0and null multi\0ple null char\0", 55);
   m_oQVariant = QVariant(0.437);
   m_oQObject.setProperty("prop_1", 1);
   m_oQObject.setProperty("prop_2", 2);

   QSharedPointer<CUser> u1(new CUser());
   QSharedPointer<CUser> u2(new CUser());

   m_oStdPair = std::make_pair(QPoint(2, 6), QRect(99, 55, 44, 22));
   m_oStdList.push_back(QDateTime());
   m_oStdList.push_back(QDateTime::currentDateTime());
   m_oStdList.push_back(QDateTime());
   m_oStdMap.insert(std::make_pair("1", u1));
   m_oStdMap.insert(std::make_pair("2", u2));

   m_oStdVector.push_back(QSharedPointer<qx::test::CPerson>(new qx::test::CPerson()));
   m_oStdVector.push_back(QSharedPointer<qx::test::CPerson>(new CUser()));
}

void CTestAll::terminate()
{
   typedef boost::tuple<long, qx::test::CPerson *> qx_elt_tmp;

   _foreach(CUser * p2, m_oQVector) { if (p2) { delete p2; } }
   _foreach(qx_elt_tmp p3, m_oQxCollection) { if (p3.get<1>()) { delete p3.get<1>(); } }
}

void CTestAll::test()
{
   boost::shared_ptr<CTestAll> o1; o1.reset(new CTestAll());
   boost::shared_ptr<CTestAll> o2; o2.reset(new CTestAll());

   qx::QxCollection<long, boost::shared_ptr<CTestAll> > coll;
   coll.insert(0, o1);
   coll.insert(1, o2);

#if _QX_SERIALIZE_POLYMORPHIC
   qx::serialization::polymorphic_xml::to_file(coll, "test_all.xml");
   qx::serialization::polymorphic_xml::from_file(coll, "test_all.xml");
#endif // _QX_SERIALIZE_POLYMORPHIC

#if _QX_SERIALIZE_BINARY
   qx::serialization::binary::to_file(coll, "test_all.bin");
   qx::serialization::binary::from_file(coll, "test_all.bin");
#endif // _QX_SERIALIZE_BINARY

#if _QX_SERIALIZE_XML
   qx::serialization::xml::to_file(coll, "test_all.xml");
   qx::serialization::xml::from_file(coll, "test_all.xml");
#endif // _QX_SERIALIZE_XML

#if _QX_SERIALIZE_PORTABLE_BINARY
   qx::serialization::portable_binary::to_file(coll, "test_all.bin2", 0);
   qx::serialization::portable_binary::from_file(coll, "test_all.bin2", 0);
#endif // _QX_SERIALIZE_PORTABLE_BINARY

   qx::clone(coll);
   qx::create("CTestAll");
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions