mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
bool type in cpp cc
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@316 e5f2f494-b856-4b98-b285-d166d9295462
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user