66#include < string>
77#include < ostream>
88#include < utility> // std::exchange, std::tuple_size
9- #if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && !defined(SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS)
10- #include < string_view>
11- #include < algorithm> // std::find
12- #endif
139
1410#include " functional/cxx_universal.h" // ::size_t
1511#include " functional/cxx_type_traits_polyfill.h"
1612#include " tuple_helper/tuple_iteration.h"
1713#include " error_code.h"
1814#include " serializer_context.h"
15+ #include " serialize_result_type.h"
1916#include " util.h"
2017
2118namespace sqlite_orm {
2219 namespace internal {
2320 template <class O >
2421 struct order_by_t ;
2522
26- template <class T , class I >
27- std::string serialize (const T& t , const serializer_context<I>& context );
23+ template <class T , class DBOs >
24+ std::string serialize (const T&, const serializer_context<DBOs>& );
2825
2926 template <class T , class Ctx >
30- std::string serialize_order_by (const T& t, const Ctx& context);
31-
32- #if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && !defined(SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS)
33- // optimized version when string_view's iterator range constructor is available
34- template <class SFINAE = void >
35- void stream_sql_escaped (std::ostream& os, const std::string& str, char char2Escape)
36- requires requires {
37- std::string_view{str.cbegin (), str.cend ()};
38- }
39- {
40- for (std::string::const_iterator it = str.cbegin (), next; true ; it = next + 1 ) {
41- next = std::find (it, str.cend (), char2Escape);
42- os << std::string_view{it, next};
43-
44- if (next == str.cend ()) [[likely]] {
27+ std::string serialize_order_by (const T&, const Ctx&);
28+
29+ inline void stream_sql_escaped (std::ostream& os, serialize_arg_type str, char char2Escape) {
30+ for (size_t offset = 0 , next; true ; offset = next + 1 ) {
31+ next = str.find (char2Escape, offset);
32+
33+ if (next == str.npos ) {
34+ os.write (str.data () + offset, str.size () - offset);
4535 break ;
4636 }
47- os << std::string (2 , char2Escape);
48- }
49- }
5037
51- template <class SFINAE = void >
52- #endif
53- inline void stream_sql_escaped (std::ostream& os, const std::string& str, char char2Escape) {
54- if (str.find (char2Escape) == str.npos ) {
55- os << str;
56- } else {
57- for (char c: str) {
58- if (c == char2Escape) {
59- os << char2Escape;
60- }
61- os << c;
62- }
38+ os.write (str.data () + offset, next - offset + 1 );
39+ os.write (&char2Escape, 1 );
6340 }
6441 }
6542
6643 inline void stream_identifier (std::ostream& ss,
67- const std::string& qualifier,
68- const std::string& identifier,
69- const std::string& alias) {
44+ serialize_arg_type qualifier,
45+ serialize_arg_type identifier,
46+ serialize_arg_type alias) {
7047 constexpr char quoteChar = ' "' ;
7148 constexpr char qualified[] = {quoteChar, ' .' , ' \0 ' };
7249 constexpr char aliased[] = {' ' , quoteChar, ' \0 ' };
@@ -92,11 +69,11 @@ namespace sqlite_orm {
9269 }
9370
9471 inline void stream_identifier (std::ostream& ss, const std::string& identifier, const std::string& alias) {
95- return stream_identifier (ss, std::string{} , identifier, alias);
72+ return stream_identifier (ss, " " , identifier, alias);
9673 }
9774
9875 inline void stream_identifier (std::ostream& ss, const std::string& identifier) {
99- return stream_identifier (ss, std::string{} , identifier, std::string{} );
76+ return stream_identifier (ss, " " , identifier, " " );
10077 }
10178
10279 template <typename Tpl, size_t ... Is>
0 commit comments