Back to index

supertuxkart  0.5+dfsg1
writer.hpp
Go to the documentation of this file.
00001 //  $Id: writer.hpp 2111 2008-05-31 07:04:30Z cosmosninja $
00002 //
00003 //  TuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2004 Matthias Braun <matze@braunis.de>
00005 //  code in this file based on lispreader from Mark Probst
00006 //
00007 //  This program is free software; you can redistribute it and/or
00008 //  modify it under the terms of the GNU General Public License
00009 //  as published by the Free Software Foundation; either version 2
00010 //  of the License, or (at your option) any later version.
00011 //
00012 //  This program is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU General Public License
00018 //  along with this program; if not, write to the Free Software
00019 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 #ifndef __LISPWRITER_H__
00021 #define __LISPWRITER_H__
00022 
00023 #include <iostream>
00024 #include <string>
00025 #include <vector>
00026 
00027 namespace lisp
00028 {
00029 
00030     class Writer
00031     {
00032     public:
00033         Writer(const std::string& filename);
00034         Writer(std::ostream& out);
00035         ~Writer();
00036 
00037         void writeComment(const std::string& comment);
00038 
00039         void beginList(const std::string& listname);
00040 
00041         void write(const std::string& name, int value);
00042         void write(const std::string& name, unsigned int value) {write(name, (int)value);}
00043         void write(const std::string& name, float value);
00044         void write(const std::string& name, const std::string& value);
00045         void write(const std::string& name, const char* value);
00046         void write(const std::string& name, bool value);
00047         void write(const std::string& name, const std::vector<int>& value);
00048         void write(const std::string& name, const std::vector<unsigned int>& value);
00049         void write(const std::string& name, const std::vector<std::string>& value);
00050         // add more write-functions when needed...
00051 
00052         void endList(const std::string& listname);
00053 
00054     private:
00055         void indent();
00056 
00057         bool m_owner;
00058         std::ostream* m_out;
00059         int m_indent_depth;
00060         std::vector<std::string> m_lists;
00061     };
00062 
00063 } //namespace lisp
00064 
00065 #endif
00066