Append a string representation of this value to a string
| 30 | |
| 31 | // Append a string representation of this value to a string |
| 32 | void ExpressionValue::AppendAsString(const StringRef& str) const noexcept |
| 33 | { |
| 34 | switch (GetType()) |
| 35 | { |
| 36 | case TypeCode::Char: |
| 37 | str.cat(cVal); |
| 38 | break; |
| 39 | |
| 40 | case TypeCode::CString: |
| 41 | str.cat(sVal); |
| 42 | break; |
| 43 | |
| 44 | case TypeCode::HeapString: |
| 45 | str.cat(shVal.Get().Ptr()); |
| 46 | break; |
| 47 | |
| 48 | case TypeCode::Float: |
| 49 | str.catf(GetFloatFormatString(), (double)fVal); |
| 50 | break; |
| 51 | |
| 52 | case TypeCode::Uint32: |
| 53 | str.catf("%" PRIu32, uVal); // convert unsigned integer to string |
| 54 | break; |
| 55 | |
| 56 | case TypeCode::Uint64: |
| 57 | str.catf("%" PRIu64, ((uint64_t)param << 32) | uVal); // convert unsigned integer to string |
| 58 | break; |
| 59 | |
| 60 | case TypeCode::Int32: |
| 61 | str.catf("%" PRIi32, uVal); // convert signed integer to string |
| 62 | break; |
| 63 | |
| 64 | case TypeCode::Bool: |
| 65 | str.cat((bVal) ? "true" : "false"); // convert bool to string |
| 66 | break; |
| 67 | |
| 68 | case TypeCode::IPAddress_tc: |
| 69 | str.cat(IP4String(uVal).c_str()); |
| 70 | break; |
| 71 | |
| 72 | case TypeCode::None: |
| 73 | str.cat("null"); |
| 74 | break; |
| 75 | |
| 76 | case TypeCode::DateTime_tc: |
| 77 | { |
| 78 | const time_t tval = Get56BitValue(); |
| 79 | tm timeInfo; |
| 80 | gmtime_r(&tval, &timeInfo); |
| 81 | str.catf("%04u-%02u-%02uT%02u:%02u:%02u", |
| 82 | timeInfo.tm_year + 1900, timeInfo.tm_mon + 1, timeInfo.tm_mday, timeInfo.tm_hour, timeInfo.tm_min, timeInfo.tm_sec); |
| 83 | } |
| 84 | break; |
| 85 | |
| 86 | case TypeCode::Duration: |
| 87 | { |
| 88 | unsigned int hours = uVal/3600, |
| 89 | minutes = (uVal / 60) % 60, |
no test coverage detected