MCPcopy Create free account
hub / github.com/axiomatic-systems/Bento4 / LoadInteger

Method LoadInteger

Source/C++/MetaData/Ap4MetaData.cpp:1593–1615  ·  view source on GitHub ↗

---------------------------------------------------------------------- | AP4_DataAtom::LoadInteger +---------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

1591| AP4_DataAtom::LoadInteger
1592+---------------------------------------------------------------------*/
1593AP4_Result
1594AP4_DataAtom::LoadInteger(long& value)
1595{
1596 AP4_Result result = AP4_FAILURE;
1597 value = 0;
1598 if (m_Source == NULL) return AP4_SUCCESS;
1599 AP4_LargeSize size = 0;
1600 m_Source->GetSize(size);
1601 if (size > 4) {
1602 return AP4_ERROR_OUT_OF_RANGE;
1603 }
1604 unsigned char bytes[4];
1605 m_Source->Seek(0);
1606 m_Source->Read(bytes, (AP4_Size)size);
1607 result = AP4_SUCCESS;
1608 switch (size) {
1609 case 1: value = bytes[0]; break;
1610 case 2: value = AP4_BytesToInt16BE(bytes); break;
1611 case 4: value = AP4_BytesToInt32BE(bytes); break;
1612 default: value = 0; result = AP4_ERROR_INVALID_FORMAT; break;
1613 }
1614 return result;
1615}
1616
1617/*----------------------------------------------------------------------
1618| AP4_MetaDataStringAtom::AP4_MetaDataStringAtom

Callers 2

ToStringMethod · 0.80
ToIntegerMethod · 0.80

Calls 5

AP4_BytesToInt16BEFunction · 0.85
AP4_BytesToInt32BEFunction · 0.85
GetSizeMethod · 0.45
SeekMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected