Code generator

Gepard ORM (GORM) serialization / deserialization

This article describes GORM version 1.4.0 capabilities.


Following is a typical collections of C++ fundamental types, STL containers and smart pointers.

[code]#include <types, STL, Qt, smart pointers>

class MySerializationBase final


    // Fundamentals
    bool        _bool1= false;
    int         _num1 = 0;
    uint32_t    _num2 = 0;
    uint64_t    _num3 = 0;
    long        _num4 = 0;
    long long   _num5 = 0;
    float       _num6 = 0;
    double      _num7 = 0;
    std::string _text1;
    QString     _text2;
    QDate       _date1;
    QTime       _time1;
    QDateTime   _datetime1;
    // Containers
    std::vector<int>    _contNum1;
    std::list<int>      _contNum2;
    std::set<int>       _contNum3;
    std::map<int, int>  _contNum4;
    std::tuple<int, int, std::string> _contNum5;
    QVector<int>        _contNum6;
    QList<int>          _contNum7;
    QSet<int>           _contNum8;
    QMap<int, int>      _contNum9;
    // Smart pointers
    std::shared_ptr<int> _smart1;
    std::auto_ptr<int>   _smart2;
    std::unique_ptr<int> _smart3;
    QSharedPointer<int>  _smart4;
    // User objects
    MySerializationChild                _link1;
    MySerializationChild*               _link2 = nullptr;
    std::vector<MySerializationChild>   _link3;
    std::vector<MySerializationChild*>  _link4;
    QList<MySerializationChild>         _link5;
    QList<MySerializationChild*>        _link6;
    std::vector<std::shared_ptr<MySerializationChild>> _link7;

Within this class is a reference to MySerializationChild class, which is mainly a HEAP oriented class with a lot of raw pointers.

[code]class MySerializationChild final


   // Fundamentals as pointers
   bool* _bool1 = nullptr;
   int* _num1 = nullptr;
   uint32_t* _num2 = nullptr;
   uint64_t* _num3 = nullptr;
   long* _num4 = nullptr;
   long long* _num5 = nullptr;
   float* _num6 = nullptr;
   double* _num7 = nullptr;
   std::string* _text1 = nullptr;
   QString* _text2 = nullptr;
   // TODO char* _text3;
   QDate* _date1 = nullptr;
   QTime* _time1 = nullptr;
   QDateTime* _datetime1 = nullptr;

The goal is to generate a code which creates an XML output and of course, on the other hand it loads that file and produce our object files.

Now, to save time, electricity, keyboard abrasion please download this Tutorial Skeleton: Click here.

Step-by-step tutorial with Gepard ORM,

  1. Open Gepard ORM, click on New / Load existing
  2. Create GORM project by Qt's project file
  3. For parse Qt dependent classes, you need to add some include folder
  4. Add myserializationbase.h and myserializationchild.h to Source files
  5. Click Serialization/Deserialization, select XML serialization format
  6. Click >>
  7. Click on structs/class fields to be confident in compile success
  8. Click Save, Click Create output
  9. Back to Qr Creator, compile tutorial and run ;)

That's should done.

The following files now created in generated_gorm folder:

  • gorm_myserializationbase.cpp
  • gorm_myserializationchild.cpp

Examine the source code, modify and use it on your will.


Thanks for using.