Lightweight 0.20261105.1
Loading...
Searching...
No Matches
SqlValueStorage.hpp
1// SPDX-License-Identifier: Apache-2.0
2
3#pragma once
4
5#include <cstdint>
6
7namespace Lightweight
8{
9
10/// Lightweight-owned storage of a SQL DATE value.
11///
12/// Layout-identical to ODBC's `SQL_DATE_STRUCT`, so an ODBC driver can bind it in place without a copy.
13///
14/// @ingroup DataTypes
16{
17 /// Year, may be negative.
18 std::int16_t year;
19 /// Month of the year, 1-12.
20 std::uint16_t month;
21 /// Day of the month, 1-31.
22 std::uint16_t day;
23};
24
25/// Lightweight-owned storage of a SQL TIMESTAMP / DATETIME value.
26///
27/// Layout-identical to ODBC's `SQL_TIMESTAMP_STRUCT`.
28///
29/// @ingroup DataTypes
31{
32 /// Year, may be negative.
33 std::int16_t year;
34 /// Month of the year, 1-12.
35 std::uint16_t month;
36 /// Day of the month, 1-31.
37 std::uint16_t day;
38 /// Hour of the day, 0-23.
39 std::uint16_t hour;
40 /// Minute of the hour, 0-59.
41 std::uint16_t minute;
42 /// Second of the minute, 0-59.
43 std::uint16_t second;
44 /// Fractional seconds in nanoseconds.
45 std::uint32_t fraction;
46};
47
48/// Lightweight-owned storage of a SQL TIME value with fractional seconds.
49///
50/// Layout-identical to the SQL Server ODBC extension `SQL_SS_TIME2_STRUCT` (12 bytes, padded).
51///
52/// @ingroup DataTypes
54{
55 /// Hour of the day, 0-23.
56 std::uint16_t hour;
57 /// Minute of the hour, 0-59.
58 std::uint16_t minute;
59 /// Second of the minute, 0-59.
60 std::uint16_t second;
61 /// Fractional seconds in microseconds, as `SqlTime` writes and reads them.
62 ///
63 /// No driver reads or writes this field today: `SqlTime` binds as `SQL_C_TYPE_TIME`, whose
64 /// `SQL_TIME_STRUCT` ends after `second`. A binding as `SQL_C_SS_TIME2` would hand the driver this field
65 /// as nanoseconds, so such a binding must convert it first.
66 std::uint32_t fraction;
67};
68
69/// Lightweight-owned storage of a SQL NUMERIC / DECIMAL value.
70///
71/// Layout-identical to ODBC's `SQL_NUMERIC_STRUCT`.
72///
73/// @ingroup DataTypes
75{
76 /// Total number of decimal digits.
77 std::uint8_t precision;
78 /// Number of digits after the decimal point.
79 std::int8_t scale;
80 /// 1 for positive, 0 for negative.
81 std::uint8_t sign;
82 /// Little-endian unscaled magnitude.
83 std::uint8_t val[16];
84};
85
86} // namespace Lightweight
std::uint16_t day
Day of the month, 1-31.
std::uint16_t month
Month of the year, 1-12.
std::int16_t year
Year, may be negative.
std::int8_t scale
Number of digits after the decimal point.
std::uint8_t precision
Total number of decimal digits.
std::uint8_t sign
1 for positive, 0 for negative.
std::uint8_t val[16]
Little-endian unscaled magnitude.
std::uint16_t minute
Minute of the hour, 0-59.
std::uint16_t hour
Hour of the day, 0-23.
std::uint16_t second
Second of the minute, 0-59.
std::uint16_t month
Month of the year, 1-12.
std::uint32_t fraction
Fractional seconds in nanoseconds.
std::uint16_t hour
Hour of the day, 0-23.
std::uint16_t minute
Minute of the hour, 0-59.
std::int16_t year
Year, may be negative.
std::uint16_t second
Second of the minute, 0-59.
std::uint16_t day
Day of the month, 1-31.