00001 /* This file is part of CrossZero 00002 * Copyright (C) 2008 Heikki Laitala 00003 * All rights reserved. 00004 * 00005 * Created: Sun Feb 17 2008 by Heikki Laitala 00006 * 00007 * $Revision:$ 00008 */ 00009 00010 #ifndef _CROSSZEROSTRINGUTILS_H_ 00011 #define _CROSSZEROSTRINGUTILS_H_ 00012 00013 #include <string> 00014 #include <sstream> 00015 00020 namespace CrossZeroStringUtils 00021 { 00045 template<class T> bool stringToValue(const std::string& str, T& val) 00046 { 00047 std::istringstream iss(str); 00048 return !(iss >> val).fail(); 00049 } 00050 00051 } //namespace ends 00052 00053 #endif //_CROSSZEROSTRINGUTILS_H_