aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/object.h
diff options
context:
space:
mode:
Diffstat (limited to 'c++-libbu++/src/object.h')
-rw-r--r--c++-libbu++/src/object.h66
1 files changed, 63 insertions, 3 deletions
diff --git a/c++-libbu++/src/object.h b/c++-libbu++/src/object.h
index e4da8de..a876061 100644
--- a/c++-libbu++/src/object.h
+++ b/c++-libbu++/src/object.h
@@ -48,9 +48,69 @@ namespace Gats
48 static Object *strToGats( const Bu::String &sStr ); 48 static Object *strToGats( const Bu::String &sStr );
49 49
50 private: 50 private:
51 static Object *strToGats( Bu::String::const_iterator &i ); 51 class StrPos
52 static Bu::String token( Bu::String::const_iterator &i ); 52 {
53 static void skipWs( Bu::String::const_iterator &i ); 53 public:
54 StrPos( const Bu::String::const_iterator &i ) :
55 i( i ), iLine( 1 ), iChar( 1 )
56 { }
57 Bu::String::const_iterator i;
58 int iLine;
59 int iChar;
60
61 char operator*()
62 {
63 return *i;
64 }
65 StrPos &operator++(int)
66 {
67 i++;
68 if( i )
69 {
70 if( *i == '\n' )
71 {
72 iLine++;
73 iChar = 0;
74 }
75 else
76 iChar++;
77 }
78 return *this;
79 }
80 operator bool()
81 {
82 return i;
83 }
84 };
85
86 class Thrower : public Bu::String::FormatProxyEndAction
87 {
88 public:
89 Thrower( Gats::Object::StrPos &i ) :
90 i( i )
91 {
92 }
93
94 virtual ~Thrower()
95 {
96 }
97
98 virtual void operator()( const Bu::String &sFinal )
99 {
100 throw Bu::ExceptionBase(
101 (Bu::String("%1: %2: ").arg(i.iLine).arg(i.iChar).end() + sFinal)
102 .getStr()
103 );
104 }
105
106 private:
107 Gats::Object::StrPos &i;
108 };
109
110 static Bu::String::FormatProxy posError( Gats::Object::StrPos &i, const Bu::String &msg );
111 static Object *strToGats( Gats::Object::StrPos &i );
112 static Bu::String token( Gats::Object::StrPos &i );
113 static void skipWs( Gats::Object::StrPos &i );
54 }; 114 };
55 115
56 const char *typeToStr( Type t ); 116 const char *typeToStr( Type t );