Pyrogenesis  trunk
UniDoubler.h
Go to the documentation of this file.
1 /* Copyright (C) 2009 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 // Make sure we have the argument (UNIDOUBLER_HEADER), and that we're not
19 // called from within another unidoubler execution (now that's just asking for
20 // trouble)
21 #if defined(UNIDOUBLER_HEADER) && !defined(IN_UNIDOUBLER)
22 
23 #define IN_UNIDOUBLER
24 
25 // When compiling CStr.cpp with PCH, the unidoubler stuff gets rather
26 // confusing because of all the nested inclusions, but this makes it work:
27 #undef CStr
28 
29 // First, set up the environment for the Unicode version
30 #define _UNICODE
31 #define CStr CStrW
32 #define tstring wstring
33 #define tchar wchar_t
34 #define _T(t) L ## t
35 
36 // Include the unidoubled file
37 #include UNIDOUBLER_HEADER
38 
39 // Clean up all the macros
40 #undef _UNICODE
41 #undef CStr
42 #undef tstring
43 #undef tchar
44 #undef _T
45 
46 
47 // Now include the 8-bit version under the name CStr8
48 #define CStr CStr8
49 #define tstring string
50 #define tchar char
51 #define _T(t) t
52 
53 #include UNIDOUBLER_HEADER
54 
55 // Clean up the macros again, to minimise namespace pollution
56 #undef CStr
57 #undef tstring
58 #undef tchar
59 #undef _T
60 
61 
62 // To please the file that originally include CStr.h, make CStr an alias for CStr8:
63 #define CStr CStr8
64 
65 #undef IN_UNIDOUBLER
66 #undef UNIDOUBLER_HEADER
67 
68 #endif