in hessian2/basic_codec/object_codec.cc [222:275]
bool Encoder::encode(const Object& value) {
switch (value.type()) {
case Object::Type::Binary: {
return encode<std::vector<uint8_t>>(value.toBinary().value().get());
}
case Object::Type::Boolean: {
return encode<bool>(value.toBoolean().value().get());
}
case Object::Type::Date: {
return encode<std::chrono::milliseconds>(value.toDate().value().get());
}
case Object::Type::Double: {
return encode<double>(value.toDouble().value().get());
}
case Object::Type::Integer: {
return encode<int32_t>(value.toInteger().value().get());
}
case Object::Type::Long: {
return encode<int64_t>(value.toLong().value().get());
}
case Object::Type::Null: {
NullObject o;
return encode<NullObject>(o);
}
case Object::Type::Ref: {
return encode<RefObject>(*dynamic_cast<const RefObject*>(&value));
}
case Object::Type::String: {
return encode<std::string>(value.toString().value().get());
}
case Object::Type::TypedList: {
return encode<TypedListObject>(
*dynamic_cast<const TypedListObject*>(&value));
}
case Object::Type::UntypedList: {
return encode<UntypedListObject>(
*dynamic_cast<const UntypedListObject*>(&value));
}
case Object::Type::TypedMap: {
return encode<TypedMapObject>(
*dynamic_cast<const TypedMapObject*>(&value));
}
case Object::Type::UntypedMap: {
return encode<UntypedMapObject>(
*dynamic_cast<const UntypedMapObject*>(&value));
}
case Object::Type::Class: {
return encode<ClassInstanceObject>(
*dynamic_cast<const ClassInstanceObject*>(&value));
}
default:
return false;
}
}