GRINS-0.7.0
Functions
GRINS::StringUtilities Namespace Reference

Functions

template<typename T >
string_to_T (const std::string &input)
 
template<typename T >
std::string T_to_string (const T 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::MoleFractionsDirichletBCFactory::add_mole_frac_to_mass_frac(), GRINS::QoIFactory::build(), GRINS::MoleFractionsDirichletBCFactory::extract_species_name(), GRINS::ICHandlingBase::init_ic_types(), GRINS::DefaultBCBuilder::parse_and_build_bc_id_map(), GRINS::GasRecombinationCatalyticWallNeumannBCFactoryImpl::parse_reactant_and_product(), GRINS::GasSolidCatalyticWallNeumannBCFactoryImpl::parse_reactants_and_product(), GRINS::DefaultBCBuilder::parse_var_sections(), and GRINSTesting::StringUtilitiesTest::test_split_string().

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 85 of file string_utils.h.

86  {
87  std::pair<std::string, double> ret = std::make_pair(std::string(), 0.0);
88  std::string::size_type colon_position = token.find(":");
89  libmesh_assert (colon_position != std::string::npos);
90  ret.first = token.substr(0, colon_position);
91  ret.second = std::atof(token.substr(colon_position + 1).c_str());
92  return ret;
93  }
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 69 of file string_utils.h.

70  {
71  std::pair<std::string, int> ret = std::make_pair(std::string(), 0);
72  std::string::size_type colon_position = token.find(":");
73  libmesh_assert (colon_position != std::string::npos);
74  ret.first = token.substr(0, colon_position);
75  ret.second = std::atoi(token.substr(colon_position + 1).c_str());
76  return ret;
77  }
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  }
template<typename T >
std::string GRINS::StringUtilities::T_to_string ( const T  input)
inline

Definition at line 55 of file string_utils.h.

56  {
57  std::stringstream converter;
58  converter << input;
59  if (converter.fail())
60  libmesh_error();
61  return converter.str();
62  }

Generated on Thu Jun 2 2016 21:52:33 for GRINS-0.7.0 by  doxygen 1.8.10