2014-11-08 14:43:58 -05:00
|
|
|
/**
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
2015-09-08 09:39:35 -04:00
|
|
|
extern "C" {
|
2015-01-30 09:35:24 -05:00
|
|
|
#include <core/string.h>
|
2015-09-08 09:39:35 -04:00
|
|
|
}
|
2014-11-08 14:43:58 -05:00
|
|
|
#include <core/tags/generic.h>
|
|
|
|
|
|
|
|
GenericTag :: GenericTag() {}
|
|
|
|
|
|
|
|
GenericTag :: GenericTag(const std::string &name)
|
2015-09-08 09:14:39 -04:00
|
|
|
: _name(name)
|
2014-11-08 14:43:58 -05:00
|
|
|
{
|
2015-09-08 09:14:39 -04:00
|
|
|
gchar *g_lc = string_lowercase(name.c_str());
|
|
|
|
_lower = g_lc;
|
|
|
|
g_free(g_lc);
|
2014-11-08 14:43:58 -05:00
|
|
|
}
|
|
|
|
|
2014-11-29 10:48:24 -05:00
|
|
|
GenericTag :: GenericTag(const GenericTag &tag)
|
|
|
|
: _name(tag._name), _lower(tag._lower)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-11-08 14:43:58 -05:00
|
|
|
const std::string GenericTag :: primary_key() const
|
|
|
|
{
|
|
|
|
return _name;
|
|
|
|
}
|
|
|
|
|
2015-09-10 08:00:42 -04:00
|
|
|
void GenericTag :: read(file &file)
|
2014-11-08 14:43:58 -05:00
|
|
|
{
|
2015-10-09 13:09:47 -04:00
|
|
|
gchar *name = file_readl(&file);
|
|
|
|
gchar *g_lc = string_lowercase(name);
|
2015-09-08 09:14:39 -04:00
|
|
|
|
2015-10-09 13:09:47 -04:00
|
|
|
_name = name;
|
2015-09-08 09:14:39 -04:00
|
|
|
_lower = g_lc;
|
2015-10-09 13:09:47 -04:00
|
|
|
|
|
|
|
g_free(name);
|
2015-09-08 09:14:39 -04:00
|
|
|
g_free(g_lc);
|
2014-11-08 14:43:58 -05:00
|
|
|
}
|
|
|
|
|
2015-09-10 08:00:42 -04:00
|
|
|
void GenericTag :: write(file &file)
|
2014-11-08 14:43:58 -05:00
|
|
|
{
|
2015-10-08 09:41:51 -04:00
|
|
|
file_writef(&file, "%s", _name.c_str());
|
2014-11-08 14:43:58 -05:00
|
|
|
}
|
|
|
|
|
2014-11-08 20:53:08 -05:00
|
|
|
const std::string &GenericTag :: name() const
|
2014-11-08 14:43:58 -05:00
|
|
|
{
|
|
|
|
return _name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string &GenericTag :: lowercase()
|
|
|
|
{
|
|
|
|
return _lower;
|
|
|
|
}
|
2014-11-18 08:22:13 -05:00
|
|
|
|
|
|
|
int GenericTag :: compare(const GenericTag *rhs)
|
|
|
|
{
|
2015-09-24 13:57:42 -04:00
|
|
|
return string_compare(_lower.c_str(), rhs->_lower.c_str());
|
2014-11-18 08:22:13 -05:00
|
|
|
}
|