00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef ACE_OS_STRING_H
00017 #define ACE_OS_STRING_H
00018 #include "ace/pre.h"
00019
00020 #include "ace/OS_Export.h"
00021
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif
00025
00026 #include "ace/Basic_Types.h"
00027
00028 #if !defined (ACE_HAS_WINCE)
00029 #include <stddef.h>
00030 #endif // ACE_HAS_WINCE
00031
00032 #if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \
00033 (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0)
00034 using std::size_t;
00035 using std::wint_t;
00036 #endif
00037
00038
00039
00040
00041
00042
00043 class ACE_OS_Export ACE_OS_String
00044 {
00045 public:
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 static const void *memchr (const void *s, int c, size_t len);
00057
00058
00059 static void *memchr (void *s, int c, size_t len);
00060
00061
00062 static int memcmp (const void *t, const void *s, size_t len);
00063
00064
00065 static void *memcpy (void *t, const void *s, size_t len);
00066
00067
00068 static void *memmove (void *t, const void *s, size_t len);
00069
00070
00071 static void *memset (void *s, int c, size_t len);
00072
00073
00074 static char *strcat (char *s, const char *t);
00075
00076 #if defined (ACE_HAS_WCHAR)
00077
00078 static wchar_t *strcat (wchar_t *s, const wchar_t *t);
00079 #endif
00080
00081
00082
00083 static const char *strchr (const char *s, int c);
00084
00085 #if defined (ACE_HAS_WCHAR)
00086
00087
00088 static const wchar_t *strchr (const wchar_t *s, wint_t c);
00089 #endif
00090
00091
00092 static char *strchr (char *s, int c);
00093
00094 #if defined (ACE_HAS_WCHAR)
00095
00096 static wchar_t *strchr (wchar_t *s, wint_t c);
00097 #endif
00098
00099
00100 static int strcmp (const char *s, const char *t);
00101
00102
00103 static int strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t);
00104
00105
00106 static char *strcpy (char *s, const char *t);
00107
00108 #if defined (ACE_HAS_WCHAR)
00109
00110 static wchar_t *strcpy (wchar_t *s, const wchar_t *t);
00111 #endif
00112
00113
00114
00115 static size_t strcspn (const char *s, const char *reject);
00116
00117 #if defined (ACE_HAS_WCHAR)
00118
00119
00120 static size_t strcspn (const wchar_t *s, const wchar_t *reject);
00121 #endif
00122
00123
00124 static char *strerror (int errnum);
00125
00126
00127 static size_t strlen (const char *s);
00128
00129
00130 static size_t strlen (const ACE_WCHAR_T *s);
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 static size_t strnlen (const char *s, size_t maxlen);
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 static size_t strnlen (const ACE_WCHAR_T *s, size_t maxlen);
00153
00154
00155 static char *strncat (char *s, const char *t, size_t len);
00156
00157
00158 static ACE_WCHAR_T *strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len);
00159
00160
00161 static int strncmp (const char *s, const char *t, size_t len);
00162
00163
00164 static int strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len);
00165
00166
00167 static char *strncpy (char *s, const char *t, size_t len);
00168
00169
00170 static ACE_WCHAR_T *strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len);
00171
00172
00173 static const char *strpbrk (const char *s1, const char *s2);
00174
00175 #if defined (ACE_HAS_WCHAR)
00176
00177 static const wchar_t *strpbrk (const wchar_t *s1, const wchar_t *s2);
00178 #endif
00179
00180
00181 static char *strpbrk (char *s1, const char *s2);
00182
00183 #if defined (ACE_HAS_WCHAR)
00184
00185 static wchar_t *strpbrk (wchar_t *s1, const wchar_t *s2);
00186 #endif
00187
00188
00189
00190 static const char *strrchr (const char *s, int c);
00191
00192 #if defined (ACE_HAS_WCHAR)
00193
00194
00195 static const wchar_t *strrchr (const wchar_t *s, wint_t c);
00196 #endif
00197
00198
00199 static char *strrchr (char *s, int c);
00200
00201 #if defined (ACE_HAS_WCHAR)
00202
00203 static wchar_t *strrchr (wchar_t *s, wint_t c);
00204 #endif
00205
00206
00207
00208 static size_t strspn (const char *s1, const char *s2);
00209
00210 #if defined (ACE_HAS_WCHAR)
00211
00212
00213 static size_t strspn (const wchar_t *s1, const wchar_t *s2);
00214 #endif
00215
00216
00217
00218 static const char *strstr (const char *s, const char *t);
00219
00220 #if defined (ACE_HAS_WCHAR)
00221
00222
00223 static const wchar_t *strstr (const wchar_t *s, const wchar_t *t);
00224 #endif
00225
00226
00227 static char *strstr (char *s, const char *t);
00228
00229 #if defined (ACE_HAS_WCHAR)
00230
00231 static wchar_t *strstr (wchar_t *s, const wchar_t *t);
00232 #endif
00233
00234
00235 static char *strtok (char *s, const char *tokens);
00236
00237 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK)
00238
00239 static wchar_t *strtok (wchar_t *s, const wchar_t *tokens);
00240 #endif
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 static int ace_isprint (const ACE_TCHAR c);
00260
00261
00262 static int ace_isspace (const ACE_TCHAR c);
00263
00264
00265 static int to_lower (int c);
00266
00267 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_TOWLOWER)
00268
00269 static wint_t to_lower (wint_t c);
00270 #endif
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 static char *itoa (int value, char *string, int radix);
00283
00284 #if defined (ACE_HAS_WCHAR)
00285
00286 static wchar_t *itoa (int value, wchar_t *string, int radix);
00287 #endif
00288
00289
00290 static int strcasecmp (const char *s, const char *t);
00291
00292 #if defined (ACE_HAS_WCHAR)
00293
00294 static int strcasecmp (const wchar_t *s, const wchar_t *t);
00295 #endif
00296
00297
00298
00299 static const char *strnchr (const char *s, int c, size_t len);
00300
00301
00302
00303 static const ACE_WCHAR_T *strnchr (const ACE_WCHAR_T *s, ACE_WINT_T c, size_t len);
00304
00305
00306 static char *strnchr (char *s, int c, size_t len);
00307
00308
00309 static ACE_WCHAR_T *strnchr (ACE_WCHAR_T *s, ACE_WINT_T c, size_t len);
00310
00311
00312 static int strncasecmp (const char *s, const char *t, size_t len);
00313
00314 #if defined (ACE_HAS_WCHAR)
00315
00316 static int strncasecmp (const wchar_t *s, const wchar_t *t, size_t len);
00317 #endif
00318
00319
00320
00321 static char *strecpy (char *des, const char *src);
00322
00323 #if defined (ACE_HAS_WCHAR)
00324
00325
00326 static wchar_t *strecpy (wchar_t *s, const wchar_t *t);
00327 #endif
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 static char *strsncpy (char *dst,
00346 const char *src,
00347 size_t maxlen);
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 static ACE_WCHAR_T *strsncpy (ACE_WCHAR_T *dst,
00366 const ACE_WCHAR_T *src,
00367 size_t maxlen);
00368
00369
00370
00371 static const char *strnstr (const char *s, const char *t, size_t len);
00372
00373
00374
00375 static const ACE_WCHAR_T *strnstr (const ACE_WCHAR_T *s,
00376 const ACE_WCHAR_T *t,
00377 size_t len);
00378
00379
00380 static char *strnstr (char *s, const char *t, size_t len);
00381
00382
00383 static ACE_WCHAR_T *strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len);
00384
00385
00386 static char *strdup (const char *s);
00387
00388 #if defined (ACE_HAS_WCHAR)
00389
00390 static wchar_t *strdup (const wchar_t *s);
00391 #endif
00392
00393
00394 static char *strtok_r (char *s, const char *tokens, char **lasts);
00395
00396 #if defined (ACE_HAS_WCHAR)
00397
00398 static wchar_t *strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts);
00399 #endif // ACE_HAS_WCHAR
00400
00401 #if !defined (ACE_LACKS_STRTOD)
00402
00403 static double strtod (const char *s, char **endptr);
00404 #endif
00405
00406 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD)
00407
00408 static double strtod (const wchar_t *s, wchar_t **endptr);
00409 #endif
00410
00411
00412 static long strtol (const char *s, char **ptr, int base);
00413
00414 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL)
00415
00416 static long strtol (const wchar_t *s, wchar_t **ptr, int base);
00417 #endif
00418
00419
00420 static unsigned long strtoul (const char *s, char **ptr, int base);
00421
00422 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL)
00423
00424 static unsigned long strtoul (const wchar_t *s, wchar_t **ptr, int base);
00425 #endif
00426
00427
00428
00429 private:
00430
00431
00432
00433
00434
00435
00436
00437
00438 #if !defined (ACE_HAS_ITOA)
00439
00440 static char *itoa_emulation (int value, char *string, int radix);
00441 #endif
00442
00443 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW)
00444
00445 static wchar_t *itow_emulation (int value, wchar_t *string, int radix);
00446 #endif
00447
00448 #if !defined (ACE_HAS_MEMCHR)
00449
00450 static const void *memchr_emulation (const void *s, int c, size_t len);
00451 #endif
00452
00453 #if defined (ACE_LACKS_STRCASECMP)
00454
00455 static int strcasecmp_emulation (const char *s, const char *t);
00456
00457
00458 static int strncasecmp_emulation (const char *s, const char *t, size_t len);
00459 #endif
00460
00461 #if defined (ACE_LACKS_STRCSPN)
00462
00463 static size_t strcspn_emulation (const char *s, const char *reject);
00464 #endif
00465
00466 #if defined (ACE_LACKS_STRCHR)
00467
00468
00469 static char *strchr_emulation (char *s, int c);
00470
00471
00472
00473 static const char *strchr_emulation (const char *s, int c);
00474 #endif
00475
00476 #if defined (ACE_LACKS_STRERROR)
00477
00478 static char *strerror_emulation (int errnum);
00479 #endif
00480
00481 #if defined (ACE_LACKS_STRPBRK)
00482
00483 static char *strpbrk_emulation (const char *string,
00484 const char *charset);
00485 #endif
00486
00487 #if defined (ACE_LACKS_STRRCHR)
00488
00489
00490 static char *strrchr_emulation (char *s, int c);
00491
00492
00493
00494 static const char *strrchr_emulation (const char *s, int c);
00495 #endif
00496
00497 #if !defined (ACE_HAS_REENTRANT_FUNCTIONS)
00498
00499 static char *strtok_r_emulation (char *s, const char *tokens, char **lasts);
00500
00501 # if defined (ACE_HAS_WCHAR)
00502
00503 static wchar_t *strtok_r_emulation (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts);
00504 # endif // ACE_HAS_WCHAR
00505 #endif
00506
00507 #if defined (ACE_LACKS_STRSPN)
00508
00509 static size_t strspn_emulation (const char *string,
00510 const char *charset);
00511 #endif
00512
00513 #if defined (ACE_LACKS_STRTOL)
00514 static long strtol_emulation (const char *nptr, char **endptr, int base);
00515 #endif
00516
00517 #if defined (ACE_LACKS_STRTOUL)
00518 static unsigned long strtoul_emulation (const char *nptr,
00519 char **endptr,
00520 int base);
00521 #endif
00522
00523 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCAT)
00524
00525 static wchar_t *wcscat_emulation (wchar_t *destination,
00526 const wchar_t *source);
00527 #endif
00528
00529 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCHR)
00530
00531 static wchar_t *wcschr_emulation (const wchar_t *string, wint_t c);
00532 #endif
00533
00534 #if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
00535
00536 static int wcscmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2);
00537 #endif
00538
00539 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCPY)
00540
00541 static wchar_t *wcscpy_emulation (wchar_t *destination,
00542 const wchar_t *source);
00543 #endif
00544
00545 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSICMP)
00546
00547 static int wcsicmp_emulation (const wchar_t *string1,
00548 const wchar_t *string2);
00549 #endif
00550
00551 #if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
00552
00553 static size_t wcslen_emulation (const ACE_WCHAR_T *string);
00554 #endif
00555
00556 #if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
00557
00558 static ACE_WCHAR_T *wcsncat_emulation (ACE_WCHAR_T *destination,
00559 const ACE_WCHAR_T *source,
00560 size_t count);
00561 #endif
00562
00563 #if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
00564
00565 static int wcsncmp_emulation (const ACE_WCHAR_T *string1,
00566 const ACE_WCHAR_T *string2,
00567 size_t len);
00568 #endif
00569
00570 #if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
00571
00572 static ACE_WCHAR_T *wcsncpy_emulation (ACE_WCHAR_T *destination,
00573 const ACE_WCHAR_T *source,
00574 size_t len);
00575 #endif
00576
00577 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNICMP)
00578
00579
00580 static int wcsnicmp_emulation (const wchar_t *string1,
00581 const wchar_t *string2,
00582 size_t len);
00583 #endif
00584
00585 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSPBRK)
00586
00587 static wchar_t *wcspbrk_emulation (const wchar_t *string,
00588 const wchar_t *charset);
00589 #endif
00590
00591 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSRCHR)
00592
00593
00594 static wchar_t *wcsrchr_emulation (wchar_t *string, wint_t c);
00595
00596
00597
00598 static const wchar_t *wcsrchr_emulation (const wchar_t *string, wint_t c);
00599 #endif
00600
00601 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCSPN)
00602
00603 static size_t wcscspn_emulation (const wchar_t *string,
00604 const wchar_t *reject);
00605 #endif
00606
00607 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSPN)
00608
00609 static size_t wcsspn_emulation (const wchar_t *string,
00610 const wchar_t *charset);
00611 #endif
00612
00613 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSTR)
00614
00615 static wchar_t *wcsstr_emulation (const wchar_t *string,
00616 const wchar_t *charset);
00617 #endif
00618
00619
00620 };
00621
00622 # if defined (ACE_HAS_INLINED_OSCALLS)
00623 # if defined (ACE_INLINE)
00624 # undef ACE_INLINE
00625 # endif
00626 # define ACE_INLINE inline
00627 # include "ace/OS_String.inl"
00628 # endif
00629
00630 #include "ace/post.h"
00631 #endif