Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

coreutils.h

Go to the documentation of this file.
00001 
00002 // Common Text Transformation Library
00003 // Copyright (C) 1997-2006 by Igor Kholodov. 
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the
00017 // Free Software Foundation, Inc.,
00018 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 // mailto:cttl@users.sourceforge.net
00021 // http://sourceforge.net/projects/cttl/
00023 
00033 // coreutils.h: string utility functions
00034 
00035 #ifndef _CTTL_COREUTILS_H_INCLUDED_
00036 #define _CTTL_COREUTILS_H_INCLUDED_
00037 
00038 #include <cassert>
00039 #include <algorithm>
00040 
00041 namespace cttl {
00042 
00044 template< typename StringT >
00045 inline void
00046 string_toupper( StringT& str_ )
00047 {
00048     std::transform( str_.begin(), str_.end(), str_.begin(), toupper );
00049 }
00050 
00052 template< typename StringT >
00053 inline void
00054 string_tolower( StringT& str_ )
00055 {
00056     std::transform( str_.begin(), str_.end(), str_.begin(), tolower );
00057          
00058 }
00059 
00076 template< typename StringT, typename CharT >
00077 inline void
00078 string_array2string( StringT& str_, CharT* array_[] )
00079 {
00080     static const CharT delimiter[] = { '\t', 0x00 };
00081     string_array2string( str_, array_, delimiter );
00082 }
00083 
00106 template< typename StringT, typename CharT >
00107 inline void
00108 string_array2string( StringT& str_, CharT* array_[], CharT delimiter_ )
00109 {
00110     const CharT delimiter[] = { delimiter_, 0x00 };
00111     string_array2string( str_, array_, delimiter );
00112 }
00113 
00136 template< typename StringT, typename CharT >
00137 inline void
00138 string_array2string( StringT& str_, CharT* array_[], CharT const* delimiter_ )
00139 {
00140     assert( array_ );
00141     if ( !*array_ ) {
00142         str_.clear();
00143         return;
00144     }
00145     str_ = *array_++;
00146     
00147     while ( *array_ ) {
00148         if ( delimiter_ )
00149             str_ += delimiter_;
00150         str_ += *array_++;
00151     }
00152 }
00153 
00154 
00155 }   // namespace cttl
00156 
00157 
00158 #endif //_CTTL_COREUTILS_H_INCLUDED_

Generated on Thu Nov 2 17:44:06 2006 for Common Text Transformation Library by  doxygen 1.3.9.1