1 /*
2     dspdfviewer - Dual Screen PDF Viewer for LaTeX-Beamer
3     Copyright (C) 2012  Danny Edel <mail@danny-edel.de>
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 along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 
21 #include "pagepart.h"
22 #include <string>
23 
24 namespace {
25 	const char * const left = "left";
26 	const char * const right = "right";
27 	const char * const both = "both";
28 }
29 
operator <<(std::ostream & out,const PagePart & pagepart)30 std::ostream& operator << ( std::ostream& out, const PagePart& pagepart ) {
31 	if ( pagepart == PagePart::LeftHalf )
32 		return out << left;
33 	else if ( pagepart == PagePart::RightHalf )
34 		return out << right;
35 	else
36 		return out << both;
37 }
38 
operator >>(std::istream & in,PagePart & pagepart)39 std::istream& operator >> ( std::istream& in, PagePart& pagepart ) {
40 	std::string s;
41 	in >> s;
42 	if ( s == left )
43 		pagepart = PagePart::LeftHalf;
44 	else if ( s == right )
45 		pagepart = PagePart::RightHalf;
46 	else if ( s == both )
47 		pagepart = PagePart::FullPage;
48 	else
49 		in.setstate( std::ios::failbit );
50 	return in;
51 }
52