* Convert an integer-array (intlist) to a string representation. Each value * is separated by a comma or a space character * @param buf output buffer where the string-representation will be stored * @param last last item to write to in the output buffer * @param array pointer to the integer-arrays that is read from * @param nelems the number of elements the array holds. * @param type the typ
| 308 | * @param type the type of elements the array holds (eg INT8, UINT16, etc.) |
| 309 | */ |
| 310 | std::string ListSettingDesc::FormatValue(const void *object) const |
| 311 | { |
| 312 | const uint8_t *p = static_cast<const uint8_t *>(GetVariableAddress(object, this->save)); |
| 313 | |
| 314 | std::string result; |
| 315 | for (size_t i = 0; i != this->save.length; i++) { |
| 316 | int64_t v; |
| 317 | switch (GetVarMemType(this->save.conv)) { |
| 318 | case SLE_VAR_BL: |
| 319 | case SLE_VAR_I8: v = *(const int8_t *)p; p += 1; break; |
| 320 | case SLE_VAR_U8: v = *(const uint8_t *)p; p += 1; break; |
| 321 | case SLE_VAR_I16: v = *(const int16_t *)p; p += 2; break; |
| 322 | case SLE_VAR_U16: v = *(const uint16_t *)p; p += 2; break; |
| 323 | case SLE_VAR_I32: v = *(const int32_t *)p; p += 4; break; |
| 324 | case SLE_VAR_U32: v = *(const uint32_t *)p; p += 4; break; |
| 325 | default: NOT_REACHED(); |
| 326 | } |
| 327 | if (i != 0) result += ','; |
| 328 | format_append(result, "{}", v); |
| 329 | } |
| 330 | return result; |
| 331 | } |
| 332 | |
| 333 | std::string OneOfManySettingDesc::FormatSingleValue(uint id) const |
| 334 | { |
no test coverage detected