/*************************************************************************** * * Copyright (c) 2008 Baidu.com, Inc. All Rights Reserved * $Id: check_cast_cstring.h,v 1.3 2009/10/14 08:24:58 chenxm Exp $ * **************************************************************************/ /** * @file check_cast_cstring.h * @author chenxm(chenxiaoming@baidu.com) * @date 2008/11/11 18:36:02 * @version $Revision: 1.3 $ * @brief * **/ #ifndef __CHECK_CAST_CSTRING_H_ #define __CHECK_CAST_CSTRING_H_ //internal use #ifndef __CHECK_CAST_H_ #error "this file cannot be included directly, please include \"check_cast.h\" instead" #endif namespace bsl{ //from c-style string template<> inline char check_cast( const char * s ){ if ( !s ){ throw bsl::NullPointerException()< long check_cast ( const char * s ); //signed char is used as int8 template<> inline signed char check_cast( const char * s ){ return check_cast( check_cast( s ) ); } //unsigned char is used as uint8 template<> inline unsigned char check_cast( const char * s ){ return check_cast( check_cast( s ) ); } template<> inline short check_cast ( const char * s ){ return check_cast( check_cast( s ) ); } template<> inline int check_cast ( const char * s ){ return check_cast( check_cast( s ) ); } template<> long long check_cast( const char * s ); template<> unsigned long check_cast( const char * s ); template<> inline unsigned short check_cast( const char * s ){ return check_cast( check_cast( s ) ); } template<> inline unsigned int check_cast( const char * s ){ return check_cast( check_cast( s ) ); } template<> unsigned long long check_cast( const char * s ); template<> float check_cast( const char * s ); template<> double check_cast( const char * s ); template<> long double check_cast( const char * s ); template<> inline char check_cast( char *s ){ if ( !s ){ throw bsl::NullPointerException()< inline long check_cast ( char * s ){ return check_cast(s); } template<> inline short check_cast ( char * s ){ return check_cast( check_cast( s ) ); } //signed char is used as int8 template<> inline signed char check_cast( char * s ){ return check_cast( check_cast( s ) ); } //unsigned char is used as uint8 template<> inline unsigned char check_cast( char * s ){ return check_cast( check_cast( s ) ); } template<> inline int check_cast ( char * s ){ return check_cast( check_cast( s ) ); } template<> inline long long check_cast( char *s ){ return check_cast(s); } template<> inline unsigned long check_cast( char *s ){ return check_cast(s); } template<> inline unsigned short check_cast( char *s ){ return check_cast( check_cast( s ) ); } template<> inline unsigned int check_cast( char *s ){ return check_cast( check_cast( s ) ); } template<> inline unsigned long long check_cast( char *s ){ return check_cast(s); } template<> inline float check_cast( char *s ){ return check_cast(s); } template<> inline double check_cast( char *s ){ return check_cast(s); } template<> inline long double check_cast( char *s ){ return check_cast(s); } } #endif //__CHECK_CAST_CSTRING_H_ /* vim: set ts=4 sw=4 sts=4 tw=100 */