From 5c5dc89b0f93ab4d15aafa30e7f48dba228df0ed Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 19 Dec 2021 12:14:30 -0500 Subject: [PATCH] cwObject.h/cpp : Replaced use of std::int64_t and uint64_t with 'long long' and 'unsigned long long'. --- cwObject.cpp | 19 +++++++++++++++---- cwObject.h | 35 ++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/cwObject.cpp b/cwObject.cpp index 40d5f1b..c1b1d73 100644 --- a/cwObject.cpp +++ b/cwObject.cpp @@ -183,8 +183,8 @@ namespace cw void _objTypePrintUInt16( const object_t* o, print_ctx_t& c ) { printf("%i",o->u.u16); } void _objTypePrintInt32( const object_t* o, print_ctx_t& c ) { printf("%i",o->u.i32); } void _objTypePrintUInt32( const object_t* o, print_ctx_t& c ) { printf("%i",o->u.u32); } - void _objTypePrintInt64( const object_t* o, print_ctx_t& c ) { printf("%" PRIx64 ,o->u.i64); } - void _objTypePrintUInt64( const object_t* o, print_ctx_t& c ) { printf("%" PRIx64 ,o->u.u64); } + void _objTypePrintInt64( const object_t* o, print_ctx_t& c ) { printf("%lli", o->u.i64); } + void _objTypePrintUInt64( const object_t* o, print_ctx_t& c ) { printf("%lli", o->u.u64); } void _objTypePrintBool( const object_t* o, print_ctx_t& c ) { printf("%s",o->u.b ? "true" : "false"); } void _objTypePrintFloat( const object_t* o, print_ctx_t& c ) { printf("%f",o->u.f); } void _objTypePrintDouble( const object_t* o, print_ctx_t& c ) { printf("%f",o->u.d); } @@ -253,8 +253,8 @@ namespace cw unsigned _objTypeToStringUInt16( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.u16); } unsigned _objTypeToStringInt32( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.i32); } unsigned _objTypeToStringUInt32( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.u32); } - unsigned _objTypeToStringInt64( const object_t* o, char* buf, unsigned n ) { assert(0); /*return toText(buf,n,o->u.i64);*/ return kInvalidOpRC; } - unsigned _objTypeToStringUInt64( const object_t* o, char* buf, unsigned n ) { assert(0); /*return toText(buf,n,o->u.u64);*/ return kInvalidOpRC; } + unsigned _objTypeToStringInt64( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.i64); } + unsigned _objTypeToStringUInt64( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.u64); } unsigned _objTypeToStringBool( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.b); } unsigned _objTypeToStringFloat( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.f); } unsigned _objTypeToStringDouble( const object_t* o, char* buf, unsigned n ) { return toText(buf,n,o->u.d); } @@ -721,6 +721,17 @@ cw::object_t* cw::newDictObject( object_t* parent ) cw::object_t* cw::newListObject( object_t* parent ) { return _objAllocate( kListTId, parent ); } +cw::object_t* cw::newPairObject( const char* label, object_t* value, object_t* parent) +{ + object_t* pair = _objAppendLeftMostNode(parent, _objAllocate( kPairTId, parent) ); + + _objCreateValueNode( pair, label ); + + pair->append_child(value); + + return value; +} + cw::object_t* cw::newPairObject( const char* label, std::uint8_t v, object_t* parent) { return _objCreatePairNode( parent, label, v ); } diff --git a/cwObject.h b/cwObject.h index ac81967..c0b4c4c 100644 --- a/cwObject.h +++ b/cwObject.h @@ -58,8 +58,8 @@ namespace cw typedef struct print_ctx_str { - unsigned indent = 0; - bool listOnOneLineFl = true; + unsigned indent = 0; + bool listOnOneLineFl = true; } print_ctx_t; typedef struct type_str @@ -103,8 +103,8 @@ namespace cw std::uint16_t u16; std::int32_t i32; std::uint32_t u32; - std::int64_t i64; - std::uint64_t u64; + long long i64; + unsigned long long u64; bool b; @@ -280,19 +280,20 @@ namespace cw object_t* newListObject( object_t* parent=nullptr ); // Return a pointer to the value node. - object_t* newPairObject( const char* label, std::uint8_t v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, std::int8_t v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, std::int16_t v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, std::uint16_t v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, std::int32_t v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, std::uint32_t v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, std::int64_t v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, std::uint64_t v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, bool v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, float v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, double v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, char* v, object_t* parent=nullptr); - object_t* newPairObject( const char* label, const char* v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, object_t* v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, std::uint8_t v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, std::int8_t v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, std::int16_t v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, std::uint16_t v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, std::int32_t v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, std::uint32_t v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, std::int64_t v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, std::uint64_t v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, bool v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, float v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, double v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, char* v, object_t* parent=nullptr); + object_t* newPairObject( const char* label, const char* v, object_t* parent=nullptr); rc_t objectFromString( const char* s, object_t*& objRef ); rc_t objectFromFile( const char* fn, object_t*& objRef );