X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Flisp%2Flisp.hpp;h=fb8dd88128d89b526b4d36425a63fd50c56d194a;hb=1486ceaaf9dd7a9d2d7e3654550b9a2768df2a56;hp=fa4bda554c1cb12a63f9bc2ec5c79bd2adc4cb31;hpb=c289aaa42a2fa753bdb4172b0d2b67c50a74e34f;p=supertux.git diff --git a/src/lisp/lisp.hpp b/src/lisp/lisp.hpp index fa4bda554..fb8dd8812 100644 --- a/src/lisp/lisp.hpp +++ b/src/lisp/lisp.hpp @@ -47,6 +47,7 @@ public: { return v.cons.car; } Lisp* get_cdr() const { return v.cons.cdr; } + bool get(std::string& val) const { if(type != TYPE_STRING && type != TYPE_SYMBOL) @@ -54,6 +55,13 @@ public: val = v.string; return true; } + + std::string get_string() const + { + assert(type == TYPE_STRING); + return v.string; + } + bool get(unsigned int& val) const { if(type != TYPE_INTEGER) @@ -61,6 +69,7 @@ public: val = v.integer; return true; } + bool get(int& val) const { if(type != TYPE_INTEGER) @@ -68,6 +77,13 @@ public: val = v.integer; return true; } + + int get_int() const + { + assert(type == TYPE_INTEGER); + return v.integer; + } + bool get(float& val) const { if(type != TYPE_REAL) { @@ -80,6 +96,13 @@ public: val = v.real; return true; } + + float get_float() const + { + assert(type == TYPE_REAL); + return v.real; + } + bool get(bool& val) const { if(type != TYPE_BOOLEAN) @@ -88,6 +111,12 @@ public: return true; } + bool get_bool() const + { + assert(type == TYPE_BOOLEAN); + return v.boolean; + } + /** conveniance functions which traverse the list until a child with a * specified name is found. The value part is then interpreted in a specific * way. The functions return true, if a child was found and could be