file_operation.h
Go to the documentation of this file.
1 #ifndef FILE_OPERATION_HPP
2 #define FILE_OPERATION_HPP
3 #include <fstream>
4 #include <iostream>
5 #include <vector>
6 struct DataBuff
7 {
8  char* data;
9  long size;
10 };
11 
12 // Common file related operations
14 {
15 public:
16  FileOperation();
17  ~FileOperation();
18  std::string setFileName(std::string file_type);
19  struct DataBuff readFileAsDatabuffer(const std::string file_path);
20  std::string readFileAsString(const std::string file_path);
21  void getAllFilesName(std::string dir_path, std::vector<std::string>& files_name);
22 
23 private:
24  int test_file_id_ = 0;
25 };
26 
27 // Read csv file data line by line
29 {
30 public:
31  std::string const& operator[](std::size_t index) const
32  {
33  return m_data[index];
34  }
35  std::size_t size() const
36  {
37  return m_data.size();
38  }
39  void readNextRow(std::istream& str);
40 
41  std::vector<std::vector<std::string>> readAllCSV(std::istream& str);
42 
43  void writeRowData(std::string csv_file, std::vector<std::string> row_vector);
44 
45 private:
46  std::vector<std::string> m_data;
47  std::vector<std::vector<std::string>> csv_table_;
48 };
49 
50 #endif
std::string const & operator[](std::size_t index) const
std::vector< std::vector< std::string > > csv_table_
char * data
Definition: file_operation.h:8
std::size_t size() const
std::vector< std::string > m_data


xbot_talker
Author(s): wangxiaoyun
autogenerated on Sat Oct 10 2020 03:27:53