Utils.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002     This file is part of PHP-AST Project by Romain Gaucher (http://rgaucher.info).
00003 
00004     PHP-AST is free software: you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation, either version 3 of the License, or
00007     (at your option) any later version.
00008 
00009     PHP-AST/ORACLE is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with PHP-AST.  If not, see <http://www.gnu.org/licenses/>.
00016 ------------------------------------------------------------------------------*/
00017 
00018 #ifndef __UTILS_H
00019 #define __UTILS_H
00020 
00021 #include <string>
00022 #include <sstream>
00023 
00024 template <class T>
00025 bool from_string(T& t, const std::string& s) {
00026     std::istringstream iss(s, std::istringstream::in);
00027     return !(iss >> t).fail();  
00028 }
00029 
00030 template <class T>
00031 std::string to_string(const T& t) {
00032     std::ostringstream oss;
00033     oss << t;
00034     return oss.str();
00035 }
00036 
00037 
00038 namespace utils {
00039 
00040 void replace(std::string& where, const std::string& what, const std::string& by);
00041 
00042 bool start_with(const std::string& str, const std::string& what);
00043 bool   end_with(const std::string& str, const std::string& what);
00044 
00045 }
00046 
00047 
00048 #endif

Generated on Wed Feb 27 20:31:06 2008 for php.ast.svn.src. by  doxygen 1.5.3