19 template<
typename ... Args>
20 static std::string
dim_value(std::string explicitValue,
const std::string format,
const Args ... args) {
22 size_t pos = explicitValue.find(
"<>");
23 if (pos !=std::string::npos)
27 if (explicitValue.empty())
30 if (explicitValue ==
" ")
38 template<
typename ... Args>
39 static std::string
string_format(
const std::string &format, Args ... args) {
40 size_t size = 1 + snprintf(
nullptr, 0, format.c_str(), args ...);
41 std::unique_ptr<char[]> buf(
new char[size]);
42 snprintf(buf.get(), size, format.c_str(), args ...);
43 return std::string(buf.get(), buf.get() + size);
49 static bool isBlank(
const std::string str) {
50 std::regex r(
"[\\s]");
51 std::string result = regex_replace(str, r,
"");
52 return result.length()==0;
61 struct nocase_compare :
public std::binary_function<unsigned char,unsigned char,bool>
63 bool operator() (
const unsigned char& c1,
const unsigned char& c2)
const {
64 return std::tolower (c1) < std::tolower (c2);
67 bool operator() (
const std::string & s1,
const std::string & s2)
const {
68 return std::lexicographical_compare
69 (s1.begin (), s1.end (),
70 s2.begin (), s2.end (),
78 static std::string
tolower(std::string data) {
79 std::transform(data.begin(), data.end(), data.begin(),
::tolower);
static std::string string_format(const std::string &format, Args...args)
static std::string tolower(std::string data)
static std::string dim_value(std::string explicitValue, const std::string format, const Args...args)
bool operator()(const std::string &s1, const std::string &s2) const
bool operator()(const unsigned char &c1, const unsigned char &c2) const
static bool isBlank(const std::string str)