2013-08-10 23:38:57 -04:00
|
|
|
/*
|
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_DATABASE_H
|
|
|
|
#define OCARINA_DATABASE_H
|
|
|
|
|
|
|
|
#include <file.h>
|
|
|
|
|
2013-08-11 10:41:22 -04:00
|
|
|
#include <vector>
|
|
|
|
|
2013-08-11 20:18:51 -04:00
|
|
|
|
|
|
|
class DatabaseEntry {
|
|
|
|
public:
|
|
|
|
bool valid;
|
|
|
|
|
|
|
|
DatabaseEntry();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-11 10:41:22 -04:00
|
|
|
template <class T>
|
2013-08-10 23:38:57 -04:00
|
|
|
class Database {
|
2013-08-11 10:41:22 -04:00
|
|
|
private:
|
|
|
|
std::vector<T> db;
|
|
|
|
unsigned int _size;
|
|
|
|
File file;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Database(std::string);
|
|
|
|
~Database();
|
2013-08-10 23:38:57 -04:00
|
|
|
|
2013-08-11 10:41:22 -04:00
|
|
|
unsigned int insert(T);
|
2013-08-11 21:09:11 -04:00
|
|
|
void remove(unsigned int);
|
2013-08-11 20:18:51 -04:00
|
|
|
unsigned int size();
|
|
|
|
unsigned int num_rows();
|
|
|
|
|
|
|
|
unsigned int first();
|
|
|
|
unsigned int last();
|
|
|
|
unsigned int next(unsigned int);
|
|
|
|
T &operator[](unsigned int);
|
2013-08-10 23:38:57 -04:00
|
|
|
};
|
|
|
|
|
2013-08-11 10:41:22 -04:00
|
|
|
#include "database.hpp"
|
|
|
|
|
2013-08-10 23:38:57 -04:00
|
|
|
#endif /* OCARINA_DATABASE_H */
|