======================================================================-====*/
#ifndef CLITKCOMMON_TXX
#define CLITKCOMMON_TXX
-/**
- -------------------------------------------------
- * @file clitkCommon.txx
- * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
- * @date 18 May 2006
- *
- -------------------------------------------------*/
//-------------------------------------------------------
// Utility functions for text file parsing (author: joel schaerer)
+//--------------------------------------------------------------------
template<class ElementType>
ElementType parse_value(std::string str)
{
assert(!parser.fail());
return value;
}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
template<class ElementType>
std::vector<ElementType> parse_string(std::string str,char delim)
{
}
return result;
}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
template<class ElementType>
std::vector<std::vector<ElementType> > parse_file(const char* filename,char delim)
{
}
return result;
}
+//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
// Convert float, double ... to string
}
//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// http://www.codeguru.com/forum/showthread.php?t=231054
+template <class T>
+bool fromString(T& t, const std::string& s,
+ std::ios_base& (*f)(std::ios_base&))
+{
+ std::istringstream iss(s);
+ return !(iss >> f >> t).fail();
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
// Convert float*, double* ... to string
template<class T>