/** * @RDE_HEADER@ * Template for 'real' structures including insert/update/delete functions for db * $Id$ * $HeadURL$ * $Author$ */ {% autoescape off %} // filename: {{ namespace_abbr }}_db_structs.h #pragma once #include #include #include #include #include #include #include #include {% if need_point3d %} #include {% endif %} {% if need_pgarray %} #include {% endif %} #include <{{ include_prefix }}/{{ namespace_abbr }}_export.h> #include <{{ include_prefix }}/{{ namespace_abbr }}_enums.hpp> {% for ext_service in ext_services.member %} #include <{{ ext_service.baseFilePath }}.hpp> {% endfor %} namespace {{ namespace }} { namespace Database { {% for cpp_struct in cpp_structs %} // {{ cpp_struct.name }} struct {{ cpp_struct.name }} { {% for m in cpp_struct.cppMember %}{{ m.cppType }} {{ m.cppMemberName }}{% if m.cppDefault %} = {{ m.cppDefault }}{% endif %}; {% endfor %} };{% endfor %} {% for data_struct in data_structs %} // read only struct {{ data_struct.name }} struct {{ data_struct.name }} { {% for m in data_struct.cppMember %}{{ m.cppType }} {{ m.cppMemberName }}{% if m.cppDefault %} = {{ m.cppDefault }}{% endif %}; {% endfor %} };{% endfor %} // converting DbStructs to/from JSON template T fromJson(const QJsonValue &value); {% for cpp_struct in cpp_structs %} // {{ cpp_struct.name }} template <> {{ namespace_abbr_upper }}_{{ library_target }}_EXPORT {{ cpp_struct.name }} fromJson(const QJsonValue &value); {{ namespace_abbr_upper }}_{{ library_target }}_EXPORT QJsonObject toJson(const {{ cpp_struct.name }} &element);{% endfor %} // vector of database struct to/from JSON-array template QJsonArray toJson(const QVector &dataVec) { QJsonArray arr; for (const T &data : dataVec) arr.append(QJsonValue(toJson(data))); return arr; } template std::vector fromJson(const QJsonArray &arr) { std::vector dataVec; dataVec.reserve(arr.size()); for (const QJsonValue &val : arr) dataVec.push_back(fromJson(val)); return dataVec; } };// namespace Database } // namespace {{ namespace }} {% endautoescape %}