src/lisp/writer.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_LISP_WRITER_HPP
00018 #define HEADER_SUPERTUX_LISP_WRITER_HPP
00019 
00020 #include <string>
00021 #include <vector>
00022 
00023 namespace lisp {
00024 
00025 class Writer
00026 {
00027 public:
00028   Writer(const std::string& filename);
00029   Writer(std::ostream* out);
00030   ~Writer();
00031 
00032   void write_comment(const std::string& comment);
00033 
00034   void start_list(const std::string& listname, bool string = false);
00035 
00036   void write(const std::string& name, int value);
00037   void write(const std::string& name, float value);
00038   void write(const std::string& name, const std::string& value,
00039              bool translatable = false);
00040   void write(const std::string& name, const char* value,
00041              bool translatable = false) { write(name, static_cast<const std::string&>(value), translatable); }
00042   void write(const std::string& name, bool value);
00043   void write(const std::string& name, const std::vector<int>& value);
00044   void write(const std::string& name, const std::vector<unsigned int>& value);
00045   void write(const std::string& name, const std::vector<float>& value);
00046   void write(const std::string& name, const std::vector<std::string>& value);
00047   // add more write-functions when needed...
00048 
00049   void end_list(const std::string& listname);
00050 
00051 private:
00052   void write_escaped_string(const std::string& str);
00053   void indent();
00054 
00055 private:
00056   std::ostream* out;
00057   bool out_owned;
00058   int indent_depth;
00059   std::vector<std::string> lists;
00060 
00061 private:
00062   Writer(const Writer&);
00063   Writer & operator=(const Writer&);
00064 };
00065 
00066 } //namespace lisp
00067 
00068 #endif //SUPERTUX_LISPWRITER_H
00069 
00070 /* EOF */

Generated on Mon Jun 9 03:38:18 2014 for SuperTux by  doxygen 1.5.1