Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_String_Utilities.hpp
Go to the documentation of this file.
1 //@HEADER
2 // *****************************************************************************
3 // Tempus: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_String_Utilities_hpp
11 #define Tempus_String_Utilities_hpp
12 
13 #include <vector>
14 #include <string>
15 #include "Teuchos_RCP.hpp"
17 #include "Tempus_config.hpp"
18 
19 namespace Tempus {
20 
22 void trim(std::string& str);
23 
25 void StringTokenizer(std::vector<std::string>& tokens, const std::string& str,
26  const std::string delimiter = ",", bool trim = false);
27 
29 void TokensToDoubles(std::vector<double>& values,
30  const std::vector<std::string>& tokens);
31 
33 void TokensToInts(std::vector<int>& values,
34  const std::vector<std::string>& tokens);
35 
39 template <typename ScalarT>
40 ScalarT getScalarParameter(const std::string& field,
41  const Teuchos::ParameterList& plist)
42 {
43  return plist.get<double>(field);
44 }
45 } // namespace Tempus
46 
47 #endif // Tempus_String_Utilities_hpp
ScalarT getScalarParameter(const std::string &field, const Teuchos::ParameterList &plist)
T & get(const std::string &name, T def_value)
void TokensToDoubles(std::vector< double > &values, const std::vector< std::string > &tokens)
Turn a vector of tokens into a vector of doubles.
void trim(std::string &str)
Removes whitespace at beginning and end of string.
void StringTokenizer(std::vector< std::string > &tokens, const std::string &str, const std::string delimiters, bool trim)
Tokenize a string, put tokens in a vector.
void TokensToInts(std::vector< int > &values, const std::vector< std::string > &tokens)
Turn a vector of tokens into a vector of ints.