-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColumnChar.cpp
62 lines (55 loc) · 1.97 KB
/
ColumnChar.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Created by Christo on 3/14/2019.
//
#include "ColumnChar.h"
/**
* \brief Constructor used to create a ColumnChar from an existant table.
* @param columnName name of the Column.
* @param tableName name of the Table that owns the column.
*/
ColumnChar::ColumnChar(std::string columnName, std::string tableName) : Column(columnName, tableName) {
dataType = CHAR;
columnFile.open(columnFilePath, std::ios::out | std::ios::app);
if(columnFile){
columnFile<<enumStringMap.at(dataType)+"_type"<<std::endl;
}
columnFile.close();
}
/**
* \brief Constructor used to create a new ColumnChar.
* @param columnName is the name of the Column.
* @param tableName is the name of the table that owns the column.
* @param description the description of the new Column.
*/
ColumnChar::ColumnChar(std::string columnName, std::string tableName, std::string description) : Column(columnName, tableName, description) {
dataType = CHAR;
columnFile.open(columnFilePath, std::ios::out | std::ios::app);
if(columnFile){
columnFile<<enumStringMap.at(dataType)+"_type"<<std::endl;
}
columnFile.close();
}
/**
* \brief Constructor used to open an existant column stored in the files of the program.
* @param columnFilePath is the path to the file.
*/
ColumnChar::ColumnChar(std::string columnFilePath) : Column(columnFilePath) {
this->columnFilePath=columnFilePath;
}
/**
* \brief method used to insert a new entry into the file
* @param data is the element to be inserted into the file.
*/
void ColumnChar::addData(std::string data) {
if(data.length()>1){
throw std::invalid_argument("Char can only be one char long, multiple characters received");
}
columnFile.open(columnFilePath, std::ios::out | std::ios::app);
if(columnFile){
columnFile<<data.at(0)<<std::endl;
}
columnFile.close();
}
std::string ColumnChar::calSum() {
return std::string();
}