1 /*
2  * serverscanner/OutputGenerator.hpp
3  *
4  * This file is part of Leges Motus, a networked, 2D shooter set in zero gravity.
5  *
6  * Copyright 2009-2010 Andrew Ayer, Nathan Partlan, Jeffrey Pfau
7  *
8  * Leges Motus is free and open source software.  You may redistribute it and/or
9  * modify it under the terms of version 2, or (at your option) version 3, of the
10  * GNU General Public License (GPL), as published by the Free Software Foundation.
11  *
12  * Leges Motus is distributed in the hope that it will be useful, but WITHOUT ANY
13  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14  * PARTICULAR PURPOSE.  See the full text of the GNU General Public License for
15  * further detail.
16  *
17  * For a full copy of the GNU General Public License, please see the COPYING file
18  * in the root of the source code tree.  You may also retrieve a copy from
19  * <http://www.gnu.org/licenses/gpl-2.0.txt>, or request a copy by writing to the
20  * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21  * 02111-1307  USA
22  *
23  */
24 
25 #ifndef LM_CLIENT_OUTPUTGENERATOR_HPP
26 #define LM_CLIENT_OUTPUTGENERATOR_HPP
27 
28 #include <stdint.h>
29 #include <ostream>
30 #include <string>
31 #include <map>
32 
33 namespace LM {
34 	class OutputGenerator {
35 		private:
36 			std::ostream* m_out;
37 			std::map<std::string, std::string> m_col_mapping;
38 
39 		protected:
40 			std::ostream& out();
41 
42 		public:
43 			OutputGenerator(std::ostream *outstream);
~OutputGenerator()44 			virtual ~OutputGenerator() {};
45 
46 			virtual void begin() = 0;
47 			virtual void end() = 0;
48 
49 			void add_column(const std::string& shortname, const std::string& longname);
50 			const std::string& get_column(const std::string& shortname);
51 
52 			virtual void begin_row() = 0;
53 			virtual void add_cell(const std::string& column) = 0;
54 			virtual void end_row() = 0;
55 
56 			virtual void begin_list() = 0;
57 			virtual void end_list() = 0;
58 
59 			virtual void add_string(const std::string& str) = 0;
60 			virtual void add_int(int num) = 0;
61 			virtual void add_time(time_t sec) = 0;
62 			virtual void add_interval(uint64_t millis) = 0;
63 	};
64 }
65 
66 #endif
67