OS_NS_string.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // OS_NS_string.inl,v 1.17 2006/05/16 13:08:55 jwillemsen Exp
00004 
00005 // OS_NS_wchar.h is only needed to get the emulation methods.
00006 // Perhaps they should be moved.  dhinton
00007 #include "ace/OS_NS_wchar.h"
00008 #include "ace/os_include/os_string.h"
00009 
00010 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00011 
00012 ACE_INLINE const void *
00013 ACE_OS::memchr (const void *s, int c, size_t len)
00014 {
00015 #if defined (ACE_HAS_MEMCHR)
00016   return ::memchr (s, c, len);
00017 #else /* ACE_HAS_MEMCHR */
00018   return ACE_OS::memchr_emulation (s, c, len);
00019 #endif /* ACE_HAS_MEMCHR */
00020 }
00021 
00022 ACE_INLINE void *
00023 ACE_OS::memchr (void *s, int c, size_t len)
00024 {
00025   return const_cast<void *> (ACE_OS::memchr (static_cast<const void *> (s),
00026                                              c,
00027                                              len));
00028 }
00029 
00030 ACE_INLINE int
00031 ACE_OS::memcmp (const void *t, const void *s, size_t len)
00032 {
00033   return ::memcmp (t, s, len);
00034 }
00035 
00036 ACE_INLINE void *
00037 ACE_OS::memcpy (void *t, const void *s, size_t len)
00038 {
00039 #if defined (ACE_HAS_MEMCPY_LOOP_UNROLL)
00040   return fast_memcpy (t, s, len);
00041 #else
00042   return ::memcpy (t, s, len);
00043 #endif /* ACE_HAS_MEMCPY_LOOP_UNROLL */
00044 }
00045 
00046 ACE_INLINE void *
00047 ACE_OS::memmove (void *t, const void *s, size_t len)
00048 {
00049   return ::memmove (t, s, len);
00050 }
00051 
00052 ACE_INLINE void *
00053 ACE_OS::memset (void *s, int c, size_t len)
00054 {
00055   return ::memset (s, c, len);
00056 }
00057 
00058 ACE_INLINE char *
00059 ACE_OS::strcat (char *s, const char *t)
00060 {
00061   return ::strcat (s, t);
00062 }
00063 
00064 #if defined (ACE_HAS_WCHAR)
00065 ACE_INLINE wchar_t *
00066 ACE_OS::strcat (wchar_t *s, const wchar_t *t)
00067 {
00068 #  if defined (ACE_LACKS_WCSCAT)
00069   return ACE_OS::wcscat_emulation (s, t);
00070 #  else /* ACE_LACKS_WCSCAT */
00071   return ::wcscat (s, t);
00072 #  endif /* ACE_LACKS_WCSCAT */
00073 }
00074 #endif /* ACE_HAS_WCHAR */
00075 
00076 ACE_INLINE const char *
00077 ACE_OS::strchr (const char *s, int c)
00078 {
00079 #if defined (ACE_LACKS_STRCHR)
00080   return ACE_OS::strchr_emulation (s, c);
00081 #else  /* ! ACE_LACKS_STRCHR */
00082   return (const char *) ::strchr (s, c);
00083 #endif /* ACE_LACKS_STRCHR */
00084 }
00085 
00086 #if defined (ACE_HAS_WCHAR)
00087 ACE_INLINE const wchar_t *
00088 ACE_OS::strchr (const wchar_t *s, wchar_t c)
00089 {
00090 #  if defined (ACE_LACKS_WCSCHR)
00091   return ACE_OS::wcschr_emulation (s, c);
00092 #  else /* ACE_LACKS_WCSCHR */
00093   return ::wcschr (s, c);
00094 #  endif /* ACE_LACKS_WCSCHR */
00095 }
00096 #endif /* ACE_HAS_WCHAR */
00097 
00098 ACE_INLINE char *
00099 ACE_OS::strchr (char *s, int c)
00100 {
00101   return ::strchr (s, c);
00102 }
00103 
00104 #if defined (ACE_HAS_WCHAR)
00105 ACE_INLINE wchar_t *
00106 ACE_OS::strchr (wchar_t *s, wchar_t c)
00107 {
00108   return
00109     const_cast<wchar_t *> (ACE_OS::strchr (const_cast<const wchar_t *> (s),
00110                                            c));
00111 }
00112 #endif /* ACE_HAS_WCHAR */
00113 
00114 ACE_INLINE int
00115 ACE_OS::strcmp (const char *s, const char *t)
00116 {
00117   return ::strcmp (s, t);
00118 }
00119 
00120 ACE_INLINE int
00121 ACE_OS::strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
00122 {
00123 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
00124   return ACE_OS::wcscmp_emulation (s, t);
00125 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00126   return ::wcscmp (s, t);
00127 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00128 }
00129 
00130 ACE_INLINE char *
00131 ACE_OS::strcpy (char *s, const char *t)
00132 {
00133   return ::strcpy (s, t);
00134 }
00135 
00136 #if defined (ACE_HAS_WCHAR)
00137 ACE_INLINE wchar_t *
00138 ACE_OS::strcpy (wchar_t *s, const wchar_t *t)
00139 {
00140 #  if defined (ACE_LACKS_WCSCPY)
00141   return ACE_OS::wcscpy_emulation (s, t);
00142 #  else /* ACE_LACKS_WCSCPY */
00143   return ::wcscpy (s, t);
00144 #  endif /* ACE_LACKS_WCSCPY */
00145 }
00146 #endif /* ACE_HAS_WCHAR */
00147 
00148 ACE_INLINE size_t
00149 ACE_OS::strcspn (const char *s, const char *reject)
00150 {
00151   return ::strcspn (s, reject);
00152 }
00153 
00154 #if defined (ACE_HAS_WCHAR)
00155 ACE_INLINE size_t
00156 ACE_OS::strcspn (const wchar_t *s, const wchar_t *reject)
00157 {
00158 #  if defined (ACE_LACKS_WCSCSPN)
00159   return ACE_OS::wcscspn_emulation (s, reject);
00160 #  else /* ACE_LACKS_WCSCSPN */
00161   return ::wcscspn (s, reject);
00162 #  endif /* ACE_LACKS_WCSCSPN */
00163 }
00164 #endif /* ACE_HAS_WCHAR */
00165 
00166 ACE_INLINE char *
00167 ACE_OS::strdup (const char *s)
00168 {
00169 #  if (defined (ACE_LACKS_STRDUP) && !defined(ACE_STRDUP_EQUIVALENT)) \
00170   || defined (ACE_HAS_STRDUP_EMULATION)
00171   return ACE_OS::strdup_emulation (s);
00172 #  elif defined (ACE_STRDUP_EQUIVALENT)
00173   return ACE_STRDUP_EQUIVALENT (s);
00174 #  elif defined (ACE_HAS_NONCONST_STRDUP)
00175   return ::strdup (const_cast<char *> (s));
00176 #else
00177   return ::strdup (s);
00178 #  endif /* (ACE_LACKS_STRDUP && !ACE_STRDUP_EQUIVALENT) || ... */
00179 }
00180 
00181 #if defined (ACE_HAS_WCHAR)
00182 ACE_INLINE wchar_t *
00183 ACE_OS::strdup (const wchar_t *s)
00184 {
00185 #  if (defined (ACE_LACKS_WCSDUP) && !defined (ACE_WCSDUP_EQUIVALENT)) \
00186   || defined (ACE_HAS_WCSDUMP_EMULATION)
00187   return ACE_OS::strdup_emulation (s);
00188 #  elif defined (ACE_WCSDUP_EQUIVALENT)
00189   return ACE_WCSDUP_EQUIVALENT (s);
00190 #  elif defined (ACE_HAS_NONCONST_WCSDUP)
00191   return ::wcsdup (const_cast<wchar_t*> (s));
00192 #  else
00193   return ::wcsdup (s);
00194 #  endif /* (ACE_LACKS_WCSDUP && !ACE_WCSDUP_EQUIVALENT) || ... */
00195 }
00196 #endif /* ACE_HAS_WCHAR */
00197 
00198 ACE_INLINE size_t
00199 ACE_OS::strlen (const char *s)
00200 {
00201   return ::strlen (s);
00202 }
00203 
00204 ACE_INLINE size_t
00205 ACE_OS::strlen (const ACE_WCHAR_T *s)
00206 {
00207 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
00208   return ACE_OS::wcslen_emulation (s);
00209 # else  /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00210   return ::wcslen (s);
00211 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00212 }
00213 
00214 ACE_INLINE char *
00215 ACE_OS::strncat (char *s, const char *t, size_t len)
00216 {
00217   return ::strncat (s, t, len);
00218 }
00219 
00220 ACE_INLINE ACE_WCHAR_T *
00221 ACE_OS::strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00222 {
00223 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
00224   return ACE_OS::wcsncat_emulation (s, t, len);
00225 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00226   return ::wcsncat (s, t, len);
00227 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00228 }
00229 
00230 ACE_INLINE char *
00231 ACE_OS::strnchr (char *s, int c, size_t len)
00232 {
00233   return const_cast<char *> (ACE_OS::strnchr (static_cast<const char *> (s),
00234                                               c,
00235                                               len));
00236 }
00237 
00238 ACE_INLINE ACE_WCHAR_T *
00239 ACE_OS::strnchr (ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
00240 {
00241   return
00242     const_cast<ACE_WCHAR_T *> (ACE_OS::strnchr (
00243                                  const_cast<const ACE_WCHAR_T *> (s),
00244                                  c,
00245                                  len));
00246 }
00247 
00248 ACE_INLINE int
00249 ACE_OS::strncmp (const char *s, const char *t, size_t len)
00250 {
00251   return ::strncmp (s, t, len);
00252 }
00253 
00254 ACE_INLINE int
00255 ACE_OS::strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00256 {
00257 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
00258   return ACE_OS::wcsncmp_emulation (s, t, len);
00259 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00260   return ::wcsncmp (s, t, len);
00261 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00262 }
00263 
00264 ACE_INLINE char *
00265 ACE_OS::strncpy (char *s, const char *t, size_t len)
00266 {
00267   return ::strncpy (s, t, len);
00268 }
00269 
00270 ACE_INLINE ACE_WCHAR_T *
00271 ACE_OS::strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00272 {
00273 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
00274   return ACE_OS::wcsncpy_emulation (s, t, len);
00275 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00276   return ::wcsncpy (s, t, len);
00277 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00278 }
00279 
00280 ACE_INLINE size_t
00281 ACE_OS::strnlen (const char *s, size_t maxlen)
00282 {
00283 #if defined (ACE_HAS_STRNLEN)
00284   return ::strnlen (s, maxlen);
00285 #else /* ACE_HAS_STRNLEN */
00286   size_t i;
00287   for (i = 0; i < maxlen; ++i)
00288     if (s[i] == '\0')
00289       break;
00290   return i;
00291 #endif /* ACE_HAS_STRNLEN */
00292 }
00293 
00294 ACE_INLINE size_t
00295 ACE_OS::strnlen (const ACE_WCHAR_T *s, size_t maxlen)
00296 {
00297 #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN)
00298   return wcsnlen (s, maxlen);
00299 #else /* ACE_HAS_WCSNLEN */
00300   size_t i;
00301   for (i = 0; i < maxlen; ++i)
00302     if (s[i] == '\0')
00303       break;
00304   return i;
00305 #endif /* ACE_HAS_WCSNLEN */
00306 }
00307 
00308 ACE_INLINE char *
00309 ACE_OS::strnstr (char *s, const char *t, size_t len)
00310 {
00311   return (char *) ACE_OS::strnstr ((const char *) s, t, len);
00312 }
00313 
00314 ACE_INLINE ACE_WCHAR_T *
00315 ACE_OS::strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00316 {
00317   return
00318     const_cast<ACE_WCHAR_T *> (ACE_OS::strnstr (
00319                                  static_cast<const ACE_WCHAR_T *> (s),
00320                                  t,
00321                                  len));
00322 }
00323 
00324 ACE_INLINE const char *
00325 ACE_OS::strpbrk (const char *s1, const char *s2)
00326 {
00327 #if defined (ACE_LACKS_STRPBRK)
00328   return ACE_OS::strpbrk_emulation (s1, s2);
00329 #else  /* ACE_LACKS_STRPBRK */
00330   return (const char *) ::strpbrk (s1, s2);
00331 #endif /* ACE_LACKS_STRPBRK */
00332 }
00333 
00334 #if defined (ACE_HAS_WCHAR)
00335 ACE_INLINE const wchar_t *
00336 ACE_OS::strpbrk (const wchar_t *s, const wchar_t *t)
00337 {
00338 #  if defined (ACE_LACKS_WCSPBRK)
00339   return ACE_OS::wcspbrk_emulation (s, t);
00340 #  else /* ACE_LACKS_WCSPBRK */
00341   return ::wcspbrk (s, t);
00342 #  endif /* ACE_LACKS_WCSPBRK */
00343 }
00344 #endif /* ACE_HAS_WCHAR */
00345 
00346 ACE_INLINE char *
00347 ACE_OS::strpbrk (char *s1, const char *s2)
00348 {
00349 #if defined (ACE_LACKS_STRPBRK)
00350   return ACE_OS::strpbrk_emulation (s1, s2);
00351 #else /* ACE_LACKS_STRPBRK */
00352   return ::strpbrk (s1, s2);
00353 #endif /* ACE_LACKS_STRPBRK */
00354 }
00355 
00356 #if defined (ACE_HAS_WCHAR)
00357 ACE_INLINE wchar_t *
00358 ACE_OS::strpbrk (wchar_t *s, const wchar_t *t)
00359 {
00360   return const_cast<wchar_t *> (ACE_OS::strpbrk (
00361                                   const_cast<const wchar_t *> (s), t));
00362 }
00363 #endif /* ACE_HAS_WCHAR */
00364 
00365 ACE_INLINE const char *
00366 ACE_OS::strrchr (const char *s, int c)
00367 {
00368 #if defined (ACE_LACKS_STRRCHR)
00369   return ACE_OS::strrchr_emulation (s, c);
00370 #else  /* ! ACE_LACKS_STRRCHR */
00371   return (const char *) ::strrchr (s, c);
00372 #endif /* ! ACE_LACKS_STRRCHR */
00373 }
00374 
00375 #if defined (ACE_HAS_WCHAR)
00376 ACE_INLINE const wchar_t *
00377 ACE_OS::strrchr (const wchar_t *s, wchar_t c)
00378 {
00379 #if defined (ACE_LACKS_WCSRCHR)
00380   return ACE_OS::wcsrchr_emulation (s, c);
00381 #else /* ! ACE_LACKS_WCSRCHR */
00382   return const_cast <const wchar_t *> (::wcsrchr (s, c));
00383 #endif /* ! ACE_LACKS_WCSRCHR */
00384 }
00385 #endif /* ACE_HAS_WCHAR */
00386 
00387 ACE_INLINE char *
00388 ACE_OS::strrchr (char *s, int c)
00389 {
00390 #if defined (ACE_LACKS_STRRCHR)
00391   return ACE_OS::strrchr_emulation (s, c);
00392 #else  /* ! ACE_LACKS_STRRCHR */
00393   return ::strrchr (s, c);
00394 #endif /* ! ACE_LACKS_STRRCHR */
00395 }
00396 
00397 #if defined (ACE_HAS_WCHAR)
00398 ACE_INLINE wchar_t *
00399 ACE_OS::strrchr (wchar_t *s, wchar_t c)
00400 {
00401   return const_cast<wchar_t *> (ACE_OS::strrchr (
00402                      const_cast<const wchar_t *> (s), c));
00403 }
00404 #endif /* ACE_HAS_WCHAR */
00405 
00406 ACE_INLINE size_t
00407 ACE_OS::strspn (const char *s, const char *t)
00408 {
00409 #if defined (ACE_LACKS_STRSPN)
00410   return ACE_OS::strspn_emulation (s, t);
00411 #else /* ACE_LACKS_STRSPN */
00412   return ::strspn (s, t);
00413 #endif /* ACE_LACKS_STRSPN */
00414 }
00415 
00416 #if defined (ACE_HAS_WCHAR)
00417 ACE_INLINE size_t
00418 ACE_OS::strspn (const wchar_t *s, const wchar_t *t)
00419 {
00420 #  if defined (ACE_LACKS_WCSSPN)
00421   return ACE_OS::wcsspn_emulation (s, t);
00422 #  else /* ACE_LACKS_WCSSPN */
00423   return ::wcsspn (s, t);
00424 #  endif /* ACE_LACKS_WCSSPN */
00425 }
00426 #endif /* ACE_HAS_WCHAR */
00427 
00428 ACE_INLINE const char *
00429 ACE_OS::strstr (const char *s, const char *t)
00430 {
00431   return (const char *) ::strstr (s, t);
00432 }
00433 
00434 #if defined (ACE_HAS_WCHAR)
00435 ACE_INLINE const wchar_t *
00436 ACE_OS::strstr (const wchar_t *s, const wchar_t *t)
00437 {
00438 #  if defined (ACE_LACKS_WCSSTR)
00439   return ACE_OS::wcsstr_emulation (s, t);
00440 #  elif defined (HPUX)
00441   return const_cast <const wchar_t *> (::wcswcs (s, t));
00442 #  else /* ACE_LACKS_WCSSTR */
00443   return const_cast <const wchar_t *> (::wcsstr (s, t));
00444 #  endif /* ACE_LACKS_WCSSTR */
00445 }
00446 #endif /* ACE_HAS_WCHAR */
00447 
00448 ACE_INLINE char *
00449 ACE_OS::strstr (char *s, const char *t)
00450 {
00451   return ::strstr (s, t);
00452 }
00453 
00454 #if defined (ACE_HAS_WCHAR)
00455 ACE_INLINE wchar_t *
00456 ACE_OS::strstr (wchar_t *s, const wchar_t *t)
00457 {
00458 #  if defined (ACE_LACKS_WCSSTR)
00459   return ACE_OS::wcsstr_emulation (s, t);
00460 #  elif defined (HPUX)
00461   return ::wcswcs (s, t);
00462 #  else /* ACE_LACKS_WCSSTR */
00463   return ::wcsstr (s, t);
00464 #  endif /* ACE_LACKS_WCSSTR */
00465 }
00466 #endif /* ACE_HAS_WCHAR */
00467 
00468 ACE_INLINE char *
00469 ACE_OS::strtok (char *s, const char *tokens)
00470 {
00471   return ::strtok (s, tokens);
00472 }
00473 
00474 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK)
00475 ACE_INLINE wchar_t *
00476 ACE_OS::strtok (wchar_t *s, const wchar_t *tokens)
00477 {
00478 #if defined (ACE_HAS_3_PARAM_WCSTOK)
00479   static wchar_t *lasts;
00480   return ::wcstok (s, tokens, &lasts);
00481 #else
00482   return ::wcstok (s, tokens);
00483 #endif /* ACE_HAS_3_PARAM_WCSTOK */
00484 }
00485 #endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOK */
00486 
00487 ACE_INLINE char *
00488 ACE_OS::strtok_r (char *s, const char *tokens, char **lasts)
00489 {
00490 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00491   return ::strtok_r (s, tokens, lasts);
00492 #else
00493   return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00494 #endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */
00495 }
00496 
00497 #if defined (ACE_HAS_WCHAR)
00498 ACE_INLINE wchar_t*
00499 ACE_OS::strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
00500 {
00501 #if defined (ACE_LACKS_WCSTOK)
00502     return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00503 #else
00504 #  if defined (ACE_HAS_3_PARAM_WCSTOK)
00505     return ::wcstok (s, tokens, lasts);
00506 #  else /* ACE_HAS_3_PARAM_WCSTOK */
00507     *lasts = ::wcstok (s, tokens);
00508     return *lasts;
00509 #  endif /* ACE_HAS_3_PARAM_WCSTOK */
00510 #endif  /* ACE_LACKS_WCSTOK */
00511 }
00512 #endif  // ACE_HAS_WCHAR
00513 
00514 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:58 2006 for ACE by doxygen 1.3.6