2 // This file is part of the aMule Project.
4 // Copyright (c) 2008 Dévai Tamás ( gonosztopi@amule.org )
5 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef FILEVIEW_PRINT_H
27 #define FILEVIEW_PRINT_H
29 #include <common/DataFileVersion.h>
30 #include <common/StringFunctions.h>
31 #include "../../kademlia/utils/UInt128.h"
32 #include "../../MD4Hash.h"
33 #include "../../Tag.h"
39 #if defined __GNUC__ && defined __GNUC_MINOR__
40 # if __GNUC__ > 3 || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))
41 # define __attribute_always_inline__ __attribute__((__always_inline__))
43 # define __attrbiute_always_inline__
46 # define __attribute_always_inline__
60 extern SDMODE g_stringDecodeMode
;
62 inline void SetStringsMode(SDMODE mode
) { g_stringDecodeMode
= mode
; }
63 inline SDMODE
GetStringsMode() { return g_stringDecodeMode
; }
65 wxString
MakePrintableString(const wxString
& str
);
67 #if !wxCHECK_VERSION(2, 9, 0)
68 inline __attribute_always_inline__
std::ostream
& operator<<(std::ostream
& x
, const wxString
& y
) { return x
<< (const char *)unicode2char(y
); }
70 inline std::ostream
& operator<<(std::ostream
& x
, const Kademlia::CUInt128
& y
) { return x
<< y
.ToHexString(); }
71 inline std::ostream
& operator<<(std::ostream
& x
, const CMD4Hash
& y
) { return x
<< y
.Encode(); }
73 inline wxString
hex(uint8_t value
) { return wxString::Format(wxT("0x%02x"), value
); }
74 inline wxString
hex(uint16_t value
) { return wxString::Format(wxT("0x%04x"), value
); }
75 inline wxString
hex(uint32_t value
) { return wxString::Format(wxT("0x%08x"), value
); }
77 inline void PrintByteArray(const void *buf
, unsigned int size
)
79 // #if wxCHECK_VERSION(2, 8, 4)
80 // cout << MakePrintableString(wxString::From8BitData(static_cast<const char *>(buf), size));
82 for (unsigned int i
= 0; i
< size
; i
++) {
83 cout
<< wxString::Format(wxT("%02X "), static_cast<const unsigned char *>(buf
)[i
]);
92 explicit CTimeT(time_t t
) { m_time
= t
; }
93 operator time_t() const { return m_time
; }
101 explicit CKadIP(uint32_t ip
) { m_ip
= ip
; }
102 operator uint32_t() const { return m_ip
; }
110 explicit CeD2kIP(uint32_t ip
) { m_ip
= ip
; }
111 operator uint32_t() const { return m_ip
; }
116 class CServerTag
: public CTag
119 CServerTag(const CTag
& tag
)
124 class CFriendTag
: public CTag
127 CFriendTag(const CTag
& tag
)
132 std::ostream
& operator<<(std::ostream
& x
, const CTimeT
& y
);
133 std::ostream
& operator<<(std::ostream
& x
, const CKadIP
& ip
);
134 std::ostream
& operator<<(std::ostream
& x
, const CeD2kIP
& ip
);
135 std::ostream
& operator<<(std::ostream
& x
, const CTag
& tag
);
136 std::ostream
& operator<<(std::ostream
& x
, const CServerTag
& tag
);
137 std::ostream
& operator<<(std::ostream
& x
, const CFriendTag
& tag
);
139 #endif /* FILEVIEW_PRINT_H */