27 template <
class EXCEPTION>
void handle_error(
const std::ostringstream &message)
29 throw EXCEPTION((message).str());
37 template <
class ForwardIt,
class T>
38 ForwardIt
bound_search(ForwardIt first, ForwardIt last,
const T &value)
40 first = std::lower_bound(first, last, value);
41 if (!(first == last) && !(value < *first))
47 template <
class ForwardIt,
class T,
class Compare>
48 ForwardIt
bound_search(ForwardIt first, ForwardIt last,
const T &value, Compare comp)
50 first = std::lower_bound(first, last, value, comp);
51 if (!(first == last) && !(comp(value, *first)))
59 auto start_it = inpt.begin();
60 auto end_it = inpt.rbegin();
61 while (std::isspace(*start_it))
63 while (std::isspace(*end_it))
65 return std::string(start_it, end_it.base());
68 inline std::vector<std::string>
get_tokens(
const std::string &str,
69 const std::string &separators)
71 std::vector<std::string> tokens;
72 auto first = std::begin(str);
73 while (first != std::end(str)) {
75 std::find_first_of(first, std::end(str), std::begin(separators), std::end(separators));
76 if (first != second) {
78 tokens.emplace_back(token);
80 if (second == std::end(str)) {
83 first = std::next(second);
90 std::transform(str.begin(), str.end(), str.begin(), ::toupper);
95 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
100 for (
char const &c : str) {
101 if (std::isdigit(c) == 0)
109 std::set<T> dataAsSet;
111 for (
const T &data : dataAsVector) {
112 dataAsSet.insert(data);
119 const std::string &prefix)
121 const unsigned prefixLength = prefix.length();
123 if (name.length() < prefixLength + 1)
124 return std::make_pair(0,
false);
126 const std::string namePrefix = name.substr(0, prefixLength);
127 const std::string nameSuffix = name.substr(prefixLength);
129 if (strcasecmp(namePrefix.c_str(), prefix.c_str()) != 0)
130 return std::make_pair(0,
false);
133 std::istringstream nameSuffixStream(nameSuffix);
134 nameSuffixStream >> id;
135 if (nameSuffixStream.fail()) {
136 return std::make_pair(0,
false);
138 return std::make_pair(
id,
true);
void handle_error(const std::ostringstream &message)
Definition Iotm_TextMeshFuncs.h:27
bool is_positive_number(const std::string &str)
Definition Iotm_TextMeshFuncs.h:98
ForwardIt bound_search(ForwardIt first, ForwardIt last, const T &value)
Definition Iotm_TextMeshFuncs.h:38
void convert_to_upper_case(std::string &str)
Definition Iotm_TextMeshFuncs.h:88
std::vector< std::string > get_tokens(const std::string &str, const std::string &separators)
Definition Iotm_TextMeshFuncs.h:68
void default_error_handler(const std::ostringstream &message)
Definition Iotm_TextMeshFuncs.h:32
void convert_to_lower_case(std::string &str)
Definition Iotm_TextMeshFuncs.h:93
std::set< T > transform_to_set(const std::vector< T > &dataAsVector)
Definition Iotm_TextMeshFuncs.h:107
std::pair< unsigned, bool > get_id_from_part_name(const std::string &name, const std::string &prefix)
Definition Iotm_TextMeshFuncs.h:118
std::string strip_whitespace(const std::string &inpt)
Definition Iotm_TextMeshFuncs.h:57
A namespace for the textmesh database format.
Definition Iotm_DatabaseIO.C:95