ocarina/lib/tags.cpp

138 lines
1.6 KiB
C++

/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <tags.h>
#include <filter.h>
#include <sstream>
/**
*
* Artist tag
*
*/
Artist :: Artist() {}
Artist :: Artist(const std::string &s)
: name(s), lower(filter :: lowercase(name))
{
}
const std::string Artist :: primary_key()
{
return name;
}
void Artist :: read(File &f)
{
name = f.getline();
lower = filter :: lowercase(name);
}
void Artist :: write(File &f)
{
f << name;
}
/**
*
* Album tag
*
*/
Album :: Album() {}
Album :: Album(const std::string &s, unsigned int y)
: name(s), lower(filter :: lowercase(name)), year(y)
{
}
const std::string Album :: primary_key()
{
std::stringstream ss;
ss << year << "." << name;
return ss.str();
}
void Album :: read(File &f)
{
f >> year;
name = f.getline();
lower = filter :: lowercase(name);
}
void Album :: write(File &f)
{
f << year << " " << name;
}
/**
*
* Genre tag
*
*/
Genre :: Genre() {}
Genre :: Genre(const std::string &s)
: name(s), lower(filter :: lowercase(name))
{
}
const std::string Genre :: primary_key()
{
return name;
}
void Genre :: read(File &f)
{
name = f.getline();
lower = filter :: lowercase(name);
}
void Genre :: write(File &f)
{
f << name;
}
/**
*
* Library tag
*
*/
Library :: Library()
: count(0), enabled(false)
{
}
Library :: Library(const std::string &s)
: root_path(s), count(0), enabled(true)
{
}
const std::string Library :: primary_key()
{
return root_path;
}
void Library :: read(File &f)
{
f >> enabled;
root_path = f.getline();
}
void Library :: write(File &f)
{
f << enabled << " " << root_path;
}