diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/util/hex.h | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/util/hex.h')
-rw-r--r-- | src/mongo/util/hex.h | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/src/mongo/util/hex.h b/src/mongo/util/hex.h index d9724986008..802d6b13737 100644 --- a/src/mongo/util/hex.h +++ b/src/mongo/util/hex.h @@ -35,59 +35,59 @@ #include "mongo/bson/util/builder.h" namespace mongo { - //can't use hex namespace because it conflicts with hex iostream function - inline int fromHex( char c ) { - if ( '0' <= c && c <= '9' ) - return c - '0'; - if ( 'a' <= c && c <= 'f' ) - return c - 'a' + 10; - if ( 'A' <= c && c <= 'F' ) - return c - 'A' + 10; - verify( false ); - return 0xff; - } - inline char fromHex( const char *c ) { - return (char)(( fromHex( c[ 0 ] ) << 4 ) | fromHex( c[ 1 ] )); - } - inline char fromHex( StringData c ) { - return (char)(( fromHex( c[ 0 ] ) << 4 ) | fromHex( c[ 1 ] )); - } - - inline std::string toHex(const void* inRaw, int len) { - static const char hexchars[] = "0123456789ABCDEF"; +// can't use hex namespace because it conflicts with hex iostream function +inline int fromHex(char c) { + if ('0' <= c && c <= '9') + return c - '0'; + if ('a' <= c && c <= 'f') + return c - 'a' + 10; + if ('A' <= c && c <= 'F') + return c - 'A' + 10; + verify(false); + return 0xff; +} +inline char fromHex(const char* c) { + return (char)((fromHex(c[0]) << 4) | fromHex(c[1])); +} +inline char fromHex(StringData c) { + return (char)((fromHex(c[0]) << 4) | fromHex(c[1])); +} - StringBuilder out; - const char* in = reinterpret_cast<const char*>(inRaw); - for (int i=0; i<len; ++i) { - char c = in[i]; - char hi = hexchars[(c & 0xF0) >> 4]; - char lo = hexchars[(c & 0x0F)]; +inline std::string toHex(const void* inRaw, int len) { + static const char hexchars[] = "0123456789ABCDEF"; - out << hi << lo; - } + StringBuilder out; + const char* in = reinterpret_cast<const char*>(inRaw); + for (int i = 0; i < len; ++i) { + char c = in[i]; + char hi = hexchars[(c & 0xF0) >> 4]; + char lo = hexchars[(c & 0x0F)]; - return out.str(); + out << hi << lo; } - template <typename T> std::string integerToHex(T val); + return out.str(); +} - inline std::string toHexLower(const void* inRaw, int len) { - static const char hexchars[] = "0123456789abcdef"; +template <typename T> +std::string integerToHex(T val); - StringBuilder out; - const char* in = reinterpret_cast<const char*>(inRaw); - for (int i=0; i<len; ++i) { - char c = in[i]; - char hi = hexchars[(c & 0xF0) >> 4]; - char lo = hexchars[(c & 0x0F)]; +inline std::string toHexLower(const void* inRaw, int len) { + static const char hexchars[] = "0123456789abcdef"; - out << hi << lo; - } + StringBuilder out; + const char* in = reinterpret_cast<const char*>(inRaw); + for (int i = 0; i < len; ++i) { + char c = in[i]; + char hi = hexchars[(c & 0xF0) >> 4]; + char lo = hexchars[(c & 0x0F)]; - return out.str(); + out << hi << lo; } - /* @return a dump of the buffer as hex byte ascii output */ - std::string hexdump(const char *data, unsigned len); + return out.str(); +} +/* @return a dump of the buffer as hex byte ascii output */ +std::string hexdump(const char* data, unsigned len); } |