Commit 78dabb44 authored by Jelte Jansen's avatar Jelte Jansen

bool type in cpp cc


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@316 e5f2f494-b856-4b98-b285-d166d9295462
parent 8cf507e8
......@@ -18,6 +18,7 @@ const unsigned char ITEM_BLOB = 0x01;
const unsigned char ITEM_HASH = 0x02;
const unsigned char ITEM_LIST = 0x03;
const unsigned char ITEM_NULL = 0x04;
const unsigned char ITEM_BOOL = 0x05;
const unsigned char ITEM_UTF8 = 0x08;
const unsigned char ITEM_MASK = 0x0f;
......@@ -553,6 +554,18 @@ decode_tag(std::stringstream& in, int& item_length)
return std::string(buf, len);
}
ElementPtr
decode_bool(std::stringstream& in, int& item_length)
{
char c;
c = in.get();
if (c == 0x01) {
return Element::create(true);
} else {
return Element::create(false);
}
}
ElementPtr
decode_blob(std::stringstream& in, int& item_length)
{
......@@ -652,6 +665,9 @@ decode_element(std::stringstream& in, int& in_length)
in_length -= item_length;
switch (type) {
case ITEM_BOOL:
element = decode_bool(in, item_length);
break;
case ITEM_BLOB:
element = decode_blob(in, item_length);
break;
......@@ -761,8 +777,13 @@ BoolElement::to_wire(int omit_length)
std::stringstream text;
text << str();
int length = text.str().length();
ss << encode_length(length, ITEM_UTF8) << text.str();
int length = 1;
ss << encode_length(length, ITEM_BOOL);
if (bool_value()) {
ss << 0x01;
} else {
ss << 0x00;
}
return ss.str();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment