44CSV_Data::CSV_Data() : data(0), type(
""), initialized(false) {
47CSV_Data::~CSV_Data() {
49 if(type.compare(
string(STRING)) == 0) {
50 delete (vector<string> *)data;
52 }
else if(type.compare(
string(FLOAT32)) == 0) {
53 delete (vector<float> *)data;
55 }
else if(type.compare(
string(FLOAT64)) == 0) {
56 delete (vector<double> *)data;
58 }
else if(type.compare(
string(INT16)) == 0) {
59 delete (vector<short> *)data;
61 }
else if(type.compare(
string(INT32)) == 0) {
62 delete (vector<int> *)data;
68void CSV_Data::insert(
CSV_Field* field,
void* value) {
70 if(type.compare(
"") == 0)
71 type = field->getType();
74 if(type.compare(
string(STRING)) == 0) {
75 data =
new vector<string>();
77 }
else if(type.compare(
string(FLOAT32)) == 0) {
78 data =
new vector<float>();
80 }
else if(type.compare(
string(FLOAT64)) == 0) {
81 data =
new vector<double>();
83 }
else if(type.compare(
string(INT16)) == 0) {
84 data =
new vector<short>();
86 }
else if(type.compare(
string(INT32)) == 0) {
87 data =
new vector<int>();
92 if(type.compare(
string(STRING)) == 0) {
93 string str = *
reinterpret_cast<string*
>(value);
94 ((vector<string>*)data)->push_back(str);
95 }
else if(type.compare(
string(FLOAT32)) == 0) {
96 float flt = atof((
reinterpret_cast<string*
>(value))->c_str());
97 ((vector<float>*)data)->push_back(flt);
98 }
else if(type.compare(
string(FLOAT64)) == 0) {
99 double dbl = atof((
reinterpret_cast<string*
>(value))->c_str());
100 ((vector<double>*)data)->push_back(dbl);
101 }
else if(type.compare(
string(INT16)) == 0) {
102 short shrt = atoi((
reinterpret_cast<string*
>(value))->c_str());
103 ((vector<short>*)data)->push_back(shrt);
104 }
else if(type.compare(
string(INT32)) == 0) {
105 int integer = atoi((
reinterpret_cast<string*
>(value))->c_str());
106 ((vector<int>*)data)->push_back(integer);
110void* CSV_Data::getData() {
114string CSV_Data::getType() {