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