blocks and items 'caption' property
This commit is contained in:
@@ -335,6 +335,26 @@ std::wstring util::pascal_case(const std::wstring& str) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string util::id_to_caption(const std::string& id) {
|
||||
std::string result = id;
|
||||
|
||||
size_t index = result.find(':');
|
||||
if (index < result.length()-1) {
|
||||
result = result.substr(index+1);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
size_t offset = 0;
|
||||
for (; offset < result.length() && result[offset] == '_'; offset++) {}
|
||||
|
||||
for (; offset < result.length(); offset++) {
|
||||
if (result[offset] == '_') {
|
||||
result[offset] = ' ';
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// @brief Split string by delimiter
|
||||
/// @param str source string
|
||||
/// @param delimiter split delimiter size
|
||||
|
||||
@@ -39,6 +39,12 @@ namespace util {
|
||||
extern std::wstring capitalized(const std::wstring& str);
|
||||
extern std::wstring pascal_case(const std::wstring& str);
|
||||
|
||||
/// @brief Convert `any_prefix:some_data_id` to `some data id`. Leaves
|
||||
/// '_' characters at end of the id.
|
||||
/// @param id source id
|
||||
/// @return resulting caption or empty string if there's nothing but prefix
|
||||
extern std::string id_to_caption(const std::string& id);
|
||||
|
||||
extern std::vector<std::string> split(const std::string& str, char delimiter);
|
||||
extern std::vector<std::wstring> split(const std::wstring& str, char delimiter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user