6 #if !SPKT_HAVE_CPP11 && defined(SPKT_HAVE_BOOST) 7 #include <boost/algorithm/string.hpp> 15 #define spkt_cstr(x) x->to_string().c_str() 26 template <
class A,
class B>
36 template <
class A,
class B,
class C>
47 template <
class A,
class B,
class C,
class D>
60 template <
class A,
class B,
class C,
class D,
75 template <
class A,
class B,
class C,
class D,
91 template <
class A,
class B,
class C,
class D,
92 class E,
class F,
class G>
109 template <
class A,
class B,
class C,
class D,
110 class E,
class F,
class G,
class H>
128 template <
class A,
class B,
class C,
class D,
129 class E,
class F,
class G,
class H,
149 template <
class A,
class B,
class C,
class D,
150 class E,
class F,
class G,
class H,
155 const char* file,
int line,
173 template <
class A,
class B,
class C,
class D,
174 class E,
class F,
class G,
class H,
175 class I,
class J,
class K>
197 template <
class A,
class B,
class C,
class D,
198 class E,
class F,
class G,
class H,
199 class I,
class J,
class K,
class L>
222 template <
class A,
class B,
class C,
class D,
223 class E,
class F,
class G,
class H,
224 class I,
class J,
class K,
class L,
250 template <
class A,
class B,
class C,
class D,
251 class E,
class F,
class G,
class H,
252 class I,
class J,
class K,
class L,
279 template <
class A,
class B,
class C,
class D,
280 class E,
class F,
class G,
class H,
281 class I,
class J,
class K,
class L,
282 class M,
class N,
class O>
309 #define prim_printf_type(ty) \ 310 inline ty to_pod(ty t){ return t; } 326 to_pod(const std::
string& str){
331 printf(
const char* fmt, ...);
333 #if SPKT_HAVE_CPP11 || defined(SPKT_HAVE_BOOST) 335 template<
typename WritableRangeT>
336 void to_upper(WritableRangeT& input)
339 for(
char& ch : input) {
340 ch = (char)std::toupper(ch);
342 #elif defined(SPKT_HAVE_BOOST) 343 boost::algorithm::to_upper(input);
344 #elif SPKT_DISABLE_REGEXP 347 # error "Either C++11 or Boost is required to build sprockit" 351 template<
typename WritableRangeT>
352 void to_lower(WritableRangeT& input)
355 for(
char& ch : input) {
356 ch = (char)std::tolower(ch);
358 #elif defined(SPKT_HAVE_BOOST) 359 boost::algorithm::to_lower(input);
361 # error "Either C++11 or Boost is required to build sprockit" 365 template<
typename SequenceT>
366 void trim(SequenceT& input)
369 auto check_isspace = [](decltype(*input.begin())& ch) {
return (
bool)std::isspace(ch); };
370 const auto& first_non_space = std::find_if_not(input.begin(), input.end(), check_isspace);
371 if(first_non_space == input.end()) {
372 input = SequenceT(input.begin(), input.begin()+1);
375 const auto& last_non_space = std::find_if_not(input.rbegin(), input.rend(), check_isspace);
376 if(last_non_space == input.rbegin() + 1) {
377 input = SequenceT(first_non_space, input.end());
380 input = SequenceT(first_non_space, last_non_space.base() + 1);
383 #elif defined(SPKT_HAVE_BOOST) 386 # error "Either C++11 or Boost is required to build sprockit" 395 #endif // SPKT_STRING_H void spkt_to_stream(std::ostream &os, const A &a)
std::string printf(const char *fmt,...)
prim_printf_type(const char *) prim_printf_type(void *) prim_printf_type(double) prim_printf_type(float) prim_printf_type(unsigned long) prim_printf_type(long) prim_printf_type(unsigned int) prim_printf_type(int) prim_printf_type(unsigned short) prim_printf_type(short) prim_printf_type(unsigned long long) prim_printf_type(long long) inline const char *to_pod(const std
std::basic_string< CharType, Traits, Alloc > trim(const typename std::basic_string< CharType, Traits, Alloc > &s, const typename std::basic_string< CharType, Traits, Alloc > &spaces=" \t")
A utility function to trim spaces off a std::string.