opendht-2.1.4/src/indexation/pht.cpp
/**
 * Output the blob into string and readable way
 *
 * @param bl   : Blob to print
 *
 * @return string that represent the blob into a readable way
 */
Output the blob into string and readable way
@param bl   : Blob to print

@return string that represent the blob into a readable way
Output the blob into string and readable way @param bl : Blob to print @return string that represent the blob into a readable way
static std::string blobToString(const Blob &bl) {
    std::stringstream ss;
    auto bn = bl.size() % 8;
    auto n = bl.size() / 8;
    for (size_t i = 0; i < bl.size(); i++)
        ss << std::bitset<8>(bl[i]) << " ";
    if (bn)
        for (unsigned b=0; b < bn; b++)
            ss << (char)((bl[n] & (1 << (7 - b))) ? '1':'0');
    return ss.str();
}
static std :: string blobToString ( const Blob & bl ) { std :: stringstream ss ; auto bn = bl . size ( ) % 8 ; auto n = bl . size ( ) / 8 ; for ( size_t i = 0 ; i < bl . size ( ) ; i ++ ) ss << std :: bitset < 8 > ( bl [ i ] ) << " " ; if ( bn ) for ( unsigned b = 0 ; b < bn ; b ++ ) ss << ( char ) ( ( bl [ n ] & ( 1 << ( 7 - b ) ) ) ? ' ' : ' ' ) ; return ss . str ( ) ; }
Output the blob into string and readable way
 @param bl   : Blob to print
Output the blob into string and readable way @param bl : Blob to print