MCPcopy Create free account
hub / github.com/adamstark/AudioFile / fourBytesToInt

Method fourBytesToInt

AudioFile.h:1232–1250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1230//=============================================================
1231template <class T>
1232int32_t AudioFile<T>::fourBytesToInt (const std::vector<uint8_t>& source, int startIndex, Endianness endianness)
1233{
1234 if (source.size() >= (startIndex + 4))
1235 {
1236 int32_t result;
1237
1238 if (endianness == Endianness::LittleEndian)
1239 result = (source[startIndex + 3] << 24) | (source[startIndex + 2] << 16) | (source[startIndex + 1] << 8) | source[startIndex];
1240 else
1241 result = (source[startIndex] << 24) | (source[startIndex + 1] << 16) | (source[startIndex + 2] << 8) | source[startIndex + 3];
1242
1243 return result;
1244 }
1245 else
1246 {
1247 assert (false && "Attempted to read four bytes from vector at position where out of bounds access would occur");
1248 return 0; // this is a dummy value as we don't have one to return
1249 }
1250}
1251
1252//=============================================================
1253template <class T>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected