#include "logbookEntry.h" namespace germanairlinesva_logbook { LogbookEntry::LogbookEntry(std::string date, std::string flightNumber, std::string aircraftType, std::string aircraftRegistration, std::string departureAirport, std::string departureGate, std::string departureRunway, std::string arrivalAirport, std::string arrivalGate, std::string arrivalRunway, std::string offBlockTime, std::string outTime, std::string inTime, std::string onBlockTime, float totalFlightTime, float taxiOutFuel, float inFlightFuel, float taxiInFuel, float totalFuel, float taxiOutDistance, float inFlightDistance, float taxiInDistance, float totalDistance, float maxLandingRate, std::uint8_t touchdowns, float maxLandingGees, std::string recordingFilename, float points, std::uint8_t flags) { this->date = date; this->flightNumber = flightNumber; this->aircraftType = aircraftType; this->aircraftRegistration = aircraftRegistration; this->departureAirport = departureAirport; this->departureGate = departureGate; this->departureRunway = departureRunway; this->arrivalAirport = arrivalAirport; this->arrivalGate = arrivalGate; this->arrivalRunway = arrivalRunway; this->offBlockTime = offBlockTime; this->outTime = outTime; this->inTime = inTime; this->onBlockTime = onBlockTime; this->totalFlightTime = totalFlightTime; this->taxiOutFuel = taxiOutFuel; this->inFlightFuel = inFlightFuel; this->taxiInFuel = taxiInFuel; this->totalFuel = totalFuel; this->taxiOutDistance = taxiOutDistance; this->inFlightDistance = inFlightDistance; this->taxiInDistance = taxiInDistance; this->totalDistance = totalDistance; this->maxLandingRate = maxLandingRate; this->touchdowns = touchdowns; this->maxLandingGees = maxLandingGees; this->recordingFilename = recordingFilename; this->points = points; this->flags = flags; file = std::vector( this->date.length() + 1 + this->flightNumber.length() + 1 + this->aircraftType.length() + 1 + this->aircraftRegistration.length() + 1 + 1 + this->departureAirport.length() + 1 + 1 + this->departureGate.length() + 1 + 1 + this->departureRunway.length() + 1 + 1 + this->arrivalAirport.length() + 1 + 1 + this->arrivalGate.length() + 1 + 1 + this->arrivalRunway.length() + 1 + this->offBlockTime.length() + 1 + this->outTime.length() + 1 + this->inTime.length() + 1 + this->onBlockTime.length() + 1 + sizeof(this->totalFlightTime) + sizeof(this->taxiOutFuel) + sizeof(this->inFlightFuel) + sizeof(this->taxiInFuel) + sizeof(this->totalFuel) + sizeof(this->taxiOutDistance) + sizeof(this->inFlightDistance) + sizeof(this->taxiInDistance) + sizeof(this->totalDistance) + sizeof(this->maxLandingRate) + sizeof(this->touchdowns) + sizeof(this->maxLandingGees) + 1 + recordingFilename.length() + 1 + sizeof(this->points) + sizeof(this->flags)); std::uint8_t *bufPtr = file.data(); std::memcpy(bufPtr, this->date.c_str(), this->date.length()); bufPtr += this->date.length() + 1; std::memcpy(bufPtr, this->flightNumber.c_str(), this->flightNumber.length()); bufPtr += this->flightNumber.length() + 1; std::memcpy(bufPtr, this->aircraftType.c_str(), this->aircraftType.length()); bufPtr += this->aircraftType.length() + 1; std::memcpy(bufPtr, this->aircraftRegistration.c_str(), this->aircraftRegistration.length()); bufPtr += this->aircraftRegistration.length() + 1; std::memset(bufPtr, static_cast(this->departureAirport.length()), sizeof(std::uint8_t)); bufPtr++; std::memcpy(bufPtr, this->departureAirport.c_str(), this->departureAirport.length()); bufPtr += this->departureAirport.length() + 1; std::memset(bufPtr, static_cast(this->departureGate.length()), sizeof(std::uint8_t)); bufPtr++; std::memcpy(bufPtr, this->departureGate.c_str(), this->departureGate.length()); bufPtr += this->departureGate.length() + 1; std::memset(bufPtr, static_cast(this->departureRunway.length()), sizeof(std::uint8_t)); bufPtr++; std::memcpy(bufPtr, this->departureRunway.c_str(), this->departureRunway.length()); bufPtr += this->departureRunway.length() + 1; std::memset(bufPtr, static_cast(this->arrivalAirport.length()), sizeof(std::uint8_t)); bufPtr++; std::memcpy(bufPtr, this->arrivalAirport.c_str(), this->arrivalAirport.length()); bufPtr += this->arrivalAirport.length() + 1; std::memset(bufPtr, static_cast(this->arrivalGate.length()), sizeof(std::uint8_t)); bufPtr++; std::memcpy(bufPtr, this->arrivalGate.c_str(), this->arrivalGate.length()); bufPtr += this->arrivalGate.length() + 1; std::memset(bufPtr, static_cast(this->arrivalRunway.length()), sizeof(std::uint8_t)); bufPtr++; std::memcpy(bufPtr, this->arrivalRunway.c_str(), this->arrivalRunway.length()); bufPtr += this->arrivalRunway.length() + 1; std::memcpy(bufPtr, this->offBlockTime.c_str(), this->offBlockTime.length()); bufPtr += this->offBlockTime.length() + 1; std::memcpy(bufPtr, this->outTime.c_str(), this->outTime.length()); bufPtr += this->outTime.length() + 1; std::memcpy(bufPtr, this->inTime.c_str(), this->inTime.length()); bufPtr += this->inTime.length() + 1; std::memcpy(bufPtr, this->onBlockTime.c_str(), this->onBlockTime.length()); bufPtr += this->onBlockTime.length() + 1; std::memcpy(bufPtr, &this->totalFlightTime, sizeof(this->totalFlightTime)); bufPtr += sizeof(this->totalFlightTime); std::memcpy(bufPtr, &this->taxiOutFuel, sizeof(this->taxiOutFuel)); bufPtr += sizeof(this->taxiOutFuel); std::memcpy(bufPtr, &this->inFlightFuel, sizeof(this->inFlightFuel)); bufPtr += sizeof(this->inFlightFuel); std::memcpy(bufPtr, &this->taxiInFuel, sizeof(this->taxiInFuel)); bufPtr += sizeof(this->taxiInFuel); std::memcpy(bufPtr, &this->totalFuel, sizeof(this->totalFuel)); bufPtr += sizeof(this->totalFuel); std::memcpy(bufPtr, &this->taxiOutDistance, sizeof(this->taxiOutDistance)); bufPtr += sizeof(this->taxiOutDistance); std::memcpy(bufPtr, &this->inFlightDistance, sizeof(this->inFlightDistance)); bufPtr += sizeof(this->inFlightDistance); std::memcpy(bufPtr, &this->taxiInDistance, sizeof(this->taxiInDistance)); bufPtr += sizeof(this->taxiInDistance); std::memcpy(bufPtr, &this->totalDistance, sizeof(this->totalDistance)); bufPtr += sizeof(this->totalDistance); std::memcpy(bufPtr, &this->maxLandingRate, sizeof(this->maxLandingRate)); bufPtr += sizeof(this->maxLandingRate); std::memcpy(bufPtr, &this->touchdowns, sizeof(this->touchdowns)); bufPtr += sizeof(this->touchdowns); std::memcpy(bufPtr, &this->maxLandingGees, sizeof(this->maxLandingGees)); bufPtr += sizeof(this->maxLandingGees); std::memset(bufPtr, static_cast(this->recordingFilename.length()), sizeof(std::uint8_t)); bufPtr++; std::memcpy(bufPtr, this->recordingFilename.c_str(), this->recordingFilename.length()); bufPtr += this->recordingFilename.length() + 1; std::memcpy(bufPtr, &this->points, sizeof(this->points)); bufPtr += sizeof(this->points); std::memcpy(bufPtr, &this->flags, sizeof(this->flags)); } } // namespace germanairlinesva_logbook