34
36
////////////////////////////////////////////////
36
BValueNode::BValueNode(const Value & v,Uint32 off) : BNode(VALUE,off),v(v)
38
BValueNode::BValueNode(const Value & v,Uint32 off) : BNode(VALUE,off),value(v)
39
41
BValueNode::~BValueNode()
42
44
void BValueNode::printDebugInfo()
44
if (v.getType() == Value::INT)
45
Out(SYS_GEN|LOG_DEBUG) << "Value = " << v.toInt() << endl;
47
Out(SYS_GEN|LOG_DEBUG) << "Value = " << v.toString() << endl;
46
if (value.getType() == Value::STRING)
47
Out(SYS_GEN|LOG_DEBUG) << "Value = " << value.toString() << endl;
48
else if (value.getType() == Value::INT)
49
Out(SYS_GEN|LOG_DEBUG) << "Value = " << value.toInt() << endl;
50
else if (value.getType() == Value::INT64)
51
Out(SYS_GEN|LOG_DEBUG) << "Value = " << value.toInt64() << endl;
50
54
////////////////////////////////////////////////
130
134
return dynamic_cast<BValueNode*>(n);
137
int BDictNode::getInt(const QString & key)
139
BValueNode* v = getValue(key);
141
throw bt::Error("Key not found in dict");
143
if (v->data().getType() != bt::Value::INT)
144
throw bt::Error("Incompatible type");
146
return v->data().toInt();
149
qint64 BDictNode::getInt64(const QString & key)
151
BValueNode* v = getValue(key);
153
throw bt::Error("Key not found in dict");
155
if (v->data().getType() != bt::Value::INT64 && v->data().getType() != bt::Value::INT)
156
throw bt::Error("Incompatible type");
158
return v->data().toInt64();
161
QString BDictNode::getString(const QString & key,QTextCodec* tc)
163
BValueNode* v = getValue(key);
165
throw bt::Error("Key not found in dict");
167
if (v->data().getType() != bt::Value::STRING)
168
throw bt::Error("Incompatible type");
171
return v->data().toString();
173
return v->data().toString(tc);
176
QByteArray BDictNode::getByteArray(const QString & key)
178
BValueNode* v = getValue(key);
180
throw bt::Error("Key not found in dict");
182
if (v->data().getType() != bt::Value::STRING)
183
throw bt::Error("Incompatible type");
185
return v->data().toByteArray();
133
188
void BDictNode::printDebugInfo()
135
190
Out(SYS_GEN|LOG_DEBUG) << "DICT" << endl;
181
236
return dynamic_cast<BValueNode*>(getChild(idx));
239
int BListNode::getInt(Uint32 idx)
241
BValueNode* v = getValue(idx);
243
throw bt::Error("Key not found in dict");
245
if (v->data().getType() != bt::Value::INT)
246
throw bt::Error("Incompatible type");
248
return v->data().toInt();
251
qint64 BListNode::getInt64(Uint32 idx)
253
BValueNode* v = getValue(idx);
255
throw bt::Error("Key not found in dict");
257
if (v->data().getType() != bt::Value::INT64 && v->data().getType() != bt::Value::INT)
258
throw bt::Error("Incompatible type");
260
return v->data().toInt64();
263
QString BListNode::getString(Uint32 idx,QTextCodec* tc)
265
BValueNode* v = getValue(idx);
267
throw bt::Error("Key not found in dict");
269
if (v->data().getType() != bt::Value::STRING)
270
throw bt::Error("Incompatible type");
273
return v->data().toString();
275
return v->data().toString(tc);
278
QByteArray BListNode::getByteArray(Uint32 idx)
280
BValueNode* v = getValue(idx);
282
throw bt::Error("Key not found in dict");
284
if (v->data().getType() != bt::Value::STRING)
285
throw bt::Error("Incompatible type");
287
return v->data().toByteArray();
184
290
void BListNode::printDebugInfo()
186
292
Out(SYS_GEN|LOG_DEBUG) << "LIST " << children.count() << endl;