0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Made generated file available by default

This lowers the threshold for those without python.
This commit is contained in:
rbock 2014-07-20 11:14:44 +02:00
parent 8ed0042b67
commit d94ab56fd8
2 changed files with 197 additions and 7 deletions

View File

@ -16,11 +16,11 @@ build_and_run(FunctionTest)
build_and_run(PreparedTest) build_and_run(PreparedTest)
build_and_run(Minimalistic) build_and_run(Minimalistic)
find_package(PythonInterp REQUIRED) # if you want to use the generator, you can do something like this:
#find_package(PythonInterp REQUIRED)
add_custom_command( #add_custom_command(
OUTPUT ${CMAKE_CURRENT_LIST_DIR}/Sample.h # OUTPUT ${CMAKE_CURRENT_LIST_DIR}/Sample.h
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/ddl2cpp ${CMAKE_CURRENT_LIST_DIR}/sample.sql Sample test # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/ddl2cpp ${CMAKE_CURRENT_LIST_DIR}/sample.sql Sample test
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/sample.sql # DEPENDS ${CMAKE_CURRENT_LIST_DIR}/sample.sql
) # )

190
tests/Sample.h Normal file
View File

@ -0,0 +1,190 @@
#ifndef TEST_SAMPLE_H
#define TEST_SAMPLE_H
#include <sqlpp11/table.h>
#include <sqlpp11/column_types.h>
namespace test
{
namespace TabFoo_
{
struct Delta
{
struct _name_t
{
static constexpr const char* _get_name() { return "delta"; }
template<typename T>
struct _member_t
{
T delta;
T& operator()() { return delta; }
const T& operator()() const { return delta; }
};
};
using _value_type = sqlpp::varchar;
struct _column_type
{
using _can_be_null = std::true_type;
};
};
struct Epsilon
{
struct _name_t
{
static constexpr const char* _get_name() { return "epsilon"; }
template<typename T>
struct _member_t
{
T epsilon;
T& operator()() { return epsilon; }
const T& operator()() const { return epsilon; }
};
};
using _value_type = sqlpp::bigint;
struct _column_type
{
using _can_be_null = std::true_type;
};
};
struct Omega
{
struct _name_t
{
static constexpr const char* _get_name() { return "omega"; }
template<typename T>
struct _member_t
{
T omega;
T& operator()() { return omega; }
const T& operator()() const { return omega; }
};
};
using _value_type = sqlpp::floating_point;
struct _column_type
{
using _can_be_null = std::true_type;
};
};
}
struct TabFoo: sqlpp::table_t<TabFoo,
TabFoo_::Delta,
TabFoo_::Epsilon,
TabFoo_::Omega>
{
using _value_type = sqlpp::no_value_t;
struct _name_t
{
static constexpr const char* _get_name() { return "tab_foo"; }
template<typename T>
struct _member_t
{
T tabFoo;
T& operator()() { return tabFoo; }
const T& operator()() const { return tabFoo; }
};
};
};
namespace TabBar_
{
struct Alpha
{
struct _name_t
{
static constexpr const char* _get_name() { return "alpha"; }
template<typename T>
struct _member_t
{
T alpha;
T& operator()() { return alpha; }
const T& operator()() const { return alpha; }
};
};
using _value_type = sqlpp::bigint;
struct _column_type
{
using _must_not_insert = std::true_type;
using _must_not_update = std::true_type;
using _can_be_null = std::true_type;
};
};
struct Beta
{
struct _name_t
{
static constexpr const char* _get_name() { return "beta"; }
template<typename T>
struct _member_t
{
T beta;
T& operator()() { return beta; }
const T& operator()() const { return beta; }
};
};
using _value_type = sqlpp::varchar;
struct _column_type
{
using _can_be_null = std::true_type;
};
};
struct Gamma
{
struct _name_t
{
static constexpr const char* _get_name() { return "gamma"; }
template<typename T>
struct _member_t
{
T gamma;
T& operator()() { return gamma; }
const T& operator()() const { return gamma; }
};
};
using _value_type = sqlpp::boolean;
struct _column_type
{
using _require_insert = std::true_type;
};
};
struct Delta
{
struct _name_t
{
static constexpr const char* _get_name() { return "delta"; }
template<typename T>
struct _member_t
{
T delta;
T& operator()() { return delta; }
const T& operator()() const { return delta; }
};
};
using _value_type = sqlpp::integer;
struct _column_type
{
using _can_be_null = std::true_type;
};
};
}
struct TabBar: sqlpp::table_t<TabBar,
TabBar_::Alpha,
TabBar_::Beta,
TabBar_::Gamma,
TabBar_::Delta>
{
using _value_type = sqlpp::no_value_t;
struct _name_t
{
static constexpr const char* _get_name() { return "tab_bar"; }
template<typename T>
struct _member_t
{
T tabBar;
T& operator()() { return tabBar; }
const T& operator()() const { return tabBar; }
};
};
};
}
#endif