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

📄 glob_var.h

📁 一个简单的minisql
💻 H
字号:
//Glob_Var.h
#ifndef GLOB_VAR_H
#define GLOB_VAR_H

#include "Buffer.h"
#include <iostream>

using namespace std;

extern char CurLocation[256];
extern char CurRelationName[33];
extern char* ErrorMessage[];


enum MSG {CREATE,SELECT,INSERT,UPDATE,DELETE,DROP,QUIT,
          SHOWDB,SHOWTABLE,USE,HELP,UNORMAL,NEW,DEFAULT,DROPDB};

//I---int  C---char   F---float
enum  Column_Type {I,C,F};    
// >  >=  <  <=  =  !=  between…and…;
enum Operator_Type {B, BE, L, LE, E, NE,BETWEEN,ALL};


typedef struct TKey_Location* pKey_Location;
typedef struct TKey_Location
{
  _F_FileAddr ptr ;    //节点指针
  int     offset;  //所在节点的第几个key
  bool operator==(TKey_Location key)
  {
    return (this->ptr == key.ptr && this->offset == key.offset);
  }
  bool operator!=(TKey_Location key)
  {
    if(this->ptr == key.ptr && this->offset == key.offset)
      return false;
    return true;
  }
}Key_Location;



//-----------------------------------------------------------------------------------------
//支持int,char和float类型
union Column_Value
{
    int   		IntValue;		 //整形值
    char* 		pCharValue;	 //字符串指针 
    float 		FloatValue;	 //浮点型值
};   		

//---------------------------------------------------------------------------------------------
//catalog给index的关于选择范围的信息
//使用者:index
typedef struct TKey_Attr* pKey_Attr;
typedef struct TKey_Attr
{
   Column_Value		value;
   pKey_Attr		next;
   TKey_Attr(){next = NULL;}
}Key_Attr;

typedef  struct TCondtion_Info  
{										      //查找的范围信息
	Operator_Type	OperType;	//关系运算符
	pKey_Attr		min;				//按照顺序链接的属性的范围下限
	pKey_Attr		max;				//按照顺序链接的属性的范围上限
	TCondtion_Info(){
		min = NULL;
		max = NULL;
		OperType = B;
	}
}Condition_Info;

//------------------------------------------------------------------------------------------------
//Catalog得出的关于选择需要的字段信息
//使用者:Record
typedef struct TSelect_Cell
{
	char			ColumnName[32];	//字段名――方便打印
	Column_Type		ColType;		//字段类型――方便打印
	int				PriorLength;		//记录头到此字段之间的长度
	int				ColLength;			//字段类型的长度
	TSelect_Cell*	next;				//下一个字段信息
	TSelect_Cell():PriorLength(0),ColLength(0),ColType(I) 
	{	
		this->next = NULL;
		strcpy(this->ColumnName,"");	
	}
}Select_Cell;

class Select_Rec_Info
{
public:
	Select_Cell*	head;
	int				ColumnNum;
    int             RecordLength;
	Select_Rec_Info():ColumnNum(0) {this->head=NULL;}
	~Select_Rec_Info(){};
};


//Catalog将待插入记录的缺省值(如果有)填完整后形成的完整的记录信息
//使用者:Record
typedef  struct TCell_Info 	//记录单个属性上的信息
{
	Column_Type	  	ColType;	//属性类型
	Column_Value	value;
	int 			PriorLength;		//记录头到当前字段之间的长度
	int				ColLength;			//当前字段的长度
	TCell_Info*		next;
	TCell_Info(){
		next = NULL;
		ColType = I;
		PriorLength = 0;
		ColLength = 0;
	}
}Cell_Info;
class Rec_Info
{
public:
	Cell_Info* 		head;
	int				    ColNum;
	int				    RecordLength;
  Rec_Info(){
		head = NULL;
		ColNum = 0;
	}
	~Rec_Info(){};
};


#endif  //GLOB_BAR_H

⌨️ 快捷键说明

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