GRINS-0.6.0
Functions
GRINS::StringUtilities Namespace Reference

Functions

template<typename T >
string_to_T (const std::string &input)
 
std::pair< std::string, int > split_string_int_on_colon (const std::string &token)
 Split on colon, and return name, int value pair. More...
 
std::pair< std::string, double > split_string_double_on_colon (const std::string &token)
 Split on colon, and return name, double value pair. More...
 
void split_string (const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
 

Function Documentation

void GRINS::StringUtilities::split_string ( const std::string &  input,
const std::string &  delimiter,
std::vector< std::string > &  results 
)

Definition at line 31 of file string_utils.C.

Referenced by GRINS::QoIFactory::build(), GRINS::ReactingLowMachNavierStokesBCHandling< Chemistry >::init_bc_types(), GRINS::ICHandlingBase::init_ic_types(), and main().

34  {
35  // Skip delimiters at beginning.
36  std::string::size_type first_pos = input.find_first_not_of(delimiter, 0);
37 
38  std::string::size_type pos = input.find(delimiter, first_pos);
39 
40  while (std::string::npos != pos || std::string::npos != first_pos)
41  {
42  // Found a token, add it to the vector.
43  results.push_back(input.substr(first_pos, pos - first_pos));
44 
45  // Skip delimiters. Note the "not_of"
46  first_pos = input.find_first_not_of(delimiter, pos);
47 
48  // Find next delimiter
49  pos = input.find(delimiter, first_pos);
50  }
51  }
std::pair<std::string, double> GRINS::StringUtilities::split_string_double_on_colon ( const std::string &  token)
inline

Split on colon, and return name, double value pair.

Taken from FIN-S for XML parsing.

Definition at line 74 of file string_utils.h.

75  {
76  std::pair<std::string, double> ret = std::make_pair(std::string(), 0.0);
77  std::string::size_type colon_position = token.find(":");
78  libmesh_assert (colon_position != std::string::npos);
79  ret.first = token.substr(0, colon_position);
80  ret.second = std::atof(token.substr(colon_position + 1).c_str());
81  return ret;
82  }
std::pair<std::string, int> GRINS::StringUtilities::split_string_int_on_colon ( const std::string &  token)
inline

Split on colon, and return name, int value pair.

Taken from FIN-S for XML parsing.

Definition at line 58 of file string_utils.h.

59  {
60  std::pair<std::string, int> ret = std::make_pair(std::string(), 0);
61  std::string::size_type colon_position = token.find(":");
62  libmesh_assert (colon_position != std::string::npos);
63  ret.first = token.substr(0, colon_position);
64  ret.second = std::atoi(token.substr(colon_position + 1).c_str());
65  return ret;
66  }
template<typename T >
T GRINS::StringUtilities::string_to_T ( const std::string &  input)
inline

Definition at line 43 of file string_utils.h.

44  {
45  std::istringstream converter(input);
46  T returnval;
47  converter >> returnval;
48  if (converter.fail())
49  libmesh_error();
50  return returnval;
51  }

Generated on Mon Jun 22 2015 21:32:24 for GRINS-0.6.0 by  doxygen 1.8.9.1