mirror of
https://github.com/oatpp/oatpp.git
synced 2025-04-18 19:00:23 +08:00
data::mapping: Void is a friend of ObjectWrapper.
This commit is contained in:
parent
bc1806fa5b
commit
29817260c7
@ -34,7 +34,7 @@
|
||||
#include <string>
|
||||
|
||||
namespace oatpp { namespace data { namespace mapping { namespace type {
|
||||
|
||||
|
||||
class Type; // FWD
|
||||
|
||||
/**
|
||||
@ -90,6 +90,8 @@ namespace __class {
|
||||
|
||||
}
|
||||
|
||||
class Void; // FWD
|
||||
|
||||
/**
|
||||
* ObjectWrapper holds std::shared_ptr to object, object static type, plus object dynamic type information.
|
||||
* @tparam T - Object Type.
|
||||
@ -97,6 +99,7 @@ namespace __class {
|
||||
*/
|
||||
template <class T, class Clazz = __class::Void>
|
||||
class ObjectWrapper {
|
||||
friend Void;
|
||||
protected:
|
||||
std::shared_ptr<T> m_ptr;
|
||||
const Type* m_valueType;
|
||||
|
@ -79,23 +79,23 @@ void ObjectWrapperTest::onRun() {
|
||||
OATPP_LOGI(TAG, "OK");
|
||||
}
|
||||
|
||||
// {
|
||||
// OATPP_LOGI(TAG, "Check valueType is NOT assigned from copy-assign operator...");
|
||||
// ObjectWrapper<std::string> pw1(oatpp::data::mapping::type::__class::String::getType());
|
||||
// ObjectWrapper<std::string> pw2;
|
||||
// pw2 = pw1;
|
||||
// OATPP_ASSERT(pw2.getValueType() == oatpp::data::mapping::type::__class::Void::getType());
|
||||
// OATPP_LOGI(TAG, "OK");
|
||||
// }
|
||||
{
|
||||
OATPP_LOGI(TAG, "Check valueType is NOT assigned from copy-assign operator...");
|
||||
ObjectWrapper<std::string> pw1(oatpp::data::mapping::type::__class::String::getType());
|
||||
ObjectWrapper<std::string> pw2;
|
||||
pw2 = pw1;
|
||||
OATPP_ASSERT(pw2.getValueType() == oatpp::data::mapping::type::__class::Void::getType());
|
||||
OATPP_LOGI(TAG, "OK");
|
||||
}
|
||||
|
||||
// {
|
||||
// OATPP_LOGI(TAG, "Check valueType is NOT assigned from move-assign operator...");
|
||||
// ObjectWrapper<std::string> pw1(oatpp::data::mapping::type::__class::String::getType());
|
||||
// ObjectWrapper<std::string> pw2;
|
||||
// pw2 = std::move(pw1);
|
||||
// OATPP_ASSERT(pw2.getValueType() == oatpp::data::mapping::type::__class::Void::getType());
|
||||
// OATPP_LOGI(TAG, "OK");
|
||||
// }
|
||||
{
|
||||
OATPP_LOGI(TAG, "Check valueType is NOT assigned from move-assign operator...");
|
||||
ObjectWrapper<std::string> pw1(oatpp::data::mapping::type::__class::String::getType());
|
||||
ObjectWrapper<std::string> pw2;
|
||||
pw2 = std::move(pw1);
|
||||
OATPP_ASSERT(pw2.getValueType() == oatpp::data::mapping::type::__class::Void::getType());
|
||||
OATPP_LOGI(TAG, "OK");
|
||||
}
|
||||
|
||||
{
|
||||
OATPP_LOGI(TAG, "Check copy-assign operator. Check == operator...");
|
||||
@ -164,6 +164,25 @@ void ObjectWrapperTest::onRun() {
|
||||
OATPP_LOGI(TAG, "OK");
|
||||
}
|
||||
|
||||
{
|
||||
OATPP_LOGI(TAG, "Check oatpp::Void type reassigned");
|
||||
|
||||
oatpp::Void v;
|
||||
v = oatpp::String("test");
|
||||
|
||||
OATPP_ASSERT(v.getValueType() == oatpp::String::Class::getType());
|
||||
|
||||
v = oatpp::Int32(32);
|
||||
|
||||
OATPP_ASSERT(v.getValueType() == oatpp::Int32::Class::getType());
|
||||
|
||||
oatpp::Int32 i = v.staticCast<oatpp::Int32>();
|
||||
|
||||
OATPP_ASSERT(i.getValueType() == oatpp::Int32::Class::getType());
|
||||
OATPP_ASSERT(i == 32);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}}}}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user