eis/inc/base/MatrixFile.h

57 lines
1.2 KiB
C++

/*********************************************
*
* Matrix data reading
*
* copyright Shanghai Baosight Software Co., Ltd.
*
* create zoufuzhou 20191001
*
************************************************/
#ifndef _MATRIXFILE_H
#define _MATRIXFILE_H
/**
*本类用于读取二维的配置文件,如
| column0 column1 column2 column3
0 | abc 1000 ddd -
1 | ccc 2000 ddd -
2 | ddd 3000 ddd -
根据关键列来读目标列数据 取数据如 MatrixFile(0,1) = 1000
*/
#include <string>
#include <iostream>
#include <vector>
using namespace std;
namespace baosight
{
class MatrixFile{
public:
MatrixFile(const std::string& file,int startline = 1,const std::string& split = " ");
//打开配置文件
int reset(const std::string& file,int startline = 1,const std::string& split = " ");
//取指定坐标数据
string operator()(unsigned int row, unsigned int column);
//取指定坐标数据
string operator()( unsigned int row, const string& column);
//取得列数
unsigned int column(void);
//取得行数
unsigned int row(void);
private:
//用列头名称取列坐标
int getColumn(const string& column);
private:
std::vector<std::string> v_columns;
std::vector<std::vector<std::string> > v_datarows;
};
};
#endif