📄 table.h~
字号:
#ifndef _TABLE_H_#define _TABLE_H_#include <vector.h>#include <Tool.h>using namespace std;class table{private: void readAttrib() { checkFileExist(name); int fd=openFile(name); char* temp = getNextLine(fd); if(temp!=NULL) { StringToken token(temp,','); int pos=0; while(token.hasMore()) { key.push_back(token.next()); pos++; } } temp = getNextLine(fd); if(temp!=NULL) { StringToken token1(temp,','); int pos=0; while(token1.hasMore()) { attrib.push_back(token1.next()); pos++; }} temp = getNextLine(fd); while(temp!=NULL){ if(strcmp(temp,"")!=0){ content.push_back(temp); } temp=getNextLine(fd); } closeFile(fd); //cout<<attrib[0]<<attrib[1]<<endl; //cout<<content[0]<<content[1]<<endl; }public: QString name; vector<QString> key; vector<QString> attrib; vector<char*> content; table(const char* x) { name = x; key = vector<QString>(0); attrib = vector<QString>(0); content = vector<char*>(0); readAttrib(); } int getCols() { return attrib.size(); } int getRows() { return content.size(); } int isKey(QString x) { for(int i= 0;i<key.size();i++) { if (x == key[i]) return 1; } } char* getItem(int i,int j) { StringToken token(content[i],','); int pos=0; for(;pos<j && token.hasMore(); pos++) token.next(); if(token.hasMore()) return token.next(); else { perror("读行错误!!!"); return 0; } }};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -