本文整理汇总了C++中Hash::raw方法的典型用法代码示例。如果您正苦于以下问题:C++ Hash::raw方法的具体用法?C++ Hash::raw怎么用?C++ Hash::raw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hash
的用法示例。
在下文中一共展示了Hash::raw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
void LabelOps::set( const Hash & hash, const std::string & label )
{
BACKTRACE_BEGIN
unsigned char buffer[ 1024 ];
struct Tongue::Header * header = reinterpret_cast< struct Tongue::Header * >( buffer );
struct Tongue::Label * labelHeader = reinterpret_cast< struct Tongue::Label * >( header + 1 );
unsigned char * labelText = reinterpret_cast< unsigned char * >( labelHeader + 1 );
struct Tongue::Hash * rawHash = reinterpret_cast< struct Tongue::Hash * >( labelText + label.size() );
if ( reinterpret_cast< unsigned char * >( rawHash + 1 ) > buffer + sizeof( buffer ) )
THROW( Error, "Label too long" );
header->opcode = static_cast< unsigned char >( Tongue::Opcode::SET_LABEL );
ASSERT( label.size() < ( 1 << 16 ) );
labelHeader->length = static_cast< unsigned short >( label.size() );
memcpy( labelText, label.c_str(), label.size() );
* rawHash = hash.raw();
size_t size = reinterpret_cast< unsigned char * >( rawHash + 1 ) - buffer;
_socket.sendAll( buffer, size );
Stream::AckOps( _socket ).wait( "setting label" );
BACKTRACE_END_VERBOSE( "Hash " << hash << " Label " << label );
}