summary refs log tree commit diff stats
path: root/lib/database.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/database.h')
-rw-r--r--lib/database.h61
1 files changed, 28 insertions, 33 deletions
diff --git a/lib/database.h b/lib/database.h index efb54e1..83c4c1c 100644 --- a/lib/database.h +++ b/lib/database.h
@@ -1,11 +1,10 @@
1#ifndef DATABASE_H_0B0A47D2 1#ifndef DATABASE_H_0B0A47D1
2#define DATABASE_H_0B0A47D2 2#define DATABASE_H_0B0A47D1
3 3
4#include <string> 4#include <string>
5#include <exception>
6#include <stdexcept> 5#include <stdexcept>
7#include <list>
8#include <set> 6#include <set>
7#include <hkutil/database.h>
9#include "notion.h" 8#include "notion.h"
10#include "word.h" 9#include "word.h"
11#include "frame.h" 10#include "frame.h"
@@ -14,8 +13,6 @@
14#include "pronunciation.h" 13#include "pronunciation.h"
15#include "order.h" 14#include "order.h"
16 15
17struct sqlite3;
18
19namespace verbly { 16namespace verbly {
20 17
21 template <typename Object> 18 template <typename Object>
@@ -28,24 +25,6 @@ namespace verbly {
28 25
29 explicit database(std::string path); 26 explicit database(std::string path);
30 27
31 // Disable copying
32
33 database(const database& other) = delete;
34 database& operator=(const database& other) = delete;
35
36 // Move constructor and move assignment
37
38 database(database&& other);
39 database& operator=(database&& other);
40
41 // Swap
42
43 friend void swap(database& first, database& second);
44
45 // Destructor
46
47 ~database();
48
49 // Information 28 // Information
50 29
51 int getMajorVersion() const 30 int getMajorVersion() const
@@ -60,17 +39,35 @@ namespace verbly {
60 39
61 // Queries 40 // Queries
62 41
63 query<notion> notions(filter where, order sortOrder = {}, int limit = 1) const; 42 query<notion> notions(
43 filter where,
44 order sortOrder = {},
45 int limit = 1) const;
64 46
65 query<word> words(filter where, order sortOrder = {}, int limit = 1) const; 47 query<word> words(
48 filter where,
49 order sortOrder = {},
50 int limit = 1) const;
66 51
67 query<frame> frames(filter where, order sortOrder = {}, int limit = 1) const; 52 query<frame> frames(
53 filter where,
54 order sortOrder = {},
55 int limit = 1) const;
68 56
69 query<part> parts(filter where, order sortOrder = {}, int limit = 1) const; 57 query<part> parts(
58 filter where,
59 order sortOrder = {},
60 int limit = 1) const;
70 61
71 query<form> forms(filter where, order sortOrder = {}, int limit = 1) const; 62 query<form> forms(
63 filter where,
64 order sortOrder = {},
65 int limit = 1) const;
72 66
73 query<pronunciation> pronunciations(filter where, order sortOrder = {}, int limit = 1) const; 67 query<pronunciation> pronunciations(
68 filter where,
69 order sortOrder = {},
70 int limit = 1) const;
74 71
75 std::set<std::string> selrestrs(int partId) const; 72 std::set<std::string> selrestrs(int partId) const;
76 73
@@ -78,9 +75,7 @@ namespace verbly {
78 75
79 private: 76 private:
80 77
81 database() = default; 78 mutable hatkirby::database ppdb_;
82
83 sqlite3* ppdb_ = nullptr;
84 79
85 int major_; 80 int major_;
86 int minor_; 81 int minor_;