cwObject.cpp : Allow 'null' objects to be converted to a null ptr to a string.

This commit is contained in:
kevin 2020-10-07 10:55:34 -04:00
parent 18096014ad
commit 33756d0e2f

View File

@ -87,6 +87,17 @@ namespace cw
rc_t _objTypeValueFromNonValue( const object_t* o, unsigned tid, void* dst ) rc_t _objTypeValueFromNonValue( const object_t* o, unsigned tid, void* dst )
{ {
switch(tid)
{
case kCStringTId:
*(const char**)dst = nullptr;
return kOkRC;
case kStringTId:
*(char**)dst = nullptr;
return kOkRC;
}
return cwLogError(kInvalidArgRC, "There is no conversion from '%s' to '%s'.", _objTypeIdToLabel(tid), o->type->label); return cwLogError(kInvalidArgRC, "There is no conversion from '%s' to '%s'.", _objTypeIdToLabel(tid), o->type->label);
} }
@ -97,6 +108,7 @@ namespace cw
*(const char**)dst = o->u.str; *(const char**)dst = o->u.str;
return kOkRC; return kOkRC;
} }
return _objTypeValueFromNonValue(o,tid,dst); return _objTypeValueFromNonValue(o,tid,dst);
} }
@ -114,6 +126,13 @@ namespace cw
*(char**)dst = o->u.str; *(char**)dst = o->u.str;
return kOkRC; return kOkRC;
} }
if( tid == kNullTId )
{
*(char**)dst = nullptr;
return kOkRC;
}
return _objTypeValueFromNonValue(o,tid,dst); return _objTypeValueFromNonValue(o,tid,dst);
} }