-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsvManager.h
More file actions
38 lines (32 loc) · 795 Bytes
/
csvManager.h
File metadata and controls
38 lines (32 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// Created by razoc on 01/10/2025.
//
#ifndef BTREECSV_CPLUSPLUS_CSVMANAGER_H
#define BTREECSV_CPLUSPLUS_CSVMANAGER_H
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using std::string;
using std::vector;
class FileHandler {
public:
virtual ~FileHandler() = default;
virtual void write(const string& file) = 0;
virtual void read(const string& file, bool header) = 0;
};
struct Product {
int id = 0;
string name;
double price = 0.0;
};
class CSVFile : public FileHandler {
private:
vector<Product> products;
public:
void add_product(const Product& p);
void print() const;
void write(const string& filename) override;
void read(const string& filename, bool header) override;
};
#endif //BTREECSV_CPLUSPLUS_CSVMANAGER_H