FriendList.h
上传用户:hysujiao87
上传日期:2007-12-02
资源大小:156k
文件大小:1k
- #pragma once
- #include <vector>
- using namespace std;
- class CFriendData
- {
- public:
- CString userID;
- CString nickname;
- sockaddr_in addr;
- BOOL online;
- public:
- CFriendData()
- {
- ::ZeroMemory(&addr, sizeof(sockaddr_in));
- online = FALSE;
- }
- CFriendData(const CFriendData &data)
- {
- userID = data.userID;
- nickname = data.nickname;
- online = data.online;
- memcpy(&addr, &data.addr, sizeof(sockaddr_in));
- }
- void operator = (const CFriendData &data){
- userID = data.userID;
- nickname = data.nickname;
- online = data.online;
- memcpy(&addr, &data.addr, sizeof(sockaddr_in));
- }
- };
- typedef vector<CFriendData*> FriendVector;
- typedef vector<CFriendData*>::iterator FriendIterator;
- class CFriendList
- {
- protected:
- FriendVector _vector;
- public:
- CFriendList(void);
- virtual ~CFriendList(void);
- HRESULT addFriend(const CFriendData &friendData);
- HRESULT deleteFriend(LPCTSTR friendID);
- CFriendData* getFriend(LPCTSTR friendID);
- CFriendData* getFriend(int index);
- int getCount(){
- return _vector.size();
- }
- void clear();
- };