core/tags/generic: Remove Generic tag
Nothing uses it anymore, so it can be safely removed :) Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
cfd501c5d6
commit
1c0235c8c7
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
extern "C" {
|
||||
#include <core/string.h>
|
||||
}
|
||||
#include <core/tags/generic.h>
|
||||
|
||||
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());
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
/**
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_CORE_TAGS_GENERIC_H
|
||||
#define OCARINA_CORE_TAGS_GENERIC_H
|
||||
|
||||
#include <core/database.h>
|
||||
|
||||
/**
|
||||
* 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 */
|
|
@ -5,7 +5,6 @@
|
|||
#define OCARINA_CORE_TAGS_LIBRARY_H
|
||||
|
||||
#include <core/database.h>
|
||||
#include <core/tags/generic.h>
|
||||
|
||||
/**
|
||||
* The Library tag is used to store a single directory added
|
||||
|
|
|
@ -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") ]
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/tags/generic.h>
|
||||
#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),
|
||||
);
|
Loading…
Reference in New Issue