|
16 | 16 | #include <string> |
17 | 17 | #include <map> |
18 | 18 | #include <memory> |
| 19 | +#include <cstdint> |
19 | 20 |
|
20 | 21 | // Forward declarations to avoid inclusion of <sqlite3.h> in a header |
21 | 22 | struct sqlite3; |
@@ -74,6 +75,110 @@ class Statement |
74 | 75 | Statement(aDatabase, aQuery.c_str()) |
75 | 76 | {} |
76 | 77 |
|
| 78 | +#ifdef __cpp_unicode_characters |
| 79 | + /** |
| 80 | + * @brief Compile and register the SQL query for the provided SQLite Database Connection |
| 81 | + * |
| 82 | + * @param[in] aDatabase the SQLite Database Connection |
| 83 | + * @param[in] aQuery an UTF-16 encoded query string |
| 84 | + * |
| 85 | + * Exception is thrown in case of error, then the Statement object is NOT constructed. |
| 86 | + */ |
| 87 | + Statement(const Database& aDatabase, const std::u16string& aQuery); |
| 88 | + |
| 89 | +#if WCHAR_MAX == 0xffff |
| 90 | + /** |
| 91 | + * @brief Compile and register the SQL query for the provided SQLite Database Connection |
| 92 | + * |
| 93 | + * @param[in] aDatabase the SQLite Database Connection |
| 94 | + * @param[in] aQuery an UTF-16 encoded query string |
| 95 | + * |
| 96 | + * Exception is thrown in case of error, then the Statement object is NOT constructed. |
| 97 | + */ |
| 98 | + Statement(const Database& aDatabase, const std::wstring& aQuery) : |
| 99 | +#ifdef __cpp_lib_string_view |
| 100 | + Statement(aDatabase, std::u16string_view(reinterpret_cast<const char16_t*>(aQuery.data()), aQuery.size())) |
| 101 | +#else |
| 102 | + Statement(aDatabase, std::u16string(reinterpret_cast<const char16_t*>(aQuery.data()), aQuery.size())) |
| 103 | +#endif |
| 104 | + {} |
| 105 | +#endif // WCHAR_MAX == 0xffff |
| 106 | +#endif // __cpp_unicode_characters |
| 107 | + |
| 108 | +#ifdef __cpp_lib_string_view |
| 109 | + /** |
| 110 | + * @brief Compile and register the SQL query for the provided SQLite Database Connection |
| 111 | + * |
| 112 | + * @param[in] aDatabase the SQLite Database Connection |
| 113 | + * @param[in] aQuery an UTF-16 encoded query string |
| 114 | + * |
| 115 | + * Exception is thrown in case of error, then the Statement object is NOT constructed. |
| 116 | + */ |
| 117 | + Statement(const Database& aDatabase, const std::string_view aQuery); |
| 118 | + |
| 119 | +#ifdef __cpp_char8_t |
| 120 | + /** |
| 121 | + * @brief Compile and register the SQL query for the provided SQLite Database Connection |
| 122 | + * |
| 123 | + * @param[in] aDatabase the SQLite Database Connection |
| 124 | + * @param[in] aQuery an UTF-8 encoded query string |
| 125 | + * |
| 126 | + * Exception is thrown in case of error, then the Statement object is NOT constructed. |
| 127 | + */ |
| 128 | + Statement(const Database& aDatabase, const std::u8string_view aQuery) : |
| 129 | + Statement(aDatabase, std::string_view(reinterpret_cast<const char*>(aQuery.data()), aQuery.size())) |
| 130 | + {} |
| 131 | +#endif // __cpp_char8_t |
| 132 | + |
| 133 | + /** |
| 134 | + * @brief Compile and register the SQL query for the provided SQLite Database Connection |
| 135 | + * |
| 136 | + * @param[in] aDatabase the SQLite Database Connection |
| 137 | + * @param[in] apQuery an UTF-16 encoded query string |
| 138 | + * |
| 139 | + * Exception is thrown in case of error, then the Statement object is NOT constructed. |
| 140 | + */ |
| 141 | + Statement(const Database& aDatabase, const char16_t* apQuery) : |
| 142 | + Statement(aDatabase, std::u16string_view(apQuery)) |
| 143 | + {} |
| 144 | + |
| 145 | + /** |
| 146 | + * @brief Compile and register the SQL query for the provided SQLite Database Connection |
| 147 | + * |
| 148 | + * @param[in] aDatabase the SQLite Database Connection |
| 149 | + * @param[in] aQuery an UTF-16 encoded query string |
| 150 | + * |
| 151 | + * Exception is thrown in case of error, then the Statement object is NOT constructed. |
| 152 | + */ |
| 153 | + Statement(const Database& aDatabase, std::u16string_view aQuery); |
| 154 | + |
| 155 | +#if WCHAR_MAX == 0xffff |
| 156 | + /** |
| 157 | + * @brief Compile and register the SQL query for the provided SQLite Database Connection |
| 158 | + * |
| 159 | + * @param[in] aDatabase the SQLite Database Connection |
| 160 | + * @param[in] apQuery an UTF-16 encoded query string |
| 161 | + * |
| 162 | + * Exception is thrown in case of error, then the Statement object is NOT constructed. |
| 163 | + */ |
| 164 | + Statement(const Database& aDatabase, const wchar_t* apQuery) : |
| 165 | + Statement(aDatabase, std::u16string_view(reinterpret_cast<const char16_t*>(apQuery))) |
| 166 | + {} |
| 167 | + |
| 168 | + /** |
| 169 | + * @brief Compile and register the SQL query for the provided SQLite Database Connection |
| 170 | + * |
| 171 | + * @param[in] aDatabase the SQLite Database Connection |
| 172 | + * @param[in] aQuery an UTF-16 encoded query string |
| 173 | + * |
| 174 | + * Exception is thrown in case of error, then the Statement object is NOT constructed. |
| 175 | + */ |
| 176 | + Statement(const Database& aDatabase, const std::wstring_view aQuery) : |
| 177 | + Statement(aDatabase, std::u16string_view(reinterpret_cast<const char16_t*>(aQuery.data()), aQuery.size())) |
| 178 | + {} |
| 179 | +#endif // WCHAR_MAX == 0xffff |
| 180 | +#endif // __cpp_lib_string_view |
| 181 | + |
77 | 182 | // Statement is non-copyable |
78 | 183 | Statement(const Statement&) = delete; |
79 | 184 | Statement& operator=(const Statement&) = delete; |
@@ -690,6 +795,24 @@ class Statement |
690 | 795 | */ |
691 | 796 | TStatementPtr prepareStatement(); |
692 | 797 |
|
| 798 | +#ifdef __cpp_unicode_characters |
| 799 | + /** |
| 800 | + * @brief Prepare statement object. |
| 801 | + * |
| 802 | + * @return Shared pointer to prepared statement object |
| 803 | + */ |
| 804 | + TStatementPtr prepareStatement(const std::u16string& query); |
| 805 | +#endif // __cpp_unicode_characters |
| 806 | + |
| 807 | +#ifdef __cpp_lib_string_view |
| 808 | + /** |
| 809 | + * @brief Prepare statement object. |
| 810 | + * |
| 811 | + * @return Shared pointer to prepared statement object |
| 812 | + */ |
| 813 | + TStatementPtr prepareStatement(const std::u16string_view query); |
| 814 | +#endif // __cpp_lib_string_view |
| 815 | + |
693 | 816 | /** |
694 | 817 | * @brief Return a prepared statement object. |
695 | 818 | * |
|
0 commit comments