43 #ifndef OME_COMMON_STRING_H
44 # define OME_COMMON_STRING_H
46 # include <ome/common/config.h>
69 std::string::size_type pos = str.find_first_not_of(
" \r\n\t\v");
70 if (pos == std::string::npos)
73 return str.substr(pos, std::string::npos);
88 std::string::size_type pos = str.find_last_not_of(
" \r\n\t\v");
89 if (pos == std::string::npos)
92 return str.substr(0, pos + 1);
107 std::string::size_type fpos = str.find_first_not_of(
" \r\n\t\v");
108 if (fpos == std::string::npos)
109 return std::string();
111 std::string::size_type lpos = str.find_last_not_of(
" \r\n\t\v");
112 if (lpos == std::string::npos)
113 return std::string();
115 return str.substr(fpos, lpos - fpos + 1);
123 #if defined(_MSC_VER) && !defined(OME_HAVE_SNPRINTF)
125 # define snprintf c99_snprintf
126 # define vsnprintf c99_vsnprintf
132 c99_vsnprintf(
char* str,
size_t size,
const char* format, va_list ap)
137 count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
139 count = _vscprintf(format, ap);
145 c99_snprintf(
char* str,
size_t size,
const char* format, ...)
150 va_start(ap, format);
151 count = vsnprintf(str, size, format, ap);
157 #endif // _MSC_VER && !OME_HAVE_SNPRINTF
162 #endif // OME_COMMON_STRING_H
std::string trim(const std::string &str)
Trim leading and trailing whitespace from a string.
Definition: string.h:105
std::string ltrim(const std::string &str)
Trim leading whitespace from a string.
Definition: string.h:67
std::string rtrim(const std::string &str)
Trim trailing whitespace from a string.
Definition: string.h:86