Add '--quiet' comand line option to suppress some output
[ncmpcpp.git] / src / enums.cpp
blob1e4c41e32aface3932b965b1b955074826aee52f
1 /***************************************************************************
2 * Copyright (C) 2008-2017 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "enums.h"
23 std::ostream &operator<<(std::ostream &os, SearchDirection sd)
25 switch (sd)
27 case SearchDirection::Backward:
28 os << "backward";
29 break;
30 case SearchDirection::Forward:
31 os << "forward";
32 break;
34 return os;
37 std::istream &operator>>(std::istream &is, SearchDirection &sd)
39 std::string ssd;
40 is >> ssd;
41 if (ssd == "backward")
42 sd = SearchDirection::Backward;
43 else if (ssd == "forward")
44 sd = SearchDirection::Forward;
45 else
46 is.setstate(std::ios::failbit);
47 return is;
50 std::ostream &operator<<(std::ostream &os, SpaceAddMode sam)
52 switch (sam)
54 case SpaceAddMode::AddRemove:
55 os << "add_remove";
56 break;
57 case SpaceAddMode::AlwaysAdd:
58 os << "always_add";
59 break;
61 return os;
64 std::istream &operator>>(std::istream &is, SpaceAddMode &sam)
66 std::string ssam;
67 is >> ssam;
68 if (ssam == "add_remove")
69 sam = SpaceAddMode::AddRemove;
70 else if (ssam == "always_add")
71 sam = SpaceAddMode::AlwaysAdd;
72 else
73 is.setstate(std::ios::failbit);
74 return is;
77 std::ostream &operator<<(std::ostream &os, SortMode sm)
79 switch (sm)
81 case SortMode::Name:
82 os << "name";
83 break;
84 case SortMode::ModificationTime:
85 os << "mtime";
86 break;
87 case SortMode::CustomFormat:
88 os << "format";
89 break;
90 case SortMode::NoOp:
91 os << "noop";
92 break;
94 return os;
97 std::istream &operator>>(std::istream &is, SortMode &sm)
99 std::string ssm;
100 is >> ssm;
101 if (ssm == "name")
102 sm = SortMode::Name;
103 else if (ssm == "mtime")
104 sm = SortMode::ModificationTime;
105 else if (ssm == "format")
106 sm = SortMode::CustomFormat;
107 else if (ssm == "noop")
108 sm = SortMode::NoOp;
109 else
110 is.setstate(std::ios::failbit);
111 return is;
114 std::ostream &operator<<(std::ostream &os, DisplayMode dm)
116 switch (dm)
118 case DisplayMode::Classic:
119 os << "classic";
120 break;
121 case DisplayMode::Columns:
122 os << "columns";
123 break;
125 return os;
128 std::istream &operator>>(std::istream &is, DisplayMode &dm)
130 std::string sdm;
131 is >> sdm;
132 if (sdm == "classic")
133 dm = DisplayMode::Classic;
134 else if (sdm == "columns")
135 dm = DisplayMode::Columns;
136 else
137 is.setstate(std::ios::failbit);
138 return is;
141 std::ostream &operator<<(std::ostream &os, Design ui)
143 switch (ui)
145 case Design::Classic:
146 os << "classic";
147 break;
148 case Design::Alternative:
149 os << "alternative";
150 break;
152 return os;
155 std::istream &operator>>(std::istream &is, Design &ui)
157 std::string sui;
158 is >> sui;
159 if (sui == "classic")
160 ui = Design::Classic;
161 else if (sui == "alternative")
162 ui = Design::Alternative;
163 else
164 is.setstate(std::ios::failbit);
165 return is;
168 std::ostream &operator<<(std::ostream& os, VisualizerType vt)
170 switch (vt)
172 case VisualizerType::Wave:
173 os << "sound wave";
174 break;
175 case VisualizerType::WaveFilled:
176 os << "sound wave filled";
177 break;
178 # ifdef HAVE_FFTW3_H
179 case VisualizerType::Spectrum:
180 os << "frequency spectrum";
181 break;
182 # endif // HAVE_FFTW3_H
183 case VisualizerType::Ellipse:
184 os << "sound ellipse";
185 break;
187 return os;
190 std::istream &operator>>(std::istream& is, VisualizerType &vt)
192 std::string svt;
193 is >> svt;
194 if (svt == "wave")
195 vt = VisualizerType::Wave;
196 else if (svt == "wave_filled")
197 vt = VisualizerType::WaveFilled;
198 # ifdef HAVE_FFTW3_H
199 else if (svt == "spectrum")
200 vt = VisualizerType::Spectrum;
201 # endif // HAVE_FFTW3_H
202 else if (svt == "ellipse")
203 vt = VisualizerType::Ellipse;
204 else
205 is.setstate(std::ios::failbit);
206 return is;