Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
CSVContentHandler.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20#ifndef CSVCONTENTHANDLER_H_
21#define CSVCONTENTHANDLER_H_
22
23#include <string>
24#include <vector>
25
26#include <tulip/tulipconf.h>
27
28namespace tlp {
29
30struct CSVToken {
31 // column extracted value
32 std::string value;
33 // indicate if value was surrounded by text delimiters
34 bool considerAsString;
35
36 CSVToken(std::string val = "", bool flag = false) : value(val), considerAsString(flag) {}
37};
38
39/**
40 * @brief Interface to inherit to get and treat data from csv files with CSVParser object.
41 */
42class TLP_QT_SCOPE CSVContentHandler {
43public:
44 virtual ~CSVContentHandler() {}
45 /**
46 * Function called at the beginning of the file parsing.
47 */
48 virtual bool begin() = 0;
49
50 /**
51 * Function called for each line in the file.
52 * @param row The number of the row.
53 * @param lineTokens The tokens in the row
54 */
55 virtual bool line(unsigned int row, const std::vector<CSVToken> &lineTokens) = 0;
56
57 /**
58 * Function called at the end of the parsing.
59 * @param rowNumber the number of row read in the file.
60 * @param columnNumber The column number for the line with the greatest column number.
61 */
62 virtual bool end(unsigned int rowNumber, unsigned int columnNumber) = 0;
63};
64} // namespace tlp
65#endif /* CSVCONTENTHANDLER_H_ */
66///@endcond