00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
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 }
00067
00068 #endif //SUPERTUX_LISPWRITER_H
00069
00070