7#ifndef _MIMETIC_UTILS_H_
8#define _MIMETIC_UTILS_H_
12#include <mimetic/libconfig.h>
13#include <mimetic/strutils.h>
18std::ostream& crlf(std::ostream&);
19std::ostream& nl(std::ostream&);
22inline int isblank(
char c)
24 return c ==
' ' || c ==
'\t';
32std::string extractFilename(
const std::string&);
35std::string int2str(
int n);
38bool string_is_blank(
const std::string&);
41int str2int(
const std::string& s);
44std::string int2hex(
unsigned int n);
47template<
typename Iterator>
48Iterator find_bm(Iterator bit, Iterator eit,
const std::string& word,
const std::random_access_iterator_tag&)
50 int bLen = word.length();
51 const char* pWord = word.c_str();
55 for(i = 0; i < 256; ++i)
58 for(i = 0; i < bLen; ++i)
59 shift[ (
unsigned char) pWord[i] ] = bLen -i - 1;
61 for(i = t = bLen-1; t >= 0; --i, --t)
66 while((c = *(bit + i)) != pWord[t])
68 i += std::max(bLen-t, shift[c]);
69 if((bit + i) >= eit)
return eit;
84template<
typename Iterator>
85Iterator find_bm(Iterator bit, Iterator eit,
const std::string& word)
87 return find_bm(bit, eit, word,
88 typename std::iterator_traits<Iterator>::iterator_category());