基础数据类型:
poco 提供了整数类型头文件 "Poco/type.h"
并提供了2个宏
POCO_PTR_IS_64_BIT
POCO_LONG_IS_64_BIT
可以用来判断是否64位环境
-
#elif defined(__GNUC__) || defined(__clang__)
-
//
-
// Unix/GCC/Clang
-
//
-
typedef signed char Int8;
-
typedef unsigned char UInt8;
-
typedef signed short Int16;
-
typedef unsigned short UInt16;
-
typedef signed int Int32;
-
typedef unsigned int UInt32;
-
#if defined(_WIN64)
-
#define POCO_PTR_IS_64_BIT 1
-
typedef signed long long IntPtr;
-
typedef unsigned long long UIntPtr;
-
typedef signed long long Int64;
-
typedef unsigned long long UInt64;
-
#else
-
typedef signed long IntPtr;
-
typedef unsigned long UIntPtr;
-
#if defined(__LP64__)
-
#define POCO_PTR_IS_64_BIT 1
-
#define POCO_LONG_IS_64_BIT 1
-
typedef signed long Int64;
-
typedef unsigned long UInt64;
-
#else
-
typedef signed long long Int64;
-
typedef unsigned long long UInt64;
-
#endif
-
#endif
-
#define POCO_HAVE_INT64 1
-
#elif defined(__DECCXX)
字节序:
poco提供2个宏来判断大/小端字节序,定义在头文件 "Poco/platform.h"
POCO_ARCH_LITTLE_ENDIAN
POCO_ARCH_BIG_ENDIAN
和一系列的字节序转换函数 "Poco/ByteOrder.h",包括网络字节序转主机字节序函数接口
-
class Foundation_API ByteOrder
-
/// This class contains a number of static methods
-
/// to convert between big-endian and little-endian
-
/// integers of various sizes.
-
{
-
public:
-
static Int16 flipBytes(Int16 value);
-
static UInt16 flipBytes(UInt16 value);
-
static Int32 flipBytes(Int32 value);
-
static UInt32 flipBytes(UInt32 value);
-
#if defined(POCO_HAVE_INT64)
-
static Int64 flipBytes(Int64 value);
-
static UInt64 flipBytes(UInt64 value);
-
#endif
-
-
static Int16 toBigEndian(Int16 value);
-
static UInt16 toBigEndian (UInt16 value);
-
static Int32 toBigEndian(Int32 value);
-
static UInt32 toBigEndian (UInt32 value);
Any:
#include "Poco/Any.h"
Poco::Any 实例可以支持各种类型数据,
Poco::AnyCast()和Poco::RefAnyCast()函数模板用来获取数据值和引用
AnyCast数据类型不同时会抛出BadCastException 异常
-
Any any(42);
-
int i = AnyCast<int>(any);
-
-
short s = AnyCast<short>(any); // throws BadCastException
DynamicAny:
-
DynamicAny any(42);
-
int i = any;
-
std::string s(any.convert<std::string>());
-
any.convert(s); // or without the need to cast
-
const int& ri(any.extract<int>());
-
short s = any;
-
-
short s = any.extract<short>(); // throws BadCastException
阅读(2018) | 评论(0) | 转发(0) |