GRINS-0.8.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)
 
void split_string_real (const std::string &input, const std::string &delimiter, std::vector< libMesh::Real > &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::MoleFractionsDirichletBCFactory::extract_var_section(), GRINS::ICHandlingBase::init_ic_types(), GRINS::DefaultBCBuilder::parse_and_build_bc_id_map(), parse_qoi_data(), GRINS::GasRecombinationCatalyticWallNeumannBCFactoryImpl::parse_reactant_and_product(), GRINS::GasSolidCatalyticWallNeumannBCFactoryImpl::parse_reactants_and_product(), split_string_real(), 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  }
void GRINS::StringUtilities::split_string_real ( const std::string &  input,
const std::string &  delimiter,
std::vector< libMesh::Real > &  results 
)

Definition at line 53 of file string_utils.C.

References split_string().

Referenced by GRINS::HITRAN::HITRAN().

56  {
57  std::vector<std::string> string_vec;
58 
59  split_string(input,delimiter,string_vec);
60 
61  results.resize(string_vec.size());
62 
63  for (unsigned int i=0; i<string_vec.size(); i++)
64  results[i] = string_to_T<libMesh::Real>(string_vec[i]);
65  }
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
Definition: string_utils.C:31
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 Tue Dec 19 2017 12:47:32 for GRINS-0.8.0 by  doxygen 1.8.9.1