Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / Project 2 / src / Models / CellString.cpp
blob: 2a105efd2820c61786edf0c9ffac2818baaae351 (plain) (blame)
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
#include "CellString.h"
#include <cstring>

CellString::CellString(const char* str) {
	value = String(str);
}

double CellString::getNumeralValue() const {
	return atof(value.get_cstr());
}

String CellString::getValueForPrint() const {
	return value;
}

void CellString::parseAndSetValue(const char* str) {
	value = String(str);
}

void CellString::writeToFile(std::ofstream& file) {
	file << '"';
	const char* strCpy = value.get_cstr();
	while (*strCpy != '\0') {
		if (*strCpy == '\\' || *strCpy == '"') file << '\\';
		file << *(strCpy++);
	}
	file << '"';
}