Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
28
libs/transit/transit_version.cpp
Normal file
28
libs/transit/transit_version.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "transit/transit_version.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <limits>
|
||||
|
||||
namespace transit
|
||||
{
|
||||
TransitVersion GetVersion(Reader & reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
NonOwningReaderSource src(reader);
|
||||
uint16_t headerVersion = std::numeric_limits<uint16_t>::max();
|
||||
ReadPrimitiveFromSource(src, headerVersion);
|
||||
CHECK_LESS(headerVersion, static_cast<uint16_t>(TransitVersion::Counter), ("Invalid transit header version."));
|
||||
|
||||
return static_cast<TransitVersion>(headerVersion);
|
||||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
LOG(LERROR, ("Error reading header version from transit mwm section.", ex.what()));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
} // namespace transit
|
||||
Loading…
Add table
Add a link
Reference in a new issue