-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyDatabase.h
51 lines (47 loc) · 1.02 KB
/
MyDatabase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <winsqlite/winsqlite3.h>
#include <string>
#include "domain.h"
#include <exception>
#include <iostream>
class DBException: public std::exception
{
public:
DBException(std::string error)
: std::exception{ error.c_str() } {}
};
class MyDatabase
{
private:
sqlite3* db;
std::string filename;
public:
class iterator
{
private:
sqlite3_stmt* current;
Tower currentTower;
const MyDatabase* db;
public:
iterator();
iterator(const MyDatabase* db, std::string pos);
iterator(const MyDatabase::iterator& it);
const Tower& operator*() const;
bool operator!=(const iterator& it) const;
bool valid() const;
iterator& operator=(const iterator& it);
iterator operator++();
iterator operator++(int);
~iterator();
};
MyDatabase(const std::string& filename);
void add(const Tower& tower);
void remove(const std::string& location);
void update(const Tower& tower);
Tower search(std::string location);
iterator begin();
iterator end();
std::vector<Tower> get_all();
int size();
~MyDatabase();
};