stringf.h

Go to the documentation of this file.
00001 #ifndef STRINGF_H
00002 #define STRINGF_H
00003 
00004 /*
00005  * Generic std::string helpers
00006  *
00007  * Copyright (C) 2003  Enrico Zini <enrico@debian.org>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00022  */
00023 
00024 #include <string>
00025 
00026 #ifndef ATTR_PRINTF
00027  #ifdef GCC
00028   #define ATTR_PRINTF(string, first) __attribute__((format (printf, string, first)))
00029  #else
00030   #define ATTR_PRINTF(string, first)
00031  #endif
00032 #endif
00033 
00034 namespace stringf
00035 {
00037     int addf(std::string& str, const char* fmt, ...) throw() ATTR_PRINTF(2, 3);
00038 
00040     std::string fmt(const char* fmt, ...) throw() ATTR_PRINTF(1, 2);
00041 
00042     std::string fmt(int val) throw ();
00043     std::string fmt(unsigned int val) throw ();
00044     std::string fmt(long int val) throw ();
00045     std::string fmt(long unsigned int val) throw ();
00046     // Useful only in templates
00047     inline std::string fmt(const std::string& str) throw () { return str; }
00048 };
00049 
00051 #define PFSTR(str) (int)(str).size(), (str).data()
00052 
00053 // vim:set ts=4 sw=4:
00054 #endif

Generated on Wed Nov 30 18:18:30 2005 for libbuffy by  doxygen 1.4.5