aboutsummaryrefslogtreecommitdiff
path: root/c++-qt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--c++-qt/gats-qt/parseexception.h25
-rw-r--r--c++-qt/gats-qt/typeexception.h26
-rw-r--r--c++-qt/src/dictionary.cpp31
-rw-r--r--c++-qt/src/object.cpp4
-rw-r--r--c++-qt/src/parseexception.cpp31
-rw-r--r--c++-qt/src/typeexception.cpp32
6 files changed, 134 insertions, 15 deletions
diff --git a/c++-qt/gats-qt/parseexception.h b/c++-qt/gats-qt/parseexception.h
new file mode 100644
index 0000000..24b26ae
--- /dev/null
+++ b/c++-qt/gats-qt/parseexception.h
@@ -0,0 +1,25 @@
1#ifndef GATS_PARSE_EXCEPTION_H
2#define GATS_PARSE_EXCEPTION_H
3
4#include <QException>
5
6namespace Gats
7{
8 class ParseException : public QException
9 {
10 public:
11 ParseException( const char * const sMessage );
12 ParseException( const ParseException &rSrc );
13 virtual ~ParseException();
14
15 virtual QException *clone() const;
16 virtual void raise() const;
17
18 virtual const char *what() const noexcept;
19
20 private:
21 const char *sMessage;
22 };
23};
24
25#endif
diff --git a/c++-qt/gats-qt/typeexception.h b/c++-qt/gats-qt/typeexception.h
new file mode 100644
index 0000000..93d00ba
--- /dev/null
+++ b/c++-qt/gats-qt/typeexception.h
@@ -0,0 +1,26 @@
1#ifndef GATS_TYPE_EXCEPTION_H
2#define GATS_TYPE_EXCEPTION_H
3
4#include <QException>
5
6namespace Gats
7{
8 class TypeException : public QException
9 {
10 public:
11 TypeException( const char * const sMessage );
12 TypeException( const TypeException &rSrc );
13 virtual ~TypeException();
14
15 virtual QException *clone() const;
16 virtual void raise() const;
17
18 virtual const char *what() const noexcept;
19
20 private:
21 const char *sMessage;
22 };
23};
24
25#endif
26
diff --git a/c++-qt/src/dictionary.cpp b/c++-qt/src/dictionary.cpp
index 9b528f1..10ec6c5 100644
--- a/c++-qt/src/dictionary.cpp
+++ b/c++-qt/src/dictionary.cpp
@@ -13,6 +13,9 @@
13#include "gats-qt/string.h" 13#include "gats-qt/string.h"
14#include "gats-qt/list.h" 14#include "gats-qt/list.h"
15 15
16#include "gats-qt/parseexception.h"
17#include "gats-qt/typeexception.h"
18
16Gats::Dictionary::Dictionary() 19Gats::Dictionary::Dictionary()
17{ 20{
18} 21}
@@ -51,7 +54,7 @@ void Gats::Dictionary::write( QIODevice &rOut ) const
51 rOut.write("e", 1 ); 54 rOut.write("e", 1 );
52} 55}
53 56
54void Gats::Dictionary::read( QIODevice &rIn, char cType ) 57void Gats::Dictionary::read( QIODevice &rIn, char /*cType*/ )
55{ 58{
56 for(;;) 59 for(;;)
57 { 60 {
@@ -60,7 +63,7 @@ void Gats::Dictionary::read( QIODevice &rIn, char cType )
60 if( cNext == 'e' ) 63 if( cNext == 'e' )
61 break; 64 break;
62 if( cNext != 's' ) 65 if( cNext != 's' )
63 throw "PUT GOOD EXCEPTION HERE"; 66 throw ParseException("Bad format reading binary Gats Dictionary.");
64 Gats::String sKey; 67 Gats::String sKey;
65 sKey.read( rIn, cNext ); 68 sKey.read( rIn, cNext );
66 69
@@ -243,7 +246,7 @@ bool Gats::Dictionary::valueBool( const QByteArray &sKey )
243{ 246{
244 Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( value( sKey ) ); 247 Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( value( sKey ) );
245 if( !pOb ) 248 if( !pOb )
246 throw "PUT GOOD EXCEPTION HERE"; 249 throw TypeException("Dictionary value requested as bool but isn't.");
247 250
248 return pOb->getValue(); 251 return pOb->getValue();
249} 252}
@@ -252,7 +255,7 @@ int64_t Gats::Dictionary::valueInt( const QByteArray &sKey )
252{ 255{
253 Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( value( sKey ) ); 256 Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( value( sKey ) );
254 if( !pOb ) 257 if( !pOb )
255 throw "PUT GOOD EXCEPTION HERE"; 258 throw TypeException("Dictionary value requested as int but isn't.");
256 259
257 return pOb->getValue(); 260 return pOb->getValue();
258} 261}
@@ -261,7 +264,7 @@ double Gats::Dictionary::valueFloat( const QByteArray &sKey )
261{ 264{
262 Gats::Float *pOb = dynamic_cast<Gats::Float *>( value( sKey ) ); 265 Gats::Float *pOb = dynamic_cast<Gats::Float *>( value( sKey ) );
263 if( !pOb ) 266 if( !pOb )
264 throw "PUT GOOD EXCEPTION HERE"; 267 throw TypeException("Dictionary value requested as float but isn't.");
265 268
266 return pOb->getValue(); 269 return pOb->getValue();
267} 270}
@@ -270,7 +273,7 @@ QByteArray Gats::Dictionary::valueStr( const QByteArray &sKey )
270{ 273{
271 Gats::String *pOb = dynamic_cast<Gats::String *>( value( sKey ) ); 274 Gats::String *pOb = dynamic_cast<Gats::String *>( value( sKey ) );
272 if( !pOb ) 275 if( !pOb )
273 throw "PUT GOOD EXCEPTION HERE"; 276 throw TypeException("Dictionary value requested as str but isn't.");
274 277
275 return *pOb; 278 return *pOb;
276} 279}
@@ -279,7 +282,7 @@ Gats::List *Gats::Dictionary::valueList( const QByteArray &sKey )
279{ 282{
280 Gats::List *pOb = dynamic_cast<Gats::List *>( value( sKey ) ); 283 Gats::List *pOb = dynamic_cast<Gats::List *>( value( sKey ) );
281 if( !pOb ) 284 if( !pOb )
282 throw "PUT GOOD EXCEPTION HERE"; 285 throw TypeException("Dictionary value requested as list but isn't.");
283 286
284 return pOb; 287 return pOb;
285} 288}
@@ -288,7 +291,7 @@ Gats::Dictionary *Gats::Dictionary::valueDict( const QByteArray &sKey )
288{ 291{
289 Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( value( sKey ) ); 292 Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( value( sKey ) );
290 if( !pOb ) 293 if( !pOb )
291 throw "PUT GOOD EXCEPTION HERE"; 294 throw TypeException("Dictionary value requested as dict but isn't.");
292 295
293 return pOb; 296 return pOb;
294} 297}
@@ -297,7 +300,7 @@ bool Gats::Dictionary::valueBool( const QByteArray &sKey ) const
297{ 300{
298 Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( value( sKey ) ); 301 Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( value( sKey ) );
299 if( !pOb ) 302 if( !pOb )
300 throw "PUT GOOD EXCEPTION HERE"; 303 throw TypeException("Dictionary value requested as bool but isn't.");
301 304
302 return pOb->getValue(); 305 return pOb->getValue();
303} 306}
@@ -306,7 +309,7 @@ int64_t Gats::Dictionary::valueInt( const QByteArray &sKey ) const
306{ 309{
307 Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( value( sKey ) ); 310 Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( value( sKey ) );
308 if( !pOb ) 311 if( !pOb )
309 throw "PUT GOOD EXCEPTION HERE"; 312 throw TypeException("Dictionary value requested as int but isn't.");
310 313
311 return pOb->getValue(); 314 return pOb->getValue();
312} 315}
@@ -315,7 +318,7 @@ double Gats::Dictionary::valueFloat( const QByteArray &sKey ) const
315{ 318{
316 Gats::Float *pOb = dynamic_cast<Gats::Float *>( value( sKey ) ); 319 Gats::Float *pOb = dynamic_cast<Gats::Float *>( value( sKey ) );
317 if( !pOb ) 320 if( !pOb )
318 throw "PUT GOOD EXCEPTION HERE"; 321 throw TypeException("Dictionary value requested as float but isn't.");
319 322
320 return pOb->getValue(); 323 return pOb->getValue();
321} 324}
@@ -324,7 +327,7 @@ QByteArray Gats::Dictionary::valueStr( const QByteArray &sKey ) const
324{ 327{
325 Gats::String *pOb = dynamic_cast<Gats::String *>( value( sKey ) ); 328 Gats::String *pOb = dynamic_cast<Gats::String *>( value( sKey ) );
326 if( !pOb ) 329 if( !pOb )
327 throw "PUT GOOD EXCEPTION HERE"; 330 throw TypeException("Dictionary value requested as str but isn't.");
328 331
329 return *pOb; 332 return *pOb;
330} 333}
@@ -333,7 +336,7 @@ Gats::List *Gats::Dictionary::valueList( const QByteArray &sKey ) const
333{ 336{
334 Gats::List *pOb = dynamic_cast<Gats::List *>( value( sKey ) ); 337 Gats::List *pOb = dynamic_cast<Gats::List *>( value( sKey ) );
335 if( !pOb ) 338 if( !pOb )
336 throw "PUT GOOD EXCEPTION HERE"; 339 throw TypeException("Dictionary value requested as list but isn't.");
337 340
338 return pOb; 341 return pOb;
339} 342}
@@ -342,7 +345,7 @@ Gats::Dictionary *Gats::Dictionary::valueDict( const QByteArray &sKey ) const
342{ 345{
343 Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( value( sKey ) ); 346 Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( value( sKey ) );
344 if( !pOb ) 347 if( !pOb )
345 throw "PUT GOOD EXCEPTION HERE"; 348 throw TypeException("Dictionary value requested as dict but isn't.");
346 349
347 return pOb; 350 return pOb;
348} 351}
diff --git a/c++-qt/src/object.cpp b/c++-qt/src/object.cpp
index 85851df..d148774 100644
--- a/c++-qt/src/object.cpp
+++ b/c++-qt/src/object.cpp
@@ -15,6 +15,8 @@
15#include "gats-qt/dictionary.h" 15#include "gats-qt/dictionary.h"
16#include "gats-qt/null.h" 16#include "gats-qt/null.h"
17 17
18#include "gats-qt/parseexception.h"
19
18#include <stdlib.h> 20#include <stdlib.h>
19 21
20#include <QIODevice> 22#include <QIODevice>
@@ -68,7 +70,7 @@ Gats::Object *Gats::Object::read( QIODevice &rIn )
68 return NULL; 70 return NULL;
69 71
70 default: 72 default:
71 throw "Invalid Gats type discovered: "; 73 throw ParseException("Invalid Gats type discovered.");
72 } 74 }
73 75
74 pObj->read( rIn, buf ); 76 pObj->read( rIn, buf );
diff --git a/c++-qt/src/parseexception.cpp b/c++-qt/src/parseexception.cpp
new file mode 100644
index 0000000..03d547a
--- /dev/null
+++ b/c++-qt/src/parseexception.cpp
@@ -0,0 +1,31 @@
1#include "gats-qt/parseexception.h"
2
3Gats::ParseException::ParseException( const char * const sMessage ) :
4 sMessage( sMessage )
5{
6}
7
8Gats::ParseException::ParseException( const ParseException &rSrc ) :
9 sMessage( rSrc.sMessage )
10{
11}
12
13Gats::ParseException::~ParseException()
14{
15}
16
17QException *Gats::ParseException::clone() const
18{
19 return new ParseException( *this );
20}
21
22void Gats::ParseException::raise() const
23{
24 throw *this;
25}
26
27const char *Gats::ParseException::what() const noexcept
28{
29 return sMessage;
30}
31
diff --git a/c++-qt/src/typeexception.cpp b/c++-qt/src/typeexception.cpp
new file mode 100644
index 0000000..13ec3de
--- /dev/null
+++ b/c++-qt/src/typeexception.cpp
@@ -0,0 +1,32 @@
1#include "gats-qt/typeexception.h"
2
3Gats::TypeException::TypeException( const char * const sMessage ) :
4 sMessage( sMessage )
5{
6}
7
8Gats::TypeException::TypeException( const TypeException &rSrc ) :
9 sMessage( rSrc.sMessage )
10{
11}
12
13Gats::TypeException::~TypeException()
14{
15}
16
17QException *Gats::TypeException::clone() const
18{
19 return new TypeException( *this );
20}
21
22void Gats::TypeException::raise() const
23{
24 throw *this;
25}
26
27const char *Gats::TypeException::what() const noexcept
28{
29 return sMessage;
30}
31
32