53 lines
877 B
C++
53 lines
877 B
C++
/**
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/string.h>
|
|
#include <core/tags/generic.h>
|
|
|
|
GenericTag :: GenericTag() {}
|
|
|
|
GenericTag :: GenericTag(const std::string &name)
|
|
: _name(name), _lower(string :: lowercase(name))
|
|
{
|
|
}
|
|
|
|
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)
|
|
{
|
|
_name = file.getline();
|
|
_lower = string :: lowercase(_name);
|
|
}
|
|
|
|
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)
|
|
{
|
|
if (_lower.size() == 0)
|
|
return 1;
|
|
if (rhs->_lower.size() == 0)
|
|
return -1;
|
|
return _lower.compare(rhs->_lower);
|
|
}
|