summaryrefslogtreecommitdiff
path: root/src/enums.cpp
blob: 1e4c41e32aface3932b965b1b955074826aee52f (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/***************************************************************************
 *   Copyright (C) 2008-2017 by Andrzej Rybczak                            *
 *   electricityispower@gmail.com                                          *
 *                                                                         *
 *   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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.              *
 ***************************************************************************/

#include "enums.h"

std::ostream &operator<<(std::ostream &os, SearchDirection sd)
{
	switch (sd)
	{
		case SearchDirection::Backward:
			os << "backward";
			break;
		case SearchDirection::Forward:
			os << "forward";
			break;
	}
	return os;
}

std::istream &operator>>(std::istream &is, SearchDirection &sd)
{
	std::string ssd;
	is >> ssd;
	if (ssd == "backward")
		sd = SearchDirection::Backward;
	else if (ssd == "forward")
		sd = SearchDirection::Forward;
	else
		is.setstate(std::ios::failbit);
	return is;
}

std::ostream &operator<<(std::ostream &os, SpaceAddMode sam)
{
	switch (sam)
	{
		case SpaceAddMode::AddRemove:
			os << "add_remove";
			break;
		case SpaceAddMode::AlwaysAdd:
			os << "always_add";
			break;
	}
	return os;
}

std::istream &operator>>(std::istream &is, SpaceAddMode &sam)
{
	std::string ssam;
	is >> ssam;
	if (ssam == "add_remove")
		sam = SpaceAddMode::AddRemove;
	else if (ssam == "always_add")
		sam = SpaceAddMode::AlwaysAdd;
	else
		is.setstate(std::ios::failbit);
	return is;
}

std::ostream &operator<<(std::ostream &os, SortMode sm)
{
	switch (sm)
	{
		case SortMode::Name:
			os << "name";
			break;
		case SortMode::ModificationTime:
			os << "mtime";
			break;
		case SortMode::CustomFormat:
			os << "format";
			break;
		case SortMode::NoOp:
			os << "noop";
			break;
	}
	return os;
}

std::istream &operator>>(std::istream &is, SortMode &sm)
{
	std::string ssm;
	is >> ssm;
	if (ssm == "name")
		sm = SortMode::Name;
	else if (ssm == "mtime")
		sm = SortMode::ModificationTime;
	else if (ssm == "format")
		sm = SortMode::CustomFormat;
	else if (ssm == "noop")
		sm = SortMode::NoOp;
	else
		is.setstate(std::ios::failbit);
	return is;
}

std::ostream &operator<<(std::ostream &os, DisplayMode dm)
{
	switch (dm)
	{
		case DisplayMode::Classic:
			os << "classic";
			break;
		case DisplayMode::Columns:
			os << "columns";
			break;
	}
	return os;
}

std::istream &operator>>(std::istream &is, DisplayMode &dm)
{
	std::string sdm;
	is >> sdm;
	if (sdm == "classic")
		dm = DisplayMode::Classic;
	else if (sdm == "columns")
		dm = DisplayMode::Columns;
	else
		is.setstate(std::ios::failbit);
	return is;
}

std::ostream &operator<<(std::ostream &os, Design ui)
{
	switch (ui)
	{
		case Design::Classic:
			os << "classic";
			break;
		case Design::Alternative:
			os << "alternative";
			break;
	}
	return os;
}

std::istream &operator>>(std::istream &is, Design &ui)
{
	std::string sui;
	is >> sui;
	if (sui == "classic")
		ui = Design::Classic;
	else if (sui == "alternative")
		ui = Design::Alternative;
	else
		is.setstate(std::ios::failbit);
	return is;
}

std::ostream &operator<<(std::ostream& os, VisualizerType vt)
{
	switch (vt)
	{
		case VisualizerType::Wave:
			os << "sound wave";
			break;
		case VisualizerType::WaveFilled:
			os << "sound wave filled";
			break;
#		ifdef HAVE_FFTW3_H
		case VisualizerType::Spectrum:
			os << "frequency spectrum";
			break;
#		endif // HAVE_FFTW3_H
		case VisualizerType::Ellipse:
			os << "sound ellipse";
			break;
	}
	return os;
}

std::istream &operator>>(std::istream& is, VisualizerType &vt)
{
	std::string svt;
	is >> svt;
	if (svt == "wave")
		vt = VisualizerType::Wave;
	else if (svt == "wave_filled")
		vt = VisualizerType::WaveFilled;
#	ifdef HAVE_FFTW3_H
	else if (svt == "spectrum")
		vt = VisualizerType::Spectrum;
#	endif // HAVE_FFTW3_H
	else if (svt == "ellipse")
		vt = VisualizerType::Ellipse;
	else
		is.setstate(std::ios::failbit);
	return is;
}