21 #ifndef CSVDATALOADER_H_ 22 #define CSVDATALOADER_H_ 24 #include <tulip/tulipconf.h> 25 #include <tulip/CSVContentHandler.h> 43 class TLP_QT_SCOPE CSVParser {
45 virtual ~CSVParser() {}
47 virtual char decimalMark()
const {
55 virtual bool parse(CSVContentHandler * handler,
57 bool firstLineOnly =
false) = 0;
72 class TLP_QT_SCOPE CSVSimpleParser :
public CSVParser {
82 CSVSimpleParser(
const std::string& fileName,
const QString &separator=
";",
const bool mergesep=
false,
char textDelimiter=
'"',
char delimiterMark=
'.',
const std::string& fileEncoding=std::string(
"UTF-8"),
unsigned int firstLine = 0,
unsigned int lastLine = UINT_MAX);
84 virtual ~CSVSimpleParser();
86 inline std::string fileName()
const {
89 inline void setFileName(
const std::string& fileName) {
93 inline char textDelimiter()
const {
94 return _textDelimiter;
97 char decimalMark()
const {
101 inline void setTextDelimiter(
char delimiter) {
102 _textDelimiter = delimiter;
105 inline std::string fileEncoding()
const {
106 return _fileEncoding;
109 inline void setFileEncoding(
const std::string& fileEncoding) {
110 _fileEncoding = fileEncoding;
114 bool firstLineOnly =
false);
117 virtual std::string treatToken(
const std::string& token,
int row,
int column);
120 void tokenize(
const std::string& str, std::vector<std::string>& tokens,
121 const QString &delimiters,
const bool mergedelim,
char _textDelimiter,
unsigned int numberOfCol);
122 std::string convertStringEncoding(
const std::string& toConvert,QTextCodec* encoder);
127 bool multiplatformgetline ( std::istream& is, std::string& str );
129 std::string removeQuotesIfAny(
const std::string &s,
const std::string& rejectedChars);
130 std::string _fileName;
134 std::string _fileEncoding;
135 unsigned int _firstLine;
136 unsigned int _lastLine;
144 class TLP_QT_SCOPE CSVInvertMatrixParser :
public tlp::CSVParser ,
public tlp::CSVContentHandler {
146 CSVInvertMatrixParser(CSVParser* parser);
147 virtual ~CSVInvertMatrixParser();
149 char decimalMark()
const {
150 return parser->decimalMark();
154 bool firstLineOnly =
false);
157 bool line(
unsigned int row,
const std::vector<std::string>& lineTokens);
158 bool end(
unsigned int rowNumber,
unsigned int columnNumber);
161 CSVContentHandler *handler;
162 std::vector<std::vector<std::string> > columns;
163 unsigned int maxLineSize;
PluginProcess subclasses are meant to notify about the progress state of some process (typically a pl...