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

📄 sps.c

📁 对sps文件的包装类
💻 C
字号:
#include "sps.h"
//class Cx_file
int Cx_file::IfXfile(char *f1)
{
	fp1=fopen(f1,"r");
	if(fp1==NULL)
	{
		cout<<"Open the Cx_file err"<<endl;
		return(9);
	}
	do
	{
		fgets(ar1,90,fp1);
		if(ar1[0]!='H')break;

	}while(!feof(fp1));

	if(ar1[0]!='X')
	{
		cout<<"This is't a Cx_file!"<<endl;
		fclose(fp1);
		return(9);
	}else 
	{
		rewind(fp1);
		return 0;
	}
	
}
int  Cx_file::readline()
{	
	if(fp1==NULL)return 9;
	if(xflag==0)
	{
		do
		{
			fgets(ar1,90,fp1);
			if(ar1[0]!='H')break;
		}while(!feof(fp1));
	}
	if(ar1[0]!='X')return 18;
	else 
	{
	  Setfilenum();
	  Setslinenum();
	  Setfirstch();
	  Setspoint();
	  Setlastch();
	  Setfistgeo();
	  Setlastgeo();
	  Setgeoline();

		xflag=1;
		return 0;
	}
}
int  Cx_file::readnext()
{	
	if(fp1==NULL)return 9;
	if(xflag==0)return 18;
	if(feof(fp1))return 36;
	fgets(ar1,90,fp1);
	if(ar1[0]!='X')return 18;
	else 
	{
	  Setfilenum();
	  Setslinenum();
	  Setfirstch();
	  Setspoint();
	   Setlastch();
	  Setfistgeo();
	  Setlastgeo();
	  Setgeoline();

		xflag=1;
		return 0;
	}
}
void Cx_file::Setfirstch()
{
	char tmp[90];
	for(int i=0;i<4;i++)tmp[i]=ar1[38+i];
	firstch=atoi(tmp);
}
void Cx_file::Setfilenum()
{
	char tmp[90];
	for(int i=0;i<4;i++)tmp[i]=ar1[7+i];
	filenum=atoi(tmp);
}
void Cx_file::Setspoint()
{
	char tmp[90];
	for(int i=0;i<8;i++)tmp[i]=ar1[29+i];
	spoint=atoi(tmp);
}
void Cx_file::Setlastch()
{
	char tmp[90];
	for(int i=0;i<4;i++)tmp[i]=ar1[42+i];
	lastch=atoi(tmp);
}
void Cx_file::Setfistgeo()
{
	char tmp[90];
	for(int i=0;i<8;i++)tmp[i]=ar1[63+i];
	fistgeo=atoi(tmp);
}
void Cx_file::Setslinenum()
{
	char tmp[90];
	for(int i=0;i<8;i++)tmp[i]=ar1[13+i];
	slinenum=atoi(tmp);
}

void Cx_file::Setgeoline()
{
	char tmp[90];
	for(int i=0;i<16;i++)tmp[i]=ar1[47+i];
	geoline=atoi(tmp);
}
void Cx_file::Setlastgeo()
{
	char tmp[90];
	for(int i=0;i<8;i++)tmp[i]=ar1[71+i];
	lastgeo=atoi(tmp);
}
void Cx_file::operator=(Cx_file& x)
{
	filenum=x.filenum;
	slinenum=x.slinenum;
	spoint=x.spoint;
	firstch=x.firstch;
	lastch=x.lastch;
	geoline=x.geoline;
	fistgeo=x.fistgeo;
	lastgeo=x.lastgeo;
	this->fp1=x.fp1;
	strcpy(ar1,x.ar1);
	xflag=x.xflag;
}
int Cx_file::Getfilenum()
	{
		return filenum;
	}
int Cx_file::Getfirstch()
	{
		return firstch;
	}
int Cx_file::Getspoint()
	{
		return spoint;
	}
int Cx_file::Getlastch()
	{
		return lastch;
	}
int Cx_file::Getfistgeo()
	{
		return fistgeo;
	}
int Cx_file::Getlastgeo()
	{
		return lastgeo;
	}
int Cx_file::Getgeoline()
	{
	return geoline;
	}


//class Cr_file
int Cr_file::Ifrfile(char *f1)
{
	fp1=fopen(f1,"r");
	if(fp1==NULL)
	{
		cout<<"Open the Cr_file err"<<endl;
		return(9);
	}
	do
	{
		fgets(ar1,90,fp1);
		if(ar1[0]!='H')break;

	}while(!feof(fp1));

	if(ar1[0]!='R')
	{
		cout<<"This is't a Cr_file!"<<endl;
		fclose(fp1);
		return(9);
	}else 
	{
		rewind(fp1);
		return 0;
	}
	
}
int  Cr_file::readline()
{	
	if(fp1==NULL)return 9;
	if(rflag==0)
	{
		do
		{
			fgets(ar1,90,fp1);
			if(ar1[0]!='H')break;
		}while(!feof(fp1));
	}
	if(ar1[0]!='R')return 18;
	else 
	{
	  Setrlilenum();
	  Setrpoint();
	  Setlst();
	  Setdepth();
	  Setx();
	  Sety();
	  Setlel();
	
		rflag=1;
		return 0;
	}
}
int  Cr_file::readnext()
{	
	if(fp1==NULL)return 9;
	if(rflag==0)return 18;
	if(feof(fp1))return 36;
	fgets(ar1,90,fp1);
	if(ar1[0]!='R')return 18;
	else 
	{
	  Setrlilenum();
	  Setrpoint();
	  Setlst();
	  Setdepth();
	  Setx();
	  Sety();
	  Setlel();

		rflag=1;
		return 0;
	}
}
void Cr_file::Setrlilenum()
{
	char tmp[90];
	for(int i=0;i<16;i++)tmp[i]=ar1[1+i];
	rlinenum=atoi(tmp);
}
void Cr_file::Setrpoint()
{
	char tmp[90];
	for(int i=0;i<8;i++)tmp[i]=ar1[17+i];
	rpoint=atoi(tmp);
}
void Cr_file::Setlst()
{
	char tmp[90];
	for(int i=0;i<4;i++)tmp[i]=ar1[28+i];
	lst=atof(tmp);
}

void Cr_file::Setdepth()
{
	char tmp[90];
	for(int i=0;i<4;i++)tmp[i]=ar1[32+i];
	depth=atof(tmp);
}
void Cr_file::Setx()
{
	char tmp[90];
	for(int i=0;i<9;i++)tmp[i]=ar1[46+i];
	x=atof(tmp);
}
void Cr_file::Sety()
{
	char tmp[90];
	for(int i=0;i<10;i++)tmp[i]=ar1[55+i];
	y=atof(tmp);
}
void Cr_file::Setlel()
{
	char tmp[90];
	for(int i=0;i<6;i++)tmp[i]=ar1[65+i];
	lel=atof(tmp);
}
int Cr_file::Getrlinenum()
{
	return rlinenum;
}
int Cr_file::Getrpoint()
{
	return rpoint;
}
float Cr_file::Getlst()
{
	return lst;
}
float Cr_file::Getdepth()
{
	return depth;
}
float Cr_file::Getx()
{
	return x;
}
float Cr_file::Gety()
{
	return y;
}
float Cr_file::Getlel()
{
	return lel;
}

//class Cs_file
int Cs_file::Ifsfile(char *f1)
{
	fp1=fopen(f1,"r");
	if(fp1==NULL)
	{
		cout<<"Open the Cs_file err"<<endl;
		return(9);
	}
	do
	{
		fgets(ar1,90,fp1);
		if(ar1[0]!='H')break;

	}while(!feof(fp1));

	if(ar1[0]!='S')
	{
		cout<<"This is't a Cs_file!"<<endl;
		fclose(fp1);
		return(9);
	}else 
	{
		rewind(fp1);
		return 0;
	}
	
}
int  Cs_file::readline()
{	
	if(fp1==NULL)return 9;
	if(sflag==0)
	{
		do
		{
			fgets(ar1,90,fp1);
			if(ar1[0]!='H')break;
		}while(!feof(fp1));
	}
	if(ar1[0]!='S')return 18;
	else 
	{
	  Setslilenum();
	  Setspoint();
	  Setlst();
	  Setdepth();
	  Setx();
	  Sety();
	  Setlel();
	
		sflag=1;
		return 0;
	}
}
int  Cs_file::readnext()
{	
	if(fp1==NULL)return 9;
	if(sflag==0)return 18;
	if(feof(fp1))return 36;
	fgets(ar1,90,fp1);
	if(ar1[0]!='S')return 18;
	else 
	{
	  Setslilenum();
	  Setspoint();
	  Setlst();
	  Setdepth();
	  Setx();
	  Sety();
	  Setlel();

		sflag=1;
		return 0;
	}
}
void Cs_file::Setslilenum()
{
	char tmp[90];
	for(int i=0;i<16;i++)tmp[i]=ar1[1+i];
	slinenum=atoi(tmp);
}
void Cs_file::Setspoint()
{
	char tmp[90];
	for(int i=0;i<8;i++)tmp[i]=ar1[17+i];
	spoint=atoi(tmp);
}
void Cs_file::Setlst()
{
	char tmp[90];
	for(int i=0;i<4;i++)tmp[i]=ar1[28+i];
	lst=atof(tmp);
}

void Cs_file::Setdepth()
{
	char tmp[90];
	for(int i=0;i<4;i++)tmp[i]=ar1[32+i];
	depth=atof(tmp);
}
void Cs_file::Setx()
{
	char tmp[90];
	for(int i=0;i<9;i++)tmp[i]=ar1[46+i];
	x=atof(tmp);
}
void Cs_file::Sety()
{
	char tmp[90];
	for(int i=0;i<10;i++)tmp[i]=ar1[55+i];
	y=atof(tmp);
}
void Cs_file::Setlel()
{
	char tmp[90];
	for(int i=0;i<6;i++)tmp[i]=ar1[65+i];
	lel=atof(tmp);
}
int Cs_file::Getslinenum()
{
	return slinenum;
}
int Cs_file::Getspoint()
{
	return spoint;
}
float Cs_file::Getlst()
{
	return lst;
}
float Cs_file::Getdepth()
{
	return depth;
}
float Cs_file::Getx()
{
	return x;
}
float Cs_file::Gety()
{
	return y;
}
float Cs_file::Getlel()
{
	return lel;
}

⌨️ 快捷键说明

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