File: Cuesheet.cc

package info (click to toggle)
flactag 2.0.4-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,096 kB
  • ctags: 477
  • sloc: sh: 10,777; cpp: 3,283; makefile: 62; sed: 7
file content (133 lines) | stat: -rw-r--r-- 3,137 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* --------------------------------------------------------------------------

   flactag -- A tagger for single album FLAC files with embedded CUE sheets
   						using data retrieved from the MusicBrainz service

   Copyright (C) 2006-2012 Andrew Hawkins
   Copyright (C) 2011-2012 Daniel Pocock

   This file is part of flactag.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
	 the Free Software Foundation, either version 3 of the License, or
	 (at your option) any later version.

   Flactag is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

     $Id$

----------------------------------------------------------------------------*/

#include "Cuesheet.h"

CCuesheet::CCuesheet()
:	m_Performer(""),
	m_Title(""),
	m_FileName("")
{
	Clear();
}

void CCuesheet::Clear()
{
	m_Leadout=(FLAC__uint64)-1;
	m_FirstTrack=255;
	m_LastTrack=255;

	m_Tracks.clear();
}

void CCuesheet::AddTrack(const CCuesheetTrack& Track)
{
	m_Tracks[Track.Number()]=Track;
	if (255==m_LastTrack || Track.Number()>m_LastTrack)
		m_LastTrack=Track.Number();

	if (255==m_FirstTrack || Track.Number()<m_FirstTrack)
		m_FirstTrack=Track.Number();
}

FLAC__byte CCuesheet::NumTracks() const
{
	return m_Tracks.size();
}

CCuesheetTrack CCuesheet::Track(FLAC__byte TrackNum) const
{
	CCuesheetTrack Ret;

	std::map<FLAC__byte,CCuesheetTrack>::const_iterator ThisTrack=m_Tracks.find(TrackNum);
	if (m_Tracks.end()!=ThisTrack)
		Ret=(*ThisTrack).second;

	return Ret;
}

void CCuesheet::SetLeadout(FLAC__uint64 Leadout)
{
	m_Leadout=Leadout;
}

FLAC__uint64 CCuesheet::Leadout() const
{
	return m_Leadout;
}

FLAC__byte CCuesheet::FirstTrack() const
{
	return m_FirstTrack;
}

FLAC__byte CCuesheet::LastTrack() const
{
	return m_LastTrack;
}

void CCuesheet::setPerformer(const std::string& Performer)
{
	m_Performer.assign(Performer);
}

void CCuesheet::setTitle(const std::string& Title)
{
	m_Title.assign(Title);
}

void CCuesheet::setFileName(const std::string& FileName)
{
	m_FileName.assign(FileName);
}

void CCuesheet::setTrackPerformer(int track, const std::string& Performer)
{
        m_Tracks[track].setPerformer(Performer);
}

void CCuesheet::setTrackTitle(int track, const std::string& Title)
{
        m_Tracks[track].setTitle(Title);
}

std::ostream& operator<<(std::ostream& os, const CCuesheet& cuesheet)
{
	FLAC__byte i;
	char Qsym = '"';
	os << "PERFORMER " << Qsym << cuesheet.m_Performer << Qsym << std::endl;
	os << "TITLE " << Qsym << cuesheet.m_Title << Qsym << std::endl;
	os << "FILE " << Qsym << cuesheet.m_FileName << Qsym << " FLAC" << std::endl;

	for(i = 1; i <= cuesheet.NumTracks(); i++)
	{
		os << cuesheet.Track(i);
	}
	return os;
}