Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / ace_wchar.h
blob4488e9d20ecf08aaa99f392843500de33863a772
1 //* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file ace_wchar.h
7 * @author Darrell Brunsch <brunsch@uci.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_WCHAR_H
12 #define ACE_WCHAR_H
14 #include "ace/config-macros.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
21 # if !defined (ACE_HAS_WCHAR)
22 # define ACE_HAS_WCHAR
23 # endif
24 # include /**/ <wchar.h>
25 #endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */
27 #if defined (ACE_HAS_WCHAR)
28 # if defined (ACE_VXWORKS)
29 # include /**/ <types/vxTypes.h> /* For wchar_t */
30 # include /**/ <stdlib.h> /* For mbstowcs, etc. */
31 # include /**/ <string.h> /* For strlen */
32 # if !defined (__RTP__)
33 # define wint_t unsigned int /* VxWorks has wchar_t but not wint_t */
34 # else
35 # include /**/ <wchar.h>
36 # include /**/ <wctype.h>
37 # endif
38 # else
39 # include /**/ <cwchar>
40 # include /**/ <cwctype>
41 # endif /* ACE_VXWORKS */
42 #endif /* ACE_HAS_WCHAR */
44 #if defined (ACE_HAS_ICONV)
45 # include /**/ <iconv.h>
46 # if !defined (ACE_MAX_ICONV_BUFFER)
47 # define ACE_MAX_ICONV_BUFFER 16*1024
48 # endif
49 #endif /* ACE_HAS_ICONV */
51 #if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \
52 (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0)
53 using std::size_t;
54 #endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */
56 // This makes the somewhat dubious assumption that if a platform lacks
57 // a native wchar_t type, then it will typedef it as unsigned short.
58 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_NATIVE_WCHAR_T)
59 # if !defined (ACE_WSTRING_HAS_USHORT_SUPPORT)
60 # define ACE_WSTRING_HAS_USHORT_SUPPORT
61 # endif /* ACE_WSTRING_HAS_USHORT_SUPPORT */
62 #endif /* ACE_HAS_WCHAR && !ACE_LACKS_NATIVE_WCHAR_T */
64 // Set the default behaviour for ACE_TEXT_WIDE to use the L-prefix
65 #if !defined (ACE_USES_L_PREFIX)
66 # define ACE_USES_L_PREFIX 1
67 #endif /* ACE_USES_L_PREFIX */
69 // Define the unicode/wchar related macros correctly
71 # if !defined (ACE_TEXT_WIDE)
72 # if (ACE_USES_L_PREFIX == 1)
73 # define ACE_TEXT_WIDE_I(STRING) L##STRING
74 # else /* ACE_USES_L_PREFIX */
75 # define ACE_TEXT_WIDE_I(STRING) STRING
76 # endif /* ACE_USES_L_PREFIX */
77 # define ACE_TEXT_WIDE(STRING) ACE_TEXT_WIDE_I (STRING)
78 # endif /* ACE_TEXT_WIDE */
80 #if defined (ACE_USES_WCHAR)
81 typedef wchar_t ACE_TCHAR;
82 typedef char ACE_ANTI_TCHAR;
83 # define ACE_TEXT(STRING) ACE_TEXT_WIDE (STRING)
84 # define ACE_TEXT_ALWAYS_CHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep ()
85 # define ACE_TEXT_ALWAYS_WCHAR(STRING) STRING
86 # define ACE_TEXT_CHAR_TO_TCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep ()
87 # define ACE_TEXT_WCHAR_TO_TCHAR(STRING) STRING
88 # define ACE_TEXT_ANTI_TO_TCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep ()
89 # if !defined (ACE_WIN32)
90 # define ACE_TEXT_PRIs ACE_TEXT("ls")
91 # else
92 # define ACE_TEXT_PRIs ACE_TEXT("s")
93 # endif
94 #else /* ACE_USES_WCHAR */
95 typedef char ACE_TCHAR;
96 typedef wchar_t ACE_ANTI_TCHAR;
97 # define ACE_TEXT(STRING) STRING
98 # define ACE_TEXT_ALWAYS_CHAR(STRING) STRING
99 # define ACE_TEXT_ALWAYS_WCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep ()
100 # define ACE_TEXT_CHAR_TO_TCHAR(STRING) STRING
101 # define ACE_TEXT_WCHAR_TO_TCHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep ()
102 # define ACE_TEXT_ANTI_TO_TCHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep ()
103 # define ACE_TEXT_PRIs ACE_TEXT("s")
104 #endif /* ACE_USES_WCHAR */
106 // The OS_String module defines some wide-char functions that are not
107 // universally available. In particular, they're not part of the
108 // XPG4 Worldwide Portability Interface wide-character string handling
109 // functions. So, if ACE_HAS_XPG4_MULTIBYTE_CHAR is defined, note that
110 // these functions are missing.
111 #if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
113 # if !defined (ACE_LACKS_ITOW)
114 # define ACE_LACKS_ITOW
115 # endif
117 # if !defined (ACE_LACKS_WCSICMP)
118 # define ACE_LACKS_WCSICMP
119 # endif
121 # if !defined (ACE_LACKS_WCSNICMP)
122 # define ACE_LACKS_WCSNICMP
123 # endif
125 # if !defined (ACE_LACKS_WCSDUP)
126 # define ACE_LACKS_WCSDUP
127 # endif
129 #endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */
131 #if defined ACE_HAS_WCHAR
133 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
136 * @class ACE_Wide_To_Ascii
138 * @brief A lightweight wchar* to char* string conversion class.
140 * The purpose of this class is to perform conversion from
141 * wchar* to char* strings. It is not intended for general
142 * purpose use.
144 class ACE_Wide_To_Ascii
146 public:
147 /// Constructor must take a wchar string.
148 ACE_Wide_To_Ascii (const wchar_t *s);
150 /// Destructor will free up the memory.
151 ~ACE_Wide_To_Ascii ();
153 /// Return the internal char* representation.
154 char *char_rep ();
156 /// Converts an wchar_t string to ascii and returns a new string.
157 static char *convert (const wchar_t *wstr);
159 private:
160 /// Internal pointer to the converted string.
161 char *s_;
163 #if defined (ACE_HAS_ICONV)
164 static iconv_t ACE_Wide_To_Ascii_iconv_env;
165 #endif /* ACE_HAS_ICONV */
167 /// Disallow these operation.
168 ACE_Wide_To_Ascii ();
169 ACE_Wide_To_Ascii (ACE_Wide_To_Ascii &);
170 ACE_Wide_To_Ascii& operator= (ACE_Wide_To_Ascii &);
174 * @class ACE_Ascii_To_Wide
176 * @brief A lightweight char* to wchar* string conversion class.
178 * The purpose of this class is to perform conversion from
179 * char* to wchar* strings. It is not intended for general
180 * purpose use.
182 class ACE_Ascii_To_Wide
184 public:
185 /// Constructor must take a wchar string.
186 ACE_Ascii_To_Wide (const char *s);
188 /// Destructor will free up the memory.
189 ~ACE_Ascii_To_Wide ();
191 /// Return the internal wchar* representation.
192 wchar_t *wchar_rep ();
194 /// Converts an char string to unicode/wide and returns a new string.
195 static wchar_t *convert (const char *str);
197 private:
198 /// Internal pointer to the converted string.
199 wchar_t *s_;
201 #if defined (ACE_HAS_ICONV)
202 static iconv_t ACE_Ascii_To_Wide_iconv_env;
203 #endif /* ACE_HAS_ICONV */
205 /// Disallow these operation.
206 ACE_Ascii_To_Wide () = delete;
207 ACE_Ascii_To_Wide (ACE_Ascii_To_Wide &) = delete;
208 ACE_Ascii_To_Wide operator= (ACE_Ascii_To_Wide &) = delete;
211 ACE_END_VERSIONED_NAMESPACE_DECL
213 #endif /* ACE_HAS_WCHAR */
215 #if defined (ACE_WIN32)
216 #if defined (ACE_USES_WCHAR)
217 #define ACE_LPSTR LPWSTR
218 #define ACE_TEXT_SERVICE_TABLE_ENTRY SERVICE_TABLE_ENTRYW
219 #define ACE_TEXT_STARTUPINFO STARTUPINFOW
220 #define ACE_TEXT_WIN32_FIND_DATA WIN32_FIND_DATAW
221 #define ACE_TEXT_OSVERSIONINFO OSVERSIONINFOW
222 #define ACE_TEXT_EXPLICIT_ACCESS EXPLICIT_ACCESS_W
224 #define ACE_TEXT_CreateEvent ::CreateEventW
225 #define ACE_TEXT_CreateFile ::CreateFileW
226 #define ACE_TEXT_CreateFileMapping ::CreateFileMappingW
227 #define ACE_TEXT_CreateMutex ::CreateMutexW
228 #define ACE_TEXT_CreateProcess ::CreateProcessW
229 #define ACE_TEXT_CreateProcessAsUser ::CreateProcessAsUserW
230 #define ACE_TEXT_CreateSemaphore ::CreateSemaphoreW
231 #define ACE_TEXT_CreateService ::CreateServiceW
232 #define ACE_TEXT_ExpandEnvironmentStrings ::ExpandEnvironmentStringsW
233 #define ACE_TEXT_FindFirstChangeNotification ::FindFirstChangeNotificationW
234 #define ACE_TEXT_FindFirstFile ::FindFirstFileW
235 #define ACE_TEXT_FindNextFile ::FindNextFileW
236 #define ACE_TEXT_FormatMessage ::FormatMessageW
237 #define ACE_TEXT_FreeEnvironmentStrings ::FreeEnvironmentStringsW
238 #define ACE_TEXT_GetComputerName ::GetComputerNameW
239 #define ACE_TEXT_GetEnvironmentStrings ::GetEnvironmentStringsW
240 #define ACE_TEXT_GetFileAttributes ::GetFileAttributesW
241 #define ACE_TEXT_GetModuleFileName ::GetModuleFileNameW
242 #define ACE_TEXT_GetTempPath ::GetTempPathW
243 #define ACE_TEXT_GetUserName ::GetUserNameW
244 #define ACE_TEXT_GetUserNameEx ::GetUserNameExW
245 #define ACE_TEXT_GetVersionEx ::GetVersionExW
246 #define ACE_TEXT_LoadLibrary ::LoadLibraryW
247 #define ACE_TEXT_MoveFileEx ::MoveFileExW
248 #define ACE_TEXT_WaitNamedPipe ::WaitNamedPipeW
249 #define ACE_TEXT_OpenFileMapping ::OpenFileMappingW
250 #define ACE_TEXT_OpenSCManager ::OpenSCManagerW
251 #define ACE_TEXT_OpenService ::OpenServiceW
252 #define ACE_TEXT_OutputDebugString ::OutputDebugStringW
253 #define ACE_TEXT_RegisterEventSource ::RegisterEventSourceW
254 #define ACE_TEXT_RegisterServiceCtrlHandler ::RegisterServiceCtrlHandlerW
255 #define ACE_TEXT_RegConnectRegistry ::RegConnectRegistryW
256 #define ACE_TEXT_RegCreateKeyEx ::RegCreateKeyExW
257 #define ACE_TEXT_RegDeleteKey ::RegDeleteKeyW
258 #define ACE_TEXT_RegDeleteValue ::RegDeleteValueW
259 #define ACE_TEXT_RegEnumKeyEx ::RegEnumKeyExW
260 #define ACE_TEXT_RegEnumValue ::RegEnumValueW
261 #define ACE_TEXT_RegCreateKey ::RegCreateKeyW
262 #define ACE_TEXT_RegOpenKey ::RegOpenKeyW
263 #define ACE_TEXT_RegOpenKeyEx ::RegOpenKeyExW
264 #define ACE_TEXT_RegQueryValueEx ::RegQueryValueExW
265 #define ACE_TEXT_RegSetValueEx ::RegSetValueExW
266 #define ACE_TEXT_ReportEvent ::ReportEventW
267 #define ACE_TEXT_SearchPath ::SearchPathW
268 #define ACE_TEXT_StartService ::StartServiceW
269 #define ACE_TEXT_StartServiceCtrlDispatcher ::StartServiceCtrlDispatcherW
270 #define ACE_TEXT_SetFileSecurity ::SetFileSecurityW
271 #define ACE_TEXT_SetEntriesInAcl ::SetEntriesInAclW
272 #define ACE_TEXT_PdhExpandCounterPath ::PdhExpandCounterPathW
273 #define ACE_TEXT_PdhOpenQuery ::PdhOpenQueryW
274 #define ACE_TEXT_PdhAddCounter ::PdhAddCounterW
275 #define ACE_TEXT_gai_strerror ::gai_strerrorW
277 #else /* ACE_USES_WCHAR */
278 #define ACE_LPSTR LPSTR
279 #define ACE_TEXT_SERVICE_TABLE_ENTRY SERVICE_TABLE_ENTRYA
280 #define ACE_TEXT_STARTUPINFO STARTUPINFOA
281 #define ACE_TEXT_WIN32_FIND_DATA WIN32_FIND_DATAA
282 #define ACE_TEXT_OSVERSIONINFO OSVERSIONINFOA
283 #define ACE_TEXT_EXPLICIT_ACCESS EXPLICIT_ACCESS_A
285 #define ACE_TEXT_CreateEvent ::CreateEventA
286 #define ACE_TEXT_CreateFile ::CreateFileA
287 #define ACE_TEXT_CreateFileMapping ::CreateFileMappingA
288 #define ACE_TEXT_CreateMutex ::CreateMutexA
289 #define ACE_TEXT_CreateProcess ::CreateProcessA
290 #define ACE_TEXT_CreateProcessAsUser ::CreateProcessAsUserA
291 #define ACE_TEXT_CreateSemaphore ::CreateSemaphoreA
292 #define ACE_TEXT_CreateService ::CreateServiceA
293 #define ACE_TEXT_ExpandEnvironmentStrings ::ExpandEnvironmentStringsA
294 #define ACE_TEXT_FindFirstChangeNotification ::FindFirstChangeNotificationA
295 #define ACE_TEXT_FindFirstFile ::FindFirstFileA
296 #define ACE_TEXT_FindNextFile ::FindNextFileA
297 #define ACE_TEXT_FormatMessage ::FormatMessageA
298 #define ACE_TEXT_FreeEnvironmentStrings ::FreeEnvironmentStringsA
299 #define ACE_TEXT_GetComputerName ::GetComputerNameA
300 #define ACE_TEXT_GetEnvironmentStrings ::GetEnvironmentStringsA
301 #define ACE_TEXT_GetFileAttributes ::GetFileAttributesA
302 #define ACE_TEXT_GetModuleFileName ::GetModuleFileNameA
303 #define ACE_TEXT_GetTempPath ::GetTempPathA
304 #define ACE_TEXT_GetUserName ::GetUserNameA
305 #define ACE_TEXT_GetUserNameEx ::GetUserNameExA
306 #define ACE_TEXT_GetVersionEx ::GetVersionExA
307 #define ACE_TEXT_LoadLibrary ::LoadLibraryA
308 #define ACE_TEXT_MoveFileEx ::MoveFileExA
309 #define ACE_TEXT_WaitNamedPipe ::WaitNamedPipeA
310 #define ACE_TEXT_OpenFileMapping ::OpenFileMappingA
311 #define ACE_TEXT_OpenSCManager ::OpenSCManagerA
312 #define ACE_TEXT_OpenService ::OpenServiceA
313 #define ACE_TEXT_OutputDebugString ::OutputDebugStringA
314 #define ACE_TEXT_RegisterEventSource ::RegisterEventSourceA
315 #define ACE_TEXT_RegisterServiceCtrlHandler ::RegisterServiceCtrlHandlerA
316 #define ACE_TEXT_RegConnectRegistry ::RegConnectRegistryA
317 #define ACE_TEXT_RegCreateKeyEx ::RegCreateKeyExA
318 #define ACE_TEXT_RegDeleteKey ::RegDeleteKeyA
319 #define ACE_TEXT_RegDeleteValue ::RegDeleteValueA
320 #define ACE_TEXT_RegEnumKeyEx ::RegEnumKeyExA
321 #define ACE_TEXT_RegEnumValue ::RegEnumValueA
322 #define ACE_TEXT_RegCreateKey ::RegCreateKeyA
323 #define ACE_TEXT_RegOpenKey ::RegOpenKeyA
324 #define ACE_TEXT_RegOpenKeyEx ::RegOpenKeyExA
325 #define ACE_TEXT_RegQueryValueEx ::RegQueryValueExA
326 #define ACE_TEXT_RegSetValueEx ::RegSetValueExA
327 #define ACE_TEXT_ReportEvent ::ReportEventA
328 #define ACE_TEXT_SearchPath ::SearchPathA
329 #define ACE_TEXT_StartService ::StartServiceA
330 #define ACE_TEXT_StartServiceCtrlDispatcher ::StartServiceCtrlDispatcherA
331 #define ACE_TEXT_SetFileSecurity ::SetFileSecurityA
332 #define ACE_TEXT_SetEntriesInAcl ::SetEntriesInAclA
333 #define ACE_TEXT_PdhExpandCounterPath ::PdhExpandCounterPathA
334 #define ACE_TEXT_PdhOpenQuery ::PdhOpenQueryA
335 #define ACE_TEXT_PdhAddCounter ::PdhAddCounterA
336 #define ACE_TEXT_gai_strerror ::gai_strerrorA
337 #endif /* ACE_USES_WCHAR */
338 #endif /* ACE_WIN32 */
340 #include "ace/ace_wchar.inl"
342 #endif /* ACE_WCHAR_H */