Enumerator class and warnings cleanup

This commit is contained in:
Charles J. Cliffe
2021-04-22 00:34:45 -04:00
parent f97f368a6a
commit a409822429
27 changed files with 247 additions and 299 deletions
+38 -38
View File
@@ -38,7 +38,7 @@ using namespace std;
#define MAX_STR_SIZE (1024)
DataElement::DataElement() : data_type(DATA_NULL) {
DataElement::DataElement() : data_type(DataElement::Type::DATA_NULL) {
//
}
@@ -58,7 +58,7 @@ char * DataElement::getDataPointer() {
return nullptr;
}
DataElement::DataElementTypeEnum DataElement::getDataType() {
DataElement::Type DataElement::getDataType() {
return data_type;
}
@@ -68,13 +68,13 @@ size_t DataElement::getDataSize() {
void DataElement::set(const char *data_in, long size_in) {
data_type = DATA_VOID;
data_type = DataElement::Type::DATA_VOID;
data_val.assign(data_in, data_in + size_in);
}
void DataElement::set(const char *data_in) {
data_type = DATA_STRING;
data_type = DataElement::Type::DATA_STRING;
size_t clamped_size = ::strnlen(data_in, MAX_STR_SIZE);
@@ -96,7 +96,7 @@ void DataElement::set(const std::set<string> &strset_in) {
void DataElement::get(DataElement::DataElementBuffer& data_in) {
if (data_type != DATA_VOID) {
if (data_type != DataElement::Type::DATA_VOID) {
throw(DataTypeMismatchException("Type mismatch, not a VOID*"));
}
@@ -106,7 +106,7 @@ void DataElement::get(DataElement::DataElementBuffer& data_in) {
void DataElement::get(std::set<string> &strset_out) {
if (data_type != DATA_STR_VECTOR)
if (data_type != DataElement::Type::DATA_STR_VECTOR)
throw(DataTypeMismatchException("Type mismatch, not a STRING VECTOR/SET"));
std::vector<string> tmp_vect;
@@ -121,33 +121,33 @@ void DataElement::get(std::set<string> &strset_out) {
}
std::string DataElement::toString() {
int dataType = getDataType();
DataElement::Type dataType = getDataType();
std::string strValue;
try {
if (dataType == DATA_STRING) {
if (dataType == DataElement::Type::DATA_STRING) {
get(strValue);
} else if (dataType == DATA_INT || dataType == DATA_LONG || dataType == DATA_LONGLONG) {
} else if (dataType == DataElement::Type::DATA_INT || dataType == DataElement::Type::DATA_LONG || dataType == DataElement::Type::DATA_LONGLONG) {
long long intSettingValue;
get(intSettingValue);
strValue = std::to_string(intSettingValue);
} else if (dataType == DATA_FLOAT || dataType == DATA_DOUBLE) {
} else if (dataType == DataElement::Type::DATA_FLOAT || dataType == DataElement::Type::DATA_DOUBLE) {
double floatSettingValue;
get(floatSettingValue);
strValue = std::to_string(floatSettingValue);
} else if (dataType == DATA_NULL) {
} else if (dataType == DataElement::Type::DATA_NULL) {
strValue = "";
} else if (dataType == DATA_WSTRING) {
} else if (dataType == DataElement::Type::DATA_WSTRING) {
std::wstring wstr;
get(wstr);
//TODO: code below returns a forced cast in (char*) beware...
strValue = *wstr.c_str();
}
else {
std::cout << "Unhandled DataElement toString for type: " << dataType << std::endl;
std::cout << "Unhandled DataElement toString for type: " << (int)dataType << std::endl;
}
} catch (const DataTypeMismatchException &e) {
std::cout << "toString() DataTypeMismatch: " << dataType << std::endl;
} catch (const DataTypeMismatchException &) {
std::cout << "toString() DataTypeMismatch: " << (int)dataType << std::endl;
}
return strValue;
@@ -659,9 +659,9 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
long long tmp_llong;
switch (child->element()->getDataType()) {
case DataElement::DATA_NULL:
case DataElement::Type::DATA_NULL:
break;
case DataElement::DATA_VOID:
case DataElement::Type::DATA_VOID:
child->element()->get(tmp_pstr_as_string); // returned VOID as string
// following badgerfish xml->json and xml->ruby convention for attributes..
if (nodeName.substr(0, 1) == string("@")) {
@@ -673,7 +673,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
}
break;
case DataElement::DATA_CHAR:
case DataElement::Type::DATA_CHAR:
child->element()->get(tmp_char);
tmp_stream.str("");
@@ -683,7 +683,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_UCHAR:
case DataElement::Type::DATA_UCHAR:
child->element()->get(tmp_uchar);
tmp_stream.str("");
@@ -693,7 +693,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_INT:
case DataElement::Type::DATA_INT:
child->element()->get(tmp_int);
tmp_stream.str("");
@@ -703,7 +703,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_UINT:
case DataElement::Type::DATA_UINT:
child->element()->get(tmp_uint);
tmp_stream.str("");
@@ -713,7 +713,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_LONG:
case DataElement::Type::DATA_LONG:
child->element()->get(tmp_long);
tmp_stream.str("");
@@ -723,7 +723,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_ULONG:
case DataElement::Type::DATA_ULONG:
child->element()->get(tmp_ulong);
tmp_stream.str("");
@@ -733,7 +733,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_LONGLONG:
case DataElement::Type::DATA_LONGLONG:
child->element()->get(tmp_llong);
tmp_stream.str("");
@@ -743,7 +743,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_FLOAT:
case DataElement::Type::DATA_FLOAT:
child->element()->get(tmp_float);
tmp_stream.str("");
@@ -753,7 +753,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_DOUBLE:
case DataElement::Type::DATA_DOUBLE:
child->element()->get(tmp_double);
tmp_stream.str("");
@@ -763,7 +763,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
text = new TiXmlText(tmp_stream.str().c_str());
element->LinkEndChild(text);
break;
case DataElement::DATA_STRING:
case DataElement::Type::DATA_STRING:
child->element()->get(tmp);
if (nodeName.substr(0, 1) == string("@")) {
elxml->SetAttribute(nodeName.substr(1).c_str(), tmp.c_str());
@@ -774,7 +774,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
}
break;
case DataElement::DATA_WSTRING:
case DataElement::Type::DATA_WSTRING:
child->element()->get(wtmp);
tmp = wsEncode(wtmp);
if (nodeName.substr(0, 1) == string("@")) {
@@ -786,7 +786,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
}
break;
case DataElement::DATA_STR_VECTOR:
case DataElement::Type::DATA_STR_VECTOR:
child->element()->get(tmp_stringvect);
tmp_stream.str("");
@@ -800,7 +800,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
tmp_stringvect.clear();
break;
case DataElement::DATA_CHAR_VECTOR:
case DataElement::Type::DATA_CHAR_VECTOR:
child->element()->get(tmp_charvect);
tmp_stream.str("");
@@ -815,7 +815,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
tmp_charvect.clear();
break;
case DataElement::DATA_UCHAR_VECTOR:
case DataElement::Type::DATA_UCHAR_VECTOR:
child->element()->get(tmp_ucharvect);
tmp_stream.str("");
@@ -830,7 +830,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
tmp_ucharvect.clear();
break;
case DataElement::DATA_INT_VECTOR:
case DataElement::Type::DATA_INT_VECTOR:
child->element()->get(tmp_intvect);
tmp_stream.str("");
@@ -845,7 +845,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
tmp_intvect.clear();
break;
case DataElement::DATA_UINT_VECTOR:
case DataElement::Type::DATA_UINT_VECTOR:
child->element()->get(tmp_uintvect);
tmp_stream.str("");
@@ -860,7 +860,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
tmp_uintvect.clear();
break;
case DataElement::DATA_LONG_VECTOR:
case DataElement::Type::DATA_LONG_VECTOR:
child->element()->get(tmp_longvect);
tmp_stream.str("");
@@ -875,7 +875,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
tmp_longvect.clear();
break;
case DataElement::DATA_ULONG_VECTOR:
case DataElement::Type::DATA_ULONG_VECTOR:
child->element()->get(tmp_ulongvect);
tmp_stream.str("");
@@ -890,7 +890,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
tmp_ulongvect.clear();
break;
case DataElement::DATA_LONGLONG_VECTOR:
case DataElement::Type::DATA_LONGLONG_VECTOR:
child->element()->get(tmp_llongvect);
tmp_stream.str("");
@@ -905,7 +905,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
tmp_llongvect.clear();
break;
case DataElement::DATA_FLOAT_VECTOR:
case DataElement::Type::DATA_FLOAT_VECTOR:
child->element()->get(tmp_floatvect);
tmp_stream.str("");
@@ -920,7 +920,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
element->LinkEndChild(text);
tmp_floatvect.clear();
break;
case DataElement::DATA_DOUBLE_VECTOR:
case DataElement::Type::DATA_DOUBLE_VECTOR:
child->element()->get(tmp_doublevect);
tmp_stream.str("");
+52 -52
View File
@@ -78,7 +78,7 @@ class DataElement
{
public :
enum DataElementTypeEnum {
enum class Type {
DATA_NULL,
DATA_CHAR,
DATA_UCHAR,
@@ -109,7 +109,7 @@ public :
typedef vector< DataElementBuffer > DataElementBufferVector;
private:
DataElementTypeEnum data_type;
Type data_type;
// raw buffer holding data_type element in bytes form.
DataElementBuffer data_val;
@@ -123,66 +123,66 @@ private:
//if the exact right determineScalarDataType specialization was not used, throw exception at runtime.
template<typename U, typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const U& /* type_in */) { throw DataTypeMismatchException("determineScalarDataType(U) usage with unsupported type !"); }
Type determineScalarDataType(const U& /* type_in */) { throw DataTypeMismatchException("determineScalarDataType(U) usage with unsupported type !"); }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const char& /* type_in */) { return DATA_CHAR; }
Type determineScalarDataType(const char& /* type_in */) { return DataElement::Type::DATA_CHAR; }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const unsigned char& /* type_in */) { return DATA_UCHAR; }
Type determineScalarDataType(const unsigned char& /* type_in */) { return DataElement::Type::DATA_UCHAR; }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const int& /* type_in */) { return DATA_INT; }
Type determineScalarDataType(const int& /* type_in */) { return DataElement::Type::DATA_INT; }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const unsigned int& /* type_in */) { return DATA_UINT; }
Type determineScalarDataType(const unsigned int& /* type_in */) { return DataElement::Type::DATA_UINT; }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const long& /* type_in */) { return DATA_LONG; }
Type determineScalarDataType(const long& /* type_in */) { return DataElement::Type::DATA_LONG; }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const unsigned long& /* type_in */) { return DATA_ULONG; }
Type determineScalarDataType(const unsigned long& /* type_in */) { return DataElement::Type::DATA_ULONG; }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const long long& /* type_in */) { return DATA_LONGLONG; }
Type determineScalarDataType(const long long& /* type_in */) { return DataElement::Type::DATA_LONGLONG; }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const float& /* type_in */) { return DATA_FLOAT; }
Type determineScalarDataType(const float& /* type_in */) { return DataElement::Type::DATA_FLOAT; }
template< typename Dummy = int >
DataElementTypeEnum determineScalarDataType(const double& /* type_in */) { return DATA_DOUBLE; }
Type determineScalarDataType(const double& /* type_in */) { return DataElement::Type::DATA_DOUBLE; }
//vector versions:
//if the exact right determineVectorDataType specialization was not used, throw exception at runtime.
template<typename V, typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<V>& /* type_in */) { throw DataTypeMismatchException("determineVectorDataType(V) usage with unsupported type !"); }
Type determineVectorDataType(const vector<V>& /* type_in */) { throw DataTypeMismatchException("determineVectorDataType(V) usage with unsupported type !"); }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<char>& /* type_in */) { return DATA_CHAR_VECTOR; }
Type determineVectorDataType(const vector<char>& /* type_in */) { return DataElement::Type::DATA_CHAR_VECTOR; }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<unsigned char>& /* type_in */) { return DATA_UCHAR_VECTOR; }
Type determineVectorDataType(const vector<unsigned char>& /* type_in */) { return DataElement::Type::DATA_UCHAR_VECTOR; }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<int>& /* type_in */) { return DATA_INT_VECTOR; }
Type determineVectorDataType(const vector<int>& /* type_in */) { return DataElement::Type::DATA_INT_VECTOR; }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<unsigned int>& /* type_in */) { return DATA_UINT_VECTOR; }
Type determineVectorDataType(const vector<unsigned int>& /* type_in */) { return DataElement::Type::DATA_UINT_VECTOR; }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<long>& /* type_in */) { return DATA_LONG_VECTOR; }
Type determineVectorDataType(const vector<long>& /* type_in */) { return DataElement::Type::DATA_LONG_VECTOR; }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<unsigned long>& /* type_in */) { return DATA_ULONG_VECTOR; }
Type determineVectorDataType(const vector<unsigned long>& /* type_in */) { return DataElement::Type::DATA_ULONG_VECTOR; }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<long long>& /* type_in */) { return DATA_LONGLONG_VECTOR; }
Type determineVectorDataType(const vector<long long>& /* type_in */) { return DataElement::Type::DATA_LONGLONG_VECTOR; }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<float>& /* type_in */) { return DATA_FLOAT_VECTOR; }
Type determineVectorDataType(const vector<float>& /* type_in */) { return DataElement::Type::DATA_FLOAT_VECTOR; }
template< typename Dummy = int >
DataElementTypeEnum determineVectorDataType(const vector<double>& /* type_in */) { return DATA_DOUBLE_VECTOR; }
Type determineVectorDataType(const vector<double>& /* type_in */) { return DataElement::Type::DATA_DOUBLE_VECTOR; }
public:
@@ -190,7 +190,7 @@ public:
DataElement(DataElement &cloneFrom);
~DataElement();
DataElementTypeEnum getDataType();
Type getDataType();
char *getDataPointer();
size_t getDataSize();
@@ -239,7 +239,7 @@ public:
template< typename Dummy = int >
void set(const string& str_in) {
data_type = DATA_STRING;
data_type = DataElement::Type::DATA_STRING;
data_val.assign(str_in.begin(), str_in.end());
}
@@ -248,7 +248,7 @@ public:
template< typename Dummy = int >
void set(const wstring& wstr_in) {
data_type = DATA_WSTRING;
data_type = DataElement::Type::DATA_WSTRING;
//wchar_t is tricky, the terminating zero is actually a (wchar_t)0 !
//wchar_t is typically 16 bits on windows, and 32 bits on Unix, so use sizeof(wchar_t) everywhere.
@@ -269,7 +269,7 @@ public:
template< typename Dummy = int >
void set(const vector<string>& vector_str_in) {
data_type = DATA_STR_VECTOR;
data_type = DataElement::Type::DATA_STR_VECTOR;
data_val_vector.clear();
@@ -299,43 +299,43 @@ public:
throw DataException("Cannot get() the scalar, DataElement is empty !");
}
DataElementTypeEnum storageType = getDataType();
DataElement::Type storageType = getDataType();
//TODO: smarter way with templates ?
if (storageType == DATA_CHAR) {
if (storageType == DataElement::Type::DATA_CHAR) {
char* storage_ptr = reinterpret_cast<char*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_UCHAR) {
} else if (storageType == DataElement::Type::DATA_UCHAR) {
auto* storage_ptr = reinterpret_cast<unsigned char*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_INT) {
} else if (storageType == DataElement::Type::DATA_INT) {
int* storage_ptr = reinterpret_cast<int*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_UINT) {
} else if (storageType == DataElement::Type::DATA_UINT) {
auto* storage_ptr = reinterpret_cast<unsigned int*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_LONG) {
} else if (storageType == DataElement::Type::DATA_LONG) {
long* storage_ptr = reinterpret_cast<long*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_ULONG) {
} else if (storageType == DataElement::Type::DATA_ULONG) {
auto* storage_ptr = reinterpret_cast<unsigned long*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_LONGLONG) {
} else if (storageType == DataElement::Type::DATA_LONGLONG) {
auto* storage_ptr = reinterpret_cast<long long*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_FLOAT) {
} else if (storageType == DataElement::Type::DATA_FLOAT) {
auto* storage_ptr = reinterpret_cast<float*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_DOUBLE) {
} else if (storageType == DataElement::Type::DATA_DOUBLE) {
auto* storage_ptr = reinterpret_cast<double*>(&data_val[0]);
//constructor-like
scalar_out = T(*storage_ptr);
@@ -350,7 +350,7 @@ public:
DataElementBuffer single_buffer;
DataElementTypeEnum storageType = getDataType();
Type storageType = getDataType();
for (auto single_storage_element : data_val_vector) {
@@ -361,40 +361,40 @@ public:
T scalar_out;
//TODO: smarter way with templates ?
if (storageType == DATA_CHAR_VECTOR) {
if (storageType == DataElement::Type::DATA_CHAR_VECTOR) {
char* storage_ptr = reinterpret_cast<char*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_UCHAR_VECTOR) {
} else if (storageType == DataElement::Type::DATA_UCHAR_VECTOR) {
auto* storage_ptr = reinterpret_cast<unsigned char*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_INT_VECTOR) {
} else if (storageType == DataElement::Type::DATA_INT_VECTOR) {
int* storage_ptr = reinterpret_cast<int*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_UINT_VECTOR) {
} else if (storageType == DataElement::Type::DATA_UINT_VECTOR) {
auto* storage_ptr = reinterpret_cast<unsigned int*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_LONG_VECTOR) {
} else if (storageType == DataElement::Type::DATA_LONG_VECTOR) {
long* storage_ptr = reinterpret_cast<long*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_ULONG_VECTOR) {
} else if (storageType == DataElement::Type::DATA_ULONG_VECTOR) {
auto* storage_ptr = reinterpret_cast<unsigned long*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_LONGLONG_VECTOR) {
} else if (storageType == DataElement::Type::DATA_LONGLONG_VECTOR) {
auto* storage_ptr = reinterpret_cast<long long*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_FLOAT_VECTOR) {
} else if (storageType == DataElement::Type::DATA_FLOAT_VECTOR) {
auto* storage_ptr = reinterpret_cast<float*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
} else if (storageType == DATA_DOUBLE_VECTOR) {
} else if (storageType == DataElement::Type::DATA_DOUBLE_VECTOR) {
auto* storage_ptr = reinterpret_cast<double*>(&single_storage_element[0]);
//constructor-like
scalar_out = T(*storage_ptr);
@@ -411,13 +411,13 @@ public:
//reset
str_out.clear();
if (data_type == DATA_NULL) {
if (data_type == DataElement::Type::DATA_NULL) {
//it means TinyXML has parsed an empty tag,
//so return an empty string.
return;
}
if (data_type != DATA_STRING && data_type != DATA_VOID) {
if (data_type != DataElement::Type::DATA_STRING && data_type != DataElement::Type::DATA_VOID) {
throw(DataTypeMismatchException("Type mismatch, neither a STRING nor a VOID*"));
}
@@ -433,13 +433,13 @@ public:
//reset
wstr_out.clear();
if (data_type == DATA_NULL) {
if (data_type == DataElement::Type::DATA_NULL) {
//it means TinyXML has parsed an empty tag,
//so return an empty string.
return;
}
if (data_type != DATA_WSTRING) {
if (data_type != DataElement::Type::DATA_WSTRING) {
throw(DataTypeMismatchException("Type mismatch, not a WSTRING"));
}
@@ -465,7 +465,7 @@ public:
template< typename Dummy = int >
void get(vector<string>& vector_str_out) {
if (data_type != DATA_STR_VECTOR) {
if (data_type != DataElement::Type::DATA_STR_VECTOR) {
throw(DataTypeMismatchException("Type mismatch, not a STRING VECTOR"));
}
@@ -551,7 +551,7 @@ public:
void findAll(const char *name_in, vector<DataNode *> &node_list_out);
explicit operator string () { string s; element()->get(s); return s; }
explicit operator const char * () { if (element()->getDataType() == DataElement::DATA_STRING) { return element()->getDataPointer(); } else { return nullptr; } }
explicit operator const char * () { if (element()->getDataType() == DataElement::Type::DATA_STRING) { return element()->getDataPointer(); } else { return nullptr; } }
explicit operator char () { char v=0; element()->get(v); return v; }
explicit operator unsigned char () { unsigned char v=0; element()->get(v); return v; }
explicit operator int () { int v=0; element()->get(v); return v; }