|
||
cbz_util.hGo to the documentation of this file.00001 // $Id: cbz_util.h,v 1.6 2003/08/11 17:22:47 abrown Exp $ 00002 // ---------------------------------------------------------------------- 00003 // 00004 // C-Breeze 00005 // C Compiler Framework 00006 // 00007 // Copyright (c) 2000 University of Texas at Austin 00008 // 00009 // Samuel Z. Guyer 00010 // Daniel A. Jimenez 00011 // Calvin Lin 00012 // 00013 // Permission is hereby granted, free of charge, to any person 00014 // obtaining a copy of this software and associated documentation 00015 // files (the "Software"), to deal in the Software without 00016 // restriction, including without limitation the rights to use, copy, 00017 // modify, merge, publish, distribute, sublicense, and/or sell copies 00018 // of the Software, and to permit persons to whom the Software is 00019 // furnished to do so, subject to the following conditions: 00020 // 00021 // The above copyright notice and this permission notice shall be 00022 // included in all copies or substantial portions of the Software. 00023 // 00024 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00025 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00026 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00027 // NONINFRINGEMENT. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT 00028 // AUSTIN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 00029 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 00030 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00031 // THE SOFTWARE. 00032 // 00033 // We acknowledge the C-to-C Translator from MIT Laboratory for 00034 // Computer Science for inspiring parts of the C-Breeze design. 00035 // 00036 // ---------------------------------------------------------------------- 00037 00038 00039 #ifndef _CBZ_UTIL_H 00040 #define _CBZ_UTIL_H 00041 00042 #include <string> 00043 #include <list> 00044 using namespace std; 00045 00046 // cbreeze utility stuff 00047 namespace cbz_util 00048 { 00049 00050 // ---------------------------------------------------------------------- 00051 // string maniuplation stuff 00052 00053 // like sprintf but gives you a result in a string 00054 string string_format( const char * pFormat, ... ); 00055 00056 // handy string-replacement function 00057 void string_replace( string & str, const string & toFind, const string & toReplaceWith ); 00058 00059 // make a string lower-case 00060 void string_to_lower( string & str ); 00061 00062 // ---------------------------------------------------------------------- 00063 // vector maniuplation stuff 00064 00065 // copy a vector into another vector 00066 template <typename T> 00067 static void vector_copy( const vector<T> & copyFrom, vector<T> & copyTo ) 00068 { 00069 // resize the destination and copy the source over 00070 size_t sz = copyFrom.size(); 00071 copyTo.resize( sz ); 00072 for ( int i = 0; i < (int)sz; ++i ) 00073 copyTo[i] = copyFrom[i]; 00074 } 00075 00076 // ---------------------------------------------------------------------- 00077 // list maniuplation stuff 00078 00079 // find an element in a list 00080 template < typename T > 00081 bool list_find( const list<T> & toSearch, const T & toFind ) 00082 { 00083 typename list<T>::const_iterator it = toSearch.begin(); 00084 while ( it != toSearch.end() ) 00085 if ( *(it++) == toFind ) 00086 return true; 00087 return false; 00088 } 00089 00090 }; 00091 00092 #endif 00093 |
Generated on August 27, 2003
Back to the C-Breeze home page