AbstractBinder.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. //
  2. // AbstractBinder.h
  3. //
  4. // $Id: //poco/Main/Data/include/Poco/Data/AbstractBinder.h#12 $
  5. //
  6. // Library: Data
  7. // Package: DataCore
  8. // Module: AbstractBinder
  9. //
  10. // Definition of the AbstractBinder class.
  11. //
  12. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
  13. // and Contributors.
  14. //
  15. // Permission is hereby granted, free of charge, to any person or organization
  16. // obtaining a copy of the software and accompanying documentation covered by
  17. // this license (the "Software") to use, reproduce, display, distribute,
  18. // execute, and transmit the Software, and to prepare derivative works of the
  19. // Software, and to permit third-parties to whom the Software is furnished to
  20. // do so, all subject to the following:
  21. //
  22. // The copyright notices in the Software and this entire statement, including
  23. // the above license grant, this restriction and the following disclaimer,
  24. // must be included in all copies of the Software, in whole or in part, and
  25. // all derivative works of the Software, unless such copies or derivative
  26. // works are solely in the form of machine-executable object code generated by
  27. // a source language processor.
  28. //
  29. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  30. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  31. // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  32. // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  33. // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  34. // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  35. // DEALINGS IN THE SOFTWARE.
  36. //
  37. #ifndef Data_AbstractBinder_INCLUDED
  38. #define Data_AbstractBinder_INCLUDED
  39. #include "Poco/Data/Data.h"
  40. #include "Poco/Data/Date.h"
  41. #include "Poco/Data/Time.h"
  42. #include "Poco/Data/BLOB.h"
  43. #include "Poco/DateTime.h"
  44. #include "Poco/Any.h"
  45. #include "Poco/DynamicAny.h"
  46. #include <vector>
  47. #include <deque>
  48. #include <list>
  49. #include <cstddef>
  50. namespace Poco {
  51. namespace Data {
  52. enum NullData
  53. {
  54. NULL_GENERIC = 0
  55. };
  56. namespace Keywords {
  57. static const NullData null = NULL_GENERIC;
  58. } // namespace Keywords
  59. class Data_API AbstractBinder
  60. /// Interface for Binding data types to placeholders.
  61. {
  62. public:
  63. enum Direction
  64. /// Binding direction for a parameter.
  65. {
  66. PD_IN,
  67. PD_OUT,
  68. PD_IN_OUT
  69. };
  70. AbstractBinder();
  71. /// Creates the AbstractBinder.
  72. virtual ~AbstractBinder();
  73. /// Destroys the AbstractBinder.
  74. virtual void bind(std::size_t pos, const Poco::Int8& val, Direction dir = PD_IN) = 0;
  75. /// Binds an Int8.
  76. virtual void bind(std::size_t pos, const std::vector<Poco::Int8>& val, Direction dir = PD_IN);
  77. /// Binds an Int8 vector.
  78. virtual void bind(std::size_t pos, const std::deque<Poco::Int8>& val, Direction dir = PD_IN);
  79. /// Binds an Int8 deque.
  80. virtual void bind(std::size_t pos, const std::list<Poco::Int8>& val, Direction dir = PD_IN);
  81. /// Binds an Int8 list.
  82. virtual void bind(std::size_t pos, const Poco::UInt8& val, Direction dir = PD_IN) = 0;
  83. /// Binds an UInt8.
  84. virtual void bind(std::size_t pos, const std::vector<Poco::UInt8>& val, Direction dir = PD_IN);
  85. /// Binds an UInt8 vector.
  86. virtual void bind(std::size_t pos, const std::deque<Poco::UInt8>& val, Direction dir = PD_IN);
  87. /// Binds an UInt8 deque.
  88. virtual void bind(std::size_t pos, const std::list<Poco::UInt8>& val, Direction dir = PD_IN);
  89. /// Binds an UInt8 list.
  90. virtual void bind(std::size_t pos, const Poco::Int16& val, Direction dir = PD_IN) = 0;
  91. /// Binds an Int16.
  92. virtual void bind(std::size_t pos, const std::vector<Poco::Int16>& val, Direction dir = PD_IN);
  93. /// Binds an Int16 vector.
  94. virtual void bind(std::size_t pos, const std::deque<Poco::Int16>& val, Direction dir = PD_IN);
  95. /// Binds an Int16 deque.
  96. virtual void bind(std::size_t pos, const std::list<Poco::Int16>& val, Direction dir = PD_IN);
  97. /// Binds an Int16 list.
  98. virtual void bind(std::size_t pos, const Poco::UInt16& val, Direction dir = PD_IN) = 0;
  99. /// Binds an UInt16.
  100. virtual void bind(std::size_t pos, const std::vector<Poco::UInt16>& val, Direction dir = PD_IN);
  101. /// Binds an UInt16 vector.
  102. virtual void bind(std::size_t pos, const std::deque<Poco::UInt16>& val, Direction dir = PD_IN);
  103. /// Binds an UInt16 deque.
  104. virtual void bind(std::size_t pos, const std::list<Poco::UInt16>& val, Direction dir = PD_IN);
  105. /// Binds an UInt16 list.
  106. virtual void bind(std::size_t pos, const Poco::Int32& val, Direction dir = PD_IN) = 0;
  107. /// Binds an Int32.
  108. virtual void bind(std::size_t pos, const std::vector<Poco::Int32>& val, Direction dir = PD_IN);
  109. /// Binds an Int32 vector.
  110. virtual void bind(std::size_t pos, const std::deque<Poco::Int32>& val, Direction dir = PD_IN);
  111. /// Binds an Int32 deque.
  112. virtual void bind(std::size_t pos, const std::list<Poco::Int32>& val, Direction dir = PD_IN);
  113. /// Binds an Int32 list.
  114. virtual void bind(std::size_t pos, const Poco::UInt32& val, Direction dir = PD_IN) = 0;
  115. /// Binds an UInt32.
  116. virtual void bind(std::size_t pos, const std::vector<Poco::UInt32>& val, Direction dir = PD_IN);
  117. /// Binds an UInt32 vector.
  118. virtual void bind(std::size_t pos, const std::deque<Poco::UInt32>& val, Direction dir = PD_IN);
  119. /// Binds an UInt32 deque.
  120. virtual void bind(std::size_t pos, const std::list<Poco::UInt32>& val, Direction dir = PD_IN);
  121. /// Binds an UInt32 list.
  122. virtual void bind(std::size_t pos, const Poco::Int64& val, Direction dir = PD_IN) = 0;
  123. /// Binds an Int64.
  124. virtual void bind(std::size_t pos, const std::vector<Poco::Int64>& val, Direction dir = PD_IN);
  125. /// Binds an Int64 vector.
  126. virtual void bind(std::size_t pos, const std::deque<Poco::Int64>& val, Direction dir = PD_IN);
  127. /// Binds an Int64 deque.
  128. virtual void bind(std::size_t pos, const std::list<Poco::Int64>& val, Direction dir = PD_IN);
  129. /// Binds an Int64 list.
  130. virtual void bind(std::size_t pos, const Poco::UInt64& val, Direction dir = PD_IN) = 0;
  131. /// Binds an UInt64.
  132. virtual void bind(std::size_t pos, const std::vector<Poco::UInt64>& val, Direction dir = PD_IN);
  133. /// Binds an UInt64 vector.
  134. virtual void bind(std::size_t pos, const std::deque<Poco::UInt64>& val, Direction dir = PD_IN);
  135. /// Binds an UInt64 deque.
  136. virtual void bind(std::size_t pos, const std::list<Poco::UInt64>& val, Direction dir = PD_IN);
  137. /// Binds an UInt64 list.
  138. #ifndef POCO_LONG_IS_64_BIT
  139. virtual void bind(std::size_t pos, const long& val, Direction dir = PD_IN) = 0;
  140. /// Binds a long.
  141. virtual void bind(std::size_t pos, const std::vector<long>& val, Direction dir = PD_IN);
  142. /// Binds a long vector.
  143. virtual void bind(std::size_t pos, const std::deque<long>& val, Direction dir = PD_IN);
  144. /// Binds a long deque.
  145. virtual void bind(std::size_t pos, const std::list<long>& val, Direction dir = PD_IN);
  146. /// Binds a long list.
  147. #endif
  148. virtual void bind(std::size_t pos, const bool& val, Direction dir = PD_IN) = 0;
  149. /// Binds a boolean.
  150. virtual void bind(std::size_t pos, const std::vector<bool>& val, Direction dir = PD_IN);
  151. /// Binds a boolean vector.
  152. virtual void bind(std::size_t pos, const std::deque<bool>& val, Direction dir = PD_IN);
  153. /// Binds a boolean deque.
  154. virtual void bind(std::size_t pos, const std::list<bool>& val, Direction dir = PD_IN);
  155. /// Binds a boolean list.
  156. virtual void bind(std::size_t pos, const float& val, Direction dir = PD_IN) = 0;
  157. /// Binds a float.
  158. virtual void bind(std::size_t pos, const std::vector<float>& val, Direction dir = PD_IN);
  159. /// Binds a float vector.
  160. virtual void bind(std::size_t pos, const std::deque<float>& val, Direction dir = PD_IN);
  161. /// Binds a float deque.
  162. virtual void bind(std::size_t pos, const std::list<float>& val, Direction dir = PD_IN);
  163. /// Binds a float list.
  164. virtual void bind(std::size_t pos, const double& val, Direction dir = PD_IN) = 0;
  165. /// Binds a double.
  166. virtual void bind(std::size_t pos, const std::vector<double>& val, Direction dir = PD_IN);
  167. /// Binds a double vector.
  168. virtual void bind(std::size_t pos, const std::deque<double>& val, Direction dir = PD_IN);
  169. /// Binds a double deque.
  170. virtual void bind(std::size_t pos, const std::list<double>& val, Direction dir = PD_IN);
  171. /// Binds a double list.
  172. virtual void bind(std::size_t pos, const char& val, Direction dir = PD_IN) = 0;
  173. /// Binds a single character.
  174. virtual void bind(std::size_t pos, const std::vector<char>& val, Direction dir = PD_IN);
  175. /// Binds a character vector.
  176. virtual void bind(std::size_t pos, const std::deque<char>& val, Direction dir = PD_IN);
  177. /// Binds a character deque.
  178. virtual void bind(std::size_t pos, const std::list<char>& val, Direction dir = PD_IN);
  179. /// Binds a character list.
  180. virtual void bind(std::size_t pos, const char* const& pVal, Direction dir = PD_IN) = 0;
  181. /// Binds a const char ptr.
  182. virtual void bind(std::size_t pos, const std::string& val, Direction dir = PD_IN) = 0;
  183. /// Binds a string.
  184. virtual void bind(std::size_t pos, const std::vector<std::string>& val, Direction dir = PD_IN);
  185. /// Binds a string vector.
  186. virtual void bind(std::size_t pos, const std::deque<std::string>& val, Direction dir = PD_IN);
  187. /// Binds a string deque.
  188. virtual void bind(std::size_t pos, const std::list<std::string>& val, Direction dir = PD_IN);
  189. /// Binds a string list.
  190. virtual void bind(std::size_t pos, const BLOB& val, Direction dir = PD_IN) = 0;
  191. /// Binds a BLOB.
  192. virtual void bind(std::size_t pos, const std::vector<BLOB>& val, Direction dir = PD_IN);
  193. /// Binds a BLOB vector.
  194. virtual void bind(std::size_t pos, const std::deque<BLOB>& val, Direction dir = PD_IN);
  195. /// Binds a BLOB deque.
  196. virtual void bind(std::size_t pos, const std::list<BLOB>& val, Direction dir = PD_IN);
  197. /// Binds a BLOB list.
  198. virtual void bind(std::size_t pos, const DateTime& val, Direction dir = PD_IN) = 0;
  199. /// Binds a DateTime.
  200. virtual void bind(std::size_t pos, const std::vector<DateTime>& val, Direction dir = PD_IN);
  201. /// Binds a DateTime vector.
  202. virtual void bind(std::size_t pos, const std::deque<DateTime>& val, Direction dir = PD_IN);
  203. /// Binds a DateTime deque.
  204. virtual void bind(std::size_t pos, const std::list<DateTime>& val, Direction dir = PD_IN);
  205. /// Binds a DateTime list.
  206. virtual void bind(std::size_t pos, const Date& val, Direction dir = PD_IN) = 0;
  207. /// Binds a Date.
  208. virtual void bind(std::size_t pos, const std::vector<Date>& val, Direction dir = PD_IN);
  209. /// Binds a Date vector.
  210. virtual void bind(std::size_t pos, const std::deque<Date>& val, Direction dir = PD_IN);
  211. /// Binds a Date deque.
  212. virtual void bind(std::size_t pos, const std::list<Date>& val, Direction dir = PD_IN);
  213. /// Binds a Date list.
  214. virtual void bind(std::size_t pos, const Time& val, Direction dir = PD_IN) = 0;
  215. /// Binds a Time.
  216. virtual void bind(std::size_t pos, const std::vector<Time>& val, Direction dir = PD_IN);
  217. /// Binds a Time vector.
  218. virtual void bind(std::size_t pos, const std::deque<Time>& val, Direction dir = PD_IN);
  219. /// Binds a Time deque.
  220. virtual void bind(std::size_t pos, const std::list<Time>& val, Direction dir = PD_IN);
  221. /// Binds a Time list.
  222. virtual void bind(std::size_t pos, const NullData& val, Direction dir = PD_IN) = 0;
  223. /// Binds a null.
  224. virtual void bind(std::size_t pos, const std::vector<NullData>& val, Direction dir = PD_IN);
  225. /// Binds a null vector.
  226. virtual void bind(std::size_t pos, const std::deque<NullData>& val, Direction dir = PD_IN);
  227. /// Binds a null deque.
  228. virtual void bind(std::size_t pos, const std::list<NullData>& val, Direction dir = PD_IN);
  229. /// Binds a null list.
  230. void bind(std::size_t pos, const Any& val, Direction dir = PD_IN);
  231. /// Binds an Any.
  232. void bind(std::size_t pos, const DynamicAny& val, Direction dir = PD_IN);
  233. /// Binds a DynamicAny.
  234. virtual void reset();
  235. /// Resets a binder. No-op by default. Implement for binders that cache data.
  236. static bool isOutBound(Direction dir);
  237. /// Returns true if direction is out bound;
  238. static bool isInBound(Direction dir);
  239. /// Returns true if direction is in bound;
  240. };
  241. //
  242. // inlines
  243. //
  244. inline void AbstractBinder::reset()
  245. {
  246. //no-op
  247. }
  248. inline bool AbstractBinder::isOutBound(Direction dir)
  249. {
  250. return PD_OUT == dir || PD_IN_OUT == dir;
  251. }
  252. inline bool AbstractBinder::isInBound(Direction dir)
  253. {
  254. return PD_IN == dir || PD_IN_OUT == dir;
  255. }
  256. } } // namespace Poco::Data
  257. #endif // Data_AbstractBinder_INCLUDED