Chinaunix首页 | 论坛 | 博客
  • 博客访问: 185592
  • 博文数量: 60
  • 博客积分: 1597
  • 博客等级: 上尉
  • 技术积分: 461
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-20 13:24
文章分类

全部博文(60)

文章存档

2017年(15)

2016年(6)

2015年(37)

2008年(2)

分类: C/C++

2015-08-24 16:17:03

基础数据类型:
    poco 提供了整数类型头文件 "Poco/type.h"
    并提供了2个宏
        POCO_PTR_IS_64_BIT 
        POCO_LONG_IS_64_BIT
    可以用来判断是否64位环境

点击(此处)折叠或打开

  1. #elif defined(__GNUC__) || defined(__clang__)
  2.     //
  3.     // Unix/GCC/Clang
  4.     //
  5.     typedef signed char Int8;
  6.     typedef unsigned char UInt8;
  7.     typedef signed short Int16;
  8.     typedef unsigned short UInt16;
  9.     typedef signed int Int32;
  10.     typedef unsigned int UInt32;
  11.     #if defined(_WIN64)
  12.         #define POCO_PTR_IS_64_BIT 1
  13.         typedef signed long long IntPtr;
  14.         typedef unsigned long long UIntPtr;
  15.         typedef signed long long Int64;
  16.         typedef unsigned long long UInt64;
  17.     #else
  18.         typedef signed long IntPtr;
  19.         typedef unsigned long UIntPtr;
  20.         #if defined(__LP64__)
  21.             #define POCO_PTR_IS_64_BIT 1
  22.             #define POCO_LONG_IS_64_BIT 1
  23.             typedef signed long Int64;
  24.             typedef unsigned long UInt64;
  25.         #else
  26.             typedef signed long long Int64;
  27.             typedef unsigned long long UInt64;
  28.         #endif
  29.     #endif
  30.     #define POCO_HAVE_INT64 1
  31. #elif defined(__DECCXX)

字节序:
    poco提供2个宏来判断大/小端字节序,定义在头文件 "Poco/platform.h"
        POCO_ARCH_LITTLE_ENDIAN
        POCO_ARCH_BIG_ENDIAN 
    和一系列的字节序转换函数 "Poco/ByteOrder.h",包括网络字节序转主机字节序函数接口

点击(此处)折叠或打开

  1. class Foundation_API ByteOrder
  2.     /// This class contains a number of static methods
  3.     /// to convert between big-endian and little-endian
  4.     /// integers of various sizes.
  5. {
  6. public:
  7.     static Int16 flipBytes(Int16 value);
  8.     static UInt16 flipBytes(UInt16 value);
  9.     static Int32 flipBytes(Int32 value);
  10.     static UInt32 flipBytes(UInt32 value);
  11. #if defined(POCO_HAVE_INT64)
  12.     static Int64 flipBytes(Int64 value);
  13.     static UInt64 flipBytes(UInt64 value);
  14. #endif

  15.     static Int16 toBigEndian(Int16 value);
  16.     static UInt16 toBigEndian (UInt16 value);
  17.     static Int32 toBigEndian(Int32 value);
  18.     static UInt32 toBigEndian (UInt32 value);

Any:
    #include "Poco/Any.h"
    Poco::Any 实例可以支持各种类型数据,
    Poco::AnyCast()和Poco::RefAnyCast()函数模板用来获取数据值和引用
    AnyCast数据类型不同时会抛出BadCastException 异常
    

点击(此处)折叠或打开

  1. Any any(42);
  2. int i = AnyCast<int>(any);

  3. short s = AnyCast<short>(any); // throws BadCastException
DynamicAny:
    

点击(此处)折叠或打开

  1. DynamicAny any(42);
  2. int i = any;
  3. std::string s(any.convert<std::string>());
  4.  any.convert(s); // or without the need to cast
  5. const int& ri(any.extract<int>());
  6. short s = any;

  7. short s = any.extract<short>(); // throws BadCastException

阅读(2018) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~