blob: 9f095c2bbc39311b75b525b393f3da1eae94fe1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* Copyright (C) 2002-2009 InspIRCd Development Team
* Copyright (C) 2009 Anope Team <team@anope.org>
*
* Please read COPYING and README for further details.
*
* These classes have been copied from InspIRCd and modified
* for use in Anope.
*
* $Id$
*
*/
#ifndef _HASHCOMP_H_
#define _HASHCOMP_H_
#include <string>
/** sepstream allows for splitting token seperated lists.
* Each successive call to sepstream::GetToken() returns
* the next token, until none remain, at which point the method returns
* an empty string.
*/
class sepstream
{
private:
/** Original string.
*/
std::string tokens;
/** Last position of a seperator token
*/
std::string::iterator last_starting_position;
/** Current string position
*/
std::string::iterator n;
/** Seperator value
*/
char sep;
public:
/** Create a sepstream and fill it with the provided data
*/
sepstream(const std::string &source, char seperator);
virtual ~sepstream() { }
/** Fetch the next token from the stream
* @param token The next token from the stream is placed here
* @return True if tokens still remain, false if there are none left
*/
virtual bool GetToken(std::string &token);
/** Fetch the entire remaining stream, without tokenizing
* @return The remaining part of the stream
*/
virtual const std::string GetRemaining();
/** Returns true if the end of the stream has been reached
* @return True if the end of the stream has been reached, otherwise false
*/
virtual bool StreamEnd();
};
/** A derived form of sepstream, which seperates on commas
*/
class commasepstream : public sepstream
{
public:
/** Initialize with comma seperator
*/
commasepstream(const std::string &source) : sepstream(source, ',') { }
};
/** A derived form of sepstream, which seperates on spaces
*/
class spacesepstream : public sepstream
{
public:
/** Initialize with space seperator
*/
spacesepstream(const std::string &source) : sepstream(source, ' ') { }
};
#endif
|