51 : m_nElementsInRaw(_nElementsInRaw)
56 friend std::ostream& operator<<(std::ostream& _ostream, const CHexView<_T>& _this)
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 _ostream <<
"0x" << std::right << std::setw(8) << std::setfill(
'0') << std::hex << std::uppercase
92 << (nRaw * m_nElementsInRaw) <<
" | " << std::left << std::setw(m_nElementsInRaw * 3)
93 << std::setfill(
' ') << _ssHex.str() <<
" | " << std::left << std::setw(m_nElementsInRaw)
94 << _ssTxt.str() <<
'\n';
99 const size_t m_nElementsInRaw;
100 const _T& m_Container;
CHexView(const _T &_Val, size_t _nElementsInRaw=16)
Definition: HexView.h:50
CHexView< BYTEVector_t > BYTEVectorHexView_t
Definition: HexView.h:103
This class helps to represent a given container's data as in a HEX viewer.
Definition: HexView.h:47
#define _T(s)
Use TCHAR instead of char or wchar_t. It will be appropriately translated.
Definition: def.h:85
Miscellaneous functions and helpers are located here.
Definition: BOOST_FILESYSTEM.h:21