in activemq-cpp/src/main/activemq/wireformat/openwire/marshal/PrimitiveTypesMarshaller.cpp [354:446]
PrimitiveValueNode PrimitiveTypesMarshaller::unmarshalPrimitive(io::DataInputStream& dataIn) {
try {
unsigned char type = dataIn.readByte();
PrimitiveValueNode value;
switch (type) {
case PrimitiveValueNode::NULL_TYPE:
value.clear();
break;
case PrimitiveValueNode::BYTE_TYPE:
value.setByte(dataIn.readByte());
break;
case PrimitiveValueNode::BOOLEAN_TYPE:
value.setBool(dataIn.readBoolean());
break;
case PrimitiveValueNode::CHAR_TYPE:
// Java Char is two bytes, for now we can read ASCII, throw away byte 1
dataIn.readByte();
value.setChar(dataIn.readChar());
break;
case PrimitiveValueNode::SHORT_TYPE:
value.setShort(dataIn.readShort());
break;
case PrimitiveValueNode::INTEGER_TYPE:
value.setInt(dataIn.readInt());
break;
case PrimitiveValueNode::LONG_TYPE:
value.setLong(dataIn.readLong());
break;
case PrimitiveValueNode::FLOAT_TYPE:
value.setFloat(dataIn.readFloat());
break;
case PrimitiveValueNode::DOUBLE_TYPE:
value.setDouble(dataIn.readDouble());
break;
case PrimitiveValueNode::BYTE_ARRAY_TYPE: {
int size = dataIn.readInt();
std::vector<unsigned char> data;
if (size > 0) {
data.resize(size);
dataIn.readFully(&data[0], size);
}
value.setByteArray(data);
break;
}
case PrimitiveValueNode::STRING_TYPE: {
int utfLength = dataIn.readShort();
if (utfLength > 0) {
std::vector<unsigned char> buffer(utfLength);
dataIn.readFully(&buffer[0], utfLength);
value.setString(std::string((char*) (&buffer[0]), utfLength));
}
break;
}
case PrimitiveValueNode::BIG_STRING_TYPE: {
int utfLength = dataIn.readInt();
if (utfLength > 0) {
std::vector<unsigned char> buffer(utfLength);
dataIn.readFully(&buffer[0], utfLength);
value.setString(std::string((char*) (&buffer[0]), utfLength));
}
break;
}
case PrimitiveValueNode::LIST_TYPE: {
PrimitiveList list;
PrimitiveTypesMarshaller::unmarshalPrimitiveList(dataIn, list);
value.setList(list);
break;
}
case PrimitiveValueNode::MAP_TYPE: {
PrimitiveMap map;
PrimitiveTypesMarshaller::unmarshalPrimitiveMap(dataIn, map);
value.setMap(map);
break;
}
default:
throw IOException(
__FILE__,
__LINE__, "PrimitiveTypesMarshaller::unmarshalPrimitive - "
"Unsupported data type: ");
}
return value;
}
AMQ_CATCH_RETHROW(io::IOException)
AMQ_CATCH_EXCEPTION_CONVERT(Exception, io::IOException)
AMQ_CATCHALL_THROW(io::IOException)
}