7 #ifndef FillFromStringUtility_h
8 #define FillFromStringUtility_h
15 #include "boost/tokenizer.hpp"
16 #include "boost/lexical_cast.hpp"
20 bool fillArrayFromString(
const std::string&
source,
C& userContainer) {
21 if (
source.empty())
return false;
22 typedef typename C::value_type V_t;
23 V_t errVal{std::numeric_limits<V_t>::has_quiet_NaN ? (std::numeric_limits<V_t>::quiet_NaN()) : 0};
24 boost::char_separator<char>
sep{
" "};
25 typedef boost::tokenizer<boost::char_separator<char> >
Tokenizer;
32 userContainer[j]=boost::lexical_cast<V_t>(*
i);
33 }
catch (
const boost::bad_lexical_cast&) {
34 userContainer[j]=errVal;
42 bool fillEmptyVectorFromString(
const std::string&
source,
C& userContainer) {
43 if (
source.empty())
return false;
44 typedef typename C::value_type V_t;
45 V_t errVal{std::numeric_limits<V_t>::has_quiet_NaN ? (std::numeric_limits<V_t>::quiet_NaN()) : 0};
46 boost::char_separator<char>
sep{
" "};
47 typedef boost::tokenizer<boost::char_separator<char> >
Tokenizer;
53 userContainer.push_back(boost::lexical_cast<V_t>(*
i));
54 }
catch (
const boost::bad_lexical_cast&) {
55 userContainer.push_back(errVal);
63 #endif // FillFromStringUtility_h