Common ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
statement.hxx
Go to the documentation of this file.
1 // file : odb/statement.hxx
2 // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
3 // license : GNU GPL v2; see accompanying LICENSE file
4 
5 #ifndef ODB_STATEMENT_HXX
6 #define ODB_STATEMENT_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <string>
11 #include <cstddef> // std::size_t
12 
13 #include <odb/forward.hxx> // connection
14 
15 #include <odb/details/export.hxx>
16 #include <odb/details/shared-ptr.hxx>
17 
18 namespace odb
19 {
20  class LIBODB_EXPORT statement: public details::shared_base
21  {
22  private:
23  statement (const statement&);
24  statement& operator= (const statement&);
25 
26  public:
28 
29  virtual const char*
30  text () const = 0;
31 
32  virtual connection_type&
33  connection () = 0;
34 
35  virtual
36  ~statement () = 0;
37 
38  protected:
39  statement () {}
40 
41  // Statement processing. Kept public only for testing.
42  //
43  public:
44  // Expected statement structure:
45  //
46  // INSERT INTO table\n
47  // [(a,\n
48  // b)\n]
49  // [OUTPUT ...\n]
50  // [VALUES\n
51  // ($1,\n
52  // $2)[\n]]
53  // [DEFAULT VALUES[\n]]
54  // [RETURNING ...]
55  // [; SELECT ...]
56  //
57  static void
58  process_insert (const char* statement,
59  const void* const* bind, // Array of bind buffer pointers.
60  std::size_t bind_size, // Number of bind elements.
61  std::size_t bind_skip, // Offset to the next bind.
62  char param_symbol, // $, ?, :, etc.
63  std::string& result);
64 
65  // Expected statement structure:
66  //
67  // UPDATE table\n
68  // SET\n
69  // a=$1,\n
70  // b=$2[\n]
71  // [OUTPUT ...]
72  // [WHERE ...]
73  //
74  static void
75  process_update (const char* statement,
76  const void* const* bind, // Array of bind buffer pointers.
77  std::size_t bind_size, // Number of bind elements.
78  std::size_t bind_skip, // Offset to the next bind.
79  char param_symbol, // $, ?, :, etc.
80  std::string& result);
81 
82  // Expected statement structure:
83  //
84  // SELECT\n
85  // [schema.]table.a,\n
86  // alias.b\n
87  // FROM [schema.]table[\n]
88  // [LEFT JOIN [schema.]table [AS alias] ON ...[\n]]*
89  // [WHERE ...]
90  //
91  static void
92  process_select (const char* statement,
93  const void* const* bind, // Array of bind buffer pointers.
94  std::size_t bind_size, // Number of bind elements.
95  std::size_t bind_skip, // Offset to the next bind.
96  char quote_open, // Identifier opening quote.
97  char quote_close, // Identifier closing quote.
98  bool optimize, // Remove unused JOINs.
99  std::string& result,
100  bool as = true); // JOINs use AS keyword.
101  };
102 }
103 
104 #include <odb/post.hxx>
105 
106 #endif // ODB_STATEMENT_HXX
Definition: statement.hxx:20
odb::connection connection_type
Definition: statement.hxx:27
statement()
Definition: statement.hxx:39
Definition: connection.hxx:33
Definition: result.hxx:75