5 #ifndef _DDS_HEXVIEW_H_ 6 #define _DDS_HEXVIEW_H_ 51 : m_nElementsInRaw(_nElementsInRaw)
58 std::stringstream ssHex;
59 ssHex << std::hex << std::uppercase;
60 std::stringstream ssTxt;
62 BYTEVector_t::const_iterator iter = _this.m_Container.begin();
63 BYTEVector_t::const_iterator iter_end = _this.m_Container.end();
64 for (; iter != iter_end; ++iter)
66 ssHex << std::setw(2) << std::setfill('0') << (static_cast<unsigned int>(*iter)) <<
' ';
67 ssTxt << (isprint(*iter) ? static_cast<char>(*iter) :
'.');
69 if (0 == (nCount % _this.m_nElementsInRaw))
71 _this.Print(_ostream, ssHex, ssTxt, nCount);
76 if (!ssHex.str().empty())
77 _this.Print(_ostream, ssHex, ssTxt, nCount);
83 void Print(std::ostream& _ostream,
84 const std::stringstream& _ssHex,
85 const std::stringstream& _ssTxt,
88 static size_t nRaw = 0;
89 if (_nCount <= m_nElementsInRaw)
91 std::ios_base::fmtflags flags(_ostream.flags());
92 _ostream <<
"0x" << std::right << std::setw(8) << std::setfill(
'0') << std::hex << std::uppercase
93 << (nRaw * m_nElementsInRaw) <<
" | " << std::left << std::setw(m_nElementsInRaw * 3)
94 << std::setfill(
' ') << _ssHex.str() <<
" | " << std::left << std::setw(m_nElementsInRaw)
95 << _ssTxt.str() <<
'\n';
97 _ostream.flags(flags);
101 const size_t m_nElementsInRaw;
102 const _T& m_Container;
CHexView(const _T &_Val, size_t _nElementsInRaw=16)
Definition: HexView.h:50
This class helps to represent a given container's data as in a HEX viewer.
Definition: HexView.h:47
CHexView< BYTEVector_t > BYTEVectorHexView_t
Definition: HexView.h:105
friend std::ostream & operator<<(std::ostream &_ostream, const CHexView< _T > &_this)
Definition: HexView.h:56
#define _T(s)
Use TCHAR instead of char or wchar_t. It will be appropriately translated.
Definition: def.h:82
Definition: BoostHelper.h:14