我正在尝试在Poco源代码中找到Poco ByteOrder :: ToNetwork(),在搜索整个源代码后,我能找到的是:
static Int16 toNetwork(Int16 value);
static UInt16 toNetwork (UInt16 value);
static Int32 toNetwork(Int32 value);
static UInt32 toNetwork (UInt32 value);
#if defined(POCO_HAVE_INT64)
static Int64 toNetwork(Int64 value);
static UInt64 toNetwork (UInt64 value);
#endif
在ByteOrder.h中
实际执行在哪里?无法在github上找到它:
https://github.com/pocoproject/poco/search?utf8=%E2%9C%93&q=tonetwork
答案 0 :(得分:0)
Poco的耐力转换由ByteOrder.h中的宏POCO_IMPLEMENT_BYTEORDER_BIG
和POCO_IMPLEMENT_BYTEORDER_LIT
定义。在大端系统上,这些宏分别扩展为POCO_IMPLEMENT_BYTEORDER_NOOP
和POCO_IMPLEMENT_BYTEORDER_FLIP
,而小端系统则相反。
//
// some macro trickery to automate the method implementation
//
#define POCO_IMPLEMENT_BYTEORDER_NOOP_(op, type) \
inline type ByteOrder::op(type value) \
{ \
return value; \
}
#define POCO_IMPLEMENT_BYTEORDER_FLIP_(op, type) \
inline type ByteOrder::op(type value) \
{ \
return flipBytes(value); \
}
#if defined(POCO_HAVE_INT64)
#define POCO_IMPLEMENT_BYTEORDER_NOOP(op) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int16) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt16) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int32) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt32) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int64) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt64)
#define POCO_IMPLEMENT_BYTEORDER_FLIP(op) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int16) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt16) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int32) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt32) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int64) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt64)
#else
#define POCO_IMPLEMENT_BYTEORDER_NOOP(op) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int16) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt16) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int32) \
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt32)
#define POCO_IMPLEMENT_BYTEORDER_FLIP(op) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int16) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt16) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int32) \
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt32)
#endif
#if defined(POCO_ARCH_BIG_ENDIAN)
#define POCO_IMPLEMENT_BYTEORDER_BIG POCO_IMPLEMENT_BYTEORDER_NOOP
#define POCO_IMPLEMENT_BYTEORDER_LIT POCO_IMPLEMENT_BYTEORDER_FLIP
#else
#define POCO_IMPLEMENT_BYTEORDER_BIG POCO_IMPLEMENT_BYTEORDER_FLIP
#define POCO_IMPLEMENT_BYTEORDER_LIT POCO_IMPLEMENT_BYTEORDER_NOOP
#endif
POCO_IMPLEMENT_BYTEORDER_BIG(toBigEndian)
POCO_IMPLEMENT_BYTEORDER_BIG(fromBigEndian)
POCO_IMPLEMENT_BYTEORDER_BIG(toNetwork)
POCO_IMPLEMENT_BYTEORDER_BIG(fromNetwork)
POCO_IMPLEMENT_BYTEORDER_LIT(toLittleEndian)
POCO_IMPLEMENT_BYTEORDER_LIT(fromLittleEndian)