From 33756d0e2f0950ce375184a50e4f72f381aee67c Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 7 Oct 2020 10:55:34 -0400 Subject: [PATCH] cwObject.cpp : Allow 'null' objects to be converted to a null ptr to a string. --- cwObject.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cwObject.cpp b/cwObject.cpp index da4fe5e..8b36822 100644 --- a/cwObject.cpp +++ b/cwObject.cpp @@ -87,6 +87,17 @@ namespace cw 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); } @@ -97,6 +108,7 @@ namespace cw *(const char**)dst = o->u.str; return kOkRC; } + return _objTypeValueFromNonValue(o,tid,dst); } @@ -114,6 +126,13 @@ namespace cw *(char**)dst = o->u.str; return kOkRC; } + + if( tid == kNullTId ) + { + *(char**)dst = nullptr; + return kOkRC; + } + return _objTypeValueFromNonValue(o,tid,dst); }