ocarina/core/tags/generic.cpp

58 lines
928 B
C++

/**
* 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 *g_lc;
_name = file.getline();
g_lc = string_lowercase(_name.c_str());
_lower = g_lc;
g_free(g_lc);
}
void GenericTag :: write(file &file)
{
file << _name;
}
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());
}