00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "pqxx/compiler-public.hxx"
00019 #include "pqxx/compiler-internal-pre.hxx"
00020
00021 #include "pqxx/util"
00022
00023 namespace pqxx
00024 {
00025 class connection_base;
00026 class transaction_base;
00027 class result;
00028
00030 namespace prepare
00031 {
00033
00042 enum param_treatment
00043 {
00045 treat_binary,
00047 treat_string,
00049 treat_bool,
00051 treat_direct
00052 };
00053
00054
00056 class PQXX_LIBEXPORT declaration
00057 {
00058 public:
00059 declaration(connection_base &, const PGSTD::string &statement);
00060
00062 const declaration &operator()(const PGSTD::string &sqltype,
00063 param_treatment) const;
00064
00065 private:
00066 connection_base &m_home;
00067 const PGSTD::string &m_statement;
00068 };
00069
00070
00072 class PQXX_LIBEXPORT invocation
00073 {
00074 public:
00075 invocation(transaction_base &, const PGSTD::string &statement);
00076
00078 result exec() const;
00079
00081 invocation &operator()();
00082
00084
00088 template<typename T>
00089 invocation &operator()(const T &v, bool nonnull=true)
00090 { return setparam(to_string(v), nonnull); }
00091
00093
00108 template<typename T>
00109 invocation &operator()(T *v, bool nonnull=true)
00110 { return setparam((v ? to_string(v) : ""), nonnull); }
00111
00113
00117 invocation &operator()(const char *v, bool nonnull=true)
00118 { return setparam((v ? to_string(v) : ""), nonnull); }
00119
00120 private:
00121 transaction_base &m_home;
00122 const PGSTD::string &m_statement;
00123 PGSTD::vector<PGSTD::string> m_values;
00124 PGSTD::vector<bool> m_nonnull;
00125
00126 invocation &setparam(const PGSTD::string &, bool nonnull);
00127 };
00128
00129
00130 namespace internal
00131 {
00133 struct PQXX_PRIVATE prepared_def
00134 {
00136 struct param
00137 {
00138 PGSTD::string sqltype;
00139 param_treatment treatment;
00140
00141 param(const PGSTD::string &SQLtype, param_treatment);
00142 };
00143
00145 PGSTD::string definition;
00147 PGSTD::vector<param> parameters;
00149 bool registered;
00151 bool complete;
00152
00153 prepared_def();
00154 explicit prepared_def(const PGSTD::string &);
00155
00156 void addparam(const PGSTD::string &sqltype, param_treatment);
00157 };
00158
00160 struct PQXX_PRIVATE get_sqltype
00161 {
00162 template<typename IT> const PGSTD::string &operator()(IT i)
00163 {
00164 return i->sqltype;
00165 }
00166 };
00167
00168 }
00169 }
00170 }
00171
00172 #include "pqxx/compiler-internal-post.hxx"