Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  
utils.h
1/***************************************************************************
2 copyright : (C) 2002-2008 by Stefano Barbato
3 email : stefano@codesink.org
4
5 $Id: utils.h,v 1.23 2008-10-07 11:06:26 tat Exp $
6 ***************************************************************************/
7#ifndef _MIMETIC_UTILS_H_
8#define _MIMETIC_UTILS_H_
9#include <algorithm>
10#include <iostream>
11#include <string>
12#include <ctype.h>
13#include <mimetic/libconfig.h>
14#include <mimetic/strutils.h>
15
16namespace mimetic
17{
18
19std::ostream& crlf(std::ostream&);
20std::ostream& nl(std::ostream&);
21
22#ifndef isblank
23inline int isblank(char c)
24{
25 return c == ' ' || c == '\t';
26}
27#endif
28
29namespace utils
30{
31
32/// returns the filename out of the fqn (fully qualified name)
33std::string extractFilename(const std::string&);
34
35/// returns a string representation of \p n
36std::string int2str(int n);
37
38/// return true if the string contains just blanks (space and tabs)
39bool string_is_blank(const std::string&);
40
41/// returns the integer value represented by \p s
42int str2int(const std::string& s);
43
44/// returns a string hexadecimal representation of \p n
45std::string int2hex(unsigned int n);
46
47// boyer-moore find
48/**
49 * find the first occurrence of \p word in (\p bit, \p eit]
50 *
51 * returns an Iterator pointing at the first character of the found pattern
52 * or \p eit if the search fails
53 */
54template<typename Iterator>
55Iterator find_bm(Iterator bit, Iterator eit, const std::string& word)
56{
57 return std::search(bit, eit, word.begin(), word.end());
58}
59
60} // ns utils
61
62}
63
64#endif
Definition body.h:18