/* * Copyright 2013 (c) Anna Schumaker. */ #include DatabaseEntry :: DatabaseEntry() : primary_key(""), valid(false) { } IndexEntry :: IndexEntry() { } IndexEntry :: IndexEntry(const std::string &key, unsigned int v) { primary_key = key; insert(v); } IndexEntry :: ~IndexEntry() { } void IndexEntry :: write(File &f) { std::set::iterator it; f << primary_key << std::endl << values.size() << " "; for (it = values.begin(); it != values.end(); it++) f << *it << " "; } void IndexEntry :: read(File &f) { unsigned int num, val; f >> primary_key >> num; for (unsigned int i = 0; i < num; i++) { f >> val; values.insert(val); } } #ifdef CONFIG_TEST void IndexEntry :: print() { std::set::iterator it; :: print("{"); for (it = values.begin(); it != values.end(); it++) { if (it != values.begin()) :: print(" "); :: print("%d", *it); } :: print("}"); } #endif /* CONFIG_TEST */ void IndexEntry :: insert(unsigned int val) { values.insert(val); } void IndexEntry :: remove(unsigned int val) { values.erase(val); }