From 1c0235c8c7a65d345925be327a613b91cba9ee94 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 29 Sep 2015 10:45:04 -0400 Subject: [PATCH] core/tags/generic: Remove Generic tag Nothing uses it anymore, so it can be safely removed :) Signed-off-by: Anna Schumaker --- core/tags/generic.cpp | 59 ------------------------ include/core/tags/generic.h | 89 ------------------------------------- include/core/tags/library.h | 1 - tests/core/tags/Sconscript | 3 +- tests/core/tags/generic.cpp | 56 ----------------------- 5 files changed, 1 insertion(+), 207 deletions(-) delete mode 100644 core/tags/generic.cpp delete mode 100644 include/core/tags/generic.h delete mode 100644 tests/core/tags/generic.cpp diff --git a/core/tags/generic.cpp b/core/tags/generic.cpp deleted file mode 100644 index a3d88bfd..00000000 --- a/core/tags/generic.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright 2014 (c) Anna Schumaker. - */ -extern "C" { -#include -} -#include - -GenericTag :: GenericTag() {} - -GenericTag :: GenericTag(const std::string &name) - : _name(name) -{ - gchar *g_lc = string_lowercase(name.c_str()); - _lower = g_lc; - g_free(g_lc); -} - -GenericTag :: GenericTag(const GenericTag &tag) - : _name(tag._name), _lower(tag._lower) -{ -} - -const std::string GenericTag :: primary_key() const -{ - return _name; -} - -void GenericTag :: read(file &file) -{ - gchar *name = file_readl(&file); - gchar *g_lc = string_lowercase(name); - - _name = name; - _lower = g_lc; - - g_free(name); - g_free(g_lc); -} - -void GenericTag :: write(file &file) -{ - file_writef(&file, "%s", _name.c_str()); -} - -const std::string &GenericTag :: name() const -{ - return _name; -} - -const std::string &GenericTag :: lowercase() -{ - return _lower; -} - -int GenericTag :: compare(const GenericTag *rhs) -{ - return string_compare(_lower.c_str(), rhs->_lower.c_str()); -} diff --git a/include/core/tags/generic.h b/include/core/tags/generic.h deleted file mode 100644 index 710f5900..00000000 --- a/include/core/tags/generic.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright 2014 (c) Anna Schumaker. - */ -#ifndef OCARINA_CORE_TAGS_GENERIC_H -#define OCARINA_CORE_TAGS_GENERIC_H - -#include - -/** - * The GenericTag class implements the basic functions that all - * tag classes need. All other tag structures should inherit - * from this class to have access to all the basic features. - * - * When writing a GenericTag to disk, only the _name field needs - * to be written. - * - * ... << name1 - * ... << name2 - * ... << name3 - - */ -class GenericTag : public DatabaseEntry { -public: - std::string _name; /**< The name associated with this tag. */ - std::string _lower; /**< The lowercase form of GenericTag::_name. */ - - GenericTag(); /**< GenericTag constructor. */ - - /** - * Generic tag constructor. - * - * @param name Name to associate with this tag. - */ - GenericTag(const std::string &); - - /** - * Generic tag copy constructor. - * - * @param tag The tag that should be copied. - */ - GenericTag(const GenericTag &); - - /** - * Called to access the generic tag's primary key. - * - * @return GenericTag::_name. - */ - virtual const std::string primary_key() const; - - /** - * Read GenericTag::_name from file and find the lowercase form. - * - * @param file The file to read from. - */ - virtual void read(file &); - - /** - * Write GenericTag::_name to file. - * - * @param file The file to write to. - */ - virtual void write(file &); - - /** - * Called to access the name associated with this tag. - * - * @return GenericTag::_name. - */ - const std::string &name() const; - - /** - * Called to access the lowercase form of GenericTag::_name. - * - * @return GenericTag::_lower. - */ - const std::string &lowercase(); - - /** - * Called to compare the names of two GenericTags - * - * @param rhs The other tag that we are comparing with. - * @return < 0: lhs < rhs, or rhs is empty. - * @return 0: lhs == rhs. - * @return > 0: rhs > lhs, or lhs is empty. - */ - int compare(const GenericTag *); -}; - -#endif /* OCARINA_CORE_TAGS_GENERIC_H */ diff --git a/include/core/tags/library.h b/include/core/tags/library.h index ea587f14..86371ea0 100644 --- a/include/core/tags/library.h +++ b/include/core/tags/library.h @@ -5,7 +5,6 @@ #define OCARINA_CORE_TAGS_LIBRARY_H #include -#include /** * The Library tag is used to store a single directory added diff --git a/tests/core/tags/Sconscript b/tests/core/tags/Sconscript index 8ef5c465..ae3d39e2 100644 --- a/tests/core/tags/Sconscript +++ b/tests/core/tags/Sconscript @@ -11,8 +11,7 @@ def TagTest(name, source): Alias("tests/core/tags", run) return run -res = [ TagTest("generic", "generic.cpp") ] -res += [ TagTest("artist", "artist.cpp") ] +res = [ TagTest("artist", "artist.cpp") ] res += [ TagTest("album", "album.cpp") ] res += [ TagTest("genre", "genre.cpp") ] res += [ TagTest("library", "library.cpp") ] diff --git a/tests/core/tags/generic.cpp b/tests/core/tags/generic.cpp deleted file mode 100644 index 0009a654..00000000 --- a/tests/core/tags/generic.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2014 (c) Anna Schumaker. - */ -#include -#include "../test.h" - -static void test_generic_tag() -{ - GenericTag tag("Generic Tag"); - file f; - - test_equal(tag.name(), (std::string)"Generic Tag"); - test_equal(tag.lowercase(), (std::string)"generic tag"); - test_equal(tag.primary_key(), (std::string)"Generic Tag"); - - file_init(&f, "generic_tag", 0); - file_open(&f, OPEN_WRITE); - tag.write(f); - file_close(&f); - - tag = GenericTag(); - test_equal(tag.name(), (std::string)""); - test_equal(tag.lowercase(), (std::string)""); - test_equal(tag.primary_key(), (std::string)""); - - file_open(&f, OPEN_READ); - tag.read(f); - file_close(&f); - - test_equal(tag.name(), (std::string)"Generic Tag"); - test_equal(tag.lowercase(), (std::string)"generic tag"); - test_equal(tag.primary_key(), (std::string)"Generic Tag"); - - tag = GenericTag(tag); - test_equal(tag.name(), (std::string)"Generic Tag"); - test_equal(tag.lowercase(), (std::string)"generic tag"); - test_equal(tag.primary_key(), (std::string)"Generic Tag"); -} - -static void test_generic_tag_comparison() -{ - GenericTag A("A"), a("a"), B("B"), empty(""); - - test_equal(A.compare(&A), 0); - test_equal(a.compare(&a), 0); - test_equal(A.compare(&B), -1); - test_equal(B.compare(&A), 1); - - test_equal(empty.compare(&A), 1); - test_equal(A.compare(&empty), -1); -} - -DECLARE_UNIT_TESTS( - UNIT_TEST("Generic Tag", test_generic_tag), - UNIT_TEST("Generic Tag Comparison", test_generic_tag_comparison), -);