From 28b329b63a3919020a9286b557f7938dc8fbd746 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Dec 2011 11:19:24 +0200 Subject: ODB compiler implementation, traits, and types test for SQL Server --- odb/mssql/traits.txx | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) (limited to 'odb/mssql/traits.txx') diff --git a/odb/mssql/traits.txx b/odb/mssql/traits.txx index b3bc442..80ee933 100644 --- a/odb/mssql/traits.txx +++ b/odb/mssql/traits.txx @@ -3,9 +3,118 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : ODB NCUEL; see accompanying LICENSE file +#include + namespace odb { namespace mssql { + // + // wrapped_value_traits + // + + template + void wrapped_value_traits:: + result_callback (void* context, + std::size_t* position, + void** buffer, + std::size_t* size, + chunk_type chunk, + std::size_t size_left, + void* tmp_buffer, + std::size_t tmp_capacity) + { + W& v (*static_cast (context)); + + if (chunk == chunk_null) + wtraits::set_null (v); + else + { + long_callback& c (*static_cast (*buffer)); + + // Redirect all further calls. + // + vtraits::set_value (wtraits::set_ref (v), + c.callback.result, + c.context.result); + + // Forward this call. + // + c.callback.result ( + c.context.result, + position, + buffer, + size, + chunk, + size_left, + tmp_buffer, + tmp_capacity); + } + } + + // + // array_long_binary_value_traits + // + + template + void array_long_binary_value_traits:: + param_callback (const void* context, + std::size_t*, + const void** buffer, + std::size_t* size, + chunk_type* chunk, + void*, + std::size_t) + { + *buffer = context; + *size = N; + *chunk = chunk_one; + } + + template + void array_long_binary_value_traits:: + result_callback (void* context, + std::size_t*, + void** buffer, + std::size_t* size, + chunk_type chunk, + std::size_t size_left, + void* tmp_buf, + std::size_t tmp_capacity) + { + // The code is similar to the vector specialization. + // + switch (chunk) + { + case chunk_null: + case chunk_one: + { + std::memset (context, 0, N); + break; + } + case chunk_first: + { + assert (size_left != 0); + + *buffer = context; + *size = size_left < N ? size_left : N; + break; + } + case chunk_next: + { + // We can get here if total size is greater than N. There is + // no way to stop until we read all the data, so dump the + // remainder into the temporary buffer. + // + *buffer = tmp_buf; + *size = tmp_capacity; + break; + } + case chunk_last: + { + break; + } + } + } } } -- cgit v1.1