⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 packetquery.cpp

📁 swain-0.5.2.zip的源代码,比较好用,希望大家喜欢.
💻 CPP
字号:
/*
This file is part of SWAIN (http://sourceforge.net/projects/swain).
Copyright (C) 2006  Daniel Lindstr鰉 and Daniel Nilsson

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA  02110-1301, USA.
*/
#include "StdAfx.h"
#include "PacketQuery.h"
#include "packetid.h"

PacketQuery::PacketQuery(){
	this->flag = 0;
	this->num_groups = 0;
	this->groups = NULL;
	this->max_results = 0;
}

PacketQuery::PacketQuery(int flag, const int *groups, int num_groups, int max_result){
	if (groups == NULL) {
		num_groups = 0;
	}
	this->flag = flag;
	this->num_groups = num_groups;
	this->groups = new int[num_groups];
	if (groups != NULL) {
		memcpy(this->groups, groups, num_groups*sizeof(int));
	}
	this->max_results = max_result;

}

PacketQuery::~PacketQuery(void){
	delete this->groups;
}

void PacketQuery::read(Socket *s, int size){
	s->receiveInt(&this->flag);
	s->receiveInt(&this->max_results);
	s->receiveInt(&this->num_groups);
	this->groups = new int[this->num_groups];
	for(int i=0; i<this->num_groups; i++)
		s->receiveInt(&this->groups[i]);
}

void PacketQuery::write(Socket *s){
	s->sendInt(this->flag);
	s->sendInt(this->max_results);
	s->sendInt(this->num_groups);
	for(int i=0; i<num_groups; i++){
		s->sendInt(this->groups[i]);
	}
}

int PacketQuery::getSize(void){
	return((num_groups+3)*sizeof(int));
}

int PacketQuery::getId(void){
	return(PACKET_QUERY);
}


int PacketQuery::getFlag(){
	return(this->flag);
}

int *PacketQuery::getGroups(void){
	return(this->groups);
}

int PacketQuery::getNumGroups(void){
	return(this->num_groups);
}

int PacketQuery::getMaxResults(void){
	return(this->max_results);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -