aboutsummaryrefslogtreecommitdiffstats
path: root/tool/PGListUtil/src/common/CIpList.h
blob: 591c3877d728eb1ee2b99a8d9ae5b3a15ade0d1e (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
#ifndef CIPLIST_H
#define CIPLIST_H

#include <boost/pool/pool.hpp>
#include <boost/xpressive/xpressive.hpp>
#include "common.h"
#include "CFilter.h"

namespace pglu {
namespace ip {

struct CIp {
	char *		caption;
	union {
		ulong	ip64;
		uint	ip32[2];
		uchar	ip8[8];
	};
	CIp *		next;
};

class CIpList {
private:
	boost::pool<>	m_poolIp;
	CIp				m_ipHead;
	CIp *			m_ipFoot;

	filter::CFilter	m_filter;

	int				m_count;
	int				m_countDisabled;

	CIp * CreateIp(boost::xpressive::cmatch & match);

public:
	CIpList();
	~CIpList();

	void Clear();

	void SetFilter(const char *filter, const filter::EFilterMode mode, const bool del);
	void UnSetFilter();

	bool LoadListFile(const char *path);
	bool SaveListFile(const char *path, const bool append);

	void CheckAndSort(const bool sortCap, const bool sortIp, const bool delDupIp);

	int Count();
	int CountDisabled();
};

} // namespace ip
} // namespace pglu

#endif // CIPLIST_H