-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCUserDB.h
More file actions
70 lines (39 loc) · 1.03 KB
/
SCUserDB.h
File metadata and controls
70 lines (39 loc) · 1.03 KB
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
#ifndef SCUSERDB_H
#define SCUSERDB_H
#include "SocketLib/SocketLib.h"
#include <string>
#include <list>
#include<map>
using std::string;
using SocketLib::Connection;
using SocketLib::Telnet;
class User
{
public:
User() { connection = 0; };
User( Connection<Telnet>* c, string& n )
: connection( c ),
name( n )
{
// no code
}
string name;
Connection<Telnet>* connection;
};
class UserDatabase
{
public:
//这样写可以使DB类更像常规的STL容器
typedef std::list<User> users;
typedef std::list<User>::iterator iterator;
static iterator begin() { return m_users.begin(); }
static iterator end() { return m_users.end(); }
static iterator find( Connection<Telnet>* p_connection );
static bool AddUser( Connection<Telnet>* p_connection, string p_name );
static void DeleteUser( Connection<Telnet>* p_connection );
static bool HasUser( string& p_name );
static bool IsValidName( const string& p_name );
protected:
static users m_users;
};
#endif