From 74f50a3bc6890c96532fe9e76e387171aec3a8c3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 27 Aug 2013 08:22:03 +0200 Subject: Add support for statement processing --- odb/statement.hxx | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'odb/statement.hxx') diff --git a/odb/statement.hxx b/odb/statement.hxx index 894b495..00ffa2e 100644 --- a/odb/statement.hxx +++ b/odb/statement.hxx @@ -7,6 +7,9 @@ #include +#include +#include // std::size_t + #include // connection #include @@ -34,6 +37,66 @@ namespace odb protected: statement () {} + + // Statement processing. Kept public only for testing. + // + public: + // Expected statement structure: + // + // INSERT INTO table\n + // [(a,\n + // b)\n] + // [OUTPUT ...\n] + // [VALUES\n + // ($1,\n + // $2)[\n]] + // [DEFAULT VALUES[\n]] + // [RETURNING ...] + // [; SELECT ...] + // + static void + process_insert (const char* statement, + const void* const* bind, // Array of bind buffer pointers. + std::size_t bind_size, // Number of bind elements. + std::size_t bind_skip, // Offset to the next bind. + char param_symbol, // $, ?, :, etc. + std::string& result); + + // Expected statement structure: + // + // UPDATE table\n + // [SET\n + // a=$1,\n + // b=$2[\n]] + // [OUTPUT ...] + // [WHERE ...] + // + static void + process_update (const char* statement, + const void* const* bind, // Array of bind buffer pointers. + std::size_t bind_size, // Number of bind elements. + std::size_t bind_skip, // Offset to the next bind. + char param_symbol, // $, ?, :, etc. + std::string& result); + + // Expected statement structure: + // + // SELECT\n + // [schema.]table.a,\n + // alias.b\n + // FROM [schema.]table\n + // [LEFT JOIN [schema.]table [AS alias] ON ...\n]* + // [WHERE ...] + // + static void + process_select (const char* statement, + const void* const* bind, // Array of bind buffer pointers. + std::size_t bind_size, // Number of bind elements. + std::size_t bind_skip, // Offset to the next bind. + char quote_open, // Identifier opening quote. + char quote_close, // Identifier closing quote. + bool optimize, // Remove unused JOINs. + std::string& result); }; } -- cgit v1.1