summaryrefslogtreecommitdiffstats
path: root/wxbufferex.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2013-03-05 17:39:48 +0100
committermanuel <manuel@mausz.at>2013-03-05 17:39:48 +0100
commit310a2c101b32a5e71a616027b6a1b788a341bc02 (patch)
treea871e1dda8b1de141ae1400ba666fe3b1de96361 /wxbufferex.cpp
downloadtsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.tar.gz
tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.tar.bz2
tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.zip
initial GPLv2 releaseHEADmaster
Diffstat (limited to 'wxbufferex.cpp')
-rw-r--r--wxbufferex.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/wxbufferex.cpp b/wxbufferex.cpp
new file mode 100644
index 0000000..78bd167
--- /dev/null
+++ b/wxbufferex.cpp
@@ -0,0 +1,80 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; version 2 of the License.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14 *
15 * Authors: Manuel Mausz (manuel@mausz.at)
16 * Christian Raschko (c.raschko@netcore.at)
17 */
18
19// Header
20#include "wxbufferex.h"
21
22//Libraries
23#include <wx/txtstrm.h>
24
25//------------------------------------------------------------------------------
26// Hex dump on the stream.
27void wxMemoryBufferEx::HexDump(wxOutputStream &strm)
28{
29 wxTextOutputStream out(strm);
30 const size_t colums = 16;
31 size_t size = GetDataLen();
32
33 //print all data
34 for(size_t i = 0; i < ((size % colums == 0) ? (size / colums) : (size / colums) + 1); i++)
35 {
36 //address
37 out << wxString::Format(_T("%.4x "), i * colums);
38
39 //print hex table
40 for(size_t j = 0; j < colums; j++)
41 {
42 if(j == colums/2)
43 out << _T(" ");
44
45 if(j + i*colums >= size)
46 {
47 out << _T(" ");
48 }
49 else
50 {
51 wxByte *pos = static_cast<wxByte *>(GetData());
52 pos += (j + i * colums);
53 out << wxString::Format(_T(" %.2x"), *pos);
54 }
55 }
56
57 //seperator
58 out << _T(" ");
59
60 //print ascii
61 for(size_t j = 0; j < colums; j++)
62 {
63 if(j == colums/2)
64 out << _T(" ");
65 if(j + i*colums >= size)
66 {
67 out << _T(" ");
68 }
69 else
70 {
71 wxByte *pos = static_cast<wxByte *>(GetData());
72 pos += ( j + i * colums);
73 out << wxString::Format(_T("%c"), (wxIsprint(*pos) ? *pos : '.'));
74 }
75 }
76
77 out << endl;
78 }
79}
80