00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00049 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_STD_H_C_STRING
00050 #define STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_STD_H_C_STRING
00051
00052 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00053 # define STLSOFT_VER_STLSOFT_SHIMS_ACCESS_STRING_STD_H_C_STRING_MAJOR 4
00054 # define STLSOFT_VER_STLSOFT_SHIMS_ACCESS_STRING_STD_H_C_STRING_MINOR 0
00055 # define STLSOFT_VER_STLSOFT_SHIMS_ACCESS_STRING_STD_H_C_STRING_REVISION 5
00056 # define STLSOFT_VER_STLSOFT_SHIMS_ACCESS_STRING_STD_H_C_STRING_EDIT 94
00057 #endif
00058
00059
00060
00061
00062
00063 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00064 # include <stlsoft/stlsoft.h>
00065 #endif
00066 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD
00067 # include <stlsoft/shims/access/string/fwd.h>
00068 #endif
00069
00070 #ifndef STLSOFT_INCL_H_STRING
00071 # define STLSOFT_INCL_H_STRING
00072 # include <string.h>
00073 #endif
00074 #if defined(STLSOFT_COMPILER_IS_GCC) || \
00075 defined(STLSOFT_COMPILER_IS_MWERKS) || \
00076 defined(STLSOFT_COMPILER_IS_SUNPRO)
00077 # include <wchar.h>
00078 #endif
00079
00080 #ifdef STLSOFT_UNITTEST
00081 # include <stdio.h>
00082 #endif
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 #ifndef _STLSOFT_NO_NAMESPACE
00103 namespace stlsoft
00104 {
00105 #endif
00106
00107
00108
00109
00110
00117 struct cannot_use_untyped_0_or_NULL_with_shims;
00118
00119
00120
00121
00122
00123
00124
00125
00126
00135 STLSOFT_INLINE ss_char_a_t const* c_str_data_a(ss_char_a_t const* s)
00136 {
00137 return (NULL != s) ? s : "";
00138 }
00139
00140 #ifdef __cplusplus
00141
00149 inline ss_char_a_t const* c_str_data(ss_char_a_t const* s)
00150 {
00151 return c_str_data_a(s);
00152 }
00153 #endif
00154
00155
00164 STLSOFT_INLINE ss_char_w_t const* c_str_data_w(ss_char_w_t const* s)
00165 {
00166 return (NULL != s) ? s : stlsoft_static_cast(ss_char_w_t const*, L"");
00167 }
00168
00169 #ifdef __cplusplus
00170
00178 inline ss_char_w_t const* c_str_data(ss_char_w_t const* s)
00179 {
00180 return c_str_data_w(s);
00181 }
00182 #endif
00183
00184 #ifdef __cplusplus
00185
00186 # ifdef _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST
00187
00195 inline ss_char_a_t const* c_str_data_a(ss_char_a_t *s)
00196 {
00197 return (NULL != s) ? s : "";
00198 }
00199
00208 inline ss_char_a_t const* c_str_data(ss_char_a_t *s)
00209 {
00210 return c_str_data_a(s);
00211 }
00212
00213
00222 inline ss_char_w_t const* c_str_data_w(ss_char_w_t *s)
00223 {
00224 return (NULL != s) ? s : L"";
00225 }
00226
00235 inline ss_char_w_t const* c_str_data(ss_char_w_t *s)
00236 {
00237 return c_str_data_w(s);
00238 }
00239 # endif
00240
00241 # if 0
00242
00250 template <ss_typename_param_k S>
00251 inline ss_char_a_t const* c_str_data_a(S const& s)
00252 {
00253 return stlsoft_ns_qual(c_str_data_a)(static_cast<ss_char_a_t const*>(stlsoft_ns_qual(c_str_ptr_a)(s))));
00254 }
00263 template <ss_typename_param_k S>
00264 inline ss_char_w_t const* c_str_data_w(S const& s)
00265 {
00266 return stlsoft_ns_qual(c_str_data_w)(static_cast<ss_char_w_t const*>(stlsoft_ns_qual(c_str_ptr_w)(s))));
00267 }
00268 # endif
00269
00270 #endif
00271
00272
00273
00274
00275
00276
00277
00278
00279
00288 STLSOFT_INLINE ss_size_t c_str_len_a(ss_char_a_t const* s)
00289 {
00290 return (s == 0) ? 0 : STLSOFT_NS_GLOBAL(strlen)(s);
00291 }
00292
00293 #ifdef __cplusplus
00294
00302 inline ss_size_t c_str_len(ss_char_a_t const* s)
00303 {
00304 return c_str_len_a(s);
00305 }
00306 #endif
00307
00308
00317 STLSOFT_INLINE ss_size_t c_str_len_w(ss_char_w_t const* s)
00318 {
00319 return (s == 0) ? 0 : STLSOFT_NS_GLOBAL(wcslen)(s);
00320 }
00321
00322 #ifdef __cplusplus
00323
00331 inline ss_size_t c_str_len(ss_char_w_t const* s)
00332 {
00333 return c_str_len_w(s);
00334 }
00335 #endif
00336
00337 #ifdef __cplusplus
00338
00339
00340 # ifdef _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST
00341
00349 inline ss_size_t c_str_len_a(ss_char_a_t *s)
00350 {
00351 return c_str_len_a(static_cast<ss_char_a_t const*>(s));
00352 }
00353
00362 inline ss_size_t c_str_len(ss_char_a_t *s)
00363 {
00364 return c_str_len_a(s);
00365 }
00366
00367
00376 inline ss_size_t c_str_len_w(ss_char_w_t *s)
00377 {
00378 return c_str_len_w(static_cast<ss_char_w_t const*>(s));
00379 }
00380
00389 inline ss_size_t c_str_len(ss_char_w_t *s)
00390 {
00391 return c_str_len_w(s);
00392 }
00393 # endif
00394
00395 #endif
00396
00397
00398
00399
00400
00401
00402
00403
00404
00413 STLSOFT_INLINE ss_char_a_t const* c_str_ptr_a(ss_char_a_t const* s)
00414 {
00415 return (NULL != s) ? s : "";
00416 }
00417
00418 #ifdef __cplusplus
00419
00427 inline ss_char_a_t const* c_str_ptr(ss_char_a_t const* s)
00428 {
00429 return c_str_ptr_a(s);
00430 }
00431 #endif
00432
00433
00442 STLSOFT_INLINE ss_char_w_t const* c_str_ptr_w(ss_char_w_t const* s)
00443 {
00444 return (NULL != s) ? s : stlsoft_static_cast(ss_char_w_t const*, L"");
00445 }
00446
00447 #ifdef __cplusplus
00448
00454 inline ss_char_w_t const* c_str_ptr(ss_char_w_t const* s)
00455 {
00456 return c_str_ptr_w(s);
00457 }
00458 #endif
00459
00460 #ifdef __cplusplus
00461
00462 # ifdef _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST
00463
00469 inline ss_char_a_t const* c_str_ptr_a(ss_char_a_t *s)
00470 {
00471 return (NULL != s) ? s : "";
00472 }
00473
00482 inline ss_char_a_t const* c_str_ptr(ss_char_a_t *s)
00483 {
00484 return c_str_ptr_a(s);
00485 }
00486
00487
00496 inline ss_char_w_t const* c_str_ptr_w(ss_char_w_t *s)
00497 {
00498 return (NULL != s) ? s : L"";
00499 }
00500
00509 inline ss_char_w_t const* c_str_ptr(ss_char_w_t *s)
00510 {
00511 return c_str_ptr_w(s);
00512 }
00513 # endif
00514 #endif
00515
00516
00517
00518
00519
00520
00521
00522
00523
00533 STLSOFT_INLINE ss_char_a_t const* c_str_ptr_null_a(ss_char_a_t const* s)
00534 {
00535 return (NULL == s || '\0' == *s) ? NULL : s;
00536 }
00537
00538 #ifdef __cplusplus
00539
00548 inline ss_char_a_t const* c_str_ptr_null(ss_char_a_t const* s)
00549 {
00550 return c_str_ptr_null_a(s);
00551 }
00552 #endif
00553
00554
00564 STLSOFT_INLINE ss_char_w_t const* c_str_ptr_null_w(ss_char_w_t const* s)
00565 {
00566 return (NULL == s || L'\0' == *s) ? NULL : s;
00567 }
00568
00569 #ifdef __cplusplus
00570
00579 inline ss_char_w_t const* c_str_ptr_null(ss_char_w_t const* s)
00580 {
00581 return c_str_ptr_null_w(s);
00582 }
00583 #endif
00584
00585 #ifdef __cplusplus
00586
00587
00588 # ifdef _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST
00589
00598 inline ss_char_a_t const* c_str_ptr_null_a(ss_char_a_t *s)
00599 {
00600 return (NULL == s || '\0' == *s) ? NULL : s;
00601 }
00602
00612 inline ss_char_a_t const* c_str_ptr_null(ss_char_a_t *s)
00613 {
00614 return c_str_ptr_null_a(s);
00615 }
00616
00617
00627 inline ss_char_w_t const* c_str_ptr_null_w(ss_char_w_t *s)
00628 {
00629 return (NULL == s || L'\0' == *s) ? NULL : s;
00630 }
00631
00641 inline ss_char_w_t const* c_str_ptr_null(ss_char_w_t *s)
00642 {
00643 return c_str_ptr_null_w(s);
00644 }
00645 # endif
00646
00647 # if 0
00648
00657 template <ss_typename_param_k S>
00658 inline ss_char_a_t const* c_str_ptr_null_a(S const& s)
00659 {
00660 return stlsoft_ns_qual(c_str_ptr_null_a)(static_cast<ss_char_a_t const*>(stlsoft_ns_qual(c_str_ptr_a)(s))));
00661 }
00671 template <ss_typename_param_k S>
00672 inline ss_char_w_t const* c_str_ptr_null_w(S const& s)
00673 {
00674 return stlsoft_ns_qual(c_str_ptr_null_w)(static_cast<ss_char_w_t const*>(stlsoft_ns_qual(c_str_ptr_w)(s))));
00675 }
00676 # endif
00677
00678 #endif
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00698 STLSOFT_INLINE ss_size_t c_str_size_a(ss_char_a_t const* s)
00699 {
00700 return c_str_len_a(s) * sizeof(ss_char_a_t);
00701 }
00702
00703 #ifdef __cplusplus
00704
00713 inline ss_size_t c_str_size(ss_char_a_t const* s)
00714 {
00715 return c_str_size_a(s);
00716 }
00717 #endif
00718
00719
00729 STLSOFT_INLINE ss_size_t c_str_size_w(ss_char_w_t const* s)
00730 {
00731 return c_str_len_w(s) * sizeof(ss_char_w_t);
00732 }
00733
00734 #ifdef __cplusplus
00735
00744 inline ss_size_t c_str_size(ss_char_w_t const* s)
00745 {
00746 return c_str_size_w(s);
00747 }
00748 #endif
00749
00750 #ifdef __cplusplus
00751
00752
00753 # ifdef _STLSOFT_STRING_ACCESS_ALLOW_NON_CONST
00754
00763 inline ss_size_t c_str_size_a(ss_char_a_t *s)
00764 {
00765 return c_str_len(s) * sizeof(ss_char_a_t);
00766 }
00767
00777 inline ss_size_t c_str_size(ss_char_a_t *s)
00778 {
00779 return c_str_size_a(s);
00780 }
00781
00782
00792 inline ss_size_t c_str_size_w(ss_char_w_t *s)
00793 {
00794 return c_str_len(s) * sizeof(ss_char_w_t);
00795 }
00796
00806 inline ss_size_t c_str_size(ss_char_w_t *s)
00807 {
00808 return c_str_size_w(s);
00809 }
00810 # endif
00811
00821 template <ss_typename_param_k S>
00822 inline ss_size_t c_str_size_a(S const& s)
00823 {
00824 return sizeof(ss_char_a_t) * c_str_len_a(s);
00825 }
00826
00836 template <ss_typename_param_k S>
00837 inline ss_size_t c_str_size_w(S const& s)
00838 {
00839 return sizeof(ss_char_w_t) * c_str_len_w(s);
00840 }
00841
00851 template <ss_typename_param_k S>
00852 inline ss_size_t c_str_size(S const& s)
00853 {
00854 return sizeof(*c_str_ptr(s)) * c_str_len(s);
00855 }
00856
00866 inline cannot_use_untyped_0_or_NULL_with_shims c_str_size(int deny_literal_NULL);
00867
00868 #endif
00869
00870
00871
00872
00873
00874 #ifdef STLSOFT_UNITTEST
00875 # include "./unittest/c_string_unittest_.h"
00876 #endif
00877
00878
00879
00880 #ifndef _STLSOFT_NO_NAMESPACE
00881 }
00882 #endif
00883
00884
00885
00886 #endif
00887
00888