aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/gatscon/gatstotree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++-libbu++/src/gatscon/gatstotree.cpp')
-rw-r--r--c++-libbu++/src/gatscon/gatstotree.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/c++-libbu++/src/gatscon/gatstotree.cpp b/c++-libbu++/src/gatscon/gatstotree.cpp
new file mode 100644
index 0000000..e388d5e
--- /dev/null
+++ b/c++-libbu++/src/gatscon/gatstotree.cpp
@@ -0,0 +1,91 @@
1#include "gatstotree.h"
2
3#include <gats/types.h>
4
5#include <QTreeWidgetItem>
6
7void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj )
8{
9 switch( pObj->getType() )
10 {
11 case Gats::typeInteger:
12 gatsToTree( p, dynamic_cast<Gats::Integer *>( pObj ) );
13 break;
14
15 case Gats::typeString:
16 gatsToTree( p, dynamic_cast<Gats::String *>( pObj ) );
17 break;
18
19 case Gats::typeFloat:
20 gatsToTree( p, dynamic_cast<Gats::Float *>( pObj ) );
21 break;
22
23 case Gats::typeBoolean:
24 gatsToTree( p, dynamic_cast<Gats::Boolean *>( pObj ) );
25 break;
26
27 case Gats::typeList:
28 gatsToTree( p, dynamic_cast<Gats::List *>( pObj ) );
29 break;
30
31 case Gats::typeDictionary:
32 gatsToTree( p, dynamic_cast<Gats::Dictionary *>( pObj ) );
33 break;
34
35 case Gats::typeNull:
36 gatsToTree( p, dynamic_cast<Gats::Null *>( pObj ) );
37 break;
38 }
39}
40
41void gatsToTree( QTreeWidgetItem *p, Gats::Integer *pObj )
42{
43 p->setText( 1, "int");
44 p->setText( 2, QString("%1").arg( pObj->getValue() ) );
45}
46
47void gatsToTree( QTreeWidgetItem *p, Gats::String *pObj )
48{
49 p->setText( 1, "str");
50 p->setText( 2, QString("%1").arg( pObj->getStr() ) );
51}
52
53void gatsToTree( QTreeWidgetItem *p, Gats::Float *pObj )
54{
55 p->setText( 1, "float");
56 p->setText( 2, QString("%1").arg( pObj->getValue() ) );
57}
58
59void gatsToTree( QTreeWidgetItem *p, Gats::Boolean *pObj )
60{
61 p->setText( 1, "bool");
62 p->setText( 2, pObj->getValue()?"true":"false" );
63}
64
65void gatsToTree( QTreeWidgetItem *p, Gats::List *pObj )
66{
67 p->setText( 1, "list");
68 int j = 0;
69 for( Gats::List::iterator i = pObj->begin(); i; i++ )
70 {
71 QTreeWidgetItem *pIt = new QTreeWidgetItem( p );
72 pIt->setText( 0, QString("%1").arg( j++ ) );
73 gatsToTree( pIt, *i );
74 }
75}
76
77void gatsToTree( QTreeWidgetItem *p, Gats::Dictionary *pObj )
78{
79 p->setText( 1, "dict");
80 for( Gats::Dictionary::iterator i = pObj->begin(); i; i++ )
81 {
82 QTreeWidgetItem *pIt = new QTreeWidgetItem( p );
83 pIt->setText( 0, QString( i.getKey().getStr() ) );
84 gatsToTree( pIt, *i );
85 }
86}
87
88void gatsToTree( QTreeWidgetItem *p, Gats::Null *pObj )
89{
90 p->setText( 1, "null");
91}