Main Page | Class Hierarchy | Class List | File List | Class Members

Conversions.h

00001 // Conversions.h -- Interface to some useful string conversion functions.
00002 
00003 /*
00004  * Copyright (C) 2003 Tudor Hulubei <tudor@hulubei.net>.
00005  *
00006  * This library is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as
00008  * published by the Free Software Foundation; either version 2, or (at
00009  * your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA,
00019  * 02111-1307, USA.
00020  */
00021 
00022 /*
00023  * NOTE: This is an interal header file.
00024  * You should not attempt to use it directly.
00025  */
00026 
00027 // $Id: Conversions_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00028 
00029 #ifndef _CSP_EXAMPLES_Conversions_H
00030 #define _CSP_EXAMPLES_Conversions_H
00031 
00032 
00039 std::wstring string2wstring(const std::string& s);
00040 
00047 std::string wstring2string(const std::wstring& ws);
00048 
00049 
00057 double wstring2double(const std::wstring& s);
00058 
00059 
00067 const std::wstring int2wstring(int x, int base = 10);
00068 
00069 
00082 template<class Iterator>
00083 void wstring2container(
00084     const std::wstring& source,
00085     Iterator iterator,
00086     const std::wstring& separator = std::wstring(L","))
00087 {
00088     if (source.empty())
00089         return;
00090 
00091     std::wstring::size_type b = 0;
00092 
00093     for (std::wstring::size_type e = 0;
00094          (e = source.find(separator, b)) != std::wstring::npos;
00095          b = e + separator.size())
00096         *iterator = source.substr(b, e - b);
00097 
00098     *iterator = source.substr(b);
00099 }
00100 
00101 
00102 #endif // _CSP_EXAMPLES_Conversions_H
00103 
00104 // Local Variables:
00105 // mode: C++
00106 // End:

Generated on Wed May 25 12:21:13 2005 for csp.kdevelop by  doxygen 1.3.9.1