change version to 0.6.4_pre
[ncmpcpp.git] / src / enums.cpp
blob4e37a074686c052dc4fe7b816b2db73217678720
1 /***************************************************************************
2 * Copyright (C) 2008-2014 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, SpaceAddMode sam)
25 switch (sam)
27 case SpaceAddMode::AddRemove:
28 os << "add_remove";
29 break;
30 case SpaceAddMode::AlwaysAdd:
31 os << "always_add";
32 break;
34 return os;
37 std::istream &operator>>(std::istream &is, SpaceAddMode &sam)
39 std::string ssam;
40 is >> ssam;
41 if (ssam == "add_remove")
42 sam = SpaceAddMode::AddRemove;
43 else if (ssam == "always_add")
44 sam = SpaceAddMode::AlwaysAdd;
45 else
46 is.setstate(std::ios::failbit);
47 return is;
50 std::ostream &operator<<(std::ostream &os, SortMode sm)
52 switch (sm)
54 case SortMode::Name:
55 os << "name";
56 break;
57 case SortMode::ModificationTime:
58 os << "mtime";
59 break;
60 case SortMode::CustomFormat:
61 os << "format";
62 break;
63 case SortMode::NoOp:
64 os << "noop";
65 break;
67 return os;
70 std::istream &operator>>(std::istream &is, SortMode &sm)
72 std::string ssm;
73 is >> ssm;
74 if (ssm == "name")
75 sm = SortMode::Name;
76 else if (ssm == "mtime")
77 sm = SortMode::ModificationTime;
78 else if (ssm == "format")
79 sm = SortMode::CustomFormat;
80 else if (ssm == "noop")
81 sm = SortMode::NoOp;
82 else
83 is.setstate(std::ios::failbit);
84 return is;
87 std::ostream &operator<<(std::ostream &os, DisplayMode dm)
89 switch (dm)
91 case DisplayMode::Classic:
92 os << "classic";
93 break;
94 case DisplayMode::Columns:
95 os << "columns";
96 break;
98 return os;
101 std::istream &operator>>(std::istream &is, DisplayMode &dm)
103 std::string sdm;
104 is >> sdm;
105 if (sdm == "classic")
106 dm = DisplayMode::Classic;
107 else if (sdm == "columns")
108 dm = DisplayMode::Columns;
109 else
110 is.setstate(std::ios::failbit);
111 return is;
114 std::ostream &operator<<(std::ostream &os, Design ui)
116 switch (ui)
118 case Design::Classic:
119 os << "classic";
120 break;
121 case Design::Alternative:
122 os << "alternative";
123 break;
125 return os;
128 std::istream &operator>>(std::istream &is, Design &ui)
130 std::string sui;
131 is >> sui;
132 if (sui == "classic")
133 ui = Design::Classic;
134 else if (sui == "alternative")
135 ui = Design::Alternative;
136 else
137 is.setstate(std::ios::failbit);
138 return is;