/** * Helper class for a vector of integer (stored as integer[] in the postgres database * $Id$ * $HeadURL$ * $Author$ * Created by Christian Ehrlicher, SLSE, 2016-05-03 */ #pragma once #include #include #include #include namespace LtsUtils { template class PgArray { public: using Type = T; using ContainerType = C; PgArray() = default; Q_DECL_CONSTEXPR explicit PgArray(const C &data) : m_data(data) {} Q_DECL_CONSTEXPR C operator()()const { return m_data; } QString toPgString() const; static PgArray fromPgString(const QString &str); private: C m_data; }; // helper to convert a postgres array (one-dimensional) into a std::vector and vice versa // { 1, 5, 5, 2, 9 } using IntArray = PgArray>; // integer[] using BigintArray = PgArray>; // bigint[] // helper to convert a two-dimensional postgres array into a std::map and vice versa // { { 1, 2 }, { 4, 3 }, { 10, 1 } } using IntArray2D = PgArray>; // integer[][] using BigintArray2D = PgArray>; // bigint[][] } // namespace LtsUtils