std::vector<double>
string_to_double (const std::vector<std::string> &s);
+
/**
* Given a string that contains text separated by a @p delimiter, split it
* into its components; for each component, remove leading and trailing
*/
std::vector<std::string>
split_string_list (const std::string &s,
- const char delimiter = ',');
+ const std::string &delimiter = ",");
+
+
+ /**
+ * Specializatin of split_string_list() for the case where the delimiter
+ * is a single char.
+ */
+ std::vector<std::string>
+ split_string_list (const std::string &s,
+ const char delimiter);
+
/**
* Take a text, usually a documentation or something, and try to break it
std::vector<std::string>
split_string_list (const std::string &s,
- const char delimiter)
+ const std::string &delimiter)
{
// keep the currently remaining part of the input string in 'tmp' and
// keep chopping elements of the list off the front
// there was space after the last delimiter. this matches what's
// discussed in the documentation
std::vector<std::string> split_list;
- split_list.reserve (std::count (tmp.begin(), tmp.end(), delimiter)+1);
while (tmp.length() != 0)
{
std::string name;
if (name.find(delimiter) != std::string::npos)
{
name.erase (name.find(delimiter), std::string::npos);
- tmp.erase (0, tmp.find(delimiter)+1);
+ tmp.erase (0, tmp.find(delimiter)+delimiter.size());
}
else
tmp = "";
}
+ std::vector<std::string>
+ split_string_list (const std::string &s,
+ const char delimiter)
+ {
+ std::string d = ",";
+ d[0] = delimiter;
+ return split_string_list(s,d);
+ }
+
std::vector<std::string>
break_text_into_lines (const std::string &original_text,
ExcInternalError());
}
+ {
+ const char *p = "alpha;; beta;; gamma ";
+ AssertThrow (Utilities::split_string_list (p, ";;").size() == 3,
+ ExcInternalError());
+ AssertThrow (Utilities::split_string_list (p, ";;")[0] == "alpha",
+ ExcInternalError());
+ AssertThrow (Utilities::split_string_list (p, ";;")[1] == "beta",
+ ExcInternalError());
+ AssertThrow (Utilities::split_string_list (p, ";;")[2] == "gamma",
+ ExcInternalError());
+ }
+
deallog << Utilities::generate_normal_random_number (13, 44) << ' ';
deallog << Utilities::generate_normal_random_number (13, 44) << ' ';
deallog << Utilities::generate_normal_random_number (13, 44) << ' ';