/** * @file * Copyright 2014 (c) Anna Schumaker. */ #ifndef OCARINA_CORE_INDEX_H #define OCARINA_CORE_INDEX_H #include #include #include /** * Class for storing index information in a Database. */ class IndexEntry : public DatabaseEntry { public: std::string key; std::set values; /** * Default IndexEntry constructor. */ IndexEntry(); /** * IndexEntry constructor. * @param key The key associated with this IndexEntry. */ IndexEntry(const std::string &); /** * Access this IndexEntry's key. * @return This IndexEntry's key. */ const std::string primary_key() const; /** * Add a new value to this entry. * @param value The new value to add. */ void insert(unsigned int); /** * Remove a value from this entry. * @param value The value to remove. */ void remove(unsigned int); /** * Write an IndexEntry to file * @param file The file to use when writing data. */ void write(File &); /** * Read an IndexEntry from file * @param file The file read from. */ void read(File &); }; /** * A special Database for index access. */ class Index : public Database { public: /** * Index constructor. * @param filepath Where to store the file on disk. * @param autosave True if changes should automatically be saved. */ Index(const std::string &, bool); /** * Add a new (key, value) pair to the index. * @param key String to store in the index. * @param value Integer value associated with the key. */ void insert(const std::string &, unsigned int); /** * Remove a (key, value) pair from the index. * @param key Key associated with the value to be removed. * @param value Value to remove from the index. */ void remove(const std::string &, unsigned int); }; #endif /* OCARINA_CORE_DATABASE_H */