Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ace_wchar.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    ace_wchar.h
00006  *
00007  *  $Id: ace_wchar.h,v 1.1.1.3.2.1 2003/04/10 14:12:29 phil Exp $
00008  *
00009  *  @author Darrell Brunsch <brunsch@uci.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_WCHAR_H
00014 #define ACE_WCHAR_H
00015 
00016 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00017 # pragma once
00018 #endif /* ACE_LACKS_PRAGMA_ONCE */
00019 
00020 // These macros have been deprecated and should be replaced by their
00021 // ACE_TEXT_* equivalents.  These macros are just hacks and may not
00022 // completely provide the old functionality.
00023 #if defined (ACE_LEGACY_MODE)
00024 // Convert the old unicode indicators
00025 # if defined (ACE_HAS_MOSTLY_UNICODE_APIS)
00026 #   define ACE_USES_WCHAR
00027 # endif /* ACE_HAS_MOSTLY_UNICODE_APIS */
00028 # if defined (ACE_HAS_UNICODE)
00029 #   define ACE_HAS_WCHAR
00030 # endif /* ACE_HAS_UNICODE */
00031 
00032 // These are defined to get older stuff to compile
00033 // FUZZ: disable check_for_tchar
00034 # define ASYS_TCHAR ACE_TCHAR
00035 # define ASYS_TEXT ACE_TEXT
00036 # define ASYS_ONLY_MULTIBYTE_STRING ACE_TEXT_ALWAYS_CHAR
00037 # define ASYS_MULTIBYTE_STRING ACE_TEXT_CHAR_TO_TCHAR
00038 # define ASYS_WIDE_STRING ACE_TEXT_CHAR_TO_TCHAR
00039 # define ACE_WIDE_STRING ACE_TEXT_CHAR_TO_TCHAR
00040 
00041 # if defined (ACE_USES_WCHAR)
00042 #   define ASYS_ONLY_WIDE_STRING(STRING) STRING
00043 # else /* ACE_USES_WCHAR */
00044 #   define ASYS_ONLY_WIDE_STRING(STRING) \
00045            ACE_Ascii_To_Wide (STRING).wchar_rep ()
00046 # endif /* ACE_USES_WCHAR */
00047 
00048 # define ACE_TEXT_STRING ACE_TString
00049 
00050 #endif /* ACE_LEGACY_MODE */
00051 
00052 #if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
00053 #  include /**/ <wchar.h>
00054 #endif /* ACE_HAS_XPG4_MULTIBYPTE_CHAR */
00055 
00056 #if defined (ACE_HAS_WCHAR)
00057 # if defined (VXWORKS)
00058 #   include /**/ <types/vxTypes.h>  /* For wchar_t */
00059 #   include /**/ <stdlib.h>         /* For mbstowcs, etc. */
00060 #   include /**/ <string.h>         /* For strlen */
00061 #   define wint_t unsigned int      /* VxWorks has wchar_t but not wint_t */
00062 # elif defined (ACE_HAS_STANDARD_CPP_LIBRARY) && \
00063     (ACE_HAS_STANDARD_CPP_LIBRARY != 0)
00064 #   include /**/ <cwchar>
00065 #   include /**/ <cwctype>
00066 # elif defined (ACE_HAS_WINCE)
00067 #   include /**/ <wtypes.h>
00068 # elif !defined (__BORLANDC__)
00069 #   include /**/ <wchar.h>
00070 # endif /* ACE_HAS_STANDARD_CPP_LIBRARY */
00071 #endif /* ACE_HAS_WCHAR */
00072 
00073 #if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \
00074             (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0)
00075 using std::size_t;
00076 #endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */
00077 
00078 // Since MSVC uses ushort16 = wchar_t, it is the only one
00079 // that does not need this defined
00080 
00081 #if defined (ACE_HAS_WCHAR) && !defined (_MSC_VER)
00082 # if !defined (ACE_WSTRING_HAS_USHORT_SUPPORT)
00083 #  define ACE_WSTRING_HAS_USHORT_SUPPORT
00084 # endif /* ACE_WSTRING_HAS_USHORT_SUPPORT */
00085 #endif /* ACE_HAS_WCHAR && !_MSC_VER */
00086 
00087 // Set the default behaviour for ACE_TEXT_WIDE to use the L-prefix
00088 #if !defined (ACE_USES_L_PREFIX)
00089 # define ACE_USES_L_PREFIX 1
00090 #endif /* ACE_USES_L_PREFIX */
00091 
00092 // Define the unicode/wchar related macros correctly
00093 
00094 # if !defined (ACE_TEXT_WIDE)
00095 #  if (ACE_USES_L_PREFIX == 1)
00096 #    define ACE_TEXT_WIDE_I(STRING) L##STRING
00097 #  else /* ACE_USES_L_PREFIX */
00098 #    define ACE_TEXT_WIDE_I(STRING) STRING
00099 #  endif /* ACE_USES_L_PREFIX */
00100 #  define ACE_TEXT_WIDE(STRING) ACE_TEXT_WIDE_I (STRING)
00101 # endif /* ACE_TEXT_WIDE */
00102 
00103 #if defined (ACE_USES_WCHAR)
00104 typedef wchar_t ACE_TCHAR;
00105 typedef char ACE_ANTI_TCHAR;
00106 # define ACE_LIB_TEXT(STRING) ACE_TEXT_WIDE (STRING)
00107 # define ACE_TEXT_ALWAYS_CHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep ()
00108 # define ACE_TEXT_ALWAYS_WCHAR(STRING) STRING
00109 # define ACE_TEXT_CHAR_TO_TCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep ()
00110 # define ACE_TEXT_WCHAR_TO_TCHAR(STRING) STRING
00111 # define ACE_TEXT_ANTI_TO_TCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep ()
00112 #else /* ACE_USES_WCHAR */
00113 typedef char ACE_TCHAR;
00114 typedef wchar_t ACE_ANTI_TCHAR;
00115 # define ACE_LIB_TEXT(STRING) STRING
00116 # define ACE_TEXT_ALWAYS_CHAR(STRING) STRING
00117 # define ACE_TEXT_ALWAYS_WCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep ()
00118 # define ACE_TEXT_CHAR_TO_TCHAR(STRING) STRING
00119 # define ACE_TEXT_WCHAR_TO_TCHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep ()
00120 # define ACE_TEXT_ANTI_TO_TCHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep ()
00121 #endif /* ACE_USES_WCHAR */
00122 
00123 #if defined (ACE_LEGACY_MODE)
00124 # define ACE_TEXT TEXT
00125 #else /* ACE_LEGACY_MODE */
00126 # define ACE_TEXT ACE_LIB_TEXT
00127 #endif /* ACE_LEGACY_MODE */
00128 
00129 // The OS_String module defines some wide-char functions that are not
00130 // universally available. In particular, they're not part of the
00131 // XPG4 Worldwide Portability Interface wide-character string handling
00132 // functions. So, if ACE_HAS_XPG4_MULTIBYTE_CHAR is defined, note that
00133 // these functions are missing.
00134 #if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
00135 
00136 #  if !defined (ACE_LACKS_ITOW)
00137 #    define ACE_LACKS_ITOW
00138 #  endif
00139 
00140 #  if !defined (ACE_LACKS_WCSICMP)
00141 #    define ACE_LACKS_WCSICMP
00142 #  endif
00143 
00144 #  if !defined (ACE_LACKS_WCSNICMP)
00145 #    define ACE_LACKS_WCSNICMP
00146 #  endif
00147 
00148 #  if !defined (ACE_LACKS_WCSDUP)
00149 #    define ACE_LACKS_WCSDUP
00150 #  endif
00151 
00152 #endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */
00153 
00154 #if defined ACE_HAS_WCHAR
00155 /**
00156  * @class ACE_Wide_To_Ascii
00157  *
00158  * @brief A lightweight wchar* to char* string conversion class.
00159  *
00160  * The purpose of this class is to perform conversion from
00161  * wchar* to char* strings.  It is not intended for general
00162  * purpose use.
00163  */
00164 class ACE_Wide_To_Ascii
00165 {
00166 public:
00167   /// Ctor must take a wchar string.
00168   ACE_Wide_To_Ascii (const wchar_t *s);
00169 
00170   /// Dtor will free up the memory.
00171   ~ACE_Wide_To_Ascii (void);
00172 
00173   /// Return the internal char* representation.
00174   char *char_rep (void);
00175 
00176   /// Converts an wchar_t string to ascii and returns a new string.
00177   static char *convert (const wchar_t *wstr);
00178 
00179 private:
00180   /// Internal pointer to the converted string.
00181   char *s_;
00182 
00183   /// Disallow these operation.
00184   ACE_Wide_To_Ascii (void);
00185   ACE_Wide_To_Ascii (ACE_Wide_To_Ascii &);
00186   ACE_Wide_To_Ascii& operator= (ACE_Wide_To_Ascii &);
00187 };
00188 
00189 /**
00190  * @class ACE_Ascii_To_Wide
00191  *
00192  * @brief A lightweight char* to wchar* string conversion class.
00193  *
00194  * The purpose of this class is to perform conversion from
00195  * char* to wchar* strings.  It is not intended for general
00196  * purpose use.
00197  */
00198 class ACE_Ascii_To_Wide
00199 {
00200 public:
00201   /// Ctor must take a wchar string.
00202   ACE_Ascii_To_Wide (const char *s);
00203 
00204   /// Dtor will free up the memory.
00205   ~ACE_Ascii_To_Wide (void);
00206 
00207   /// Return the internal wchar* representation.
00208   wchar_t *wchar_rep (void);
00209 
00210   /// Converts an char string to unicode/wide and returns a new string.
00211   static wchar_t *convert (const char *str);
00212 
00213 private:
00214   /// Internal pointer to the converted string.
00215   wchar_t *s_;
00216 
00217   /// Disallow these operation.
00218   ACE_Ascii_To_Wide (void);
00219   ACE_Ascii_To_Wide (ACE_Ascii_To_Wide &);
00220   ACE_Ascii_To_Wide operator= (ACE_Ascii_To_Wide &);
00221 };
00222 
00223 #if defined (ACE_LEGACY_MODE)
00224 typedef ACE_Ascii_To_Wide ACE_OS_CString;
00225 typedef ACE_Wide_To_Ascii ACE_OS_WString;
00226 #endif /* ACE_LEGACY_MODE */
00227 
00228 #endif /* ACE_HAS_WCHAR */
00229 
00230 #if defined (ACE_WIN32)
00231 #if defined (ACE_USES_WCHAR)
00232 #define ACE_TEXT_SERVICE_TABLE_ENTRY             SERVICE_TABLE_ENTRYW
00233 #define ACE_TEXT_STARTUPINFO                     STARTUPINFOW
00234 #define ACE_TEXT_WIN32_FIND_DATA                 WIN32_FIND_DATAW
00235 
00236 #define ACE_TEXT_CreateEvent                     ::CreateEventW
00237 #define ACE_TEXT_CreateFile                      ::CreateFileW
00238 #define ACE_TEXT_CreateFileMapping               ::CreateFileMappingW
00239 #define ACE_TEXT_CreateMutex                     ::CreateMutexW
00240 #define ACE_TEXT_CreateProcess                   ::CreateProcessW
00241 #define ACE_TEXT_CreateSemaphore                 ::CreateSemaphoreW
00242 #define ACE_TEXT_CreateService                   ::CreateServiceW
00243 #define ACE_TEXT_ExpandEnvironmentStrings        ::ExpandEnvironmentStringsW
00244 #define ACE_TEXT_FindFirstChangeNotification     ::FindFirstChangeNotificationW
00245 #define ACE_TEXT_FindFirstFile                   ::FindFirstFileW
00246 #define ACE_TEXT_FindNextFile                    ::FindNextFileW
00247 #define ACE_TEXT_FormatMessage                   ::FormatMessageW
00248 #define ACE_TEXT_FreeEnvironmentStrings          ::FreeEnvironmentStringsW
00249 #define ACE_TEXT_GetComputerName                 ::GetComputerNameW
00250 #define ACE_TEXT_GetEnvironmentStrings           ::GetEnvironmentStringsW
00251 #define ACE_TEXT_GetModuleFileName               ::GetModuleFileNameW
00252 #define ACE_TEXT_GetTempPath                     ::GetTempPathW
00253 #define ACE_TEXT_GetUserName                     ::GetUserNameW
00254 #define ACE_TEXT_LoadLibrary                     ::LoadLibraryW
00255 #define ACE_TEXT_MoveFileEx                      ::MoveFileExW
00256 #define ACE_TEXT_WaitNamedPipe                   ::WaitNamedPipeW
00257 #define ACE_TEXT_OpenFileMapping                 ::OpenFileMappingW
00258 #define ACE_TEXT_OpenSCManager                   ::OpenSCManagerW
00259 #define ACE_TEXT_OpenService                     ::OpenServiceW
00260 #define ACE_TEXT_RegisterEventSource             ::RegisterEventSourceW
00261 #define ACE_TEXT_RegisterServiceCtrlHandler      ::RegisterServiceCtrlHandlerW
00262 #define ACE_TEXT_RegConnectRegistry              ::RegConnectRegistryW
00263 #define ACE_TEXT_RegCreateKeyEx                  ::RegCreateKeyExW
00264 #define ACE_TEXT_RegDeleteKey                    ::RegDeleteKeyW
00265 #define ACE_TEXT_RegDeleteValue                  ::RegDeleteValueW
00266 #define ACE_TEXT_RegEnumKeyEx                    ::RegEnumKeyExW
00267 #define ACE_TEXT_RegEnumValue                    ::RegEnumValueW
00268 #define ACE_TEXT_RegCreateKey                    ::RegCreateKeyW
00269 #define ACE_TEXT_RegOpenKey                      ::RegOpenKeyW
00270 #define ACE_TEXT_RegOpenKeyEx                    ::RegOpenKeyExW
00271 #define ACE_TEXT_RegQueryValueEx                 ::RegQueryValueExW
00272 #define ACE_TEXT_RegSetValueEx                   ::RegSetValueExW
00273 #define ACE_TEXT_ReportEvent                     ::ReportEventW
00274 #define ACE_TEXT_SearchPath                      ::SearchPathW
00275 #define ACE_TEXT_StartService                    ::StartServiceW
00276 #define ACE_TEXT_StartServiceCtrlDispatcher      ::StartServiceCtrlDispatcherW
00277 
00278 #else /* ACE_USES_WCHAR */
00279 #define ACE_TEXT_SERVICE_TABLE_ENTRY             SERVICE_TABLE_ENTRYA
00280 #define ACE_TEXT_STARTUPINFO                     STARTUPINFOA
00281 #define ACE_TEXT_WIN32_FIND_DATA                 WIN32_FIND_DATAA
00282 
00283 #define ACE_TEXT_CreateEvent                     ::CreateEventA
00284 #define ACE_TEXT_CreateFile                      ::CreateFileA
00285 #define ACE_TEXT_CreateFileMapping               ::CreateFileMappingA
00286 #define ACE_TEXT_CreateMutex                     ::CreateMutexA
00287 #define ACE_TEXT_CreateProcess                   ::CreateProcessA
00288 #define ACE_TEXT_CreateSemaphore                 ::CreateSemaphoreA
00289 #define ACE_TEXT_CreateService                   ::CreateServiceA
00290 #define ACE_TEXT_ExpandEnvironmentStrings        ::ExpandEnvironmentStringsA
00291 #define ACE_TEXT_FindFirstChangeNotification     ::FindFirstChangeNotificationA
00292 #define ACE_TEXT_FindFirstFile                   ::FindFirstFileA
00293 #define ACE_TEXT_FindNextFile                    ::FindNextFileA
00294 #define ACE_TEXT_FormatMessage                   ::FormatMessageA
00295 #define ACE_TEXT_FreeEnvironmentStrings          ::FreeEnvironmentStringsA
00296 #define ACE_TEXT_GetComputerName                 ::GetComputerNameA
00297 #define ACE_TEXT_GetEnvironmentStrings           ::GetEnvironmentStringsA
00298 #define ACE_TEXT_GetModuleFileName               ::GetModuleFileNameA
00299 #define ACE_TEXT_GetTempPath                     ::GetTempPathA
00300 #define ACE_TEXT_GetUserName                     ::GetUserNameA
00301 #define ACE_TEXT_LoadLibrary                     ::LoadLibraryA
00302 #define ACE_TEXT_MoveFileEx                      ::MoveFileExA
00303 #define ACE_TEXT_WaitNamedPipe                   ::WaitNamedPipeA
00304 #define ACE_TEXT_OpenFileMapping                 ::OpenFileMappingA
00305 #define ACE_TEXT_OpenSCManager                   ::OpenSCManagerA
00306 #define ACE_TEXT_OpenService                     ::OpenServiceA
00307 #define ACE_TEXT_RegisterEventSource             ::RegisterEventSourceA
00308 #define ACE_TEXT_RegisterServiceCtrlHandler      ::RegisterServiceCtrlHandlerA
00309 #define ACE_TEXT_RegConnectRegistry              ::RegConnectRegistryA
00310 #define ACE_TEXT_RegCreateKeyEx                  ::RegCreateKeyExA
00311 #define ACE_TEXT_RegDeleteKey                    ::RegDeleteKeyA
00312 #define ACE_TEXT_RegDeleteValue                  ::RegDeleteValueA
00313 #define ACE_TEXT_RegEnumKeyEx                    ::RegEnumKeyExA
00314 #define ACE_TEXT_RegEnumValue                    ::RegEnumValueA
00315 #define ACE_TEXT_RegCreateKey                    ::RegCreateKeyA
00316 #define ACE_TEXT_RegOpenKey                      ::RegOpenKeyA
00317 #define ACE_TEXT_RegOpenKeyEx                    ::RegOpenKeyExA
00318 #define ACE_TEXT_RegQueryValueEx                 ::RegQueryValueExA
00319 #define ACE_TEXT_RegSetValueEx                   ::RegSetValueExA
00320 #define ACE_TEXT_ReportEvent                     ::ReportEventA
00321 #define ACE_TEXT_SearchPath                      ::SearchPathA
00322 #define ACE_TEXT_StartService                    ::StartServiceA
00323 #define ACE_TEXT_StartServiceCtrlDispatcher      ::StartServiceCtrlDispatcherA
00324 #endif /* ACE_USES_WCHAR */
00325 #endif /* ACE_WIN32 */
00326 
00327 #include "ace/ace_wchar.inl"
00328 
00329 #endif /* ACE_WCHAR_H */

Generated on Mon Jun 16 11:19:02 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002