Vault  4.1
vhex.h
Go to the documentation of this file.
00001 /*
00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved.
00003 This file is part of the Code Vault version 4.1
00004 http://www.bombaydigital.com/
00005 License: MIT. See LICENSE.md in the Vault top level directory.
00006 */
00007 
00008 #ifndef vhex_h
00009 #define vhex_h
00010 
00013 #include "vstring.h"
00014 
00015 class VTextIOStream;
00016 class VBinaryIOStream;
00017 
00035 class VHex {
00036     public:
00037 
00045         static void bufferToHexString(const Vu8* buffer, Vs64 bufferLength, VString& s, bool wantLeading0x = false);
00052         static void hexStringToBuffer(const VString& hexDigits, Vu8* buffer, bool hasLeading0x = false);
00053 
00060         static void stringToHex(const VString& text, VString& hexDigits, bool wantLeading0x = false);
00067         static void hexToString(const VString& hexDigits, VString& text, bool hasLeading0x = false);
00068 
00074         static void byteToHexString(Vu8 byteValue, VString& s);
00081         static void byteToHexChars(Vu8 byteValue, char* highNibbleChar, char* lowNibbleChar);
00087         static Vu8 hexStringToByte(const char* twoHexDigits);
00094         static Vu8 hexCharsToByte(char highNibbleChar, char lowNibbleChar);
00095 
00101         static char nibbleToHexChar(Vu8 nibbleValue);
00108         static Vu8 hexCharToNibble(char hexChar);
00109 
00117         static void bufferToPrintableASCIIString(const Vu8* buffer, Vs64 bufferLength, VString& s);
00118 
00136         static void readHexDump(VTextIOStream& inputStream, VBinaryIOStream& outputStream);
00137 
00146         VHex(VTextIOStream* outputStream = NULL, int numBytesPerRow = 16, int indentCount = 2, bool labelsInHex = false, bool showASCIIValues = true);
00150         virtual ~VHex();
00151 
00158         void printHex(const Vu8* buffer, Vs64 length, Vs64 offset = 0);
00162         void reset();
00166         void flush();
00167 
00168     private:
00169 
00170         VHex(const VHex&); // not copyable
00171         VHex& operator=(const VHex&); // not assignable
00172 
00176         void _printPending();
00177 
00178         VTextIOStream*  mOutputStream;      
00179         int             mNumBytesPerRow;    
00180         int             mIndentCount;       
00181         bool            mLabelsInHex;       
00182         bool            mShowASCIIValues;   
00183         int             mStartColumn;       
00184         Vs64            mOffset;            
00185         int             mPendingBufferUsed; 
00186         Vu8*            mPendingBuffer;     
00187         VString         mLineBuffer;        
00188 };
00189 
00190 #endif /* vhex_h */
00191 

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.