void decodeCar(Car &car, char *buffer, int offset, int actingBlockLength, int actingVersion) { car.wrapForDecode(buffer, offset, actingBlockLength, actingVersion); std::string sb; sb.append("\ncar.serialNumberId=").append(format(Car::serialNumberSchemaId())); sb.append("\ncar.modelYearId=").append(format(Car::modelYearSchemaId())); sb.append("\ncar.availableId=").append(format(Car::availableSchemaId())); sb.append("\ncar.codeId=").append(format(Car::codeSchemaId())); sb.append("\ncar.someNumbersId=").append(format(Car::someNumbersSchemaId())); sb.append("\ncar.vehicleCodeId=").append(format(Car::vehicleCodeSchemaId())); sb.append("\ncar.extrasId=").append(format(Car::extrasSchemaId())); sb.append("\ncar.engineId=").append(format(Car::engineSchemaId())); sb.append("\ncar.fuelFiguresId=").append(format(Car::fuelFiguresSchemaId())); sb.append("\ncar.fuelFigures.speedId=").append(format(Car::FuelFigures::speedSchemaId())); sb.append("\ncar.fuelFigures.mpgId=").append(format(Car::FuelFigures::mpgSchemaId())); sb.append("\ncar.performanceFiguresId=").append(format(Car::performanceFiguresSchemaId())); sb.append("\ncar.performanceFigures.octaneRatingId=").append(format(Car::PerformanceFigures::octaneRatingSchemaId())); sb.append("\ncar.performanceFigures.accelerationId=").append(format(Car::PerformanceFigures::accelerationSchemaId())); sb.append("\ncar.performanceFigures.acceleration.mphId=").append(format(Car::PerformanceFigures::Acceleration::mphSchemaId())); sb.append("\ncar.performanceFigures.acceleration.secondsId=").append(format(Car::PerformanceFigures::Acceleration::secondsSchemaId())); sb.append("\ncar.makeId=").append(format(Car::makeSchemaId())); sb.append("\ncar.makeCharacterEncoding=").append(Car::makeCharacterEncoding()); sb.append("\ncar.makeMetaAttribute.SEMANTIC_TYPE=").append(Car::makeMetaAttribute(MetaAttribute::SEMANTIC_TYPE)); sb.append("\ncar.modelId=").append(format(Car::modelSchemaId())); sb.append("\ncar.modelCharacterEncoding=").append(Car::modelCharacterEncoding()); sb.append("\n"); sb.append("\ncar.serialNumber=").append(format((int)car.serialNumber())); sb.append("\ncar.modelYear=").append(format((int)car.modelYear())); sb.append("\ncar.available=").append(format(car.available())); sb.append("\ncar.code=").append(format(car.code())); sb.append("\ncar.someNumbers="); for (int i = 0, size = Car::someNumbersLength(); i < size; i++) { sb.append(format(car.someNumbers(i))).append(", "); } sb.append("\ncar.vehicleCodeLength=").append(format((int)car.vehicleCodeLength())); sb.append("\ncar.vehicleCode="); for (int i = 0, size = Car::vehicleCodeLength(); i < size; i++) { sb.append(format((char)car.vehicleCode(i))); } OptionalExtras &extras = car.extras(); sb.append("\ncar.extras.cruiseControl=").append(format(extras.cruiseControl())); sb.append("\ncar.extras.sportsPack=").append(format(extras.sportsPack())); sb.append("\ncar.extras.sunRoof=").append(format(extras.sunRoof())); Engine &engine = car.engine(); sb.append("\ncar.engine.capacity=").append(format((int)engine.capacity())); sb.append("\ncar.engine.numCylinders=").append(format((int)engine.numCylinders())); sb.append("\ncar.engine.maxRpm=").append(format((int)engine.maxRpm())); sb.append("\ncar.engine.manufacturerCodeLength=").append(format((int)engine.manufacturerCodeLength())); sb.append("\ncar.engine.manufacturerCode="); for (int i = 0, size = Engine::manufacturerCodeLength(); i < size; i++) { sb.append(format((char)engine.manufacturerCode(i))); } char tmp[1024]; int bytesCopied = engine.getFuel(tmp, sizeof(tmp)); sb.append("\ncar.engine.fuelLength=").append(format(bytesCopied)); sb.append("\ncar.engine.fuel=").append(tmp, bytesCopied); Car::FuelFigures &fuelFigures = car.fuelFigures(); while (fuelFigures.hasNext()) { fuelFigures.next(); sb.append("\ncar.fuelFigures.speed=").append(format((int)fuelFigures.speed())); sb.append("\ncar.fuelFigures.mpg=").append(format((double)fuelFigures.mpg())); } Car::PerformanceFigures &performanceFigures = car.performanceFigures(); while (performanceFigures.hasNext()) { performanceFigures.next(); sb.append("\ncar.performanceFigures.octaneRating=").append(format((int)performanceFigures.octaneRating())); Car::PerformanceFigures::Acceleration &acceleration = performanceFigures.acceleration(); while (acceleration.hasNext()) { acceleration.next(); sb.append("\ncar.performanceFigures.acceleration.mph=").append(format((int)acceleration.mph())); sb.append("\ncar.performanceFigures.acceleration.seconds=").append(format((double)acceleration.seconds())); } } bytesCopied = car.getMake(tmp, sizeof(tmp)); sb.append("\ncar.makeLength=").append(format((int)bytesCopied)); sb.append("\ncar.make=").append(tmp, bytesCopied); bytesCopied = car.getModel(tmp, sizeof(tmp)); sb.append("\ncar.modelLength=").append(format((int)bytesCopied)); sb.append("\ncar.model=").append(tmp, bytesCopied); cout << sb << endl; }
std::size_t decodeCar( Car &car, char *buffer, std::uint64_t offset, std::uint64_t actingBlockLength, std::uint64_t actingVersion, std::uint64_t bufferLength) { car.wrapForDecode(buffer, offset, actingBlockLength, actingVersion, bufferLength); std::cout.setf(std::ios::fixed); std::cout << "\ncar.serialNumberId=" << Car::serialNumberId(); std::cout << "\ncar.modelYearId=" << Car::modelYearId(); std::cout << "\ncar.availableId=" << Car::availableId(); std::cout << "\ncar.codeId=" << Car::codeId(); std::cout << "\ncar.someNumbersId=" << Car::someNumbersId(); std::cout << "\ncar.vehicleCodeId=" << Car::vehicleCodeId(); std::cout << "\ncar.extrasId=" << Car::extrasId(); std::cout << "\ncar.engineId=" << Car::engineId(); std::cout << "\ncar.fuelFiguresId=" << Car::fuelFiguresId(); std::cout << "\ncar.fuelFigures.speedId=" << Car::FuelFigures::speedId(); std::cout << "\ncar.fuelFigures.mpgId=" << Car::FuelFigures::mpgId(); std::cout << "\ncar.fuelFigures.usageDescriptionId=" << Car::FuelFigures::usageDescriptionId(); std::cout << "\ncar.performanceFiguresId=" << Car::performanceFiguresId(); std::cout << "\ncar.performanceFigures.octaneRatingId=" << Car::PerformanceFigures::octaneRatingId(); std::cout << "\ncar.performanceFigures.accelerationId=" << Car::PerformanceFigures::accelerationId(); std::cout << "\ncar.performanceFigures.acceleration.mphId=" << Car::PerformanceFigures::Acceleration::mphId(); std::cout << "\ncar.performanceFigures.acceleration.secondsId=" << Car::PerformanceFigures::Acceleration::secondsId(); std::cout << "\ncar.makeId=" << Car::makeId(); std::cout << "\ncar.makeCharacterEncoding=" << Car::makeCharacterEncoding(); std::cout << "\ncar.modelId=" << Car::modelId(); std::cout << "\ncar.modelCharacterEncoding=" << Car::modelCharacterEncoding(); std::cout << "\ncar.activationCodeId=" << Car::activationCodeId(); std::cout << "\ncar.activationCodeCharacterEncoding=" << Car::activationCodeCharacterEncoding(); std::cout << "\n"; std::cout << "\ncar.serialNumber=" << car.serialNumber(); std::cout << "\ncar.modelYear=" << car.modelYear(); std::cout << "\ncar.available=" << format(car.available()); std::cout << "\ncar.code=" << format(car.code()); std::cout << "\ncar.someNumbers="; std::string separator(""); for (std::uint64_t i = 0; i < Car::someNumbersLength(); i++) { std::cout << separator << car.someNumbers(i); separator = ", "; } std::cout << "\ncar.vehicleCode="; separator = ""; for (std::uint64_t i = 0; i < Car::vehicleCodeLength(); i++) { std::cout << separator << car.vehicleCode(i); separator = ", "; } OptionalExtras &extras = car.extras(); std::cout << "\ncar.extras.cruiseControl=" << format(extras.cruiseControl()); std::cout << "\ncar.extras.sportsPack=" << format(extras.sportsPack()); std::cout << "\ncar.extras.sunRoof=" << format(extras.sunRoof()); std::cout << "\ncar.discountedModel=" << format(car.discountedModel()); Engine &engine = car.engine(); std::cout << "\ncar.engine.capacity=" << (int)engine.capacity(); std::cout << "\ncar.engine.numCylinders=" << (int)engine.numCylinders(); std::cout << "\ncar.engine.maxRpm=" << (int)engine.maxRpm(); std::cout << "\ncar.engine.manufacturerCodeLength=" << (int)engine.manufacturerCodeLength(); std::cout << "\ncar.engine.manufacturerCode="; separator = ""; for (std::uint64_t i = 0; i < Engine::manufacturerCodeLength(); i++) { std::cout << separator << engine.manufacturerCode(i); separator = ", "; } char tmp[1024]; std::uint64_t bytesCopied = engine.getFuel(tmp, sizeof(tmp)); std::cout << "\ncar.engine.fuelLength=" << bytesCopied; std::cout << "\ncar.engine.fuel=" << std::string(tmp, bytesCopied); Car::FuelFigures &fuelFigures = car.fuelFigures(); while (fuelFigures.hasNext()) { fuelFigures.next(); std::cout << "\ncar.fuelFigures.speed=" << (int)fuelFigures.speed(); std::cout << "\ncar.fuelFigures.mpg=" << std::setprecision(1) << (double)fuelFigures.mpg(); std::string usageDesc = fuelFigures.getUsageDescriptionAsString(); std::cout << "\ncar.fuelFigures.usageDescriptionLength=" << usageDesc.length(); std::cout << "\ncar.fuelFigures.usageDescription=" << usageDesc; } Car::PerformanceFigures &performanceFigures = car.performanceFigures(); while (performanceFigures.hasNext()) { performanceFigures.next(); std::cout << "\ncar.performanceFigures.octaneRating=" << (std::uint64_t)performanceFigures.octaneRating(); Car::PerformanceFigures::Acceleration &acceleration = performanceFigures.acceleration(); while (acceleration.hasNext()) { acceleration.next(); std::cout << "\ncar.performanceFigures.acceleration.mph=" << acceleration.mph(); std::cout << "\ncar.performanceFigures.acceleration.seconds=" << std::setprecision(1) << acceleration.seconds(); } } bytesCopied = car.getMake(tmp, sizeof(tmp)); std::cout << "\ncar.makeLength=" << bytesCopied; std::cout << "\ncar.make=" << std::string(tmp, bytesCopied); bytesCopied = car.getModel(tmp, sizeof(tmp)); std::cout << "\ncar.modelLength=" << bytesCopied; std::cout << "\ncar.model=" << std::string(tmp, bytesCopied); bytesCopied = car.getActivationCode(tmp, sizeof(tmp)); std::cout << "\ncar.activationCodeLength=" << bytesCopied; std::cout << "\ncar.activationCode=" << std::string(tmp, bytesCopied); std::cout << "\ncar.encodedLength=" << (int)car.encodedLength() << "\n"; return car.encodedLength(); }