include/SDL_stdinc.h
changeset 8464 a2a909304cfe
parent 8460 f483e8bdae3c
parent 7076 1666f7a7494e
child 8477 ad08f0d710f3
equal deleted inserted replaced
8463:98dbf81ed5e9 8464:a2a909304cfe
    98  */
    98  */
    99 /*@{*/
    99 /*@{*/
   100 #ifdef __cplusplus
   100 #ifdef __cplusplus
   101 #define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
   101 #define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
   102 #define SDL_static_cast(type, expression) static_cast<type>(expression)
   102 #define SDL_static_cast(type, expression) static_cast<type>(expression)
       
   103 #define SDL_const_cast(type, expression) const_cast<type>(expression)
   103 #else
   104 #else
   104 #define SDL_reinterpret_cast(type, expression) ((type)(expression))
   105 #define SDL_reinterpret_cast(type, expression) ((type)(expression))
   105 #define SDL_static_cast(type, expression) ((type)(expression))
   106 #define SDL_static_cast(type, expression) ((type)(expression))
       
   107 #define SDL_const_cast(type, expression) ((type)(expression))
   106 #endif
   108 #endif
   107 /*@}*//*Cast operators*/
   109 /*@}*//*Cast operators*/
   108 
   110 
   109 /* Define a four character code as a Uint32 */
   111 /* Define a four character code as a Uint32 */
   110 #define SDL_FOURCC(A, B, C, D) \
   112 #define SDL_FOURCC(A, B, C, D) \
   507 #define SDL_strlwr SDL_strlwr_inline
   509 #define SDL_strlwr SDL_strlwr_inline
   508 #endif
   510 #endif
   509 
   511 
   510 extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
   512 extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
   511 #ifdef HAVE_STRCHR
   513 #ifdef HAVE_STRCHR
   512 SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
   514 SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,strchr(str, c)); }
   513 #ifdef __cplusplus
       
   514 return const_cast<char*>(strchr(str, c));
       
   515 #else
       
   516 return (char*)strchr(str, c);
       
   517 #endif
       
   518 }
       
   519 #define SDL_strchr SDL_strchr_inline
   515 #define SDL_strchr SDL_strchr_inline
   520 #elif defined(HAVE_INDEX)  /* !!! FIXME: is there anywhere that has this but not strchr? */
   516 #elif defined(HAVE_INDEX)  /* !!! FIXME: is there anywhere that has this but not strchr? */
   521 SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
   517 SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,index(str, c)); }
   522 #define SDL_strchr SDL_strchr_inline
   518 #define SDL_strchr SDL_strchr_inline
   523 #endif
   519 #endif
   524 
   520 
   525 extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
   521 extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
   526 #ifdef HAVE_STRRCHR
   522 #ifdef HAVE_STRRCHR
   527 SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
   523 SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,strrchr(str, c)); }
   528 #ifdef __cplusplus
       
   529 return const_cast<char*>(strrchr(str, c));
       
   530 #else
       
   531 return (char*)strrchr(str, c);
       
   532 #endif
       
   533 }
       
   534 #define SDL_strrchr SDL_strrchr_inline
   524 #define SDL_strrchr SDL_strrchr_inline
   535 #elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
   525 #elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
   536 SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
   526 SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,rindex(str, c)); }
   537 #ifdef __cplusplus
       
   538 return const_cast<char*>(rindex(str, c));
       
   539 #else
       
   540 return (char*)rindex(str, c);
       
   541 #endif
       
   542 }
       
   543 #define SDL_strrchr SDL_strrchr_inline
   527 #define SDL_strrchr SDL_strrchr_inline
   544 #endif
   528 #endif
   545 
   529 
   546 extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
   530 extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
   547 #ifdef HAVE_STRSTR
   531 #ifdef HAVE_STRSTR
   548 SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
   532 SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return SDL_const_cast(char*,strstr(haystack, needle)); }
   549 #ifdef __cplusplus
       
   550 return const_cast<char*>(strstr(haystack, needle));
       
   551 #else
       
   552 return (char*)strstr(haystack, needle);
       
   553 #endif
       
   554 }
       
   555 #define SDL_strstr SDL_strstr_inline
   533 #define SDL_strstr SDL_strstr_inline
   556 #endif
   534 #endif
   557 
   535 
   558 extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix);
   536 extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix);
   559 #ifdef HAVE__LTOA
   537 #ifdef HAVE__LTOA