?? establish.h
字號:
#ifndef _ESTABLISH_H
#define _ESTABLISH_H
#include "common.h"
bool Check_Digit_Fomat(string& str)// how to check whether the data is float or double?
{
for (size_t i = 0 ; i<str.length();++i)
if(!isdigit(str[i]))
return false;
return true;
}
int establish(string& table_name,const char* data_path)
{
map<string, list<column *> * >::iterator map_ptr;
map_ptr = SQL.find(table_name);
if(map_ptr==SQL.end())
{
cerr<<"table don't exist\n";
return -1;//table not exist
}
ifstream in;
in.open(data_path);
if (!in.is_open())
{
cerr<<"can't open the file\n";
return -2;//can't open the file
}
string strline;
string str;
int count = 0;
while (getline(in,strline))
{
int i = 0;
while(i!=strline.length()-1)//change the , to blank
{
if(strline[i]==',')
strline[i]=' ';
++i;
}
istringstream iss(strline);
list<column*>::iterator ptr = (*(map_ptr->second)).begin();//table.begin();
for( ; ptr!=(*(map_ptr->second)).end() ; ++ptr)
{
iss>>str;
if (((*ptr)->type_float&&Check_Digit_Fomat(str))||((*ptr)->type_char))// check the data format
(*ptr)->data.push_back(str);
}
count++;
}
in.close();
return count;
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -