Skip to content
Snippets Groups Projects
Commit bd42ac2f authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[string] add to_camel_case

parent 1c7f229e
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
#include <algorithm>
#include <cctype>
#include <string>
#include <sstream>
#include "string.hh"
......@@ -37,6 +38,19 @@ std::string to_upper(const std::string& ss)
}
std::string to_camel_case(const std::string& ss)
{
std::stringstream out;
for (auto&& word : tokenize(ss, "_", boost::algorithm::token_compress_on)) {
if (word.size() > 0) {
out << to_upper(word.substr(0, 1));
out << word.substr(1);
}
}
return out.str();
}
} // namespace Common
} // namespace XT
} // namespace Dune
......@@ -128,6 +128,12 @@ std::string to_lower(const std::string& ss);
std::string to_upper(const std::string& ss);
/**
* \brief Converts this_sample_string to ThisSampleString.
*/
std::string to_camel_case(const std::string& ss);
/**
\brief Returns a string of lengths t' whitespace (or whitespace chars).
\param[in] t defines the length of the return string (after conversion to string)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment