2024-12-01 19:35:24 +00:00
|
|
|
//| Copyright: (C) 2020-2024 Kevin Larke <contact AT larke DOT org>
|
|
|
|
//| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
|
2019-12-19 03:24:12 +00:00
|
|
|
#ifndef cwCOMMON_H
|
|
|
|
#define cwCOMMON_H
|
|
|
|
|
|
|
|
#include <cstdio> // declares 'NULL'
|
|
|
|
#include <cstdarg>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define kInvalidIdx ((unsigned)-1)
|
|
|
|
#define kInvalidId ((unsigned)-1)
|
|
|
|
#define kInvalidCnt ((unsigned)-1)
|
|
|
|
|
|
|
|
|
|
|
|
namespace cw
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2020-03-17 02:58:05 +00:00
|
|
|
kOkRC = 0, // 0
|
|
|
|
kObjAllocFailRC, // 1 - an object allocation failed
|
|
|
|
kObjFreeFailRC, // 2 - an object free failed
|
|
|
|
kInvalidOpRC, // 3 - the current state does not support the operation
|
|
|
|
kInvalidArgRC, // 4 -
|
|
|
|
kInvalidIdRC, // 5 - an identifer was found to be invalid
|
|
|
|
kOpenFailRC, // 6
|
|
|
|
kCloseFailRC, // 7
|
|
|
|
kWriteFailRC, // 8
|
|
|
|
kReadFailRC, // 9
|
|
|
|
kFlushFailRC, // 10
|
|
|
|
kSeekFailRC, // 11
|
|
|
|
kEofRC, // 12
|
|
|
|
kResourceNotAvailableRC, // 13
|
|
|
|
kMemAllocFailRC, // 14
|
|
|
|
kGetAttrFailRC, // 15
|
|
|
|
kSetAttrFailRC, // 16
|
|
|
|
kTimeOutRC, // 17
|
|
|
|
kProtocolErrorRC, // 18
|
|
|
|
kOpFailRC, // 19
|
|
|
|
kSyntaxErrorRC, // 20
|
|
|
|
kBufTooSmallRC, // 21
|
2024-02-08 15:55:48 +00:00
|
|
|
kEleNotFoundRC, // 22 - use by cwObject to indicate that an optional value does not exist.
|
2020-03-31 16:47:37 +00:00
|
|
|
kDuplicateRC, // 23 - an invalid duplicate was detected
|
|
|
|
kAssertFailRC, // 24 - used with cwLogFatal
|
2020-04-16 13:27:04 +00:00
|
|
|
kInvalidDataTypeRC, // 25
|
2020-09-01 19:46:21 +00:00
|
|
|
kFileNotFoundRC, // 26
|
|
|
|
kTestFailRC, // 27
|
2020-09-22 15:37:19 +00:00
|
|
|
kInvalidStateRC, // 28
|
2021-08-15 19:56:34 +00:00
|
|
|
kTypeMismatchRC, // 29
|
2022-10-15 19:07:06 +00:00
|
|
|
kNotImplementedRC, // 30
|
2023-11-14 12:51:50 +00:00
|
|
|
kDataCorruptRC, // 31
|
|
|
|
kBaseAppRC // 32
|
2019-12-19 03:24:12 +00:00
|
|
|
} cwRC_t;
|
|
|
|
|
|
|
|
typedef unsigned rc_t;
|
|
|
|
|
|
|
|
|
|
|
|
template< typename T >
|
|
|
|
struct handle
|
|
|
|
{
|
|
|
|
typedef T p_type;
|
|
|
|
T* p = nullptr;
|
|
|
|
|
|
|
|
void set(T* ptr) { this->p=ptr; }
|
2019-12-24 15:05:24 +00:00
|
|
|
void clear() { this->p=nullptr; }
|
2019-12-19 03:24:12 +00:00
|
|
|
bool isValid() const { return this->p != nullptr; }
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|