ocarina/include/database.h
Anna Schumaker 13313482d4 database: Make read() and write() functions for database entries
I had planned on using the stream operator for my database class but
this created some crazy compiler error that I was having difficulty
figuring out.  I decided to take the easy route for now and instead
create read() and write() functions that do exactly the same thing.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:52 -04:00

50 lines
736 B
C++

/*
* Copyright 2013 (c) Anna Schumaker.
*/
#ifndef OCARINA_DATABASE_H
#define OCARINA_DATABASE_H
#include <file.h>
#include <print.h>
#include <vector>
class DatabaseEntry {
public:
bool valid;
DatabaseEntry();
virtual void write(File &) = 0;
virtual void read(File &) = 0;
};
template <class T>
class Database {
private:
std::vector<T> db;
unsigned int _size;
File file;
public:
Database(std::string);
~Database();
void save();
void load();
unsigned int insert(T);
void remove(unsigned int);
unsigned int size();
unsigned int num_rows();
unsigned int first();
unsigned int last();
unsigned int next(unsigned int);
T &operator[](unsigned int);
};
#include "database.hpp"
#endif /* OCARINA_DATABASE_H */