common_util 1.1.0
|
Common string utilities. More...
#include <string>
#include <vector>
Go to the source code of this file.
Typedefs | |
using | cutl::strvec = std::vector< std::string > |
The type of vector strings used in this library. | |
Functions | |
std::string | cutl::to_upper (const std::string &str) |
Convert a string to upper case. | |
std::string | cutl::to_lower (const std::string &str) |
Convert a string to lower case. | |
std::string | cutl::lstrip (const std::string &str) |
Remove leading whitespaces from a string. | |
std::string | cutl::rstrip (const std::string &str) |
Remove trailing whitespaces from a string. | |
std::string | cutl::strip (const std::string &str) |
Remove leading and trailing whitespaces from a string. | |
bool | cutl::starts_with (const std::string &str, const std::string &start, bool ignoreCase=false) |
Check if a string starts with a given substring. | |
bool | cutl::ends_with (const std::string &str, const std::string &end, bool ignoreCase=false) |
Check if a string ends with a given substring. | |
strvec | cutl::split (const std::string &str, const std::string &separator) |
Split a string into a vector of substrings using a given separator. | |
std::string | cutl::join (const strvec &strlist, const std::string &separator="") |
Join a vector of strings into a single string using a given separator. | |
std::string | cutl::desensitizing (const std::string &str) |
Desensitizing a string by replacing some characters with '*'. | |
std::string | cutl::ws2s (const std::wstring &ws, const std::string &locale="") |
Convert a wide string to a string. | |
std::wstring | cutl::s2ws (const std::string &s, const std::string &locale="") |
Convert a string to a wide string. | |
Common string utilities.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations.
std::string cutl::desensitizing | ( | const std::string & | str | ) |
Desensitizing a string by replacing some characters with '*'.
str | the string to be desensitized. |
bool cutl::ends_with | ( | const std::string & | str, |
const std::string & | end, | ||
bool | ignoreCase = false |
||
) |
Check if a string ends with a given substring.
str | the string to be checked. |
end | the substring to be checked. |
ignoreCase | whether to ignore case when comparing, default is false. |
std::string cutl::join | ( | const strvec & | strlist, |
const std::string & | separator = "" |
||
) |
Join a vector of strings into a single string using a given separator.
strlist | the vector of strings to be joined. |
separator | the separator to join the strings. |
std::string cutl::lstrip | ( | const std::string & | str | ) |
Remove leading whitespaces from a string.
str | the string to be stripped. |
std::string cutl::rstrip | ( | const std::string & | str | ) |
Remove trailing whitespaces from a string.
str | the string to be stripped. |
std::wstring cutl::s2ws | ( | const std::string & | s, |
const std::string & | locale = "" |
||
) |
Convert a string to a wide string.
s | the string to be converted. |
locale | the locale used to convert the string, default is "". the locale parameter is reference to setlocale() |
strvec cutl::split | ( | const std::string & | str, |
const std::string & | separator | ||
) |
Split a string into a vector of substrings using a given separator.
str | the string to be split. |
separator | the separator to split the string. |
bool cutl::starts_with | ( | const std::string & | str, |
const std::string & | start, | ||
bool | ignoreCase = false |
||
) |
Check if a string starts with a given substring.
str | the string to be checked. |
start | the substring to be checked. |
ignoreCase | whether to ignore case when comparing, default is false. |
std::string cutl::strip | ( | const std::string & | str | ) |
Remove leading and trailing whitespaces from a string.
str | the string to be stripped. |
std::string cutl::to_lower | ( | const std::string & | str | ) |
Convert a string to lower case.
str | the string to be converted. |
std::string cutl::to_upper | ( | const std::string & | str | ) |
Convert a string to upper case.
str | the string to be converted. |
std::string cutl::ws2s | ( | const std::wstring & | ws, |
const std::string & | locale = "" |
||
) |
Convert a wide string to a string.
ws | the wide string to be converted. |
locale | the locale used to convert the wide string, default is "". the locale parameter is reference to setlocale() |