22 #ifndef SINGA_UTILS_TOKENIZER_H_ 23 #define SINGA_UTILS_TOKENIZER_H_ 27 #include "singa/utils/logging.h" 30 inline bool icasecmp(
const string& l,
const string& r) {
31 return l.size() == r.size() &&
32 equal(l.cbegin(), l.cend(), r.cbegin(),
33 [](string::value_type l1, string::value_type r1) {
34 return toupper(l1) == toupper(r1);
38 inline string ToLowerCase(
const string& input) {
40 out.resize(input.size());
41 std::transform(input.begin(), input.end(), out.begin(), ::tolower);
45 inline int ArgPos(
int argc,
char** arglist,
const char* arg) {
46 for (
int i = 0; i < argc; i++) {
47 if (strcmp(arglist[i], arg) == 0) {
55 inline std::string VecToStr(
const std::vector<T> & in) {
56 std::string out =
"(";
59 out += std::to_string(x) +
", ";
79 Tokenizer(
const std::string& str,
const std::string& sep): start_(0),
80 sep_(sep), buf_(str) {}
81 Tokenizer & operator>>(std::string& out) {
82 CHECK_LT(start_, buf_.length());
84 auto pos = buf_.find_first_of(sep_, start);
85 if (pos == std::string::npos)
87 start_ = (
unsigned int)(pos + 1);
88 out = buf_.substr(start, pos);
91 bool Valid() {
return start_ < buf_.length(); }
96 const std::string& buf_;
101 #endif // SINGA_UTILS_TOKENIZER_H_ Tokenize a string.
Definition: string.h:77
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: common.h:48