MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SlCalcVectorLen

Function SlCalcVectorLen

src/saveload/saveload.cpp:1559–1579  ·  view source on GitHub ↗

* Return the size in bytes of a std::vector. * @param vector The std::vector to find the size of * @param conv VarType type of variable that is used for calculating the size */

Source from the content-addressed store, hash-verified

1557 * @param conv VarType type of variable that is used for calculating the size
1558 */
1559static inline size_t SlCalcVectorLen(const void *vector, VarType conv)
1560{
1561 switch (GetVarMemType(conv)) {
1562 case SLE_VAR_BL: NOT_REACHED(); // Not supported
1563 case SLE_VAR_I8: return SlStorageHelper<std::vector, int8_t>::SlCalcLen(vector, conv);
1564 case SLE_VAR_U8: return SlStorageHelper<std::vector, uint8_t>::SlCalcLen(vector, conv);
1565 case SLE_VAR_I16: return SlStorageHelper<std::vector, int16_t>::SlCalcLen(vector, conv);
1566 case SLE_VAR_U16: return SlStorageHelper<std::vector, uint16_t>::SlCalcLen(vector, conv);
1567 case SLE_VAR_I32: return SlStorageHelper<std::vector, int32_t>::SlCalcLen(vector, conv);
1568 case SLE_VAR_U32: return SlStorageHelper<std::vector, uint32_t>::SlCalcLen(vector, conv);
1569 case SLE_VAR_I64: return SlStorageHelper<std::vector, int64_t>::SlCalcLen(vector, conv);
1570 case SLE_VAR_U64: return SlStorageHelper<std::vector, uint64_t>::SlCalcLen(vector, conv);
1571
1572 case SLE_VAR_STR:
1573 /* Strings are a length-prefixed field type in the savegame table format,
1574 * these may not be directly stored in another length-prefixed container type. */
1575 NOT_REACHED();
1576
1577 default: NOT_REACHED();
1578 }
1579}
1580
1581/**
1582 * Save/load a std::vector.

Callers 1

SlCalcObjMemberLengthFunction · 0.85

Calls 2

GetVarMemTypeFunction · 0.85
NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected