当前位置: 代码迷 >> 综合 >> csv typing
  详细解决方案

csv typing

热度:10   发布时间:2023-12-21 21:34:04.0

string class usage:

http://blog.csdn.net/lanyzh0909/article/details/6957649


相关文档:

http://7090.iteye.com/blog/1454766

http://people.apache.org/~donaldp/buildr/1.4.10/site/rdoc/CSV.html



class Csv
{
private:
public:
Csv(){};
Csv(const char *FileAddr, int FileSize);
~Csv(){};




bool ReadField(int Row, int Col, string &Str);
bool ReadField(int Row, int Col, int &Val);
bool ReadField(int Row, int Col, float &Val);


int FindCols(int Col, const string &Str); //find the row index of Str in the specific columnn 
int FindCols(int Col, int Val);
int FindCols(int Col, float Val);




string &ReadLine(); //read a new line to the m_line from m_pos


int CntLine(const char *path);
string CntCol(string line);
protected:
char *m_FileAddr;
int m_FileSize;


private:
string m_Line;
string m_Field;
char* m_Pos; //current position of the csv file


};


string &Csv::ReadLine()
{
const short LineSizeLimit = 100; //read data from the flash to string object which storages the data to Heap,not the stack of the Task
const char *pos = m_Pos;


while((*pos != '\r' && *(pos + 1) != '\n') && pos < m_Pos