LeechCraft  0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
sqliteimpl.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include "oraltypes.h"
12 
14 {
15  struct ImplFactory
16  {
17  using IsImpl_t = void;
18 
19  struct TypeLits
20  {
21  constexpr static CtString IntAutoincrement { "INTEGER PRIMARY KEY AUTOINCREMENT" };
22  constexpr static CtString Binary { "BLOB" };
23  };
24 
25  constexpr static CtString LimitNone { "-1" };
26 
27  constexpr static auto GetInsertPrefix (InsertAction::IgnoreTag)
28  {
29  return "INSERT OR IGNORE"_ct;
30  }
31 
32  constexpr static auto GetInsertPrefix (InsertAction::DefaultTag)
33  {
34  return "INSERT"_ct;
35  }
36 
37  template<auto... Ptrs>
39  {
40  return "INSERT"_ct;
41  }
42 
43  constexpr static auto GetInsertPrefix (InsertAction::Replace::WholeType)
44  {
45  return "INSERT"_ct;
46  }
47 
48  constexpr static auto GetInsertSuffix (InsertAction::DefaultTag)
49  {
50  return ""_ct;
51  }
52 
53  constexpr static auto GetInsertSuffix (InsertAction::IgnoreTag)
54  {
55  return ""_ct;
56  }
57 
58  constexpr static auto GetInsertSuffix (InsertAction::Replace, auto fields)
59  {
60  return "ON CONFLICT DO UPDATE SET " + JoinTup (ZipWith (fields, " = EXCLUDED.", fields), ", ");
61  }
62 
63  constexpr static auto GetInsertSuffix (InsertAction::DefaultTag, auto pkName)
64  {
65  return "RETURNING "_ct + pkName;
66  }
67 
68  constexpr static auto GetInsertSuffix (InsertAction::IgnoreTag, auto pkName)
69  {
70  return "RETURNING "_ct + pkName;
71  }
72 
73  constexpr static auto GetInsertSuffix (InsertAction::Replace, auto fields, auto pkName)
74  {
75  return "ON CONFLICT DO UPDATE SET " + JoinTup (ZipWith (fields, " = EXCLUDED.", fields), ", ") +
76  " RETURNING " + pkName;
77  }
78  };
79 }
80 
81 namespace LC::Util::oral
82 {
84 }
static constexpr auto GetInsertPrefix(InsertAction::IgnoreTag)
Definition: sqliteimpl.h:27
static constexpr auto GetInsertSuffix(InsertAction::DefaultTag)
Definition: sqliteimpl.h:48
constexpr auto JoinTup(auto &&stringsTuple, auto &&sep) noexcept
Definition: ctstringutils.h:30
static constexpr auto GetInsertSuffix(InsertAction::Replace, auto fields, auto pkName)
Definition: sqliteimpl.h:73
static constexpr auto GetInsertPrefix(InsertAction::Replace::WholeType)
Definition: sqliteimpl.h:43
static constexpr auto GetInsertPrefix(InsertAction::Replace::FieldsType< Ptrs... >)
Definition: sqliteimpl.h:38
static constexpr auto GetInsertSuffix(InsertAction::DefaultTag, auto pkName)
Definition: sqliteimpl.h:63
static constexpr auto GetInsertSuffix(InsertAction::Replace, auto fields)
Definition: sqliteimpl.h:58
auto ZipWith(const Container< T1 > &c1, const Container< T2 > &c2, F f)
Definition: prelude.h:37
constexpr detail::MemberPtrs< Ptrs... > fields
Definition: oral.h:1089
static constexpr auto GetInsertSuffix(InsertAction::IgnoreTag, auto pkName)
Definition: sqliteimpl.h:68
static constexpr auto GetInsertSuffix(InsertAction::IgnoreTag)
Definition: sqliteimpl.h:53
static constexpr auto GetInsertPrefix(InsertAction::DefaultTag)
Definition: sqliteimpl.h:32