Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

utils.h

Go to the documentation of this file.
00001 /* 
00002  * This file is part of the rfc822 library (C) rebel42@users.sourceforge.net.
00003  *
00004  * The rfc822 library is released under the terms of the GNU Library General Public License as
00005  * published by the Free Software Foundation; either version 2 of the
00006  * License, or (at your option) any later version. See the file COPYING
00007  * as included in the distribution for details.
00008  */
00009 #ifndef UTILS_H
00010 #define UTILS_H
00011 
00012 #include <string>
00013 #include <list>
00014 #include <iostream>
00015 
00016 using namespace std;
00017 
00018 namespace utils {
00019 
00020 void warn(const char* fmt, ...);
00021 inline void nowarn(const char* fmt, ...)
00022         { }
00023 
00024 string lc(const string&);
00025 string uc(const string&);
00026 void chomp(string&);
00027 
00028 list<string> split(const string& str, const string& delim = "\n", bool fInsertEmpty = false);
00029 
00030 string join(const list<string> &str, const string& conn = ",");
00031 
00032 }; // namespace utils
00033 
00034 ostream& operator << (ostream& o, const list<string>&);
00035 
00036 template <class T>
00037 ostream& operator << (ostream& o, const list<T>& l) 
00038 {
00039         o << '(';
00040                 
00041         list<T>::const_iterator it = l.begin();
00042         if(it != l.end()) {
00043                 o << *it;
00044                 while(++it != l.end()) {
00045                         o << ',' << ' ' << *it;
00046                 }
00047         }
00048         o << ')';
00049                 
00050         return o;
00051 }
00052 
00053 #endif

Generated on Mon Oct 22 17:03:48 2001 for rfc822 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001