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 char decimalMark()
const {
70 class TLP_QT_SCOPE CSVSimpleParser :
public CSVParser {
80 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);
82 virtual ~CSVSimpleParser();
84 inline std::string fileName()
const {
87 inline void setFileName(
const std::string& fileName) {
91 inline char textDelimiter()
const {
92 return _textDelimiter;
95 char decimalMark()
const {
99 inline void setTextDelimiter(
char delimiter) {
100 _textDelimiter = delimiter;
103 inline std::string fileEncoding()
const {
104 return _fileEncoding;
107 inline void setFileEncoding(
const std::string& fileEncoding) {
108 _fileEncoding = fileEncoding;
114 virtual std::string treatToken(
const std::string& token,
int row,
int column);
117 void tokenize(
const std::string& str, std::vector<std::string>& tokens,
118 const QString &delimiters,
const bool mergedelim,
char _textDelimiter,
unsigned int numberOfCol);
119 std::string convertStringEncoding(
const std::string& toConvert,QTextCodec* encoder);
124 bool multiplatformgetline ( std::istream& is, std::string& str );
126 std::string removeQuotesIfAny(
const std::string &s,
const std::string& rejectedChars);
127 std::string _fileName;
131 std::string _fileEncoding;
132 unsigned int _firstLine;
133 unsigned int _lastLine;
141 class TLP_QT_SCOPE CSVInvertMatrixParser :
public tlp::CSVParser ,
public tlp::CSVContentHandler {
143 CSVInvertMatrixParser(CSVParser* parser);
144 virtual ~CSVInvertMatrixParser();
146 char decimalMark()
const {
147 return parser->decimalMark();
153 bool line(
unsigned int row,
const std::vector<std::string>& lineTokens);
154 bool end(
unsigned int rowNumber,
unsigned int columnNumber);
157 CSVContentHandler *handler;
158 std::vector<std::vector<std::string> > columns;
159 unsigned int maxLineSize;
PluginProcess subclasses are meant to notify about the progress state of some process (typically a pl...