Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
table.h
Package: Simple_DB.tar.gz [view]
Upload User: mxh851202
Upload Date: 2014-12-23
Package Size: 3593k
Code Size: 2k
Category:
Linux-Unix program
Development Platform:
Unix_Linux
- #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;
- }
- return 0;
- }
- 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