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

📄 message.cpp

📁 本代码是基于LINUX系统下的
💻 CPP
字号:
#include "Message.h"CMessage::CMessage(char *buff, int buf_length)
{
	assert(buff != NULL);
	total_length = buf_length;
	total_Str = new char[total_length];
	if(total_Str != NULL)
	cout<< "make success!"<< endl;
	int i=0;
	while(i < total_length)
	{
		total_Str[i] = buff[i];
		i++;
	}
	Type = buff[1];
	Sid = 0;
}

void CMessage::SetSingleStr(char *str, int startc,int length)
{		assert((startc+length) <= total_length);
		int i = 0,j = startc;
		while(i < length)
		{
			total_Str[j] = str[i];
			i++;
			j++;
		}
}

void CMessage::GetsingleStr(char *str,  int startc, int length)
{
	assert(total_Str != NULL);
	int i = 0,j = startc;
	while(i < length)
	{
		str[i] = total_Str[j];
		i++;
		j++;
	}
	str[length] = '\0';
}

int CMessage::GetTotalStrLen()
{
		return total_length;
}

int CMessage::GetType()
{	
	if(total_Str == NULL)
	cout<< "null"<< endl;
	else 
	cout<< "not null"<< endl;
	assert(total_Str != NULL);
	int i = total_Str[1];
	return i;
}

int CMessage::GetSID()
{
	return Sid;
}

CMessage::~CMessage()
{	
	//cout<< "the CMessage is running:";
	if(total_Str != NULL)delete[]total_Str;

}

⌨️ 快捷键说明

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