| 121 | } |
| 122 | |
| 123 | std::string DataElement::toString() { |
| 124 | DataElement::Type dataType = getDataType(); |
| 125 | std::string strValue; |
| 126 | |
| 127 | try { |
| 128 | if (dataType == DataElement::Type::DATA_STRING) { |
| 129 | get(strValue); |
| 130 | } else if (dataType == DataElement::Type::DATA_INT || dataType == DataElement::Type::DATA_LONG || dataType == DataElement::Type::DATA_LONGLONG) { |
| 131 | long long intSettingValue; |
| 132 | get(intSettingValue); |
| 133 | strValue = std::to_string(intSettingValue); |
| 134 | } else if (dataType == DataElement::Type::DATA_FLOAT || dataType == DataElement::Type::DATA_DOUBLE) { |
| 135 | double floatSettingValue; |
| 136 | get(floatSettingValue); |
| 137 | strValue = std::to_string(floatSettingValue); |
| 138 | } else if (dataType == DataElement::Type::DATA_NULL) { |
| 139 | strValue = ""; |
| 140 | } else if (dataType == DataElement::Type::DATA_WSTRING) { |
| 141 | std::wstring wstr; |
| 142 | get(wstr); |
| 143 | //TODO: code below returns a forced cast in (char*) beware... |
| 144 | strValue = *wstr.c_str(); |
| 145 | } |
| 146 | else { |
| 147 | std::cout << "Unhandled DataElement toString for type: " << (int)dataType << std::endl; |
| 148 | } |
| 149 | } catch (const DataTypeMismatchException &) { |
| 150 | std::cout << "toString() DataTypeMismatch: " << (int)dataType << std::endl; |
| 151 | } |
| 152 | |
| 153 | return strValue; |
| 154 | } |
| 155 | |
| 156 | /* DataNode class */ |
| 157 |
no test coverage detected