00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00026
00036
00037
00038 #ifndef _CTTL_COREUTILS_H_INCLUDED_
00039 #define _CTTL_COREUTILS_H_INCLUDED_
00040
00041 #include <cassert>
00042 #include <algorithm>
00043 #include <ctype.h>
00044
00045 namespace cttl {
00046
00048 template< typename StringT >
00049 inline void
00050 string_toupper( StringT& str_ )
00051 {
00052 std::transform( str_.begin(), str_.end(), str_.begin(), toupper );
00053 }
00054
00056 template< typename StringT >
00057 inline void
00058 string_tolower( StringT& str_ )
00059 {
00060 std::transform( str_.begin(), str_.end(), str_.begin(), tolower );
00061
00062 }
00063
00086 template< typename StringT, typename CharT >
00087 inline void
00088 string_array2string( StringT& str_, CharT const* const* array_, CharT const* delimiter_ )
00089 {
00090 assert( array_ );
00091 if ( !*array_ ) {
00092 str_.clear();
00093 return;
00094 }
00095 str_ = *array_++;
00096
00097 while ( *array_ ) {
00098 if ( delimiter_ )
00099 str_ += delimiter_;
00100 str_ += *array_++;
00101 }
00102 }
00103
00123 template< typename StringT, typename CharT >
00124 inline void
00125 string_array2string( StringT& str_, CharT const* const* array_ )
00126 {
00127 static const CharT delimiter[] = { CharT( '\t' ), 0x00 };
00128 string_array2string( str_, array_, delimiter );
00129 }
00130
00153 template< typename StringT, typename CharT >
00154 inline void
00155 string_array2string( StringT& str_, CharT const* const* array_, CharT delimiter_ )
00156 {
00157 const CharT delimiter[] = { delimiter_, 0x00 };
00158 string_array2string( str_, array_, delimiter );
00159 }
00160
00161 }
00162
00163
00164 #endif //_CTTL_COREUTILS_H_INCLUDED_