|
tdslite latest
C++ API reference
|
Helper type to execute SQL commands. More...
#include <tdslite/detail/tdsl_command_context.hpp>
Classes | |
| struct | command_options |
| struct | query_result |
Public Types | |
| using | tds_context_type = tds_context< NetImpl > |
| using | column_metadata_cref = const tdsl::tds_colmetadata_token & |
| using | row_cref = const tdsl::tdsl_row & |
| using | row_callback_fn_t = void(*)(void *, column_metadata_cref, row_cref) |
| using | execute_rpc_result = tdsl::expected< tdsl::uint32_t, e_rpc_error_code > |
Public Member Functions | |
| command_context (tds_context_type &ctx, const command_options &opts={}) noexcept | |
| Default c-tor. | |
| ~command_context () noexcept | |
| Unregister the callbacks registered by this context. | |
| command_context (const command_context &)=delete | |
| command_context & | operator= (const command_context &)=delete |
| template<typename T , traits::enable_when::same_any_of< T, string_view, wstring_view, struct progmem_string_view > = true> | |
| auto | execute_query (T command, row_callback_fn_t row_callback=+[](void *, const tds_colmetadata_token &, const tdsl_row &) -> void {}, void *rcb_uptr=nullptr) noexcept -> query_result |
| Execute a query. | |
| template<typename T , traits::enable_when::same_any_of< T, string_view, wstring_view, struct progmem_string_view > = true> | |
| execute_rpc_result | execute_rpc (T command, tdsl::span< sql_parameter_binding > params={}, e_rpc_mode mode=e_rpc_mode::executesql, row_callback_fn_t row_callback=+[](void *, const tds_colmetadata_token &, const tdsl_row &) -> void {}, void *rcb_uptr=nullptr) noexcept |
| Perform a remote procedure call (e.g. | |
Static Public Member Functions | |
| static token_handler_result | token_handler (void *uptr, e_tds_message_token_type token_type, tdsl::binary_reader< tdsl::endian::little > &rr) noexcept |
| Token handler for command_context. | |
Helper type to execute SQL commands.
The context is designed to be constructed on demand.
| NetImpl | Network implementation type |
| using tdsl::detail::command_context< NetImpl >::tds_context_type = tds_context<NetImpl> |
| using tdsl::detail::command_context< NetImpl >::column_metadata_cref = const tdsl::tds_colmetadata_token & |
| using tdsl::detail::command_context< NetImpl >::row_cref = const tdsl::tdsl_row & |
| using tdsl::detail::command_context< NetImpl >::row_callback_fn_t = void (*)(void *, column_metadata_cref, row_cref) |
| using tdsl::detail::command_context< NetImpl >::execute_rpc_result = tdsl::expected<tdsl::uint32_t, e_rpc_error_code> |
|
inlinenoexcept |
Default c-tor.
| [in] | ctx | The TDS context associated with the command |
|
inlinenoexcept |
Unregister the callbacks registered by this context.
The tds_context outlives the command context, so the callbacks must not keep pointing to this object after it is destroyed. Otherwise, a subsequent DONE token (e.g. one received during a later login) would be delivered to a dangling pointer.
|
delete |
|
delete |
|
inlinenoexcept |
Execute a query.
| T | Auto-deduced string type (char_span or u16char_span) |
| [in] | command | SQL command to execute |
| [in] | row_callback | Row callback function (optional) |
| [in] | rcb_uptr | Row callback user pointer (optional) |
The result set returned by query command can be read by providing a row callback function
request_too_large is set. The command must leave 8 bytes of the buffer free, for the packet header.
|
inlinenoexcept |
Perform a remote procedure call (e.g.
execute a stored procedure or a parameterized query)
| T | String view type |
| [in] | command | Command to execute |
| [in] | params | Parameters of the command, if any |
| [in] | mode | RPC execution mode |
| [in] | row_callback | Row callback function (optional) |
| [in] | rcb_uptr | Row callback user pointer (optional) |
The result set returned by query command can be read by providing a row callback function
mode value is invalid or not supported command is longer than 4000 characters (not executed)
|
inlinestaticnoexcept |
Token handler for command_context.
Handles COLMETADATA & ROW token types.
| [in] | uptr | User-ptr (command context instance) |
| [in] | token_type | Type of the token to handle |
| [in] | rr | Binary reader |
unhandled