[Super-tux-commit] supertux/lib/utils configfile.cpp,1.1,1.2 configfile.h,1.1,1.2 exceptions.h,1.1,1
Brought to you by:
wkendrick
From: Tobias G. <to...@us...> - 2004-07-21 16:52:04
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32238/lib/utils Modified Files: configfile.cpp configfile.h exceptions.h lispreader.cpp lispreader.h lispwriter.cpp lispwriter.h Log Message: The SuperTux library features a SuperTux namespace now. + minor Bugfixes and cleanups Index: lispwriter.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispwriter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lispwriter.h 20 Jul 2004 17:51:38 -0000 1.1 +++ lispwriter.h 21 Jul 2004 16:51:53 -0000 1.2 @@ -24,33 +24,38 @@ #include <string> #include <vector> -class LispWriter -{ -public: - LispWriter(std::ostream& out); - ~LispWriter(); +namespace SuperTux + { - void write_comment(const std::string& comment); - - void start_list(const std::string& listname); + class LispWriter + { + public: + LispWriter(std::ostream& out); + ~LispWriter(); - void write_int(const std::string& name, int value); - void write_float(const std::string& name, float value); - void write_string(const std::string& name, const std::string& value); - void write_bool(const std::string& name, bool value); - void write_int_vector(const std::string& name, const std::vector<int>& value); - void write_int_vector(const std::string& name, const std::vector<unsigned int>& value); - // add more write-functions when needed... - - void end_list(const std::string& listname); + void write_comment(const std::string& comment); -private: - void indent(); - - std::ostream& out; - int indent_depth; - std::vector<std::string> lists; -}; + void start_list(const std::string& listname); -#endif + void write_int(const std::string& name, int value); + void write_float(const std::string& name, float value); + void write_string(const std::string& name, const std::string& value); + void write_bool(const std::string& name, bool value); + void write_int_vector(const std::string& name, const std::vector<int>& value); + void write_int_vector(const std::string& name, const std::vector<unsigned int>& value); + // add more write-functions when needed... + + void end_list(const std::string& listname); + + private: + void indent(); + + std::ostream& out; + int indent_depth; + std::vector<std::string> lists; + }; + +} //namespace SuperTux + +#endif //SUPERTUX_LISPWRITER_H Index: configfile.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- configfile.h 20 Jul 2004 17:51:37 -0000 1.1 +++ configfile.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -22,6 +22,8 @@ #include "utils/lispreader.h" +namespace SuperTux { + class Config { public: void load (); @@ -32,6 +34,7 @@ extern Config* config; +} //namespace SuperTux #endif Index: lispreader.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lispreader.h 20 Jul 2004 17:51:38 -0000 1.1 +++ lispreader.h 21 Jul 2004 16:51:53 -0000 1.2 @@ -33,6 +33,8 @@ #include "utils/exceptions.h" +namespace SuperTux { + #define LISP_STREAM_FILE 1 #define LISP_STREAM_STRING 2 #define LISP_STREAM_ANY 3 @@ -200,5 +202,7 @@ lisp_object_t* get_lisp(); }; +} //namespace SuperTux + #endif /*SUPERTUX_LISPREADER_H*/ Index: lispwriter.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispwriter.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lispwriter.cpp 20 Jul 2004 17:51:38 -0000 1.1 +++ lispwriter.cpp 21 Jul 2004 16:51:53 -0000 1.2 @@ -21,6 +21,8 @@ #include "utils/lispwriter.h" +using namespace SuperTux; + LispWriter::LispWriter(std::ostream& newout) : out(newout), indent_depth(0) { Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- configfile.cpp 20 Jul 2004 17:51:37 -0000 1.1 +++ configfile.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -24,13 +24,15 @@ #include "app/setup.h" #include "app/globals.h" +using namespace SuperTux; + #ifdef WIN32 const char * config_filename = "/st_config.dat"; #else const char * config_filename = "/config"; #endif -Config* config = 0; +Config* SuperTux::config = 0; static void defaults () { Index: exceptions.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/exceptions.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- exceptions.h 20 Jul 2004 17:51:38 -0000 1.1 +++ exceptions.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -24,21 +24,26 @@ #include <exception> #include <string> -class SuperTuxException : public std::exception -{ - public: - SuperTuxException(const char* _message, const char* _file = "", const unsigned int _line = 0) - : message(_message), file(_file), line(_line) { }; - virtual ~SuperTuxException() throw() { }; +namespace SuperTux + { - const char* what() const throw() { return message; }; - const char* what_file() const throw() { return file; }; - const unsigned int what_line() const throw() { return line; }; - - private: - const char* message; - const char* file; - const unsigned int line; -}; + class SuperTuxException : public std::exception + { + public: + SuperTuxException(const char* _message, const char* _file = "", const unsigned int _line = 0) + : message(_message), file(_file), line(_line) { }; + virtual ~SuperTuxException() throw() { }; + + const char* what() const throw() { return message; }; + const char* what_file() const throw() { return file; }; + const unsigned int what_line() const throw() { return line; }; + + private: + const char* message; + const char* file; + const unsigned int line; + }; + +} #endif /*SUPERTUX_EXCEPTIONS_H*/ Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lispreader.cpp 20 Jul 2004 17:51:38 -0000 1.1 +++ lispreader.cpp 21 Jul 2004 16:51:53 -0000 1.2 @@ -31,6 +31,8 @@ #include "app/setup.h" #include "utils/lispreader.h" +using namespace SuperTux; + #define TOKEN_ERROR -1 #define TOKEN_EOF 0 #define TOKEN_OPEN_PAREN 1 @@ -285,7 +287,7 @@ } lisp_stream_t* -lisp_stream_init_file (lisp_stream_t *stream, FILE *file) +SuperTux::lisp_stream_init_file (lisp_stream_t *stream, FILE *file) { stream->type = LISP_STREAM_FILE; stream->v.file = file; @@ -294,7 +296,7 @@ } lisp_stream_t* -lisp_stream_init_string (lisp_stream_t *stream, char *buf) +SuperTux::lisp_stream_init_string (lisp_stream_t *stream, char *buf) { stream->type = LISP_STREAM_STRING; stream->v.string.buf = buf; @@ -304,7 +306,7 @@ } lisp_stream_t* -lisp_stream_init_any (lisp_stream_t *stream, void *data, +SuperTux::lisp_stream_init_any (lisp_stream_t *stream, void *data, int (*next_char) (void *data), void (*unget_char) (char c, void *data)) { @@ -320,7 +322,7 @@ } lisp_object_t* -lisp_make_integer (int value) +SuperTux::lisp_make_integer (int value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_INTEGER); @@ -330,7 +332,7 @@ } lisp_object_t* -lisp_make_real (float value) +SuperTux::lisp_make_real (float value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_REAL); @@ -340,7 +342,7 @@ } lisp_object_t* -lisp_make_symbol (const char *value) +SuperTux::lisp_make_symbol (const char *value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_SYMBOL); @@ -350,7 +352,7 @@ } lisp_object_t* -lisp_make_string (const char *value) +SuperTux::lisp_make_string (const char *value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_STRING); @@ -360,7 +362,7 @@ } lisp_object_t* -lisp_make_cons (lisp_object_t *car, lisp_object_t *cdr) +SuperTux::lisp_make_cons (lisp_object_t *car, lisp_object_t *cdr) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_CONS); @@ -371,7 +373,7 @@ } lisp_object_t* -lisp_make_boolean (int value) +SuperTux::lisp_make_boolean (int value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_BOOLEAN); @@ -404,7 +406,7 @@ } lisp_object_t* -lisp_read (lisp_stream_t *in) +SuperTux::lisp_read (lisp_stream_t *in) { int token = _scan(in); lisp_object_t *obj = lisp_nil(); @@ -502,7 +504,7 @@ } void -lisp_free (lisp_object_t *obj) +SuperTux::lisp_free (lisp_object_t *obj) { if (obj == 0) return; @@ -547,7 +549,7 @@ } lisp_object_t* -lisp_read_from_string (const char *buf) +SuperTux::lisp_read_from_string (const char *buf) { lisp_stream_t stream; @@ -642,7 +644,7 @@ } int -lisp_compile_pattern (lisp_object_t **obj, int *num_subs) +SuperTux::lisp_compile_pattern (lisp_object_t **obj, int *num_subs) { int index = 0; int result; @@ -775,7 +777,7 @@ } int -lisp_match_pattern (lisp_object_t *pattern, lisp_object_t *obj, lisp_object_t **vars, int num_subs) +SuperTux::lisp_match_pattern (lisp_object_t *pattern, lisp_object_t *obj, lisp_object_t **vars, int num_subs) { int i; @@ -787,7 +789,7 @@ } int -lisp_match_string (const char *pattern_string, lisp_object_t *obj, lisp_object_t **vars) +SuperTux::lisp_match_string (const char *pattern_string, lisp_object_t *obj, lisp_object_t **vars) { lisp_object_t *pattern; int result; @@ -813,7 +815,7 @@ } int -lisp_type (lisp_object_t *obj) +SuperTux::lisp_type (lisp_object_t *obj) { if (obj == 0) return LISP_TYPE_NIL; @@ -821,7 +823,7 @@ } int -lisp_integer (lisp_object_t *obj) +SuperTux::lisp_integer (lisp_object_t *obj) { if (obj->type != LISP_TYPE_INTEGER) throw LispReaderException("lisp_integer()", __FILE__, __LINE__); @@ -830,7 +832,7 @@ } char* -lisp_symbol (lisp_object_t *obj) +SuperTux::lisp_symbol (lisp_object_t *obj) { if (obj->type != LISP_TYPE_SYMBOL) throw LispReaderException("lisp_symbol()", __FILE__, __LINE__); @@ -839,7 +841,7 @@ } char* -lisp_string (lisp_object_t *obj) +SuperTux::lisp_string (lisp_object_t *obj) { if (obj->type != LISP_TYPE_STRING) throw LispReaderException("lisp_string()", __FILE__, __LINE__); @@ -848,7 +850,7 @@ } int -lisp_boolean (lisp_object_t *obj) +SuperTux::lisp_boolean (lisp_object_t *obj) { if (obj->type != LISP_TYPE_BOOLEAN) throw LispReaderException("lisp_boolean()", __FILE__, __LINE__); @@ -857,7 +859,7 @@ } float -lisp_real (lisp_object_t *obj) +SuperTux::lisp_real (lisp_object_t *obj) { if (obj->type != LISP_TYPE_REAL && obj->type != LISP_TYPE_INTEGER) throw LispReaderException("lisp_real()", __FILE__, __LINE__); @@ -868,7 +870,7 @@ } lisp_object_t* -lisp_car (lisp_object_t *obj) +SuperTux::lisp_car (lisp_object_t *obj) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) throw LispReaderException("lisp_car()", __FILE__, __LINE__); @@ -877,7 +879,7 @@ } lisp_object_t* -lisp_cdr (lisp_object_t *obj) +SuperTux::lisp_cdr (lisp_object_t *obj) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) throw LispReaderException("lisp_cdr()", __FILE__, __LINE__); @@ -886,7 +888,7 @@ } lisp_object_t* -lisp_cxr (lisp_object_t *obj, const char *x) +SuperTux::lisp_cxr (lisp_object_t *obj, const char *x) { int i; @@ -902,7 +904,7 @@ } int -lisp_list_length (lisp_object_t *obj) +SuperTux::lisp_list_length (lisp_object_t *obj) { int length = 0; @@ -919,7 +921,7 @@ } lisp_object_t* -lisp_list_nth_cdr (lisp_object_t *obj, int index) +SuperTux::lisp_list_nth_cdr (lisp_object_t *obj, int index) { while (index > 0) { @@ -936,7 +938,7 @@ } lisp_object_t* -lisp_list_nth (lisp_object_t *obj, int index) +SuperTux::lisp_list_nth (lisp_object_t *obj, int index) { obj = lisp_list_nth_cdr(obj, index); @@ -947,7 +949,7 @@ } void -lisp_dump (lisp_object_t *obj, FILE *out) +SuperTux::lisp_dump (lisp_object_t *obj, FILE *out) { if (obj == 0) { @@ -1275,7 +1277,7 @@ return lst; } -lisp_object_t* lisp_read_from_file(const std::string& filename) +lisp_object_t* SuperTux::lisp_read_from_file(const std::string& filename) { FILE* in = fopen(filename.c_str(), "r"); |