From 77c5026f14cf2b29ea61c47e307c760a8a25c8a8 Mon Sep 17 00:00:00 2001 From: kpl Date: Sat, 29 Feb 2020 00:12:15 -0500 Subject: [PATCH] cwObject.cpp,cwObjectTemplate.h,main.cpp : Fixed cwObject bool parsing. --- cwObject.cpp | 1 + cwObjectTemplate.h | 14 +++++++++++++- main.cpp | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cwObject.cpp b/cwObject.cpp index cb922a1..89ecbc0 100644 --- a/cwObject.cpp +++ b/cwObject.cpp @@ -240,6 +240,7 @@ namespace cw object_t* o = mem::allocZ(); o->type = type; o->parent = parent; + return o; } diff --git a/cwObjectTemplate.h b/cwObjectTemplate.h index 13eacff..104896f 100644 --- a/cwObjectTemplate.h +++ b/cwObjectTemplate.h @@ -44,7 +44,17 @@ namespace cw } return obj; } - + + template<> object_t* _objSetLeafValue( object_t* obj, bool value ) + { + if( obj != NULL ) + { + obj->u.b = value; + obj->type = _objIdToType(kBoolTId); + } + return obj; + } + template<> object_t* _objSetLeafValue< char*>( object_t* obj, char* value ) { if( obj != NULL ) @@ -73,6 +83,8 @@ namespace cw template<> object_t* _objCreateValueNode< char*>( object_t* parent, char* value, const char* msg, unsigned flags ) { return _objAppendLeftMostNode( parent, _objSetLeafValue( _objAllocate(), value ) ); } + template<> object_t* _objCreateValueNode( object_t* parent, bool value, const char* msg, unsigned flags ) + { return _objAppendLeftMostNode( parent, _objSetLeafValue( _objAllocate(), value ) ); } template< typename T > rc_t getObjectValue( const T& src, unsigned tid, void* dst, const char* typeLabel ) diff --git a/main.cpp b/main.cpp index 3107e8a..9192569 100644 --- a/main.cpp +++ b/main.cpp @@ -113,7 +113,7 @@ void numbCvtTest( cw::object_t* cfg, int argc, const char* argv[] ) void objectTest( cw::object_t* cfg, int argc, const char* argv[] ) { cw::object_t* o; - const char s [] = "{ a:1, b:2, c:[ 1.23, 4.56 ] }"; + const char s [] = "{ a:1, b:2, c:[ 1.23, 4.56 ], d:true, e:false, f:true }"; cw::objectFromString(s,o); int v;