Fix language getting reset to system default on saving preferences
[amule.git] / src / utils / fileview / Print.h
blob36d2aba5fca999411fa3ed06111a08af00ebf484
1 // -*- C++ -*-
2 // This file is part of the aMule Project.
3 //
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 )
6 //
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
9 // respective authors.
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.
20 //
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"
35 #include <cstdio>
36 #include <time.h>
37 #include <iostream>
39 #if defined __GNUC__ && defined __GNUC_MINOR__
40 # if __GNUC__ > 3 || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))
41 # define __attribute_always_inline__ __attribute__((__always_inline__))
42 # else
43 # define __attrbiute_always_inline__
44 # endif
45 #else
46 # define __attribute_always_inline__
47 #endif
49 using std::cout;
50 using std::cerr;
51 using std::endl;
53 enum SDMODE {
54 SD_DISPLAY,
55 SD_SAFE,
56 SD_UTF8,
57 SD_NONE
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); }
69 #endif
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));
81 // #else
82 for (unsigned int i = 0; i < size; i++) {
83 cout << wxString::Format(wxT("%02X "), static_cast<const unsigned char *>(buf)[i]);
85 // #endif
89 class CTimeT
91 public:
92 explicit CTimeT(time_t t) { m_time = t; }
93 operator time_t() const { return m_time; }
94 private:
95 time_t m_time;
98 class CKadIP
100 public:
101 explicit CKadIP(uint32_t ip) { m_ip = ip; }
102 operator uint32_t() const { return m_ip; }
103 private:
104 uint32_t m_ip;
107 class CeD2kIP
109 public:
110 explicit CeD2kIP(uint32_t ip) { m_ip = ip; }
111 operator uint32_t() const { return m_ip; }
112 private:
113 uint32_t m_ip;
116 class CServerTag : public CTag
118 public:
119 CServerTag(const CTag& tag)
120 : CTag(tag)
124 class CFriendTag : public CTag
126 public:
127 CFriendTag(const CTag& tag)
128 : 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 */