Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
UniDoubler.h
Go to the documentation of this file.
1/* Copyright (C) 2021 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#ifndef _UNICODE
31#define _UNICODE
32#endif
33#define CStr CStrW
34#define tstring wstring
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
44// Now include the 8-bit version under the name CStr8
45#define CStr CStr8
46#define tstring string
47
48#include UNIDOUBLER_HEADER
49
50// Clean up the macros again, to minimise namespace pollution
51#undef CStr
52#undef tstring
53
54// To please the file that originally include CStr.h, make CStr an alias for CStr8:
55#define CStr CStr8
56
57#undef IN_UNIDOUBLER
58#undef UNIDOUBLER_HEADER
59
60#endif