diff --git a/cpp/evolution/v0/generated/binary/protocols.cc b/cpp/evolution/v0/generated/binary/protocols.cc index 0896ca9..b21b777 100644 --- a/cpp/evolution/v0/generated/binary/protocols.cc +++ b/cpp/evolution/v0/generated/binary/protocols.cc @@ -1549,6 +1549,1448 @@ void ProtocolWithChangesReader::CloseImpl() { stream_.VerifyFinished(); } +void ProtocolWithChangesIndexedWriter::WriteInt8ToIntImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToInt", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToLongImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToLong", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToUintImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToUint", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToUlongImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToUlong", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToFloatImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToFloat", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToDoubleImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToDouble", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUintImpl(int32_t const& value) { + step_index_.set_step_offset("IntToUint", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToLongImpl(int32_t const& value) { + step_index_.set_step_offset("IntToLong", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToFloatImpl(int32_t const& value) { + step_index_.set_step_offset("IntToFloat", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToDoubleImpl(int32_t const& value) { + step_index_.set_step_offset("IntToDouble", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUintToUlongImpl(uint32_t const& value) { + step_index_.set_step_offset("UintToUlong", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUintToFloatImpl(uint32_t const& value) { + step_index_.set_step_offset("UintToFloat", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUintToDoubleImpl(uint32_t const& value) { + step_index_.set_step_offset("UintToDouble", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToDoubleImpl(float const& value) { + step_index_.set_step_offset("FloatToDouble", stream_.Pos()); + yardl::binary::WriteFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteComplexFloatToComplexDoubleImpl(std::complex const& value) { + step_index_.set_step_offset("ComplexFloatToComplexDouble", stream_.Pos()); + yardl::binary::WriteFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToStringImpl(int32_t const& value) { + step_index_.set_step_offset("IntToString", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUintToStringImpl(uint32_t const& value) { + step_index_.set_step_offset("UintToString", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteLongToStringImpl(int64_t const& value) { + step_index_.set_step_offset("LongToString", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUlongToStringImpl(uint64_t const& value) { + step_index_.set_step_offset("UlongToString", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToStringImpl(float const& value) { + step_index_.set_step_offset("FloatToString", stream_.Pos()); + yardl::binary::WriteFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteDoubleToStringImpl(double const& value) { + step_index_.set_step_offset("DoubleToString", stream_.Pos()); + yardl::binary::WriteFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToOptionalImpl(int32_t const& value) { + step_index_.set_step_offset("IntToOptional", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToOptionalImpl(float const& value) { + step_index_.set_step_offset("FloatToOptional", stream_.Pos()); + yardl::binary::WriteFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStringToOptionalImpl(std::string const& value) { + step_index_.set_step_offset("StringToOptional", stream_.Pos()); + yardl::binary::WriteString(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUnionImpl(int32_t const& value) { + step_index_.set_step_offset("IntToUnion", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToUnionImpl(float const& value) { + step_index_.set_step_offset("FloatToUnion", stream_.Pos()); + yardl::binary::WriteFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStringToUnionImpl(std::string const& value) { + step_index_.set_step_offset("StringToUnion", stream_.Pos()); + yardl::binary::WriteString(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalIntToFloatImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalIntToFloat", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalFloatToStringImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalFloatToString", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedLongToStringImpl(evo_test::AliasedLongToString const& value) { + step_index_.set_step_offset("AliasedLongToString", stream_.Pos()); + evo_test::binary::WriteAliasedLongToString(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStringToAliasedStringImpl(std::string const& value) { + step_index_.set_step_offset("StringToAliasedString", stream_.Pos()); + yardl::binary::WriteString(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStringToAliasedIntImpl(std::string const& value) { + step_index_.set_step_offset("StringToAliasedInt", stream_.Pos()); + yardl::binary::WriteString(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteEnumToAliasedEnumImpl(evo_test::GrowingEnum const& value) { + step_index_.set_step_offset("EnumToAliasedEnum", stream_.Pos()); + yardl::binary::WriteEnum(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalIntToUnionImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalIntToUnion", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalRecordToUnionImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalRecordToUnion", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRecordWithChangesImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordWithChanges", stream_.Pos()); + evo_test::binary::WriteRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges const& value) { + step_index_.set_step_offset("AliasedRecordWithChanges", stream_.Pos()); + evo_test::binary::WriteAliasedRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToRenamedRecordImpl(evo_test::RenamedRecord const& value) { + step_index_.set_step_offset("RecordToRenamedRecord", stream_.Pos()); + evo_test::binary::WriteRenamedRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedRecordImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedRecord", stream_.Pos()); + evo_test::binary::WriteRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedAliasImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedAlias", stream_.Pos()); + evo_test::binary::WriteRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamIntToStringToFloatImpl(int32_t const& value) { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("StreamIntToStringToFloat", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamIntToStringToFloatImpl(std::vector const& values) { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("StreamIntToStringToFloat", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamIntToStringToFloatImpl() { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + step_index_.add_stream_offsets("StreamIntToStringToFloat", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void ProtocolWithChangesIndexedWriter::WriteVectorIntToStringToFloatImpl(std::vector const& value) { + step_index_.set_step_offset("VectorIntToStringToFloat", stream_.Pos()); + yardl::binary::WriteVector(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteIntFloatUnionReorderedImpl(std::variant const& value) { + step_index_.set_step_offset("IntFloatUnionReordered", stream_.Pos()); + WriteUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteVectorUnionReorderedImpl(std::vector> const& value) { + step_index_.set_step_offset("VectorUnionReordered", stream_.Pos()); + yardl::binary::WriteVector, WriteUnion>(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamUnionReorderedImpl(std::variant const& value) { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + step_index_.add_stream_offset("StreamUnionReordered", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamUnionReorderedImpl(std::vector> const& values) { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("StreamUnionReordered", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamUnionReorderedImpl() { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + step_index_.add_stream_offsets("StreamUnionReordered", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamOfAliasTypeChangeImpl(evo_test::StreamItem const& value) { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("StreamOfAliasTypeChange", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamOfAliasTypeChangeImpl(std::vector const& values) { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("StreamOfAliasTypeChange", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamOfAliasTypeChangeImpl() { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + step_index_.add_stream_offsets("StreamOfAliasTypeChange", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("Rlink", stream_.Pos()); + evo_test::binary::WriteRLink(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRXImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRX", stream_.Pos()); + evo_test::binary::WriteRLink(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRYImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRY", stream_.Pos()); + evo_test::binary::WriteRLink(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRZImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRZ", stream_.Pos()); + evo_test::binary::WriteRLink(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRaRLinkImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRLink", stream_.Pos()); + evo_test::binary::WriteRA(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRaRXImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRX", stream_.Pos()); + evo_test::binary::WriteRA(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRaRYImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRY", stream_.Pos()); + evo_test::binary::WriteRA(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRaRZImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRZ", stream_.Pos()); + evo_test::binary::WriteRA(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRbRLinkImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRLink", stream_.Pos()); + evo_test::binary::WriteRB(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRbRXImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRX", stream_.Pos()); + evo_test::binary::WriteRB(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRbRYImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRY", stream_.Pos()); + evo_test::binary::WriteRB(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRbRZImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRZ", stream_.Pos()); + evo_test::binary::WriteRB(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRcRLinkImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRLink", stream_.Pos()); + evo_test::binary::WriteRC(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRcRXImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRX", stream_.Pos()); + evo_test::binary::WriteRC(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRcRYImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRY", stream_.Pos()); + evo_test::binary::WriteRC(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRcRZImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRZ", stream_.Pos()); + evo_test::binary::WriteRC(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRNewImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRNew", stream_.Pos()); + evo_test::binary::WriteRLink(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRaRNewImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRNew", stream_.Pos()); + evo_test::binary::WriteRA(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRbRNewImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRNew", stream_.Pos()); + evo_test::binary::WriteRB(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRcRNewImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRNew", stream_.Pos()); + evo_test::binary::WriteRC(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRUnionImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRUnion", stream_.Pos()); + evo_test::binary::WriteRLink(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRaRUnionImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRUnion", stream_.Pos()); + evo_test::binary::WriteRA(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRbRUnionImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRUnion", stream_.Pos()); + evo_test::binary::WriteRB(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRcRUnionImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRUnion", stream_.Pos()); + evo_test::binary::WriteRC(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalRecordWithChangesImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalRecordWithChanges", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedOptionalRecordWithChangesImpl(std::optional const& value) { + step_index_.set_step_offset("AliasedOptionalRecordWithChanges", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUnionRecordWithChangesImpl(std::variant const& value) { + step_index_.set_step_offset("UnionRecordWithChanges", stream_.Pos()); + WriteUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithSameTypesetImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithSameTypeset", stream_.Pos()); + WriteUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithTypesAddedImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithTypesAdded", stream_.Pos()); + WriteUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithTypesRemovedImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithTypesRemoved", stream_.Pos()); + WriteUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToOptionalImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToOptional", stream_.Pos()); + evo_test::binary::WriteRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedOptionalImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedOptional", stream_.Pos()); + evo_test::binary::WriteRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToUnionImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToUnion", stream_.Pos()); + evo_test::binary::WriteRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedUnionImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedUnion", stream_.Pos()); + evo_test::binary::WriteRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUnionToAliasedUnionImpl(std::variant const& value) { + step_index_.set_step_offset("UnionToAliasedUnion", stream_.Pos()); + WriteUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteUnionToAliasedUnionWithChangesImpl(std::variant const& value) { + step_index_.set_step_offset("UnionToAliasedUnionWithChanges", stream_.Pos()); + WriteUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalToAliasedOptionalImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalToAliasedOptional", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalToAliasedOptionalWithChangesImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalToAliasedOptionalWithChanges", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecord", stream_.Pos()); + evo_test::binary::WriteGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToOpenAliasImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToOpenAlias", stream_.Pos()); + evo_test::binary::WriteGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToClosedAliasImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToClosedAlias", stream_.Pos()); + evo_test::binary::WriteGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToHalfClosedAliasImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToHalfClosedAlias", stream_.Pos()); + evo_test::binary::WriteGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedGenericRecordToAliasImpl(evo_test::AliasedHalfClosedGenericRecord const& value) { + step_index_.set_step_offset("AliasedGenericRecordToAlias", stream_.Pos()); + evo_test::binary::WriteAliasedHalfClosedGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToReversedImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToReversed", stream_.Pos()); + evo_test::binary::WriteGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteClosedGenericRecordToUnionImpl(evo_test::AliasedClosedGenericRecord const& value) { + step_index_.set_step_offset("ClosedGenericRecordToUnion", stream_.Pos()); + evo_test::binary::WriteAliasedClosedGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToAliasedUnionImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToAliasedUnion", stream_.Pos()); + evo_test::binary::WriteGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericUnionToReversedImpl(evo_test::AliasedClosedGenericUnion const& value) { + step_index_.set_step_offset("GenericUnionToReversed", stream_.Pos()); + evo_test::binary::WriteAliasedClosedGenericUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericUnionOfChangedRecordImpl(evo_test::AliasedClosedGenericUnion const& value) { + step_index_.set_step_offset("GenericUnionOfChangedRecord", stream_.Pos()); + evo_test::binary::WriteAliasedClosedGenericUnion(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordImpl(evo_test::GenericParentRecord const& value) { + step_index_.set_step_offset("GenericParentRecord", stream_.Pos()); + evo_test::binary::WriteGenericParentRecord(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericNestedRecordsImpl(evo_test::GenericRecord, evo_test::ChangedGeneric> const& value) { + step_index_.set_step_offset("GenericNestedRecords", stream_.Pos()); + evo_test::binary::WriteGenericRecord, evo_test::binary::WriteUnchangedGeneric, evo_test::ChangedGeneric, evo_test::binary::WriteChangedGeneric>(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordStreamImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, evo_test::binary::WriteGenericRecord>(stream_, value, item_offset); + step_index_.add_stream_offset("GenericRecordStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordStreamImpl(std::vector> const& values) { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, evo_test::binary::WriteGenericRecord>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("GenericRecordStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndGenericRecordStreamImpl() { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + step_index_.add_stream_offsets("GenericRecordStream", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordStreamImpl(evo_test::GenericParentRecord const& value) { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, evo_test::binary::WriteGenericParentRecord>(stream_, value, item_offset); + step_index_.add_stream_offset("GenericParentRecordStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordStreamImpl(std::vector> const& values) { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, evo_test::binary::WriteGenericParentRecord>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("GenericParentRecordStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndGenericParentRecordStreamImpl() { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + step_index_.add_stream_offsets("GenericParentRecordStream", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void ProtocolWithChangesIndexedWriter::WriteVectorRecordWithChangesImpl(std::vector const& value) { + step_index_.set_step_offset("VectorRecordWithChanges", stream_.Pos()); + yardl::binary::WriteVector(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamedRecordWithChangesImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("StreamedRecordWithChanges", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamedRecordWithChangesImpl(std::vector const& values) { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("StreamedRecordWithChanges", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamedRecordWithChangesImpl() { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + step_index_.add_stream_offsets("StreamedRecordWithChanges", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void ProtocolWithChangesIndexedWriter::Flush() { + stream_.Flush(); +} + +void ProtocolWithChangesIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToIntImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToInt"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToLongImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToLong"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToUintImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToUint"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToUlongImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToUlong"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToFloatImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToFloat"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToDoubleImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToDouble"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadIntToUintImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToUint"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadIntToLongImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToLong"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadIntToFloatImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToFloat"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadIntToDoubleImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToDouble"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUintToUlongImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("UintToUlong"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUintToFloatImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("UintToFloat"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUintToDoubleImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("UintToDouble"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadFloatToDoubleImpl(float& value) { + auto pos = step_index_.get_step_offset("FloatToDouble"); + stream_.Seek(pos); + yardl::binary::ReadFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadComplexFloatToComplexDoubleImpl(std::complex& value) { + auto pos = step_index_.get_step_offset("ComplexFloatToComplexDouble"); + stream_.Seek(pos); + yardl::binary::ReadFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadIntToStringImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToString"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUintToStringImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("UintToString"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadLongToStringImpl(int64_t& value) { + auto pos = step_index_.get_step_offset("LongToString"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUlongToStringImpl(uint64_t& value) { + auto pos = step_index_.get_step_offset("UlongToString"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadFloatToStringImpl(float& value) { + auto pos = step_index_.get_step_offset("FloatToString"); + stream_.Seek(pos); + yardl::binary::ReadFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadDoubleToStringImpl(double& value) { + auto pos = step_index_.get_step_offset("DoubleToString"); + stream_.Seek(pos); + yardl::binary::ReadFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadIntToOptionalImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToOptional"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadFloatToOptionalImpl(float& value) { + auto pos = step_index_.get_step_offset("FloatToOptional"); + stream_.Seek(pos); + yardl::binary::ReadFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadStringToOptionalImpl(std::string& value) { + auto pos = step_index_.get_step_offset("StringToOptional"); + stream_.Seek(pos); + yardl::binary::ReadString(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadIntToUnionImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToUnion"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadFloatToUnionImpl(float& value) { + auto pos = step_index_.get_step_offset("FloatToUnion"); + stream_.Seek(pos); + yardl::binary::ReadFloatingPoint(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadStringToUnionImpl(std::string& value) { + auto pos = step_index_.get_step_offset("StringToUnion"); + stream_.Seek(pos); + yardl::binary::ReadString(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadOptionalIntToFloatImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalIntToFloat"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadOptionalFloatToStringImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalFloatToString"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadAliasedLongToStringImpl(evo_test::AliasedLongToString& value) { + auto pos = step_index_.get_step_offset("AliasedLongToString"); + stream_.Seek(pos); + evo_test::binary::ReadAliasedLongToString(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadStringToAliasedStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("StringToAliasedString"); + stream_.Seek(pos); + yardl::binary::ReadString(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadStringToAliasedIntImpl(std::string& value) { + auto pos = step_index_.get_step_offset("StringToAliasedInt"); + stream_.Seek(pos); + yardl::binary::ReadString(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadEnumToAliasedEnumImpl(evo_test::GrowingEnum& value) { + auto pos = step_index_.get_step_offset("EnumToAliasedEnum"); + stream_.Seek(pos); + yardl::binary::ReadEnum(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadOptionalIntToUnionImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalIntToUnion"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadOptionalRecordToUnionImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalRecordToUnion"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRecordWithChangesImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordWithChanges"); + stream_.Seek(pos); + evo_test::binary::ReadRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges& value) { + auto pos = step_index_.get_step_offset("AliasedRecordWithChanges"); + stream_.Seek(pos); + evo_test::binary::ReadAliasedRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRecordToRenamedRecordImpl(evo_test::RenamedRecord& value) { + auto pos = step_index_.get_step_offset("RecordToRenamedRecord"); + stream_.Seek(pos); + evo_test::binary::ReadRenamedRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedRecordImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedRecord"); + stream_.Seek(pos); + evo_test::binary::ReadRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedAliasImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedAlias"); + stream_.Seek(pos); + evo_test::binary::ReadRecordWithChanges(stream_, value); +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(int32_t& value) { + if (!step_index_.offset_within_stream("StreamIntToStringToFloat", "VectorIntToStringToFloat", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamIntToStringToFloat")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamIntToStringToFloat", "VectorIntToStringToFloat", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamIntToStringToFloat")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(int32_t& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamIntToStringToFloat", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamIntToStringToFloat", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamIntToStringToFloatImpl() { + return step_index_.get_stream_count("StreamIntToStringToFloat"); +} + +void ProtocolWithChangesIndexedReader::ReadVectorIntToStringToFloatImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("VectorIntToStringToFloat"); + stream_.Seek(pos); + yardl::binary::ReadVector(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadIntFloatUnionReorderedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("IntFloatUnionReordered"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadVectorUnionReorderedImpl(std::vector>& value) { + auto pos = step_index_.get_step_offset("VectorUnionReordered"); + stream_.Seek(pos); + yardl::binary::ReadVector, ReadUnion>(stream_, value); +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::variant& value) { + if (!step_index_.offset_within_stream("StreamUnionReordered", "StreamOfAliasTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamUnionReordered")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("StreamUnionReordered", "StreamOfAliasTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamUnionReordered")); + } + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamUnionReordered", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamUnionReordered", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamUnionReorderedImpl() { + return step_index_.get_stream_count("StreamUnionReordered"); +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value) { + if (!step_index_.offset_within_stream("StreamOfAliasTypeChange", "Rlink", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfAliasTypeChange")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamOfAliasTypeChange", "Rlink", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfAliasTypeChange")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfAliasTypeChange", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfAliasTypeChange", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamOfAliasTypeChangeImpl() { + return step_index_.get_stream_count("StreamOfAliasTypeChange"); +} + +void ProtocolWithChangesIndexedReader::ReadRlinkImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("Rlink"); + stream_.Seek(pos); + evo_test::binary::ReadRLink(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRXImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRX"); + stream_.Seek(pos); + evo_test::binary::ReadRLink(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRYImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRY"); + stream_.Seek(pos); + evo_test::binary::ReadRLink(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRZImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRZ"); + stream_.Seek(pos); + evo_test::binary::ReadRLink(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRaRLinkImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRLink"); + stream_.Seek(pos); + evo_test::binary::ReadRA(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRaRXImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRX"); + stream_.Seek(pos); + evo_test::binary::ReadRA(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRaRYImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRY"); + stream_.Seek(pos); + evo_test::binary::ReadRA(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRaRZImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRZ"); + stream_.Seek(pos); + evo_test::binary::ReadRA(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRbRLinkImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRLink"); + stream_.Seek(pos); + evo_test::binary::ReadRB(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRbRXImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRX"); + stream_.Seek(pos); + evo_test::binary::ReadRB(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRbRYImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRY"); + stream_.Seek(pos); + evo_test::binary::ReadRB(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRbRZImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRZ"); + stream_.Seek(pos); + evo_test::binary::ReadRB(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRcRLinkImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRLink"); + stream_.Seek(pos); + evo_test::binary::ReadRC(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRcRXImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRX"); + stream_.Seek(pos); + evo_test::binary::ReadRC(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRcRYImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRY"); + stream_.Seek(pos); + evo_test::binary::ReadRC(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRcRZImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRZ"); + stream_.Seek(pos); + evo_test::binary::ReadRC(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRNewImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRNew"); + stream_.Seek(pos); + evo_test::binary::ReadRLink(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRaRNewImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRNew"); + stream_.Seek(pos); + evo_test::binary::ReadRA(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRbRNewImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRNew"); + stream_.Seek(pos); + evo_test::binary::ReadRB(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRcRNewImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRNew"); + stream_.Seek(pos); + evo_test::binary::ReadRC(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRUnionImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRUnion"); + stream_.Seek(pos); + evo_test::binary::ReadRLink(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRaRUnionImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRUnion"); + stream_.Seek(pos); + evo_test::binary::ReadRA(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRbRUnionImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRUnion"); + stream_.Seek(pos); + evo_test::binary::ReadRB(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRcRUnionImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRUnion"); + stream_.Seek(pos); + evo_test::binary::ReadRC(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadOptionalRecordWithChangesImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalRecordWithChanges"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadAliasedOptionalRecordWithChangesImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("AliasedOptionalRecordWithChanges"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUnionRecordWithChangesImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionRecordWithChanges"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithSameTypesetImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithSameTypeset"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithTypesAddedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithTypesAdded"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithTypesRemovedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithTypesRemoved"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRecordToOptionalImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToOptional"); + stream_.Seek(pos); + evo_test::binary::ReadRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedOptionalImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedOptional"); + stream_.Seek(pos); + evo_test::binary::ReadRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRecordToUnionImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToUnion"); + stream_.Seek(pos); + evo_test::binary::ReadRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedUnionImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedUnion"); + stream_.Seek(pos); + evo_test::binary::ReadRecordWithChanges(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUnionToAliasedUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionToAliasedUnion"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadUnionToAliasedUnionWithChangesImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionToAliasedUnionWithChanges"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadOptionalToAliasedOptionalImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalToAliasedOptional"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadOptionalToAliasedOptionalWithChangesImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalToAliasedOptionalWithChanges"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecord"); + stream_.Seek(pos); + evo_test::binary::ReadGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToOpenAliasImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToOpenAlias"); + stream_.Seek(pos); + evo_test::binary::ReadGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToClosedAliasImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToClosedAlias"); + stream_.Seek(pos); + evo_test::binary::ReadGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToHalfClosedAliasImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToHalfClosedAlias"); + stream_.Seek(pos); + evo_test::binary::ReadGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadAliasedGenericRecordToAliasImpl(evo_test::AliasedHalfClosedGenericRecord& value) { + auto pos = step_index_.get_step_offset("AliasedGenericRecordToAlias"); + stream_.Seek(pos); + evo_test::binary::ReadAliasedHalfClosedGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToReversedImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToReversed"); + stream_.Seek(pos); + evo_test::binary::ReadGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadClosedGenericRecordToUnionImpl(evo_test::AliasedClosedGenericRecord& value) { + auto pos = step_index_.get_step_offset("ClosedGenericRecordToUnion"); + stream_.Seek(pos); + evo_test::binary::ReadAliasedClosedGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToAliasedUnionImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToAliasedUnion"); + stream_.Seek(pos); + evo_test::binary::ReadGenericRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericUnionToReversedImpl(evo_test::AliasedClosedGenericUnion& value) { + auto pos = step_index_.get_step_offset("GenericUnionToReversed"); + stream_.Seek(pos); + evo_test::binary::ReadAliasedClosedGenericUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericUnionOfChangedRecordImpl(evo_test::AliasedClosedGenericUnion& value) { + auto pos = step_index_.get_step_offset("GenericUnionOfChangedRecord"); + stream_.Seek(pos); + evo_test::binary::ReadAliasedClosedGenericUnion(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericParentRecordImpl(evo_test::GenericParentRecord& value) { + auto pos = step_index_.get_step_offset("GenericParentRecord"); + stream_.Seek(pos); + evo_test::binary::ReadGenericParentRecord(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadGenericNestedRecordsImpl(evo_test::GenericRecord, evo_test::ChangedGeneric>& value) { + auto pos = step_index_.get_step_offset("GenericNestedRecords"); + stream_.Seek(pos); + evo_test::binary::ReadGenericRecord, evo_test::binary::ReadUnchangedGeneric, evo_test::ChangedGeneric, evo_test::binary::ReadChangedGeneric>(stream_, value); +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(evo_test::GenericRecord& value) { + if (!step_index_.offset_within_stream("GenericRecordStream", "GenericParentRecordStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericRecordStream")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericRecord>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("GenericRecordStream", "GenericParentRecordStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericRecordStream")); + } + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericRecord>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(evo_test::GenericRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericRecordStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericRecord>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericRecordStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericRecord>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountGenericRecordStreamImpl() { + return step_index_.get_stream_count("GenericRecordStream"); +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value) { + if (!step_index_.offset_within_stream("GenericParentRecordStream", "VectorRecordWithChanges", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericParentRecordStream")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("GenericParentRecordStream", "VectorRecordWithChanges", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericParentRecordStream")); + } + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericParentRecordStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericParentRecordStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountGenericParentRecordStreamImpl() { + return step_index_.get_stream_count("GenericParentRecordStream"); +} + +void ProtocolWithChangesIndexedReader::ReadVectorRecordWithChangesImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("VectorRecordWithChanges"); + stream_.Seek(pos); + yardl::binary::ReadVector(stream_, value); +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value) { + if (!step_index_.offset_within_stream("StreamedRecordWithChanges", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamedRecordWithChanges")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamedRecordWithChanges", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamedRecordWithChanges")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamedRecordWithChanges", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamedRecordWithChanges", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamedRecordWithChangesImpl() { + return step_index_.get_stream_count("StreamedRecordWithChanges"); +} + +void ProtocolWithChangesIndexedReader::CloseImpl() { +} + void UnusedProtocolWriter::WriteRecordsImpl(evo_test::UnchangedRecord const& value) { yardl::binary::WriteBlock(stream_, value); } @@ -1586,5 +3028,83 @@ void UnusedProtocolReader::CloseImpl() { stream_.VerifyFinished(); } +void UnusedProtocolIndexedWriter::WriteRecordsImpl(evo_test::UnchangedRecord const& value) { + step_index_.set_step_offset("Records", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("Records", item_offset); +} + +void UnusedProtocolIndexedWriter::WriteRecordsImpl(std::vector const& values) { + step_index_.set_step_offset("Records", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("Records", item_offsets); +} + +void UnusedProtocolIndexedWriter::EndRecordsImpl() { + step_index_.set_step_offset("Records", stream_.Pos()); + step_index_.add_stream_offsets("Records", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void UnusedProtocolIndexedWriter::Flush() { + stream_.Flush(); +} + +void UnusedProtocolIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool UnusedProtocolIndexedReader::ReadRecordsImpl(evo_test::UnchangedRecord& value) { + if (!step_index_.offset_within_stream("Records", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Records")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool UnusedProtocolIndexedReader::ReadRecordsImpl(std::vector& values) { + if (!step_index_.offset_within_stream("Records", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Records")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool UnusedProtocolIndexedReader::ReadRecordsImpl(evo_test::UnchangedRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Records", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool UnusedProtocolIndexedReader::ReadRecordsImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Records", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t UnusedProtocolIndexedReader::CountRecordsImpl() { + return step_index_.get_stream_count("Records"); +} + +void UnusedProtocolIndexedReader::CloseImpl() { +} + } // namespace evo_test::binary diff --git a/cpp/evolution/v0/generated/binary/protocols.h b/cpp/evolution/v0/generated/binary/protocols.h index 911c95d..17affdf 100644 --- a/cpp/evolution/v0/generated/binary/protocols.h +++ b/cpp/evolution/v0/generated/binary/protocols.h @@ -143,6 +143,137 @@ class ProtocolWithChangesWriter : public evo_test::ProtocolWithChangesWriterBase Version version_; }; +// Binary indexed writer for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedWriter : public evo_test::ProtocolWithChangesWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ProtocolWithChangesIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, evo_test::ProtocolWithChangesWriterBase::SchemaFromVersion(version)), version_(version) {} + + ProtocolWithChangesIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, evo_test::ProtocolWithChangesWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteInt8ToIntImpl(int8_t const& value) override; + void WriteInt8ToLongImpl(int8_t const& value) override; + void WriteInt8ToUintImpl(int8_t const& value) override; + void WriteInt8ToUlongImpl(int8_t const& value) override; + void WriteInt8ToFloatImpl(int8_t const& value) override; + void WriteInt8ToDoubleImpl(int8_t const& value) override; + void WriteIntToUintImpl(int32_t const& value) override; + void WriteIntToLongImpl(int32_t const& value) override; + void WriteIntToFloatImpl(int32_t const& value) override; + void WriteIntToDoubleImpl(int32_t const& value) override; + void WriteUintToUlongImpl(uint32_t const& value) override; + void WriteUintToFloatImpl(uint32_t const& value) override; + void WriteUintToDoubleImpl(uint32_t const& value) override; + void WriteFloatToDoubleImpl(float const& value) override; + void WriteComplexFloatToComplexDoubleImpl(std::complex const& value) override; + void WriteIntToStringImpl(int32_t const& value) override; + void WriteUintToStringImpl(uint32_t const& value) override; + void WriteLongToStringImpl(int64_t const& value) override; + void WriteUlongToStringImpl(uint64_t const& value) override; + void WriteFloatToStringImpl(float const& value) override; + void WriteDoubleToStringImpl(double const& value) override; + void WriteIntToOptionalImpl(int32_t const& value) override; + void WriteFloatToOptionalImpl(float const& value) override; + void WriteStringToOptionalImpl(std::string const& value) override; + void WriteIntToUnionImpl(int32_t const& value) override; + void WriteFloatToUnionImpl(float const& value) override; + void WriteStringToUnionImpl(std::string const& value) override; + void WriteOptionalIntToFloatImpl(std::optional const& value) override; + void WriteOptionalFloatToStringImpl(std::optional const& value) override; + void WriteAliasedLongToStringImpl(evo_test::AliasedLongToString const& value) override; + void WriteStringToAliasedStringImpl(std::string const& value) override; + void WriteStringToAliasedIntImpl(std::string const& value) override; + void WriteEnumToAliasedEnumImpl(evo_test::GrowingEnum const& value) override; + void WriteOptionalIntToUnionImpl(std::optional const& value) override; + void WriteOptionalRecordToUnionImpl(std::optional const& value) override; + void WriteRecordWithChangesImpl(evo_test::RecordWithChanges const& value) override; + void WriteAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges const& value) override; + void WriteRecordToRenamedRecordImpl(evo_test::RenamedRecord const& value) override; + void WriteRecordToAliasedRecordImpl(evo_test::RecordWithChanges const& value) override; + void WriteRecordToAliasedAliasImpl(evo_test::RecordWithChanges const& value) override; + // Stream and Vector type changes + void WriteStreamIntToStringToFloatImpl(int32_t const& value) override; + void WriteStreamIntToStringToFloatImpl(std::vector const& values) override; + void EndStreamIntToStringToFloatImpl() override; + void WriteVectorIntToStringToFloatImpl(std::vector const& value) override; + void WriteIntFloatUnionReorderedImpl(std::variant const& value) override; + void WriteVectorUnionReorderedImpl(std::vector> const& value) override; + void WriteStreamUnionReorderedImpl(std::variant const& value) override; + void WriteStreamUnionReorderedImpl(std::vector> const& values) override; + void EndStreamUnionReorderedImpl() override; + void WriteStreamOfAliasTypeChangeImpl(evo_test::StreamItem const& value) override; + void WriteStreamOfAliasTypeChangeImpl(std::vector const& values) override; + void EndStreamOfAliasTypeChangeImpl() override; + // Comprehensive NamedType changes + void WriteRlinkImpl(evo_test::RLink const& value) override; + void WriteRlinkRXImpl(evo_test::RLink const& value) override; + void WriteRlinkRYImpl(evo_test::RLink const& value) override; + void WriteRlinkRZImpl(evo_test::RLink const& value) override; + void WriteRaRLinkImpl(evo_test::RA const& value) override; + void WriteRaRXImpl(evo_test::RA const& value) override; + void WriteRaRYImpl(evo_test::RA const& value) override; + void WriteRaRZImpl(evo_test::RA const& value) override; + void WriteRbRLinkImpl(evo_test::RB const& value) override; + void WriteRbRXImpl(evo_test::RB const& value) override; + void WriteRbRYImpl(evo_test::RB const& value) override; + void WriteRbRZImpl(evo_test::RB const& value) override; + void WriteRcRLinkImpl(evo_test::RC const& value) override; + void WriteRcRXImpl(evo_test::RC const& value) override; + void WriteRcRYImpl(evo_test::RC const& value) override; + void WriteRcRZImpl(evo_test::RC const& value) override; + void WriteRlinkRNewImpl(evo_test::RLink const& value) override; + void WriteRaRNewImpl(evo_test::RA const& value) override; + void WriteRbRNewImpl(evo_test::RB const& value) override; + void WriteRcRNewImpl(evo_test::RC const& value) override; + void WriteRlinkRUnionImpl(evo_test::RLink const& value) override; + void WriteRaRUnionImpl(evo_test::RA const& value) override; + void WriteRbRUnionImpl(evo_test::RB const& value) override; + void WriteRcRUnionImpl(evo_test::RC const& value) override; + void WriteOptionalRecordWithChangesImpl(std::optional const& value) override; + void WriteAliasedOptionalRecordWithChangesImpl(std::optional const& value) override; + void WriteUnionRecordWithChangesImpl(std::variant const& value) override; + void WriteUnionWithSameTypesetImpl(std::variant const& value) override; + void WriteUnionWithTypesAddedImpl(std::variant const& value) override; + void WriteUnionWithTypesRemovedImpl(std::variant const& value) override; + void WriteRecordToOptionalImpl(evo_test::RecordWithChanges const& value) override; + void WriteRecordToAliasedOptionalImpl(evo_test::RecordWithChanges const& value) override; + void WriteRecordToUnionImpl(evo_test::RecordWithChanges const& value) override; + void WriteRecordToAliasedUnionImpl(evo_test::RecordWithChanges const& value) override; + void WriteUnionToAliasedUnionImpl(std::variant const& value) override; + void WriteUnionToAliasedUnionWithChangesImpl(std::variant const& value) override; + void WriteOptionalToAliasedOptionalImpl(std::optional const& value) override; + void WriteOptionalToAliasedOptionalWithChangesImpl(std::optional const& value) override; + void WriteGenericRecordImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordToOpenAliasImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordToClosedAliasImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordToHalfClosedAliasImpl(evo_test::GenericRecord const& value) override; + void WriteAliasedGenericRecordToAliasImpl(evo_test::AliasedHalfClosedGenericRecord const& value) override; + void WriteGenericRecordToReversedImpl(evo_test::GenericRecord const& value) override; + void WriteClosedGenericRecordToUnionImpl(evo_test::AliasedClosedGenericRecord const& value) override; + void WriteGenericRecordToAliasedUnionImpl(evo_test::GenericRecord const& value) override; + void WriteGenericUnionToReversedImpl(evo_test::AliasedClosedGenericUnion const& value) override; + void WriteGenericUnionOfChangedRecordImpl(evo_test::AliasedClosedGenericUnion const& value) override; + void WriteGenericParentRecordImpl(evo_test::GenericParentRecord const& value) override; + void WriteGenericNestedRecordsImpl(evo_test::GenericRecord, evo_test::ChangedGeneric> const& value) override; + void WriteGenericRecordStreamImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordStreamImpl(std::vector> const& values) override; + void EndGenericRecordStreamImpl() override; + void WriteGenericParentRecordStreamImpl(evo_test::GenericParentRecord const& value) override; + void WriteGenericParentRecordStreamImpl(std::vector> const& values) override; + void EndGenericParentRecordStreamImpl() override; + void WriteVectorRecordWithChangesImpl(std::vector const& value) override; + void WriteStreamedRecordWithChangesImpl(evo_test::RecordWithChanges const& value) override; + void WriteStreamedRecordWithChangesImpl(std::vector const& values) override; + void EndStreamedRecordWithChangesImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the ProtocolWithChanges protocol. class ProtocolWithChangesReader : public evo_test::ProtocolWithChangesReaderBase, yardl::binary::BinaryReader { public: @@ -269,6 +400,150 @@ class ProtocolWithChangesReader : public evo_test::ProtocolWithChangesReaderBase size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedReader : public evo_test::ProtocolWithChangesIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ProtocolWithChangesIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(evo_test::ProtocolWithChangesIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ProtocolWithChangesIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(evo_test::ProtocolWithChangesIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadInt8ToIntImpl(int8_t& value) override; + void ReadInt8ToLongImpl(int8_t& value) override; + void ReadInt8ToUintImpl(int8_t& value) override; + void ReadInt8ToUlongImpl(int8_t& value) override; + void ReadInt8ToFloatImpl(int8_t& value) override; + void ReadInt8ToDoubleImpl(int8_t& value) override; + void ReadIntToUintImpl(int32_t& value) override; + void ReadIntToLongImpl(int32_t& value) override; + void ReadIntToFloatImpl(int32_t& value) override; + void ReadIntToDoubleImpl(int32_t& value) override; + void ReadUintToUlongImpl(uint32_t& value) override; + void ReadUintToFloatImpl(uint32_t& value) override; + void ReadUintToDoubleImpl(uint32_t& value) override; + void ReadFloatToDoubleImpl(float& value) override; + void ReadComplexFloatToComplexDoubleImpl(std::complex& value) override; + void ReadIntToStringImpl(int32_t& value) override; + void ReadUintToStringImpl(uint32_t& value) override; + void ReadLongToStringImpl(int64_t& value) override; + void ReadUlongToStringImpl(uint64_t& value) override; + void ReadFloatToStringImpl(float& value) override; + void ReadDoubleToStringImpl(double& value) override; + void ReadIntToOptionalImpl(int32_t& value) override; + void ReadFloatToOptionalImpl(float& value) override; + void ReadStringToOptionalImpl(std::string& value) override; + void ReadIntToUnionImpl(int32_t& value) override; + void ReadFloatToUnionImpl(float& value) override; + void ReadStringToUnionImpl(std::string& value) override; + void ReadOptionalIntToFloatImpl(std::optional& value) override; + void ReadOptionalFloatToStringImpl(std::optional& value) override; + void ReadAliasedLongToStringImpl(evo_test::AliasedLongToString& value) override; + void ReadStringToAliasedStringImpl(std::string& value) override; + void ReadStringToAliasedIntImpl(std::string& value) override; + void ReadEnumToAliasedEnumImpl(evo_test::GrowingEnum& value) override; + void ReadOptionalIntToUnionImpl(std::optional& value) override; + void ReadOptionalRecordToUnionImpl(std::optional& value) override; + void ReadRecordWithChangesImpl(evo_test::RecordWithChanges& value) override; + void ReadAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges& value) override; + void ReadRecordToRenamedRecordImpl(evo_test::RenamedRecord& value) override; + void ReadRecordToAliasedRecordImpl(evo_test::RecordWithChanges& value) override; + void ReadRecordToAliasedAliasImpl(evo_test::RecordWithChanges& value) override; + bool ReadStreamIntToStringToFloatImpl(int32_t& value) override; + bool ReadStreamIntToStringToFloatImpl(std::vector& values) override; + bool ReadStreamIntToStringToFloatImpl(int32_t& value, size_t idx) override; + bool ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) override; + size_t CountStreamIntToStringToFloatImpl() override; + void ReadVectorIntToStringToFloatImpl(std::vector& value) override; + void ReadIntFloatUnionReorderedImpl(std::variant& value) override; + void ReadVectorUnionReorderedImpl(std::vector>& value) override; + bool ReadStreamUnionReorderedImpl(std::variant& value) override; + bool ReadStreamUnionReorderedImpl(std::vector>& values) override; + bool ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) override; + bool ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) override; + size_t CountStreamUnionReorderedImpl() override; + bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value) override; + bool ReadStreamOfAliasTypeChangeImpl(std::vector& values) override; + bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) override; + bool ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) override; + size_t CountStreamOfAliasTypeChangeImpl() override; + void ReadRlinkImpl(evo_test::RLink& value) override; + void ReadRlinkRXImpl(evo_test::RLink& value) override; + void ReadRlinkRYImpl(evo_test::RLink& value) override; + void ReadRlinkRZImpl(evo_test::RLink& value) override; + void ReadRaRLinkImpl(evo_test::RA& value) override; + void ReadRaRXImpl(evo_test::RA& value) override; + void ReadRaRYImpl(evo_test::RA& value) override; + void ReadRaRZImpl(evo_test::RA& value) override; + void ReadRbRLinkImpl(evo_test::RB& value) override; + void ReadRbRXImpl(evo_test::RB& value) override; + void ReadRbRYImpl(evo_test::RB& value) override; + void ReadRbRZImpl(evo_test::RB& value) override; + void ReadRcRLinkImpl(evo_test::RC& value) override; + void ReadRcRXImpl(evo_test::RC& value) override; + void ReadRcRYImpl(evo_test::RC& value) override; + void ReadRcRZImpl(evo_test::RC& value) override; + void ReadRlinkRNewImpl(evo_test::RLink& value) override; + void ReadRaRNewImpl(evo_test::RA& value) override; + void ReadRbRNewImpl(evo_test::RB& value) override; + void ReadRcRNewImpl(evo_test::RC& value) override; + void ReadRlinkRUnionImpl(evo_test::RLink& value) override; + void ReadRaRUnionImpl(evo_test::RA& value) override; + void ReadRbRUnionImpl(evo_test::RB& value) override; + void ReadRcRUnionImpl(evo_test::RC& value) override; + void ReadOptionalRecordWithChangesImpl(std::optional& value) override; + void ReadAliasedOptionalRecordWithChangesImpl(std::optional& value) override; + void ReadUnionRecordWithChangesImpl(std::variant& value) override; + void ReadUnionWithSameTypesetImpl(std::variant& value) override; + void ReadUnionWithTypesAddedImpl(std::variant& value) override; + void ReadUnionWithTypesRemovedImpl(std::variant& value) override; + void ReadRecordToOptionalImpl(evo_test::RecordWithChanges& value) override; + void ReadRecordToAliasedOptionalImpl(evo_test::RecordWithChanges& value) override; + void ReadRecordToUnionImpl(evo_test::RecordWithChanges& value) override; + void ReadRecordToAliasedUnionImpl(evo_test::RecordWithChanges& value) override; + void ReadUnionToAliasedUnionImpl(std::variant& value) override; + void ReadUnionToAliasedUnionWithChangesImpl(std::variant& value) override; + void ReadOptionalToAliasedOptionalImpl(std::optional& value) override; + void ReadOptionalToAliasedOptionalWithChangesImpl(std::optional& value) override; + void ReadGenericRecordImpl(evo_test::GenericRecord& value) override; + void ReadGenericRecordToOpenAliasImpl(evo_test::GenericRecord& value) override; + void ReadGenericRecordToClosedAliasImpl(evo_test::GenericRecord& value) override; + void ReadGenericRecordToHalfClosedAliasImpl(evo_test::GenericRecord& value) override; + void ReadAliasedGenericRecordToAliasImpl(evo_test::AliasedHalfClosedGenericRecord& value) override; + void ReadGenericRecordToReversedImpl(evo_test::GenericRecord& value) override; + void ReadClosedGenericRecordToUnionImpl(evo_test::AliasedClosedGenericRecord& value) override; + void ReadGenericRecordToAliasedUnionImpl(evo_test::GenericRecord& value) override; + void ReadGenericUnionToReversedImpl(evo_test::AliasedClosedGenericUnion& value) override; + void ReadGenericUnionOfChangedRecordImpl(evo_test::AliasedClosedGenericUnion& value) override; + void ReadGenericParentRecordImpl(evo_test::GenericParentRecord& value) override; + void ReadGenericNestedRecordsImpl(evo_test::GenericRecord, evo_test::ChangedGeneric>& value) override; + bool ReadGenericRecordStreamImpl(evo_test::GenericRecord& value) override; + bool ReadGenericRecordStreamImpl(std::vector>& values) override; + bool ReadGenericRecordStreamImpl(evo_test::GenericRecord& value, size_t idx) override; + bool ReadGenericRecordStreamImpl(std::vector>& values, size_t idx) override; + size_t CountGenericRecordStreamImpl() override; + bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value) override; + bool ReadGenericParentRecordStreamImpl(std::vector>& values) override; + bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) override; + bool ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) override; + size_t CountGenericParentRecordStreamImpl() override; + void ReadVectorRecordWithChangesImpl(std::vector& value) override; + bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value) override; + bool ReadStreamedRecordWithChangesImpl(std::vector& values) override; + bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) override; + bool ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) override; + size_t CountStreamedRecordWithChangesImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the UnusedProtocol protocol. class UnusedProtocolWriter : public evo_test::UnusedProtocolWriterBase, yardl::binary::BinaryWriter { public: @@ -289,6 +564,26 @@ class UnusedProtocolWriter : public evo_test::UnusedProtocolWriterBase, yardl::b Version version_; }; +// Binary indexed writer for the UnusedProtocol protocol. +class UnusedProtocolIndexedWriter : public evo_test::UnusedProtocolWriterBase, yardl::binary::BinaryIndexedWriter { + public: + UnusedProtocolIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, evo_test::UnusedProtocolWriterBase::SchemaFromVersion(version)), version_(version) {} + + UnusedProtocolIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, evo_test::UnusedProtocolWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteRecordsImpl(evo_test::UnchangedRecord const& value) override; + void WriteRecordsImpl(std::vector const& values) override; + void EndRecordsImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the UnusedProtocol protocol. class UnusedProtocolReader : public evo_test::UnusedProtocolReaderBase, yardl::binary::BinaryReader { public: @@ -311,4 +606,29 @@ class UnusedProtocolReader : public evo_test::UnusedProtocolReaderBase, yardl::b size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the UnusedProtocol protocol. +class UnusedProtocolIndexedReader : public evo_test::UnusedProtocolIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + UnusedProtocolIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(evo_test::UnusedProtocolIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + UnusedProtocolIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(evo_test::UnusedProtocolIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadRecordsImpl(evo_test::UnchangedRecord& value) override; + bool ReadRecordsImpl(std::vector& values) override; + bool ReadRecordsImpl(evo_test::UnchangedRecord& value, size_t idx) override; + bool ReadRecordsImpl(std::vector& values, size_t idx) override; + size_t CountRecordsImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + } // namespace evo_test::binary diff --git a/cpp/evolution/v0/generated/protocols.cc b/cpp/evolution/v0/generated/protocols.cc index a90d65d..6b1f2b4 100644 --- a/cpp/evolution/v0/generated/protocols.cc +++ b/cpp/evolution/v0/generated/protocols.cc @@ -9,330 +9,6 @@ #endif namespace evo_test { -namespace { -void ProtocolWithChangesWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInt8ToInt()"; break; - case 1: expected_method = "WriteInt8ToLong()"; break; - case 2: expected_method = "WriteInt8ToUint()"; break; - case 3: expected_method = "WriteInt8ToUlong()"; break; - case 4: expected_method = "WriteInt8ToFloat()"; break; - case 5: expected_method = "WriteInt8ToDouble()"; break; - case 6: expected_method = "WriteIntToUint()"; break; - case 7: expected_method = "WriteIntToLong()"; break; - case 8: expected_method = "WriteIntToFloat()"; break; - case 9: expected_method = "WriteIntToDouble()"; break; - case 10: expected_method = "WriteUintToUlong()"; break; - case 11: expected_method = "WriteUintToFloat()"; break; - case 12: expected_method = "WriteUintToDouble()"; break; - case 13: expected_method = "WriteFloatToDouble()"; break; - case 14: expected_method = "WriteComplexFloatToComplexDouble()"; break; - case 15: expected_method = "WriteIntToString()"; break; - case 16: expected_method = "WriteUintToString()"; break; - case 17: expected_method = "WriteLongToString()"; break; - case 18: expected_method = "WriteUlongToString()"; break; - case 19: expected_method = "WriteFloatToString()"; break; - case 20: expected_method = "WriteDoubleToString()"; break; - case 21: expected_method = "WriteIntToOptional()"; break; - case 22: expected_method = "WriteFloatToOptional()"; break; - case 23: expected_method = "WriteStringToOptional()"; break; - case 24: expected_method = "WriteIntToUnion()"; break; - case 25: expected_method = "WriteFloatToUnion()"; break; - case 26: expected_method = "WriteStringToUnion()"; break; - case 27: expected_method = "WriteOptionalIntToFloat()"; break; - case 28: expected_method = "WriteOptionalFloatToString()"; break; - case 29: expected_method = "WriteAliasedLongToString()"; break; - case 30: expected_method = "WriteStringToAliasedString()"; break; - case 31: expected_method = "WriteStringToAliasedInt()"; break; - case 32: expected_method = "WriteEnumToAliasedEnum()"; break; - case 33: expected_method = "WriteOptionalIntToUnion()"; break; - case 34: expected_method = "WriteOptionalRecordToUnion()"; break; - case 35: expected_method = "WriteRecordWithChanges()"; break; - case 36: expected_method = "WriteAliasedRecordWithChanges()"; break; - case 37: expected_method = "WriteRecordToRenamedRecord()"; break; - case 38: expected_method = "WriteRecordToAliasedRecord()"; break; - case 39: expected_method = "WriteRecordToAliasedAlias()"; break; - case 40: expected_method = "WriteStreamIntToStringToFloat() or EndStreamIntToStringToFloat()"; break; - case 41: expected_method = "WriteVectorIntToStringToFloat()"; break; - case 42: expected_method = "WriteIntFloatUnionReordered()"; break; - case 43: expected_method = "WriteVectorUnionReordered()"; break; - case 44: expected_method = "WriteStreamUnionReordered() or EndStreamUnionReordered()"; break; - case 45: expected_method = "WriteStreamOfAliasTypeChange() or EndStreamOfAliasTypeChange()"; break; - case 46: expected_method = "WriteRlink()"; break; - case 47: expected_method = "WriteRlinkRX()"; break; - case 48: expected_method = "WriteRlinkRY()"; break; - case 49: expected_method = "WriteRlinkRZ()"; break; - case 50: expected_method = "WriteRaRLink()"; break; - case 51: expected_method = "WriteRaRX()"; break; - case 52: expected_method = "WriteRaRY()"; break; - case 53: expected_method = "WriteRaRZ()"; break; - case 54: expected_method = "WriteRbRLink()"; break; - case 55: expected_method = "WriteRbRX()"; break; - case 56: expected_method = "WriteRbRY()"; break; - case 57: expected_method = "WriteRbRZ()"; break; - case 58: expected_method = "WriteRcRLink()"; break; - case 59: expected_method = "WriteRcRX()"; break; - case 60: expected_method = "WriteRcRY()"; break; - case 61: expected_method = "WriteRcRZ()"; break; - case 62: expected_method = "WriteRlinkRNew()"; break; - case 63: expected_method = "WriteRaRNew()"; break; - case 64: expected_method = "WriteRbRNew()"; break; - case 65: expected_method = "WriteRcRNew()"; break; - case 66: expected_method = "WriteRlinkRUnion()"; break; - case 67: expected_method = "WriteRaRUnion()"; break; - case 68: expected_method = "WriteRbRUnion()"; break; - case 69: expected_method = "WriteRcRUnion()"; break; - case 70: expected_method = "WriteOptionalRecordWithChanges()"; break; - case 71: expected_method = "WriteAliasedOptionalRecordWithChanges()"; break; - case 72: expected_method = "WriteUnionRecordWithChanges()"; break; - case 73: expected_method = "WriteUnionWithSameTypeset()"; break; - case 74: expected_method = "WriteUnionWithTypesAdded()"; break; - case 75: expected_method = "WriteUnionWithTypesRemoved()"; break; - case 76: expected_method = "WriteRecordToOptional()"; break; - case 77: expected_method = "WriteRecordToAliasedOptional()"; break; - case 78: expected_method = "WriteRecordToUnion()"; break; - case 79: expected_method = "WriteRecordToAliasedUnion()"; break; - case 80: expected_method = "WriteUnionToAliasedUnion()"; break; - case 81: expected_method = "WriteUnionToAliasedUnionWithChanges()"; break; - case 82: expected_method = "WriteOptionalToAliasedOptional()"; break; - case 83: expected_method = "WriteOptionalToAliasedOptionalWithChanges()"; break; - case 84: expected_method = "WriteGenericRecord()"; break; - case 85: expected_method = "WriteGenericRecordToOpenAlias()"; break; - case 86: expected_method = "WriteGenericRecordToClosedAlias()"; break; - case 87: expected_method = "WriteGenericRecordToHalfClosedAlias()"; break; - case 88: expected_method = "WriteAliasedGenericRecordToAlias()"; break; - case 89: expected_method = "WriteGenericRecordToReversed()"; break; - case 90: expected_method = "WriteClosedGenericRecordToUnion()"; break; - case 91: expected_method = "WriteGenericRecordToAliasedUnion()"; break; - case 92: expected_method = "WriteGenericUnionToReversed()"; break; - case 93: expected_method = "WriteGenericUnionOfChangedRecord()"; break; - case 94: expected_method = "WriteGenericParentRecord()"; break; - case 95: expected_method = "WriteGenericNestedRecords()"; break; - case 96: expected_method = "WriteGenericRecordStream() or EndGenericRecordStream()"; break; - case 97: expected_method = "WriteGenericParentRecordStream() or EndGenericParentRecordStream()"; break; - case 98: expected_method = "WriteVectorRecordWithChanges()"; break; - case 99: expected_method = "WriteStreamedRecordWithChanges() or EndStreamedRecordWithChanges()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteInt8ToInt()"; break; - case 1: attempted_method = "WriteInt8ToLong()"; break; - case 2: attempted_method = "WriteInt8ToUint()"; break; - case 3: attempted_method = "WriteInt8ToUlong()"; break; - case 4: attempted_method = "WriteInt8ToFloat()"; break; - case 5: attempted_method = "WriteInt8ToDouble()"; break; - case 6: attempted_method = "WriteIntToUint()"; break; - case 7: attempted_method = "WriteIntToLong()"; break; - case 8: attempted_method = "WriteIntToFloat()"; break; - case 9: attempted_method = "WriteIntToDouble()"; break; - case 10: attempted_method = "WriteUintToUlong()"; break; - case 11: attempted_method = "WriteUintToFloat()"; break; - case 12: attempted_method = "WriteUintToDouble()"; break; - case 13: attempted_method = "WriteFloatToDouble()"; break; - case 14: attempted_method = "WriteComplexFloatToComplexDouble()"; break; - case 15: attempted_method = "WriteIntToString()"; break; - case 16: attempted_method = "WriteUintToString()"; break; - case 17: attempted_method = "WriteLongToString()"; break; - case 18: attempted_method = "WriteUlongToString()"; break; - case 19: attempted_method = "WriteFloatToString()"; break; - case 20: attempted_method = "WriteDoubleToString()"; break; - case 21: attempted_method = "WriteIntToOptional()"; break; - case 22: attempted_method = "WriteFloatToOptional()"; break; - case 23: attempted_method = "WriteStringToOptional()"; break; - case 24: attempted_method = "WriteIntToUnion()"; break; - case 25: attempted_method = "WriteFloatToUnion()"; break; - case 26: attempted_method = "WriteStringToUnion()"; break; - case 27: attempted_method = "WriteOptionalIntToFloat()"; break; - case 28: attempted_method = "WriteOptionalFloatToString()"; break; - case 29: attempted_method = "WriteAliasedLongToString()"; break; - case 30: attempted_method = "WriteStringToAliasedString()"; break; - case 31: attempted_method = "WriteStringToAliasedInt()"; break; - case 32: attempted_method = "WriteEnumToAliasedEnum()"; break; - case 33: attempted_method = "WriteOptionalIntToUnion()"; break; - case 34: attempted_method = "WriteOptionalRecordToUnion()"; break; - case 35: attempted_method = "WriteRecordWithChanges()"; break; - case 36: attempted_method = "WriteAliasedRecordWithChanges()"; break; - case 37: attempted_method = "WriteRecordToRenamedRecord()"; break; - case 38: attempted_method = "WriteRecordToAliasedRecord()"; break; - case 39: attempted_method = "WriteRecordToAliasedAlias()"; break; - case 40: attempted_method = end ? "EndStreamIntToStringToFloat()" : "WriteStreamIntToStringToFloat()"; break; - case 41: attempted_method = "WriteVectorIntToStringToFloat()"; break; - case 42: attempted_method = "WriteIntFloatUnionReordered()"; break; - case 43: attempted_method = "WriteVectorUnionReordered()"; break; - case 44: attempted_method = end ? "EndStreamUnionReordered()" : "WriteStreamUnionReordered()"; break; - case 45: attempted_method = end ? "EndStreamOfAliasTypeChange()" : "WriteStreamOfAliasTypeChange()"; break; - case 46: attempted_method = "WriteRlink()"; break; - case 47: attempted_method = "WriteRlinkRX()"; break; - case 48: attempted_method = "WriteRlinkRY()"; break; - case 49: attempted_method = "WriteRlinkRZ()"; break; - case 50: attempted_method = "WriteRaRLink()"; break; - case 51: attempted_method = "WriteRaRX()"; break; - case 52: attempted_method = "WriteRaRY()"; break; - case 53: attempted_method = "WriteRaRZ()"; break; - case 54: attempted_method = "WriteRbRLink()"; break; - case 55: attempted_method = "WriteRbRX()"; break; - case 56: attempted_method = "WriteRbRY()"; break; - case 57: attempted_method = "WriteRbRZ()"; break; - case 58: attempted_method = "WriteRcRLink()"; break; - case 59: attempted_method = "WriteRcRX()"; break; - case 60: attempted_method = "WriteRcRY()"; break; - case 61: attempted_method = "WriteRcRZ()"; break; - case 62: attempted_method = "WriteRlinkRNew()"; break; - case 63: attempted_method = "WriteRaRNew()"; break; - case 64: attempted_method = "WriteRbRNew()"; break; - case 65: attempted_method = "WriteRcRNew()"; break; - case 66: attempted_method = "WriteRlinkRUnion()"; break; - case 67: attempted_method = "WriteRaRUnion()"; break; - case 68: attempted_method = "WriteRbRUnion()"; break; - case 69: attempted_method = "WriteRcRUnion()"; break; - case 70: attempted_method = "WriteOptionalRecordWithChanges()"; break; - case 71: attempted_method = "WriteAliasedOptionalRecordWithChanges()"; break; - case 72: attempted_method = "WriteUnionRecordWithChanges()"; break; - case 73: attempted_method = "WriteUnionWithSameTypeset()"; break; - case 74: attempted_method = "WriteUnionWithTypesAdded()"; break; - case 75: attempted_method = "WriteUnionWithTypesRemoved()"; break; - case 76: attempted_method = "WriteRecordToOptional()"; break; - case 77: attempted_method = "WriteRecordToAliasedOptional()"; break; - case 78: attempted_method = "WriteRecordToUnion()"; break; - case 79: attempted_method = "WriteRecordToAliasedUnion()"; break; - case 80: attempted_method = "WriteUnionToAliasedUnion()"; break; - case 81: attempted_method = "WriteUnionToAliasedUnionWithChanges()"; break; - case 82: attempted_method = "WriteOptionalToAliasedOptional()"; break; - case 83: attempted_method = "WriteOptionalToAliasedOptionalWithChanges()"; break; - case 84: attempted_method = "WriteGenericRecord()"; break; - case 85: attempted_method = "WriteGenericRecordToOpenAlias()"; break; - case 86: attempted_method = "WriteGenericRecordToClosedAlias()"; break; - case 87: attempted_method = "WriteGenericRecordToHalfClosedAlias()"; break; - case 88: attempted_method = "WriteAliasedGenericRecordToAlias()"; break; - case 89: attempted_method = "WriteGenericRecordToReversed()"; break; - case 90: attempted_method = "WriteClosedGenericRecordToUnion()"; break; - case 91: attempted_method = "WriteGenericRecordToAliasedUnion()"; break; - case 92: attempted_method = "WriteGenericUnionToReversed()"; break; - case 93: attempted_method = "WriteGenericUnionOfChangedRecord()"; break; - case 94: attempted_method = "WriteGenericParentRecord()"; break; - case 95: attempted_method = "WriteGenericNestedRecords()"; break; - case 96: attempted_method = end ? "EndGenericRecordStream()" : "WriteGenericRecordStream()"; break; - case 97: attempted_method = end ? "EndGenericParentRecordStream()" : "WriteGenericParentRecordStream()"; break; - case 98: attempted_method = "WriteVectorRecordWithChanges()"; break; - case 99: attempted_method = end ? "EndStreamedRecordWithChanges()" : "WriteStreamedRecordWithChanges()"; break; - case 100: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ProtocolWithChangesReaderBaseInvalidState(uint8_t attempted, uint8_t current) { - auto f = [](uint8_t i) -> std::string { - switch (i/2) { - case 0: return "ReadInt8ToInt()"; - case 1: return "ReadInt8ToLong()"; - case 2: return "ReadInt8ToUint()"; - case 3: return "ReadInt8ToUlong()"; - case 4: return "ReadInt8ToFloat()"; - case 5: return "ReadInt8ToDouble()"; - case 6: return "ReadIntToUint()"; - case 7: return "ReadIntToLong()"; - case 8: return "ReadIntToFloat()"; - case 9: return "ReadIntToDouble()"; - case 10: return "ReadUintToUlong()"; - case 11: return "ReadUintToFloat()"; - case 12: return "ReadUintToDouble()"; - case 13: return "ReadFloatToDouble()"; - case 14: return "ReadComplexFloatToComplexDouble()"; - case 15: return "ReadIntToString()"; - case 16: return "ReadUintToString()"; - case 17: return "ReadLongToString()"; - case 18: return "ReadUlongToString()"; - case 19: return "ReadFloatToString()"; - case 20: return "ReadDoubleToString()"; - case 21: return "ReadIntToOptional()"; - case 22: return "ReadFloatToOptional()"; - case 23: return "ReadStringToOptional()"; - case 24: return "ReadIntToUnion()"; - case 25: return "ReadFloatToUnion()"; - case 26: return "ReadStringToUnion()"; - case 27: return "ReadOptionalIntToFloat()"; - case 28: return "ReadOptionalFloatToString()"; - case 29: return "ReadAliasedLongToString()"; - case 30: return "ReadStringToAliasedString()"; - case 31: return "ReadStringToAliasedInt()"; - case 32: return "ReadEnumToAliasedEnum()"; - case 33: return "ReadOptionalIntToUnion()"; - case 34: return "ReadOptionalRecordToUnion()"; - case 35: return "ReadRecordWithChanges()"; - case 36: return "ReadAliasedRecordWithChanges()"; - case 37: return "ReadRecordToRenamedRecord()"; - case 38: return "ReadRecordToAliasedRecord()"; - case 39: return "ReadRecordToAliasedAlias()"; - case 40: return "ReadStreamIntToStringToFloat()"; - case 41: return "ReadVectorIntToStringToFloat()"; - case 42: return "ReadIntFloatUnionReordered()"; - case 43: return "ReadVectorUnionReordered()"; - case 44: return "ReadStreamUnionReordered()"; - case 45: return "ReadStreamOfAliasTypeChange()"; - case 46: return "ReadRlink()"; - case 47: return "ReadRlinkRX()"; - case 48: return "ReadRlinkRY()"; - case 49: return "ReadRlinkRZ()"; - case 50: return "ReadRaRLink()"; - case 51: return "ReadRaRX()"; - case 52: return "ReadRaRY()"; - case 53: return "ReadRaRZ()"; - case 54: return "ReadRbRLink()"; - case 55: return "ReadRbRX()"; - case 56: return "ReadRbRY()"; - case 57: return "ReadRbRZ()"; - case 58: return "ReadRcRLink()"; - case 59: return "ReadRcRX()"; - case 60: return "ReadRcRY()"; - case 61: return "ReadRcRZ()"; - case 62: return "ReadRlinkRNew()"; - case 63: return "ReadRaRNew()"; - case 64: return "ReadRbRNew()"; - case 65: return "ReadRcRNew()"; - case 66: return "ReadRlinkRUnion()"; - case 67: return "ReadRaRUnion()"; - case 68: return "ReadRbRUnion()"; - case 69: return "ReadRcRUnion()"; - case 70: return "ReadOptionalRecordWithChanges()"; - case 71: return "ReadAliasedOptionalRecordWithChanges()"; - case 72: return "ReadUnionRecordWithChanges()"; - case 73: return "ReadUnionWithSameTypeset()"; - case 74: return "ReadUnionWithTypesAdded()"; - case 75: return "ReadUnionWithTypesRemoved()"; - case 76: return "ReadRecordToOptional()"; - case 77: return "ReadRecordToAliasedOptional()"; - case 78: return "ReadRecordToUnion()"; - case 79: return "ReadRecordToAliasedUnion()"; - case 80: return "ReadUnionToAliasedUnion()"; - case 81: return "ReadUnionToAliasedUnionWithChanges()"; - case 82: return "ReadOptionalToAliasedOptional()"; - case 83: return "ReadOptionalToAliasedOptionalWithChanges()"; - case 84: return "ReadGenericRecord()"; - case 85: return "ReadGenericRecordToOpenAlias()"; - case 86: return "ReadGenericRecordToClosedAlias()"; - case 87: return "ReadGenericRecordToHalfClosedAlias()"; - case 88: return "ReadAliasedGenericRecordToAlias()"; - case 89: return "ReadGenericRecordToReversed()"; - case 90: return "ReadClosedGenericRecordToUnion()"; - case 91: return "ReadGenericRecordToAliasedUnion()"; - case 92: return "ReadGenericUnionToReversed()"; - case 93: return "ReadGenericUnionOfChangedRecord()"; - case 94: return "ReadGenericParentRecord()"; - case 95: return "ReadGenericNestedRecords()"; - case 96: return "ReadGenericRecordStream()"; - case 97: return "ReadGenericParentRecordStream()"; - case 98: return "ReadVectorRecordWithChanges()"; - case 99: return "ReadStreamedRecordWithChanges()"; - case 100: return "Close()"; - default: return ""; - } - }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); -} - -} // namespace - std::string ProtocolWithChangesWriterBase::schema_ = R"({"protocol":{"name":"ProtocolWithChanges","sequence":[{"name":"int8ToInt","type":"int8"},{"name":"int8ToLong","type":"int8"},{"name":"int8ToUint","type":"int8"},{"name":"int8ToUlong","type":"int8"},{"name":"int8ToFloat","type":"int8"},{"name":"int8ToDouble","type":"int8"},{"name":"intToUint","type":"int32"},{"name":"intToLong","type":"int32"},{"name":"intToFloat","type":"int32"},{"name":"intToDouble","type":"int32"},{"name":"uintToUlong","type":"uint32"},{"name":"uintToFloat","type":"uint32"},{"name":"uintToDouble","type":"uint32"},{"name":"floatToDouble","type":"float32"},{"name":"complexFloatToComplexDouble","type":"complexfloat32"},{"name":"intToString","type":"int32"},{"name":"uintToString","type":"uint32"},{"name":"longToString","type":"int64"},{"name":"ulongToString","type":"uint64"},{"name":"floatToString","type":"float32"},{"name":"doubleToString","type":"float64"},{"name":"intToOptional","type":"int32"},{"name":"floatToOptional","type":"float32"},{"name":"stringToOptional","type":"string"},{"name":"intToUnion","type":"int32"},{"name":"floatToUnion","type":"float32"},{"name":"stringToUnion","type":"string"},{"name":"optionalIntToFloat","type":[null,"int32"]},{"name":"optionalFloatToString","type":[null,"float32"]},{"name":"aliasedLongToString","type":"EvoTest.AliasedLongToString"},{"name":"stringToAliasedString","type":"string"},{"name":"stringToAliasedInt","type":"string"},{"name":"enumToAliasedEnum","type":"EvoTest.GrowingEnum"},{"name":"optionalIntToUnion","type":[null,"int32"]},{"name":"optionalRecordToUnion","type":[null,"EvoTest.RecordWithChanges"]},{"name":"recordWithChanges","type":"EvoTest.RecordWithChanges"},{"name":"aliasedRecordWithChanges","type":"EvoTest.AliasedRecordWithChanges"},{"name":"recordToRenamedRecord","type":"EvoTest.RenamedRecord"},{"name":"recordToAliasedRecord","type":"EvoTest.RecordWithChanges"},{"name":"recordToAliasedAlias","type":"EvoTest.RecordWithChanges"},{"name":"streamIntToStringToFloat","type":{"stream":{"items":"int32"}}},{"name":"vectorIntToStringToFloat","type":{"vector":{"items":"int32"}}},{"name":"intFloatUnionReordered","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"vectorUnionReordered","type":{"vector":{"items":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]}}},{"name":"streamUnionReordered","type":{"stream":{"items":[{"tag":"int32","type":"int32"},{"tag":"string","type":"string"}]}}},{"name":"streamOfAliasTypeChange","type":{"stream":{"items":"EvoTest.StreamItem"}}},{"name":"rlink","type":"EvoTest.RLink"},{"name":"rlinkRX","type":"EvoTest.RLink"},{"name":"rlinkRY","type":"EvoTest.RLink"},{"name":"rlinkRZ","type":"EvoTest.RLink"},{"name":"raRLink","type":"EvoTest.RA"},{"name":"raRX","type":"EvoTest.RA"},{"name":"raRY","type":"EvoTest.RA"},{"name":"raRZ","type":"EvoTest.RA"},{"name":"rbRLink","type":"EvoTest.RB"},{"name":"rbRX","type":"EvoTest.RB"},{"name":"rbRY","type":"EvoTest.RB"},{"name":"rbRZ","type":"EvoTest.RB"},{"name":"rcRLink","type":"EvoTest.RC"},{"name":"rcRX","type":"EvoTest.RC"},{"name":"rcRY","type":"EvoTest.RC"},{"name":"rcRZ","type":"EvoTest.RC"},{"name":"rlinkRNew","type":"EvoTest.RLink"},{"name":"raRNew","type":"EvoTest.RA"},{"name":"rbRNew","type":"EvoTest.RB"},{"name":"rcRNew","type":"EvoTest.RC"},{"name":"rlinkRUnion","type":"EvoTest.RLink"},{"name":"raRUnion","type":"EvoTest.RA"},{"name":"rbRUnion","type":"EvoTest.RB"},{"name":"rcRUnion","type":"EvoTest.RC"},{"name":"optionalRecordWithChanges","type":[null,"EvoTest.RecordWithChanges"]},{"name":"aliasedOptionalRecordWithChanges","type":[null,"EvoTest.AliasedRecordWithChanges"]},{"name":"unionRecordWithChanges","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"}]},{"name":"unionWithSameTypeset","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"},{"tag":"string","type":"string"}]},{"name":"unionWithTypesAdded","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"float32","type":"float32"}]},{"name":"unionWithTypesRemoved","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"},{"tag":"string","type":"string"}]},{"name":"recordToOptional","type":"EvoTest.RecordWithChanges"},{"name":"recordToAliasedOptional","type":"EvoTest.RecordWithChanges"},{"name":"recordToUnion","type":"EvoTest.RecordWithChanges"},{"name":"recordToAliasedUnion","type":"EvoTest.RecordWithChanges"},{"name":"unionToAliasedUnion","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"}]},{"name":"unionToAliasedUnionWithChanges","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"}]},{"name":"optionalToAliasedOptional","type":[null,"EvoTest.RecordWithChanges"]},{"name":"optionalToAliasedOptionalWithChanges","type":[null,"int32"]},{"name":"genericRecord","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToOpenAlias","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToClosedAlias","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToHalfClosedAlias","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"aliasedGenericRecordToAlias","type":{"name":"EvoTest.AliasedHalfClosedGenericRecord","typeArguments":["int32"]}},{"name":"genericRecordToReversed","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"closedGenericRecordToUnion","type":"EvoTest.AliasedClosedGenericRecord"},{"name":"genericRecordToAliasedUnion","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericUnionToReversed","type":"EvoTest.AliasedClosedGenericUnion"},{"name":"genericUnionOfChangedRecord","type":"EvoTest.AliasedClosedGenericUnion"},{"name":"genericParentRecord","type":{"name":"EvoTest.GenericParentRecord","typeArguments":["int32"]}},{"name":"genericNestedRecords","type":{"name":"EvoTest.GenericRecord","typeArguments":[{"name":"EvoTest.UnchangedGeneric","typeArguments":["int32"]},{"name":"EvoTest.ChangedGeneric","typeArguments":["string","int32"]}]}},{"name":"genericRecordStream","type":{"stream":{"items":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}}}},{"name":"genericParentRecordStream","type":{"stream":{"items":{"name":"EvoTest.GenericParentRecord","typeArguments":["int32"]}}}},{"name":"vectorRecordWithChanges","type":{"vector":{"items":"EvoTest.RecordWithChanges"}}},{"name":"streamedRecordWithChanges","type":{"stream":{"items":"EvoTest.RecordWithChanges"}}}]},"types":[{"name":"AliasedClosedGenericRecord","type":{"name":"EvoTest.AliasedHalfClosedGenericRecord","typeArguments":["int32"]}},{"name":"AliasedClosedGenericUnion","type":{"name":"EvoTest.AliasedHalfClosedGenericUnion","typeArguments":[{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}]}},{"name":"AliasedHalfClosedGenericRecord","typeParameters":["T"],"type":{"name":"EvoTest.GenericRecord","typeArguments":["T","string"]}},{"name":"AliasedHalfClosedGenericUnion","typeParameters":["T"],"type":{"name":"EvoTest.GenericUnion","typeArguments":["T","float32"]}},{"name":"AliasedLongToString","type":"int64"},{"name":"AliasedRecordWithChanges","type":"EvoTest.RecordWithChanges"},{"name":"ChangedGeneric","typeParameters":["Y","Z"],"fields":[{"name":"y","type":"Y"},{"name":"z","type":{"name":"EvoTest.UnchangedGeneric","typeArguments":["Z"]}}]},{"name":"GenericParentRecord","typeParameters":["T"],"fields":[{"name":"record","type":{"name":"EvoTest.GenericRecord","typeArguments":["T","string"]}},{"name":"recordOfUnion","type":{"name":"EvoTest.GenericRecord","typeArguments":[{"name":"EvoTest.GenericUnion","typeArguments":["T","float32"]},"string"]}},{"name":"unionOfRecord","type":{"name":"EvoTest.GenericUnion","typeArguments":[{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]},"float32"]}}]},{"name":"GenericRecord","typeParameters":["T1","T2"],"fields":[{"name":"removed","type":[null,"bool"]},{"name":"field1","type":"T1"},{"name":"field2","type":"T2"}]},{"name":"GenericUnion","typeParameters":["T1","T2"],"type":[{"tag":"T1","type":"T1"},{"tag":"T2","type":"T2"}]},{"name":"GrowingEnum","base":"uint16","values":[{"symbol":"a","value":0},{"symbol":"b","value":1},{"symbol":"c","value":2}]},{"name":"RA","type":"EvoTest.RB"},{"name":"RB","type":"EvoTest.RC"},{"name":"RC","fields":[{"name":"subject","type":"string"}]},{"name":"RLink","type":"EvoTest.RA"},{"name":"RecordWithChanges","fields":[{"name":"deprecatedFloat","type":"float32"},{"name":"intToLong","type":"int32"},{"name":"deprecatedVector","type":{"vector":{"items":"int32"}}},{"name":"floatToDouble","type":"float32"},{"name":"deprecatedArray","type":{"array":{"items":"uint8","dimensions":[{"length":7}]}}},{"name":"optionalLongToString","type":[null,"int64"]},{"name":"deprecatedMap","type":{"map":{"keys":"string","values":{"vector":{"items":"int32"}}}}},{"name":"unchangedRecord","type":"EvoTest.UnchangedRecord"}]},{"name":"RenamedRecord","fields":[{"name":"i","type":"int32"},{"name":"s","type":"string"}]},{"name":"StreamItem","type":"EvoTest.RecordWithChanges"},{"name":"UnchangedGeneric","typeParameters":["T2"],"fields":[{"name":"field","type":"T2"}]},{"name":"UnchangedRecord","fields":[{"name":"name","type":"string"},{"name":"age","type":"int32"},{"name":"meta","type":{"map":{"keys":"string","values":"float64"}}}]}]})"; std::vector ProtocolWithChangesWriterBase::previous_schemas_ = { @@ -345,9 +21,10 @@ std::string ProtocolWithChangesWriterBase::SchemaFromVersion(Version version) { } } + void ProtocolWithChangesWriterBase::WriteInt8ToInt(int8_t const& value) { if (unlikely(state_ != 0)) { - ProtocolWithChangesWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteInt8ToIntImpl(value); @@ -356,7 +33,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToInt(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToLong(int8_t const& value) { if (unlikely(state_ != 1)) { - ProtocolWithChangesWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteInt8ToLongImpl(value); @@ -365,7 +42,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToLong(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToUint(int8_t const& value) { if (unlikely(state_ != 2)) { - ProtocolWithChangesWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteInt8ToUintImpl(value); @@ -374,7 +51,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToUint(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToUlong(int8_t const& value) { if (unlikely(state_ != 3)) { - ProtocolWithChangesWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteInt8ToUlongImpl(value); @@ -383,7 +60,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToUlong(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToFloat(int8_t const& value) { if (unlikely(state_ != 4)) { - ProtocolWithChangesWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } WriteInt8ToFloatImpl(value); @@ -392,7 +69,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToFloat(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToDouble(int8_t const& value) { if (unlikely(state_ != 5)) { - ProtocolWithChangesWriterBaseInvalidState(5, false, state_); + InvalidState(5, false); } WriteInt8ToDoubleImpl(value); @@ -401,7 +78,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToDouble(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToUint(int32_t const& value) { if (unlikely(state_ != 6)) { - ProtocolWithChangesWriterBaseInvalidState(6, false, state_); + InvalidState(6, false); } WriteIntToUintImpl(value); @@ -410,7 +87,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUint(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToLong(int32_t const& value) { if (unlikely(state_ != 7)) { - ProtocolWithChangesWriterBaseInvalidState(7, false, state_); + InvalidState(7, false); } WriteIntToLongImpl(value); @@ -419,7 +96,7 @@ void ProtocolWithChangesWriterBase::WriteIntToLong(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToFloat(int32_t const& value) { if (unlikely(state_ != 8)) { - ProtocolWithChangesWriterBaseInvalidState(8, false, state_); + InvalidState(8, false); } WriteIntToFloatImpl(value); @@ -428,7 +105,7 @@ void ProtocolWithChangesWriterBase::WriteIntToFloat(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToDouble(int32_t const& value) { if (unlikely(state_ != 9)) { - ProtocolWithChangesWriterBaseInvalidState(9, false, state_); + InvalidState(9, false); } WriteIntToDoubleImpl(value); @@ -437,7 +114,7 @@ void ProtocolWithChangesWriterBase::WriteIntToDouble(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToUlong(uint32_t const& value) { if (unlikely(state_ != 10)) { - ProtocolWithChangesWriterBaseInvalidState(10, false, state_); + InvalidState(10, false); } WriteUintToUlongImpl(value); @@ -446,7 +123,7 @@ void ProtocolWithChangesWriterBase::WriteUintToUlong(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToFloat(uint32_t const& value) { if (unlikely(state_ != 11)) { - ProtocolWithChangesWriterBaseInvalidState(11, false, state_); + InvalidState(11, false); } WriteUintToFloatImpl(value); @@ -455,7 +132,7 @@ void ProtocolWithChangesWriterBase::WriteUintToFloat(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToDouble(uint32_t const& value) { if (unlikely(state_ != 12)) { - ProtocolWithChangesWriterBaseInvalidState(12, false, state_); + InvalidState(12, false); } WriteUintToDoubleImpl(value); @@ -464,7 +141,7 @@ void ProtocolWithChangesWriterBase::WriteUintToDouble(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteFloatToDouble(float const& value) { if (unlikely(state_ != 13)) { - ProtocolWithChangesWriterBaseInvalidState(13, false, state_); + InvalidState(13, false); } WriteFloatToDoubleImpl(value); @@ -473,7 +150,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToDouble(float const& value) { void ProtocolWithChangesWriterBase::WriteComplexFloatToComplexDouble(std::complex const& value) { if (unlikely(state_ != 14)) { - ProtocolWithChangesWriterBaseInvalidState(14, false, state_); + InvalidState(14, false); } WriteComplexFloatToComplexDoubleImpl(value); @@ -482,7 +159,7 @@ void ProtocolWithChangesWriterBase::WriteComplexFloatToComplexDouble(std::comple void ProtocolWithChangesWriterBase::WriteIntToString(int32_t const& value) { if (unlikely(state_ != 15)) { - ProtocolWithChangesWriterBaseInvalidState(15, false, state_); + InvalidState(15, false); } WriteIntToStringImpl(value); @@ -491,7 +168,7 @@ void ProtocolWithChangesWriterBase::WriteIntToString(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToString(uint32_t const& value) { if (unlikely(state_ != 16)) { - ProtocolWithChangesWriterBaseInvalidState(16, false, state_); + InvalidState(16, false); } WriteUintToStringImpl(value); @@ -500,7 +177,7 @@ void ProtocolWithChangesWriterBase::WriteUintToString(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteLongToString(int64_t const& value) { if (unlikely(state_ != 17)) { - ProtocolWithChangesWriterBaseInvalidState(17, false, state_); + InvalidState(17, false); } WriteLongToStringImpl(value); @@ -509,7 +186,7 @@ void ProtocolWithChangesWriterBase::WriteLongToString(int64_t const& value) { void ProtocolWithChangesWriterBase::WriteUlongToString(uint64_t const& value) { if (unlikely(state_ != 18)) { - ProtocolWithChangesWriterBaseInvalidState(18, false, state_); + InvalidState(18, false); } WriteUlongToStringImpl(value); @@ -518,7 +195,7 @@ void ProtocolWithChangesWriterBase::WriteUlongToString(uint64_t const& value) { void ProtocolWithChangesWriterBase::WriteFloatToString(float const& value) { if (unlikely(state_ != 19)) { - ProtocolWithChangesWriterBaseInvalidState(19, false, state_); + InvalidState(19, false); } WriteFloatToStringImpl(value); @@ -527,7 +204,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToString(float const& value) { void ProtocolWithChangesWriterBase::WriteDoubleToString(double const& value) { if (unlikely(state_ != 20)) { - ProtocolWithChangesWriterBaseInvalidState(20, false, state_); + InvalidState(20, false); } WriteDoubleToStringImpl(value); @@ -536,7 +213,7 @@ void ProtocolWithChangesWriterBase::WriteDoubleToString(double const& value) { void ProtocolWithChangesWriterBase::WriteIntToOptional(int32_t const& value) { if (unlikely(state_ != 21)) { - ProtocolWithChangesWriterBaseInvalidState(21, false, state_); + InvalidState(21, false); } WriteIntToOptionalImpl(value); @@ -545,7 +222,7 @@ void ProtocolWithChangesWriterBase::WriteIntToOptional(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteFloatToOptional(float const& value) { if (unlikely(state_ != 22)) { - ProtocolWithChangesWriterBaseInvalidState(22, false, state_); + InvalidState(22, false); } WriteFloatToOptionalImpl(value); @@ -554,7 +231,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToOptional(float const& value) { void ProtocolWithChangesWriterBase::WriteStringToOptional(std::string const& value) { if (unlikely(state_ != 23)) { - ProtocolWithChangesWriterBaseInvalidState(23, false, state_); + InvalidState(23, false); } WriteStringToOptionalImpl(value); @@ -563,7 +240,7 @@ void ProtocolWithChangesWriterBase::WriteStringToOptional(std::string const& val void ProtocolWithChangesWriterBase::WriteIntToUnion(int32_t const& value) { if (unlikely(state_ != 24)) { - ProtocolWithChangesWriterBaseInvalidState(24, false, state_); + InvalidState(24, false); } WriteIntToUnionImpl(value); @@ -572,7 +249,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUnion(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteFloatToUnion(float const& value) { if (unlikely(state_ != 25)) { - ProtocolWithChangesWriterBaseInvalidState(25, false, state_); + InvalidState(25, false); } WriteFloatToUnionImpl(value); @@ -581,7 +258,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToUnion(float const& value) { void ProtocolWithChangesWriterBase::WriteStringToUnion(std::string const& value) { if (unlikely(state_ != 26)) { - ProtocolWithChangesWriterBaseInvalidState(26, false, state_); + InvalidState(26, false); } WriteStringToUnionImpl(value); @@ -590,7 +267,7 @@ void ProtocolWithChangesWriterBase::WriteStringToUnion(std::string const& value) void ProtocolWithChangesWriterBase::WriteOptionalIntToFloat(std::optional const& value) { if (unlikely(state_ != 27)) { - ProtocolWithChangesWriterBaseInvalidState(27, false, state_); + InvalidState(27, false); } WriteOptionalIntToFloatImpl(value); @@ -599,7 +276,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalIntToFloat(std::optional const& value) { if (unlikely(state_ != 28)) { - ProtocolWithChangesWriterBaseInvalidState(28, false, state_); + InvalidState(28, false); } WriteOptionalFloatToStringImpl(value); @@ -608,7 +285,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalFloatToString(std::optional const& value) { if (unlikely(state_ != 33)) { - ProtocolWithChangesWriterBaseInvalidState(33, false, state_); + InvalidState(33, false); } WriteOptionalIntToUnionImpl(value); @@ -653,7 +330,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalIntToUnion(std::optional const& value) { if (unlikely(state_ != 34)) { - ProtocolWithChangesWriterBaseInvalidState(34, false, state_); + InvalidState(34, false); } WriteOptionalRecordToUnionImpl(value); @@ -662,7 +339,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalRecordToUnion(std::optional const& values) { if (unlikely(state_ != 40)) { - ProtocolWithChangesWriterBaseInvalidState(40, false, state_); + InvalidState(40, false); } WriteStreamIntToStringToFloatImpl(values); @@ -723,7 +400,7 @@ void ProtocolWithChangesWriterBase::WriteStreamIntToStringToFloat(std::vector const& value) { if (unlikely(state_ != 41)) { - ProtocolWithChangesWriterBaseInvalidState(41, false, state_); + InvalidState(41, false); } WriteVectorIntToStringToFloatImpl(value); @@ -748,7 +425,7 @@ void ProtocolWithChangesWriterBase::WriteVectorIntToStringToFloat(std::vector const& value) { if (unlikely(state_ != 42)) { - ProtocolWithChangesWriterBaseInvalidState(42, false, state_); + InvalidState(42, false); } WriteIntFloatUnionReorderedImpl(value); @@ -757,7 +434,7 @@ void ProtocolWithChangesWriterBase::WriteIntFloatUnionReordered(std::variant> const& value) { if (unlikely(state_ != 43)) { - ProtocolWithChangesWriterBaseInvalidState(43, false, state_); + InvalidState(43, false); } WriteVectorUnionReorderedImpl(value); @@ -766,7 +443,7 @@ void ProtocolWithChangesWriterBase::WriteVectorUnionReordered(std::vector const& value) { if (unlikely(state_ != 44)) { - ProtocolWithChangesWriterBaseInvalidState(44, false, state_); + InvalidState(44, false); } WriteStreamUnionReorderedImpl(value); @@ -774,7 +451,7 @@ void ProtocolWithChangesWriterBase::WriteStreamUnionReordered(std::variant> const& values) { if (unlikely(state_ != 44)) { - ProtocolWithChangesWriterBaseInvalidState(44, false, state_); + InvalidState(44, false); } WriteStreamUnionReorderedImpl(values); @@ -782,7 +459,7 @@ void ProtocolWithChangesWriterBase::WriteStreamUnionReordered(std::vector const& values) { if (unlikely(state_ != 45)) { - ProtocolWithChangesWriterBaseInvalidState(45, false, state_); + InvalidState(45, false); } WriteStreamOfAliasTypeChangeImpl(values); @@ -814,7 +491,7 @@ void ProtocolWithChangesWriterBase::WriteStreamOfAliasTypeChange(std::vector const& value) { if (unlikely(state_ != 70)) { - ProtocolWithChangesWriterBaseInvalidState(70, false, state_); + InvalidState(70, false); } WriteOptionalRecordWithChangesImpl(value); @@ -1055,7 +732,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalRecordWithChanges(std::optional void ProtocolWithChangesWriterBase::WriteAliasedOptionalRecordWithChanges(std::optional const& value) { if (unlikely(state_ != 71)) { - ProtocolWithChangesWriterBaseInvalidState(71, false, state_); + InvalidState(71, false); } WriteAliasedOptionalRecordWithChangesImpl(value); @@ -1064,7 +741,7 @@ void ProtocolWithChangesWriterBase::WriteAliasedOptionalRecordWithChanges(std::o void ProtocolWithChangesWriterBase::WriteUnionRecordWithChanges(std::variant const& value) { if (unlikely(state_ != 72)) { - ProtocolWithChangesWriterBaseInvalidState(72, false, state_); + InvalidState(72, false); } WriteUnionRecordWithChangesImpl(value); @@ -1073,7 +750,7 @@ void ProtocolWithChangesWriterBase::WriteUnionRecordWithChanges(std::variant const& value) { if (unlikely(state_ != 73)) { - ProtocolWithChangesWriterBaseInvalidState(73, false, state_); + InvalidState(73, false); } WriteUnionWithSameTypesetImpl(value); @@ -1082,7 +759,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithSameTypeset(std::variant const& value) { if (unlikely(state_ != 74)) { - ProtocolWithChangesWriterBaseInvalidState(74, false, state_); + InvalidState(74, false); } WriteUnionWithTypesAddedImpl(value); @@ -1091,7 +768,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithTypesAdded(std::variant const& value) { if (unlikely(state_ != 75)) { - ProtocolWithChangesWriterBaseInvalidState(75, false, state_); + InvalidState(75, false); } WriteUnionWithTypesRemovedImpl(value); @@ -1100,7 +777,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithTypesRemoved(std::variant const& value) { if (unlikely(state_ != 80)) { - ProtocolWithChangesWriterBaseInvalidState(80, false, state_); + InvalidState(80, false); } WriteUnionToAliasedUnionImpl(value); @@ -1145,7 +822,7 @@ void ProtocolWithChangesWriterBase::WriteUnionToAliasedUnion(std::variant const& value) { if (unlikely(state_ != 81)) { - ProtocolWithChangesWriterBaseInvalidState(81, false, state_); + InvalidState(81, false); } WriteUnionToAliasedUnionWithChangesImpl(value); @@ -1154,7 +831,7 @@ void ProtocolWithChangesWriterBase::WriteUnionToAliasedUnionWithChanges(std::var void ProtocolWithChangesWriterBase::WriteOptionalToAliasedOptional(std::optional const& value) { if (unlikely(state_ != 82)) { - ProtocolWithChangesWriterBaseInvalidState(82, false, state_); + InvalidState(82, false); } WriteOptionalToAliasedOptionalImpl(value); @@ -1163,7 +840,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalToAliasedOptional(std::optional void ProtocolWithChangesWriterBase::WriteOptionalToAliasedOptionalWithChanges(std::optional const& value) { if (unlikely(state_ != 83)) { - ProtocolWithChangesWriterBaseInvalidState(83, false, state_); + InvalidState(83, false); } WriteOptionalToAliasedOptionalWithChangesImpl(value); @@ -1172,7 +849,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalToAliasedOptionalWithChanges(st void ProtocolWithChangesWriterBase::WriteGenericRecord(evo_test::GenericRecord const& value) { if (unlikely(state_ != 84)) { - ProtocolWithChangesWriterBaseInvalidState(84, false, state_); + InvalidState(84, false); } WriteGenericRecordImpl(value); @@ -1181,7 +858,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecord(evo_test::GenericRecord const& value) { if (unlikely(state_ != 85)) { - ProtocolWithChangesWriterBaseInvalidState(85, false, state_); + InvalidState(85, false); } WriteGenericRecordToOpenAliasImpl(value); @@ -1190,7 +867,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToOpenAlias(evo_test::Gene void ProtocolWithChangesWriterBase::WriteGenericRecordToClosedAlias(evo_test::GenericRecord const& value) { if (unlikely(state_ != 86)) { - ProtocolWithChangesWriterBaseInvalidState(86, false, state_); + InvalidState(86, false); } WriteGenericRecordToClosedAliasImpl(value); @@ -1199,7 +876,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToClosedAlias(evo_test::Ge void ProtocolWithChangesWriterBase::WriteGenericRecordToHalfClosedAlias(evo_test::GenericRecord const& value) { if (unlikely(state_ != 87)) { - ProtocolWithChangesWriterBaseInvalidState(87, false, state_); + InvalidState(87, false); } WriteGenericRecordToHalfClosedAliasImpl(value); @@ -1208,7 +885,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToHalfClosedAlias(evo_test void ProtocolWithChangesWriterBase::WriteAliasedGenericRecordToAlias(evo_test::AliasedHalfClosedGenericRecord const& value) { if (unlikely(state_ != 88)) { - ProtocolWithChangesWriterBaseInvalidState(88, false, state_); + InvalidState(88, false); } WriteAliasedGenericRecordToAliasImpl(value); @@ -1217,7 +894,7 @@ void ProtocolWithChangesWriterBase::WriteAliasedGenericRecordToAlias(evo_test::A void ProtocolWithChangesWriterBase::WriteGenericRecordToReversed(evo_test::GenericRecord const& value) { if (unlikely(state_ != 89)) { - ProtocolWithChangesWriterBaseInvalidState(89, false, state_); + InvalidState(89, false); } WriteGenericRecordToReversedImpl(value); @@ -1226,7 +903,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToReversed(evo_test::Gener void ProtocolWithChangesWriterBase::WriteClosedGenericRecordToUnion(evo_test::AliasedClosedGenericRecord const& value) { if (unlikely(state_ != 90)) { - ProtocolWithChangesWriterBaseInvalidState(90, false, state_); + InvalidState(90, false); } WriteClosedGenericRecordToUnionImpl(value); @@ -1235,7 +912,7 @@ void ProtocolWithChangesWriterBase::WriteClosedGenericRecordToUnion(evo_test::Al void ProtocolWithChangesWriterBase::WriteGenericRecordToAliasedUnion(evo_test::GenericRecord const& value) { if (unlikely(state_ != 91)) { - ProtocolWithChangesWriterBaseInvalidState(91, false, state_); + InvalidState(91, false); } WriteGenericRecordToAliasedUnionImpl(value); @@ -1244,7 +921,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToAliasedUnion(evo_test::G void ProtocolWithChangesWriterBase::WriteGenericUnionToReversed(evo_test::AliasedClosedGenericUnion const& value) { if (unlikely(state_ != 92)) { - ProtocolWithChangesWriterBaseInvalidState(92, false, state_); + InvalidState(92, false); } WriteGenericUnionToReversedImpl(value); @@ -1253,7 +930,7 @@ void ProtocolWithChangesWriterBase::WriteGenericUnionToReversed(evo_test::Aliase void ProtocolWithChangesWriterBase::WriteGenericUnionOfChangedRecord(evo_test::AliasedClosedGenericUnion const& value) { if (unlikely(state_ != 93)) { - ProtocolWithChangesWriterBaseInvalidState(93, false, state_); + InvalidState(93, false); } WriteGenericUnionOfChangedRecordImpl(value); @@ -1262,7 +939,7 @@ void ProtocolWithChangesWriterBase::WriteGenericUnionOfChangedRecord(evo_test::A void ProtocolWithChangesWriterBase::WriteGenericParentRecord(evo_test::GenericParentRecord const& value) { if (unlikely(state_ != 94)) { - ProtocolWithChangesWriterBaseInvalidState(94, false, state_); + InvalidState(94, false); } WriteGenericParentRecordImpl(value); @@ -1271,7 +948,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecord(evo_test::GenericPa void ProtocolWithChangesWriterBase::WriteGenericNestedRecords(evo_test::GenericRecord, evo_test::ChangedGeneric> const& value) { if (unlikely(state_ != 95)) { - ProtocolWithChangesWriterBaseInvalidState(95, false, state_); + InvalidState(95, false); } WriteGenericNestedRecordsImpl(value); @@ -1280,7 +957,7 @@ void ProtocolWithChangesWriterBase::WriteGenericNestedRecords(evo_test::GenericR void ProtocolWithChangesWriterBase::WriteGenericRecordStream(evo_test::GenericRecord const& value) { if (unlikely(state_ != 96)) { - ProtocolWithChangesWriterBaseInvalidState(96, false, state_); + InvalidState(96, false); } WriteGenericRecordStreamImpl(value); @@ -1288,7 +965,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordStream(evo_test::GenericRe void ProtocolWithChangesWriterBase::WriteGenericRecordStream(std::vector> const& values) { if (unlikely(state_ != 96)) { - ProtocolWithChangesWriterBaseInvalidState(96, false, state_); + InvalidState(96, false); } WriteGenericRecordStreamImpl(values); @@ -1296,7 +973,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordStream(std::vector const& value) { if (unlikely(state_ != 97)) { - ProtocolWithChangesWriterBaseInvalidState(97, false, state_); + InvalidState(97, false); } WriteGenericParentRecordStreamImpl(value); @@ -1320,7 +997,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(evo_test::Gen void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(std::vector> const& values) { if (unlikely(state_ != 97)) { - ProtocolWithChangesWriterBaseInvalidState(97, false, state_); + InvalidState(97, false); } WriteGenericParentRecordStreamImpl(values); @@ -1328,7 +1005,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(std::vector const& value) { if (unlikely(state_ != 98)) { - ProtocolWithChangesWriterBaseInvalidState(98, false, state_); + InvalidState(98, false); } WriteVectorRecordWithChangesImpl(value); @@ -1353,7 +1030,7 @@ void ProtocolWithChangesWriterBase::WriteVectorRecordWithChanges(std::vector const& values) { if (unlikely(state_ != 99)) { - ProtocolWithChangesWriterBaseInvalidState(99, false, state_); + InvalidState(99, false); } WriteStreamedRecordWithChangesImpl(values); @@ -1369,7 +1046,7 @@ void ProtocolWithChangesWriterBase::WriteStreamedRecordWithChanges(std::vector& value) { if (unlikely(state_ != 28)) { - ProtocolWithChangesReaderBaseInvalidState(28, state_); + InvalidState(28); } ReadComplexFloatToComplexDoubleImpl(value); @@ -1538,7 +1427,7 @@ void ProtocolWithChangesReaderBase::ReadComplexFloatToComplexDouble(std::complex void ProtocolWithChangesReaderBase::ReadIntToString(int32_t& value) { if (unlikely(state_ != 30)) { - ProtocolWithChangesReaderBaseInvalidState(30, state_); + InvalidState(30); } ReadIntToStringImpl(value); @@ -1547,7 +1436,7 @@ void ProtocolWithChangesReaderBase::ReadIntToString(int32_t& value) { void ProtocolWithChangesReaderBase::ReadUintToString(uint32_t& value) { if (unlikely(state_ != 32)) { - ProtocolWithChangesReaderBaseInvalidState(32, state_); + InvalidState(32); } ReadUintToStringImpl(value); @@ -1556,7 +1445,7 @@ void ProtocolWithChangesReaderBase::ReadUintToString(uint32_t& value) { void ProtocolWithChangesReaderBase::ReadLongToString(int64_t& value) { if (unlikely(state_ != 34)) { - ProtocolWithChangesReaderBaseInvalidState(34, state_); + InvalidState(34); } ReadLongToStringImpl(value); @@ -1565,7 +1454,7 @@ void ProtocolWithChangesReaderBase::ReadLongToString(int64_t& value) { void ProtocolWithChangesReaderBase::ReadUlongToString(uint64_t& value) { if (unlikely(state_ != 36)) { - ProtocolWithChangesReaderBaseInvalidState(36, state_); + InvalidState(36); } ReadUlongToStringImpl(value); @@ -1574,7 +1463,7 @@ void ProtocolWithChangesReaderBase::ReadUlongToString(uint64_t& value) { void ProtocolWithChangesReaderBase::ReadFloatToString(float& value) { if (unlikely(state_ != 38)) { - ProtocolWithChangesReaderBaseInvalidState(38, state_); + InvalidState(38); } ReadFloatToStringImpl(value); @@ -1583,7 +1472,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToString(float& value) { void ProtocolWithChangesReaderBase::ReadDoubleToString(double& value) { if (unlikely(state_ != 40)) { - ProtocolWithChangesReaderBaseInvalidState(40, state_); + InvalidState(40); } ReadDoubleToStringImpl(value); @@ -1592,7 +1481,7 @@ void ProtocolWithChangesReaderBase::ReadDoubleToString(double& value) { void ProtocolWithChangesReaderBase::ReadIntToOptional(int32_t& value) { if (unlikely(state_ != 42)) { - ProtocolWithChangesReaderBaseInvalidState(42, state_); + InvalidState(42); } ReadIntToOptionalImpl(value); @@ -1601,7 +1490,7 @@ void ProtocolWithChangesReaderBase::ReadIntToOptional(int32_t& value) { void ProtocolWithChangesReaderBase::ReadFloatToOptional(float& value) { if (unlikely(state_ != 44)) { - ProtocolWithChangesReaderBaseInvalidState(44, state_); + InvalidState(44); } ReadFloatToOptionalImpl(value); @@ -1610,7 +1499,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToOptional(float& value) { void ProtocolWithChangesReaderBase::ReadStringToOptional(std::string& value) { if (unlikely(state_ != 46)) { - ProtocolWithChangesReaderBaseInvalidState(46, state_); + InvalidState(46); } ReadStringToOptionalImpl(value); @@ -1619,7 +1508,7 @@ void ProtocolWithChangesReaderBase::ReadStringToOptional(std::string& value) { void ProtocolWithChangesReaderBase::ReadIntToUnion(int32_t& value) { if (unlikely(state_ != 48)) { - ProtocolWithChangesReaderBaseInvalidState(48, state_); + InvalidState(48); } ReadIntToUnionImpl(value); @@ -1628,7 +1517,7 @@ void ProtocolWithChangesReaderBase::ReadIntToUnion(int32_t& value) { void ProtocolWithChangesReaderBase::ReadFloatToUnion(float& value) { if (unlikely(state_ != 50)) { - ProtocolWithChangesReaderBaseInvalidState(50, state_); + InvalidState(50); } ReadFloatToUnionImpl(value); @@ -1637,7 +1526,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToUnion(float& value) { void ProtocolWithChangesReaderBase::ReadStringToUnion(std::string& value) { if (unlikely(state_ != 52)) { - ProtocolWithChangesReaderBaseInvalidState(52, state_); + InvalidState(52); } ReadStringToUnionImpl(value); @@ -1646,7 +1535,7 @@ void ProtocolWithChangesReaderBase::ReadStringToUnion(std::string& value) { void ProtocolWithChangesReaderBase::ReadOptionalIntToFloat(std::optional& value) { if (unlikely(state_ != 54)) { - ProtocolWithChangesReaderBaseInvalidState(54, state_); + InvalidState(54); } ReadOptionalIntToFloatImpl(value); @@ -1655,7 +1544,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalIntToFloat(std::optional& value) { if (unlikely(state_ != 56)) { - ProtocolWithChangesReaderBaseInvalidState(56, state_); + InvalidState(56); } ReadOptionalFloatToStringImpl(value); @@ -1664,7 +1553,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalFloatToString(std::optional& value) { if (unlikely(state_ != 66)) { - ProtocolWithChangesReaderBaseInvalidState(66, state_); + InvalidState(66); } ReadOptionalIntToUnionImpl(value); @@ -1709,7 +1598,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalIntToUnion(std::optional& value) { if (unlikely(state_ != 68)) { - ProtocolWithChangesReaderBaseInvalidState(68, state_); + InvalidState(68); } ReadOptionalRecordToUnionImpl(value); @@ -1718,7 +1607,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalRecordToUnion(std::optional& value) { if (unlikely(state_ != 84)) { - ProtocolWithChangesReaderBaseInvalidState(84, state_); + InvalidState(84); } ReadIntFloatUnionReorderedImpl(value); @@ -1839,7 +1728,7 @@ void ProtocolWithChangesReaderBase::ReadIntFloatUnionReordered(std::variant>& value) { if (unlikely(state_ != 86)) { - ProtocolWithChangesReaderBaseInvalidState(86, state_); + InvalidState(86); } ReadVectorUnionReorderedImpl(value); @@ -1852,7 +1741,7 @@ bool ProtocolWithChangesReaderBase::ReadStreamUnionReordered(std::variant& value) { if (unlikely(state_ != 140)) { - ProtocolWithChangesReaderBaseInvalidState(140, state_); + InvalidState(140); } ReadOptionalRecordWithChangesImpl(value); @@ -2193,7 +2082,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalRecordWithChanges(std::optional< void ProtocolWithChangesReaderBase::ReadAliasedOptionalRecordWithChanges(std::optional& value) { if (unlikely(state_ != 142)) { - ProtocolWithChangesReaderBaseInvalidState(142, state_); + InvalidState(142); } ReadAliasedOptionalRecordWithChangesImpl(value); @@ -2202,7 +2091,7 @@ void ProtocolWithChangesReaderBase::ReadAliasedOptionalRecordWithChanges(std::op void ProtocolWithChangesReaderBase::ReadUnionRecordWithChanges(std::variant& value) { if (unlikely(state_ != 144)) { - ProtocolWithChangesReaderBaseInvalidState(144, state_); + InvalidState(144); } ReadUnionRecordWithChangesImpl(value); @@ -2211,7 +2100,7 @@ void ProtocolWithChangesReaderBase::ReadUnionRecordWithChanges(std::variant& value) { if (unlikely(state_ != 146)) { - ProtocolWithChangesReaderBaseInvalidState(146, state_); + InvalidState(146); } ReadUnionWithSameTypesetImpl(value); @@ -2220,7 +2109,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithSameTypeset(std::variant& value) { if (unlikely(state_ != 148)) { - ProtocolWithChangesReaderBaseInvalidState(148, state_); + InvalidState(148); } ReadUnionWithTypesAddedImpl(value); @@ -2229,7 +2118,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithTypesAdded(std::variant& value) { if (unlikely(state_ != 150)) { - ProtocolWithChangesReaderBaseInvalidState(150, state_); + InvalidState(150); } ReadUnionWithTypesRemovedImpl(value); @@ -2238,7 +2127,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithTypesRemoved(std::variant& value) { if (unlikely(state_ != 160)) { - ProtocolWithChangesReaderBaseInvalidState(160, state_); + InvalidState(160); } ReadUnionToAliasedUnionImpl(value); @@ -2283,7 +2172,7 @@ void ProtocolWithChangesReaderBase::ReadUnionToAliasedUnion(std::variant& value) { if (unlikely(state_ != 162)) { - ProtocolWithChangesReaderBaseInvalidState(162, state_); + InvalidState(162); } ReadUnionToAliasedUnionWithChangesImpl(value); @@ -2292,7 +2181,7 @@ void ProtocolWithChangesReaderBase::ReadUnionToAliasedUnionWithChanges(std::vari void ProtocolWithChangesReaderBase::ReadOptionalToAliasedOptional(std::optional& value) { if (unlikely(state_ != 164)) { - ProtocolWithChangesReaderBaseInvalidState(164, state_); + InvalidState(164); } ReadOptionalToAliasedOptionalImpl(value); @@ -2301,7 +2190,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalToAliasedOptional(std::optional< void ProtocolWithChangesReaderBase::ReadOptionalToAliasedOptionalWithChanges(std::optional& value) { if (unlikely(state_ != 166)) { - ProtocolWithChangesReaderBaseInvalidState(166, state_); + InvalidState(166); } ReadOptionalToAliasedOptionalWithChangesImpl(value); @@ -2310,7 +2199,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalToAliasedOptionalWithChanges(std void ProtocolWithChangesReaderBase::ReadGenericRecord(evo_test::GenericRecord& value) { if (unlikely(state_ != 168)) { - ProtocolWithChangesReaderBaseInvalidState(168, state_); + InvalidState(168); } ReadGenericRecordImpl(value); @@ -2319,7 +2208,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecord(evo_test::GenericRecord& value) { if (unlikely(state_ != 170)) { - ProtocolWithChangesReaderBaseInvalidState(170, state_); + InvalidState(170); } ReadGenericRecordToOpenAliasImpl(value); @@ -2328,7 +2217,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToOpenAlias(evo_test::Gener void ProtocolWithChangesReaderBase::ReadGenericRecordToClosedAlias(evo_test::GenericRecord& value) { if (unlikely(state_ != 172)) { - ProtocolWithChangesReaderBaseInvalidState(172, state_); + InvalidState(172); } ReadGenericRecordToClosedAliasImpl(value); @@ -2337,7 +2226,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToClosedAlias(evo_test::Gen void ProtocolWithChangesReaderBase::ReadGenericRecordToHalfClosedAlias(evo_test::GenericRecord& value) { if (unlikely(state_ != 174)) { - ProtocolWithChangesReaderBaseInvalidState(174, state_); + InvalidState(174); } ReadGenericRecordToHalfClosedAliasImpl(value); @@ -2346,7 +2235,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToHalfClosedAlias(evo_test: void ProtocolWithChangesReaderBase::ReadAliasedGenericRecordToAlias(evo_test::AliasedHalfClosedGenericRecord& value) { if (unlikely(state_ != 176)) { - ProtocolWithChangesReaderBaseInvalidState(176, state_); + InvalidState(176); } ReadAliasedGenericRecordToAliasImpl(value); @@ -2355,7 +2244,7 @@ void ProtocolWithChangesReaderBase::ReadAliasedGenericRecordToAlias(evo_test::Al void ProtocolWithChangesReaderBase::ReadGenericRecordToReversed(evo_test::GenericRecord& value) { if (unlikely(state_ != 178)) { - ProtocolWithChangesReaderBaseInvalidState(178, state_); + InvalidState(178); } ReadGenericRecordToReversedImpl(value); @@ -2364,7 +2253,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToReversed(evo_test::Generi void ProtocolWithChangesReaderBase::ReadClosedGenericRecordToUnion(evo_test::AliasedClosedGenericRecord& value) { if (unlikely(state_ != 180)) { - ProtocolWithChangesReaderBaseInvalidState(180, state_); + InvalidState(180); } ReadClosedGenericRecordToUnionImpl(value); @@ -2373,7 +2262,7 @@ void ProtocolWithChangesReaderBase::ReadClosedGenericRecordToUnion(evo_test::Ali void ProtocolWithChangesReaderBase::ReadGenericRecordToAliasedUnion(evo_test::GenericRecord& value) { if (unlikely(state_ != 182)) { - ProtocolWithChangesReaderBaseInvalidState(182, state_); + InvalidState(182); } ReadGenericRecordToAliasedUnionImpl(value); @@ -2382,7 +2271,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToAliasedUnion(evo_test::Ge void ProtocolWithChangesReaderBase::ReadGenericUnionToReversed(evo_test::AliasedClosedGenericUnion& value) { if (unlikely(state_ != 184)) { - ProtocolWithChangesReaderBaseInvalidState(184, state_); + InvalidState(184); } ReadGenericUnionToReversedImpl(value); @@ -2391,7 +2280,7 @@ void ProtocolWithChangesReaderBase::ReadGenericUnionToReversed(evo_test::Aliased void ProtocolWithChangesReaderBase::ReadGenericUnionOfChangedRecord(evo_test::AliasedClosedGenericUnion& value) { if (unlikely(state_ != 186)) { - ProtocolWithChangesReaderBaseInvalidState(186, state_); + InvalidState(186); } ReadGenericUnionOfChangedRecordImpl(value); @@ -2400,7 +2289,7 @@ void ProtocolWithChangesReaderBase::ReadGenericUnionOfChangedRecord(evo_test::Al void ProtocolWithChangesReaderBase::ReadGenericParentRecord(evo_test::GenericParentRecord& value) { if (unlikely(state_ != 188)) { - ProtocolWithChangesReaderBaseInvalidState(188, state_); + InvalidState(188); } ReadGenericParentRecordImpl(value); @@ -2409,7 +2298,7 @@ void ProtocolWithChangesReaderBase::ReadGenericParentRecord(evo_test::GenericPar void ProtocolWithChangesReaderBase::ReadGenericNestedRecords(evo_test::GenericRecord, evo_test::ChangedGeneric>& value) { if (unlikely(state_ != 190)) { - ProtocolWithChangesReaderBaseInvalidState(190, state_); + InvalidState(190); } ReadGenericNestedRecordsImpl(value); @@ -2422,7 +2311,7 @@ bool ProtocolWithChangesReaderBase::ReadGenericRecordStream(evo_test::GenericRec state_ = 194; return false; } - ProtocolWithChangesReaderBaseInvalidState(192, state_); + InvalidState(192); } bool result = ReadGenericRecordStreamImpl(value); @@ -2442,7 +2331,7 @@ bool ProtocolWithChangesReaderBase::ReadGenericRecordStream(std::vector std::string { switch (i/2) { - case 0: return "ReadRecords()"; - case 1: return "Close()"; + case 0: return "ReadInt8ToInt()"; + case 1: return "ReadInt8ToLong()"; + case 2: return "ReadInt8ToUint()"; + case 3: return "ReadInt8ToUlong()"; + case 4: return "ReadInt8ToFloat()"; + case 5: return "ReadInt8ToDouble()"; + case 6: return "ReadIntToUint()"; + case 7: return "ReadIntToLong()"; + case 8: return "ReadIntToFloat()"; + case 9: return "ReadIntToDouble()"; + case 10: return "ReadUintToUlong()"; + case 11: return "ReadUintToFloat()"; + case 12: return "ReadUintToDouble()"; + case 13: return "ReadFloatToDouble()"; + case 14: return "ReadComplexFloatToComplexDouble()"; + case 15: return "ReadIntToString()"; + case 16: return "ReadUintToString()"; + case 17: return "ReadLongToString()"; + case 18: return "ReadUlongToString()"; + case 19: return "ReadFloatToString()"; + case 20: return "ReadDoubleToString()"; + case 21: return "ReadIntToOptional()"; + case 22: return "ReadFloatToOptional()"; + case 23: return "ReadStringToOptional()"; + case 24: return "ReadIntToUnion()"; + case 25: return "ReadFloatToUnion()"; + case 26: return "ReadStringToUnion()"; + case 27: return "ReadOptionalIntToFloat()"; + case 28: return "ReadOptionalFloatToString()"; + case 29: return "ReadAliasedLongToString()"; + case 30: return "ReadStringToAliasedString()"; + case 31: return "ReadStringToAliasedInt()"; + case 32: return "ReadEnumToAliasedEnum()"; + case 33: return "ReadOptionalIntToUnion()"; + case 34: return "ReadOptionalRecordToUnion()"; + case 35: return "ReadRecordWithChanges()"; + case 36: return "ReadAliasedRecordWithChanges()"; + case 37: return "ReadRecordToRenamedRecord()"; + case 38: return "ReadRecordToAliasedRecord()"; + case 39: return "ReadRecordToAliasedAlias()"; + case 40: return "ReadStreamIntToStringToFloat()"; + case 41: return "ReadVectorIntToStringToFloat()"; + case 42: return "ReadIntFloatUnionReordered()"; + case 43: return "ReadVectorUnionReordered()"; + case 44: return "ReadStreamUnionReordered()"; + case 45: return "ReadStreamOfAliasTypeChange()"; + case 46: return "ReadRlink()"; + case 47: return "ReadRlinkRX()"; + case 48: return "ReadRlinkRY()"; + case 49: return "ReadRlinkRZ()"; + case 50: return "ReadRaRLink()"; + case 51: return "ReadRaRX()"; + case 52: return "ReadRaRY()"; + case 53: return "ReadRaRZ()"; + case 54: return "ReadRbRLink()"; + case 55: return "ReadRbRX()"; + case 56: return "ReadRbRY()"; + case 57: return "ReadRbRZ()"; + case 58: return "ReadRcRLink()"; + case 59: return "ReadRcRX()"; + case 60: return "ReadRcRY()"; + case 61: return "ReadRcRZ()"; + case 62: return "ReadRlinkRNew()"; + case 63: return "ReadRaRNew()"; + case 64: return "ReadRbRNew()"; + case 65: return "ReadRcRNew()"; + case 66: return "ReadRlinkRUnion()"; + case 67: return "ReadRaRUnion()"; + case 68: return "ReadRbRUnion()"; + case 69: return "ReadRcRUnion()"; + case 70: return "ReadOptionalRecordWithChanges()"; + case 71: return "ReadAliasedOptionalRecordWithChanges()"; + case 72: return "ReadUnionRecordWithChanges()"; + case 73: return "ReadUnionWithSameTypeset()"; + case 74: return "ReadUnionWithTypesAdded()"; + case 75: return "ReadUnionWithTypesRemoved()"; + case 76: return "ReadRecordToOptional()"; + case 77: return "ReadRecordToAliasedOptional()"; + case 78: return "ReadRecordToUnion()"; + case 79: return "ReadRecordToAliasedUnion()"; + case 80: return "ReadUnionToAliasedUnion()"; + case 81: return "ReadUnionToAliasedUnionWithChanges()"; + case 82: return "ReadOptionalToAliasedOptional()"; + case 83: return "ReadOptionalToAliasedOptionalWithChanges()"; + case 84: return "ReadGenericRecord()"; + case 85: return "ReadGenericRecordToOpenAlias()"; + case 86: return "ReadGenericRecordToClosedAlias()"; + case 87: return "ReadGenericRecordToHalfClosedAlias()"; + case 88: return "ReadAliasedGenericRecordToAlias()"; + case 89: return "ReadGenericRecordToReversed()"; + case 90: return "ReadClosedGenericRecordToUnion()"; + case 91: return "ReadGenericRecordToAliasedUnion()"; + case 92: return "ReadGenericUnionToReversed()"; + case 93: return "ReadGenericUnionOfChangedRecord()"; + case 94: return "ReadGenericParentRecord()"; + case 95: return "ReadGenericNestedRecords()"; + case 96: return "ReadGenericRecordStream()"; + case 97: return "ReadGenericParentRecordStream()"; + case 98: return "ReadVectorRecordWithChanges()"; + case 99: return "ReadStreamedRecordWithChanges()"; + case 100: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamIntToStringToFloat(int32_t& value, size_t idx) { + return ReadStreamIntToStringToFloatImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamIntToStringToFloat(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamIntToStringToFloatImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamIntToStringToFloat() { + return CountStreamIntToStringToFloatImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamUnionReordered(std::variant& value, size_t idx) { + return ReadStreamUnionReorderedImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamUnionReordered(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamUnionReorderedImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamUnionReordered() { + return CountStreamUnionReorderedImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamOfAliasTypeChange(evo_test::StreamItem& value, size_t idx) { + return ReadStreamOfAliasTypeChangeImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamOfAliasTypeChange(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamOfAliasTypeChangeImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamOfAliasTypeChange() { + return CountStreamOfAliasTypeChangeImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericRecordStream(evo_test::GenericRecord& value, size_t idx) { + return ReadGenericRecordStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericRecordStream(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadGenericRecordStreamImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountGenericRecordStream() { + return CountGenericRecordStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericParentRecordStream(evo_test::GenericParentRecord& value, size_t idx) { + return ReadGenericParentRecordStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericParentRecordStream(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadGenericParentRecordStreamImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountGenericParentRecordStream() { + return CountGenericParentRecordStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamedRecordWithChanges(evo_test::RecordWithChanges& value, size_t idx) { + return ReadStreamedRecordWithChangesImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamedRecordWithChanges(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamedRecordWithChangesImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamedRecordWithChanges() { + return CountStreamedRecordWithChangesImpl(); +} + +void ProtocolWithChangesIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string UnusedProtocolWriterBase::schema_ = R"({"protocol":{"name":"UnusedProtocol","sequence":[{"name":"records","type":{"stream":{"items":"EvoTest.UnchangedRecord"}}}]},"types":[{"name":"UnchangedRecord","fields":[{"name":"name","type":"string"},{"name":"age","type":"int32"},{"name":"meta","type":{"map":{"keys":"string","values":"float64"}}}]}]})"; @@ -3206,9 +3293,10 @@ std::string UnusedProtocolWriterBase::SchemaFromVersion(Version version) { } } + void UnusedProtocolWriterBase::WriteRecords(evo_test::UnchangedRecord const& value) { if (unlikely(state_ != 0)) { - UnusedProtocolWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteRecordsImpl(value); @@ -3216,7 +3304,7 @@ void UnusedProtocolWriterBase::WriteRecords(evo_test::UnchangedRecord const& val void UnusedProtocolWriterBase::WriteRecords(std::vector const& values) { if (unlikely(state_ != 0)) { - UnusedProtocolWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteRecordsImpl(values); @@ -3224,7 +3312,7 @@ void UnusedProtocolWriterBase::WriteRecords(std::vector UnusedProtocolReaderBase::previous_schemas_ = UnusedProtocolWriterBase::previous_schemas_; @@ -3256,13 +3357,14 @@ Version UnusedProtocolReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol UnusedProtocol."); } + bool UnusedProtocolReaderBase::ReadRecords(evo_test::UnchangedRecord& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - UnusedProtocolReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadRecordsImpl(value); @@ -3282,7 +3384,7 @@ bool UnusedProtocolReaderBase::ReadRecords(std::vector 1) { std::vector values; @@ -3337,4 +3440,39 @@ void UnusedProtocolReaderBase::CopyTo(UnusedProtocolWriterBase& writer, size_t r writer.EndRecords(); } } + +void UnusedProtocolReaderBase::InvalidState(uint8_t attempted) { + auto f = [](uint8_t i) -> std::string { + switch (i/2) { + case 0: return "ReadRecords()"; + case 1: return "Close()"; + default: return ""; + } + }; + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool UnusedProtocolIndexedReaderBase::ReadRecords(evo_test::UnchangedRecord& value, size_t idx) { + return ReadRecordsImpl(value, idx); +} + +bool UnusedProtocolIndexedReaderBase::ReadRecords(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadRecordsImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t UnusedProtocolIndexedReaderBase::CountRecords() { + return CountRecordsImpl(); +} + +void UnusedProtocolIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; +} + } // namespace evo_test diff --git a/cpp/evolution/v0/generated/protocols.h b/cpp/evolution/v0/generated/protocols.h index 48dd046..42a2b43 100644 --- a/cpp/evolution/v0/generated/protocols.h +++ b/cpp/evolution/v0/generated/protocols.h @@ -491,9 +491,11 @@ class ProtocolWithChangesWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ProtocolWithChangesReaderBase; + friend class ProtocolWithChangesIndexedReaderBase; }; // Abstract reader for the ProtocolWithChanges protocol. @@ -942,9 +944,70 @@ class ProtocolWithChangesReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedReaderBase : public ProtocolWithChangesReaderBase { + public: + // Stream and Vector type changes + using ProtocolWithChangesReaderBase::ReadStreamIntToStringToFloat; + [[nodiscard]] bool ReadStreamIntToStringToFloat(int32_t& value, size_t idx); + [[nodiscard]] bool ReadStreamIntToStringToFloat(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamIntToStringToFloat(); + + using ProtocolWithChangesReaderBase::ReadStreamUnionReordered; + [[nodiscard]] bool ReadStreamUnionReordered(std::variant& value, size_t idx); + [[nodiscard]] bool ReadStreamUnionReordered(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountStreamUnionReordered(); + + using ProtocolWithChangesReaderBase::ReadStreamOfAliasTypeChange; + [[nodiscard]] bool ReadStreamOfAliasTypeChange(evo_test::StreamItem& value, size_t idx); + [[nodiscard]] bool ReadStreamOfAliasTypeChange(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamOfAliasTypeChange(); + + using ProtocolWithChangesReaderBase::ReadGenericRecordStream; + [[nodiscard]] bool ReadGenericRecordStream(evo_test::GenericRecord& value, size_t idx); + [[nodiscard]] bool ReadGenericRecordStream(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountGenericRecordStream(); + + using ProtocolWithChangesReaderBase::ReadGenericParentRecordStream; + [[nodiscard]] bool ReadGenericParentRecordStream(evo_test::GenericParentRecord& value, size_t idx); + [[nodiscard]] bool ReadGenericParentRecordStream(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountGenericParentRecordStream(); + + using ProtocolWithChangesReaderBase::ReadStreamedRecordWithChanges; + [[nodiscard]] bool ReadStreamedRecordWithChanges(evo_test::RecordWithChanges& value, size_t idx); + [[nodiscard]] bool ReadStreamedRecordWithChanges(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamedRecordWithChanges(); + + virtual ~ProtocolWithChangesIndexedReaderBase() = default; + + protected: + virtual bool ReadStreamIntToStringToFloatImpl(int32_t& value, size_t idx) = 0; + virtual bool ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamIntToStringToFloatImpl() = 0; + virtual bool ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountStreamUnionReorderedImpl() = 0; + virtual bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) = 0; + virtual bool ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamOfAliasTypeChangeImpl() = 0; + virtual bool ReadGenericRecordStreamImpl(evo_test::GenericRecord& value, size_t idx) = 0; + virtual bool ReadGenericRecordStreamImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountGenericRecordStreamImpl() = 0; + virtual bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) = 0; + virtual bool ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountGenericParentRecordStreamImpl() = 0; + virtual bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) = 0; + virtual bool ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamedRecordWithChangesImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the UnusedProtocol protocol. class UnusedProtocolWriterBase { public: @@ -980,9 +1043,11 @@ class UnusedProtocolWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class UnusedProtocolReaderBase; + friend class UnusedProtocolIndexedReaderBase; }; // Abstract reader for the UnusedProtocol protocol. @@ -1012,6 +1077,26 @@ class UnusedProtocolReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; + +// Abstract Indexed reader for the UnusedProtocol protocol. +class UnusedProtocolIndexedReaderBase : public UnusedProtocolReaderBase { + public: + using UnusedProtocolReaderBase::ReadRecords; + [[nodiscard]] bool ReadRecords(evo_test::UnchangedRecord& value, size_t idx); + [[nodiscard]] bool ReadRecords(std::vector& values, size_t idx); + [[nodiscard]] size_t CountRecords(); + + virtual ~UnusedProtocolIndexedReaderBase() = default; + + protected: + virtual bool ReadRecordsImpl(evo_test::UnchangedRecord& value, size_t idx) = 0; + virtual bool ReadRecordsImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountRecordsImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; } // namespace evo_test diff --git a/cpp/evolution/v1/generated/binary/protocols.cc b/cpp/evolution/v1/generated/binary/protocols.cc index 16784ac..00803c1 100644 --- a/cpp/evolution/v1/generated/binary/protocols.cc +++ b/cpp/evolution/v1/generated/binary/protocols.cc @@ -4873,6 +4873,4411 @@ void ProtocolWithChangesReader::CloseImpl() { stream_.VerifyFinished(); } +void ProtocolWithChangesIndexedWriter::WriteInt8ToIntImpl(int32_t const& value) { + step_index_.set_step_offset("Int8ToInt", stream_.Pos()); + switch (version_) { + case Version::v0: { + int8_t int8_to_int = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'int32' to 'int8'"); + } + int8_to_int = static_cast(value); + yardl::binary::WriteInteger(stream_, int8_to_int); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToLongImpl(int64_t const& value) { + step_index_.set_step_offset("Int8ToLong", stream_.Pos()); + switch (version_) { + case Version::v0: { + int8_t int8_to_long = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'int64' to 'int8'"); + } + int8_to_long = static_cast(value); + yardl::binary::WriteInteger(stream_, int8_to_long); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToUintImpl(uint32_t const& value) { + step_index_.set_step_offset("Int8ToUint", stream_.Pos()); + switch (version_) { + case Version::v0: { + int8_t int8_to_uint = {}; + if (value > std::numeric_limits::max()) { + throw std::runtime_error("Numeric overflow detected while converting 'uint32' to 'int8'"); + } + int8_to_uint = static_cast(value); + yardl::binary::WriteInteger(stream_, int8_to_uint); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToUlongImpl(uint64_t const& value) { + step_index_.set_step_offset("Int8ToUlong", stream_.Pos()); + switch (version_) { + case Version::v0: { + int8_t int8_to_ulong = {}; + if (value > std::numeric_limits::max()) { + throw std::runtime_error("Numeric overflow detected while converting 'uint64' to 'int8'"); + } + int8_to_ulong = static_cast(value); + yardl::binary::WriteInteger(stream_, int8_to_ulong); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToFloatImpl(float const& value) { + step_index_.set_step_offset("Int8ToFloat", stream_.Pos()); + switch (version_) { + case Version::v0: { + int8_t int8_to_float = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int8'"); + } + int8_to_float = static_cast(std::round(value)); + yardl::binary::WriteInteger(stream_, int8_to_float); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToDoubleImpl(double const& value) { + step_index_.set_step_offset("Int8ToDouble", stream_.Pos()); + switch (version_) { + case Version::v0: { + int8_t int8_to_double = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float64' to 'int8'"); + } + int8_to_double = static_cast(std::round(value)); + yardl::binary::WriteInteger(stream_, int8_to_double); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUintImpl(uint32_t const& value) { + step_index_.set_step_offset("IntToUint", stream_.Pos()); + switch (version_) { + case Version::v0: { + int32_t int_to_uint = {}; + if (value > std::numeric_limits::max()) { + throw std::runtime_error("Numeric overflow detected while converting 'uint32' to 'int32'"); + } + int_to_uint = static_cast(value); + yardl::binary::WriteInteger(stream_, int_to_uint); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToLongImpl(int64_t const& value) { + step_index_.set_step_offset("IntToLong", stream_.Pos()); + switch (version_) { + case Version::v0: { + int32_t int_to_long = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'int64' to 'int32'"); + } + int_to_long = static_cast(value); + yardl::binary::WriteInteger(stream_, int_to_long); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToFloatImpl(float const& value) { + step_index_.set_step_offset("IntToFloat", stream_.Pos()); + switch (version_) { + case Version::v0: { + int32_t int_to_float = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int32'"); + } + int_to_float = static_cast(std::round(value)); + yardl::binary::WriteInteger(stream_, int_to_float); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToDoubleImpl(double const& value) { + step_index_.set_step_offset("IntToDouble", stream_.Pos()); + switch (version_) { + case Version::v0: { + int32_t int_to_double = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float64' to 'int32'"); + } + int_to_double = static_cast(std::round(value)); + yardl::binary::WriteInteger(stream_, int_to_double); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUintToUlongImpl(uint64_t const& value) { + step_index_.set_step_offset("UintToUlong", stream_.Pos()); + switch (version_) { + case Version::v0: { + uint32_t uint_to_ulong = {}; + if (value > std::numeric_limits::max()) { + throw std::runtime_error("Numeric overflow detected while converting 'uint64' to 'uint32'"); + } + uint_to_ulong = static_cast(value); + yardl::binary::WriteInteger(stream_, uint_to_ulong); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUintToFloatImpl(float const& value) { + step_index_.set_step_offset("UintToFloat", stream_.Pos()); + switch (version_) { + case Version::v0: { + uint32_t uint_to_float = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'uint32'"); + } + uint_to_float = static_cast(std::round(value)); + yardl::binary::WriteInteger(stream_, uint_to_float); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUintToDoubleImpl(double const& value) { + step_index_.set_step_offset("UintToDouble", stream_.Pos()); + switch (version_) { + case Version::v0: { + uint32_t uint_to_double = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float64' to 'uint32'"); + } + uint_to_double = static_cast(std::round(value)); + yardl::binary::WriteInteger(stream_, uint_to_double); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToDoubleImpl(double const& value) { + step_index_.set_step_offset("FloatToDouble", stream_.Pos()); + switch (version_) { + case Version::v0: { + float float_to_double = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float64' to 'float32'"); + } + float_to_double = static_cast(value); + yardl::binary::WriteFloatingPoint(stream_, float_to_double); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteComplexFloatToComplexDoubleImpl(std::complex const& value) { + step_index_.set_step_offset("ComplexFloatToComplexDouble", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::complex complex_float_to_complex_double = {}; + if (std::real(value) > std::numeric_limits::value_type>::max() || std::real(value) < std::numeric_limits::value_type>::lowest()) { + throw std::runtime_error("Real part overflow detected while converting 'complexfloat64' to 'complexfloat32'"); + } + if (std::imag(value) > std::numeric_limits::value_type>::max() || std::imag(value) < std::numeric_limits::value_type>::lowest()) { + throw std::runtime_error("Imaginary part overflow detected while converting 'complexfloat64' to 'complexfloat32'"); + } + complex_float_to_complex_double = std::complex(value); + yardl::binary::WriteFloatingPoint(stream_, complex_float_to_complex_double); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToStringImpl(std::string const& value) { + step_index_.set_step_offset("IntToString", stream_.Pos()); + switch (version_) { + case Version::v0: { + int32_t int_to_string = {}; + try { + int_to_string = std::stoi(value); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value + "\" to number"); + } + yardl::binary::WriteInteger(stream_, int_to_string); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUintToStringImpl(std::string const& value) { + step_index_.set_step_offset("UintToString", stream_.Pos()); + switch (version_) { + case Version::v0: { + uint32_t uint_to_string = {}; + try { + uint_to_string = std::stoul(value); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value + "\" to number"); + } + yardl::binary::WriteInteger(stream_, uint_to_string); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteLongToStringImpl(std::string const& value) { + step_index_.set_step_offset("LongToString", stream_.Pos()); + switch (version_) { + case Version::v0: { + int64_t long_to_string = {}; + try { + long_to_string = std::stol(value); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value + "\" to number"); + } + yardl::binary::WriteInteger(stream_, long_to_string); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUlongToStringImpl(std::string const& value) { + step_index_.set_step_offset("UlongToString", stream_.Pos()); + switch (version_) { + case Version::v0: { + uint64_t ulong_to_string = {}; + try { + ulong_to_string = std::stoul(value); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value + "\" to number"); + } + yardl::binary::WriteInteger(stream_, ulong_to_string); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToStringImpl(std::string const& value) { + step_index_.set_step_offset("FloatToString", stream_.Pos()); + switch (version_) { + case Version::v0: { + float float_to_string = {}; + try { + float_to_string = std::stof(value); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value + "\" to number"); + } + yardl::binary::WriteFloatingPoint(stream_, float_to_string); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteDoubleToStringImpl(std::string const& value) { + step_index_.set_step_offset("DoubleToString", stream_.Pos()); + switch (version_) { + case Version::v0: { + double double_to_string = {}; + try { + double_to_string = std::stod(value); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value + "\" to number"); + } + yardl::binary::WriteFloatingPoint(stream_, double_to_string); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToOptionalImpl(std::optional const& value) { + step_index_.set_step_offset("IntToOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + int32_t int_to_optional = {}; + if (value.has_value()) { + int_to_optional = value.value(); + } + yardl::binary::WriteInteger(stream_, int_to_optional); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToOptionalImpl(std::optional const& value) { + step_index_.set_step_offset("FloatToOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + float float_to_optional = {}; + if (value.has_value()) { + float_to_optional = value.value(); + } + yardl::binary::WriteFloatingPoint(stream_, float_to_optional); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStringToOptionalImpl(std::optional const& value) { + step_index_.set_step_offset("StringToOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::string string_to_optional = {}; + if (value.has_value()) { + string_to_optional = value.value(); + } + yardl::binary::WriteString(stream_, string_to_optional); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUnionImpl(std::variant const& value) { + step_index_.set_step_offset("IntToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + int32_t int_to_union = {}; + if (value.index() == 0) { + int_to_union = std::get<0>(value); + } + yardl::binary::WriteInteger(stream_, int_to_union); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToUnionImpl(std::variant const& value) { + step_index_.set_step_offset("FloatToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + float float_to_union = {}; + if (value.index() == 0) { + float_to_union = std::get<0>(value); + } + yardl::binary::WriteFloatingPoint(stream_, float_to_union); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStringToUnionImpl(std::variant const& value) { + step_index_.set_step_offset("StringToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::string string_to_union = {}; + if (value.index() == 0) { + string_to_union = std::get<0>(value); + } + yardl::binary::WriteString(stream_, string_to_union); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalIntToFloatImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalIntToFloat", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::optional optional_int_to_float = {}; + if (value.has_value()) { + if (value.value() > std::numeric_limits::max() || value.value() < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int32'"); + } + optional_int_to_float = static_cast(std::round(value.value())); + } + yardl::binary::WriteOptional(stream_, optional_int_to_float); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalFloatToStringImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalFloatToString", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::optional optional_float_to_string = {}; + if (value.has_value()) { + try { + optional_float_to_string = std::stof(value.value()); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value.value() + "\" to number"); + } + } + yardl::binary::WriteOptional(stream_, optional_float_to_string); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedLongToStringImpl(evo_test::AliasedLongToString const& value) { + step_index_.set_step_offset("AliasedLongToString", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteAliasedLongToString_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedLongToString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStringToAliasedStringImpl(evo_test::AliasedString const& value) { + step_index_.set_step_offset("StringToAliasedString", stream_.Pos()); + evo_test::binary::WriteAliasedString(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStringToAliasedIntImpl(evo_test::AliasedInt const& value) { + step_index_.set_step_offset("StringToAliasedInt", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::string string_to_aliased_int = {}; + string_to_aliased_int = std::to_string(value); + yardl::binary::WriteString(stream_, string_to_aliased_int); + break; + } + default: + evo_test::binary::WriteAliasedInt(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteEnumToAliasedEnumImpl(evo_test::AliasedEnum const& value) { + step_index_.set_step_offset("EnumToAliasedEnum", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteEnum(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedEnum(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalIntToUnionImpl(std::variant const& value) { + step_index_.set_step_offset("OptionalIntToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::optional optional_int_to_union = {}; + if (value.index() == 1) { + optional_int_to_union = std::get<1>(value); + } + yardl::binary::WriteOptional(stream_, optional_int_to_union); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalRecordToUnionImpl(std::variant const& value) { + step_index_.set_step_offset("OptionalRecordToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::optional optional_record_to_union = {}; + if (value.index() == 1) { + optional_record_to_union = std::get<1>(value); + } + yardl::binary::WriteOptional(stream_, optional_record_to_union); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordWithChangesImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges const& value) { + step_index_.set_step_offset("AliasedRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteAliasedRecordWithChanges_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToRenamedRecordImpl(evo_test::RenamedRecord const& value) { + step_index_.set_step_offset("RecordToRenamedRecord", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRenamedRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRenamedRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedRecordImpl(evo_test::AliasedRecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedRecord", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedAliasImpl(evo_test::AliasOfAliasedRecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedAlias", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasOfAliasedRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStreamIntToStringToFloatImpl(std::string const& value) { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + int32_t stream_int_to_string_to_float = {}; + try { + stream_int_to_string_to_float = std::stoi(value); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value + "\" to number"); + } + yardl::binary::WriteBlockAndSaveOffset(stream_, stream_int_to_string_to_float, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("StreamIntToStringToFloat", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamIntToStringToFloatImpl(std::vector const& values) { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.resize(values.size()); + for (size_t i = 0; i < values.size(); i++) { + int32_t item = {}; + try { + item = std::stoi(values[i]); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + values[i] + "\" to number"); + } + stream_int_to_string_to_float[i] = item; + } + yardl::binary::WriteVectorAndSaveOffsets(stream_, stream_int_to_string_to_float, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("StreamIntToStringToFloat", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamIntToStringToFloatImpl() { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + step_index_.add_stream_offsets("StreamIntToStringToFloat", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteVectorIntToStringToFloatImpl(std::vector const& value) { + step_index_.set_step_offset("VectorIntToStringToFloat", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::vector vector_int_to_string_to_float = {}; + vector_int_to_string_to_float.resize(value.size()); + for (size_t i = 0; i < value.size(); i++) { + int32_t item = {}; + try { + item = std::stoi(value[i]); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value[i] + "\" to number"); + } + vector_int_to_string_to_float[i] = item; + } + yardl::binary::WriteVector(stream_, vector_int_to_string_to_float); + break; + } + default: + yardl::binary::WriteVector(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntFloatUnionReorderedImpl(std::variant const& value) { + step_index_.set_step_offset("IntFloatUnionReordered", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant int_float_union_reordered = {}; + switch (value.index()) { + case 0: { + int_float_union_reordered = std::get<0>(value); + break; + } + case 1: { + int_float_union_reordered = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, int_float_union_reordered); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteVectorUnionReorderedImpl(std::vector> const& value) { + step_index_.set_step_offset("VectorUnionReordered", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::vector> vector_union_reordered = {}; + vector_union_reordered.resize(value.size()); + for (size_t i = 0; i < value.size(); i++) { + std::variant item = {}; + switch (value[i].index()) { + case 0: { + item = std::get<0>(value[i]); + break; + } + case 1: { + item = std::get<1>(value[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + vector_union_reordered[i] = item; + } + yardl::binary::WriteVector, WriteUnion>(stream_, vector_union_reordered); + break; + } + default: + yardl::binary::WriteVector, WriteUnion>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStreamUnionReorderedImpl(std::variant const& value) { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + std::variant stream_union_reordered = {}; + switch (value.index()) { + case 0: { + stream_union_reordered = std::get<0>(value); + break; + } + case 1: { + stream_union_reordered = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, stream_union_reordered, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("StreamUnionReordered", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamUnionReorderedImpl(std::vector> const& values) { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + std::vector> stream_union_reordered = {}; + stream_union_reordered.resize(values.size()); + for (size_t i = 0; i < values.size(); i++) { + std::variant item = {}; + switch (values[i].index()) { + case 0: { + item = std::get<0>(values[i]); + break; + } + case 1: { + item = std::get<1>(values[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + stream_union_reordered[i] = item; + } + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, stream_union_reordered, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("StreamUnionReordered", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamUnionReorderedImpl() { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + step_index_.add_stream_offsets("StreamUnionReordered", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUnionStreamImpl(int32_t const& value) { + step_index_.set_step_offset("IntToUnionStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("IntToUnionStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUnionStreamImpl(std::vector const& values) { + step_index_.set_step_offset("IntToUnionStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("IntToUnionStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndIntToUnionStreamImpl() { + step_index_.set_step_offset("IntToUnionStream", stream_.Pos()); + step_index_.add_stream_offsets("IntToUnionStream", std::vector{}); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionStreamTypeChangeImpl(std::variant const& value) { + step_index_.set_step_offset("UnionStreamTypeChange", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("UnionStreamTypeChange", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteUnionStreamTypeChangeImpl(std::vector> const& values) { + step_index_.set_step_offset("UnionStreamTypeChange", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("UnionStreamTypeChange", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndUnionStreamTypeChangeImpl() { + step_index_.set_step_offset("UnionStreamTypeChange", stream_.Pos()); + step_index_.add_stream_offsets("UnionStreamTypeChange", std::vector{}); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStreamOfAliasTypeChangeImpl(evo_test::StreamItem const& value) { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("StreamOfAliasTypeChange", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamOfAliasTypeChangeImpl(std::vector const& values) { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("StreamOfAliasTypeChange", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamOfAliasTypeChangeImpl() { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + step_index_.add_stream_offsets("StreamOfAliasTypeChange", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("Rlink", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRXImpl(evo_test::RX const& value) { + step_index_.set_step_offset("RlinkRX", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRX(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRYImpl(evo_test::RY const& value) { + step_index_.set_step_offset("RlinkRY", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRY(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRZImpl(evo_test::RZ const& value) { + step_index_.set_step_offset("RlinkRZ", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRZ(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRLinkImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RaRLink", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRA_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRXImpl(evo_test::RX const& value) { + step_index_.set_step_offset("RaRX", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRA_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRX(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRYImpl(evo_test::RY const& value) { + step_index_.set_step_offset("RaRY", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRA_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRY(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRZImpl(evo_test::RZ const& value) { + step_index_.set_step_offset("RaRZ", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRA_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRZ(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRLinkImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RbRLink", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRB_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRXImpl(evo_test::RX const& value) { + step_index_.set_step_offset("RbRX", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRB_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRX(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRYImpl(evo_test::RY const& value) { + step_index_.set_step_offset("RbRY", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRB_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRY(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRZImpl(evo_test::RZ const& value) { + step_index_.set_step_offset("RbRZ", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRB_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRZ(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRLinkImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RcRLink", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRC_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRXImpl(evo_test::RX const& value) { + step_index_.set_step_offset("RcRX", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRC_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRX(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRYImpl(evo_test::RY const& value) { + step_index_.set_step_offset("RcRY", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRC_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRY(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRZImpl(evo_test::RZ const& value) { + step_index_.set_step_offset("RcRZ", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRC_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRZ(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRNewImpl(evo_test::RNew const& value) { + step_index_.set_step_offset("RlinkRNew", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRNew(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRNewImpl(evo_test::RNew const& value) { + step_index_.set_step_offset("RaRNew", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRA_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRNew(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRNewImpl(evo_test::RNew const& value) { + step_index_.set_step_offset("RbRNew", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRB_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRNew(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRNewImpl(evo_test::RNew const& value) { + step_index_.set_step_offset("RcRNew", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRC_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteRNew(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRUnionImpl(evo_test::RUnion const& value) { + step_index_.set_step_offset("RlinkRUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::RC_v0 rlink_r_union = {}; + if (value.index() == 0) { + rlink_r_union = std::get<0>(value); + } + evo_test::binary::WriteRC_v0(stream_, rlink_r_union); + break; + } + default: + evo_test::binary::WriteRUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRUnionImpl(evo_test::RUnion const& value) { + step_index_.set_step_offset("RaRUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::RC_v0 ra_r_union = {}; + if (value.index() == 0) { + ra_r_union = std::get<0>(value); + } + evo_test::binary::WriteRC_v0(stream_, ra_r_union); + break; + } + default: + evo_test::binary::WriteRUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRUnionImpl(evo_test::RUnion const& value) { + step_index_.set_step_offset("RbRUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::RC_v0 rb_r_union = {}; + if (value.index() == 0) { + rb_r_union = std::get<0>(value); + } + evo_test::binary::WriteRC_v0(stream_, rb_r_union); + break; + } + default: + evo_test::binary::WriteRUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRUnionImpl(evo_test::RUnion const& value) { + step_index_.set_step_offset("RcRUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::RC_v0 rc_r_union = {}; + if (value.index() == 0) { + rc_r_union = std::get<0>(value); + } + evo_test::binary::WriteRC_v0(stream_, rc_r_union); + break; + } + default: + evo_test::binary::WriteRUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalRecordWithChangesImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteOptional(stream_, value); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedOptionalRecordWithChangesImpl(std::optional const& value) { + step_index_.set_step_offset("AliasedOptionalRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteOptional(stream_, value); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionRecordWithChangesImpl(std::variant const& value) { + step_index_.set_step_offset("UnionRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_record_with_changes = {}; + switch (value.index()) { + case 0: { + union_record_with_changes = std::get<0>(value); + break; + } + case 1: { + union_record_with_changes = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_record_with_changes); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithSameTypesetImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithSameTypeset", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_with_same_typeset = {}; + switch (value.index()) { + case 0: { + union_with_same_typeset = std::get<0>(value); + break; + } + case 1: { + union_with_same_typeset = std::get<1>(value); + break; + } + case 2: { + union_with_same_typeset = std::get<2>(value); + break; + } + case 3: { + union_with_same_typeset = std::get<3>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_same_typeset); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithTypesAddedImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithTypesAdded", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_with_types_added = {}; + switch (value.index()) { + case 0: { + union_with_types_added = std::get<0>(value); + break; + } + case 1: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32", "float32", "string"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'RecordWithChanges: RecordWithChanges_v0 | float32'"); + break; + } + case 2: { + union_with_types_added = std::get<2>(value); + break; + } + case 3: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32", "float32", "string"}; + throw std::runtime_error("Source type '" + source_types[3] + "' incompatible with target union type 'RecordWithChanges: RecordWithChanges_v0 | float32'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_types_added); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithTypesRemovedImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithTypesRemoved", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_with_types_removed = {}; + switch (value.index()) { + case 0: { + union_with_types_removed = std::get<0>(value); + break; + } + case 1: { + union_with_types_removed = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_types_removed); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToOptionalImpl(std::optional const& value) { + step_index_.set_step_offset("RecordToOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges_v0 record_to_optional = {}; + if (value.has_value()) { + record_to_optional = value.value(); + } + evo_test::binary::WriteRecordWithChanges_v0(stream_, record_to_optional); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedOptionalImpl(evo_test::AliasedOptionalRecord const& value) { + step_index_.set_step_offset("RecordToAliasedOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges_v0 record_to_aliased_optional = {}; + if (value.has_value()) { + record_to_aliased_optional = value.value(); + } + evo_test::binary::WriteRecordWithChanges_v0(stream_, record_to_aliased_optional); + break; + } + default: + evo_test::binary::WriteAliasedOptionalRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToUnionImpl(std::variant const& value) { + step_index_.set_step_offset("RecordToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges_v0 record_to_union = {}; + if (value.index() == 0) { + record_to_union = std::get<0>(value); + } + evo_test::binary::WriteRecordWithChanges_v0(stream_, record_to_union); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedUnionImpl(evo_test::AliasedRecordOrString const& value) { + step_index_.set_step_offset("RecordToAliasedUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges_v0 record_to_aliased_union = {}; + if (value.index() == 0) { + record_to_aliased_union = std::get<0>(value); + } + evo_test::binary::WriteRecordWithChanges_v0(stream_, record_to_aliased_union); + break; + } + default: + evo_test::binary::WriteAliasedRecordOrString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionToAliasedUnionImpl(evo_test::AliasedRecordOrInt const& value) { + step_index_.set_step_offset("UnionToAliasedUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_to_aliased_union = {}; + switch (value.index()) { + case 0: { + union_to_aliased_union = std::get<0>(value); + break; + } + case 1: { + union_to_aliased_union = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_to_aliased_union); + break; + } + default: + evo_test::binary::WriteAliasedRecordOrInt(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionToAliasedUnionWithChangesImpl(evo_test::AliasedRecordOrString const& value) { + step_index_.set_step_offset("UnionToAliasedUnionWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_to_aliased_union_with_changes = {}; + switch (value.index()) { + case 0: { + union_to_aliased_union_with_changes = std::get<0>(value); + break; + } + case 1: { + std::vector source_types = {"EvoTest.RecordWithChanges", "string"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'RecordWithChanges: RecordWithChanges_v0 | int32'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_to_aliased_union_with_changes); + break; + } + default: + evo_test::binary::WriteAliasedRecordOrString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalToAliasedOptionalImpl(evo_test::AliasedOptionalRecord const& value) { + step_index_.set_step_offset("OptionalToAliasedOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteOptional(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedOptionalRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalToAliasedOptionalWithChangesImpl(evo_test::AliasedOptionalString const& value) { + step_index_.set_step_offset("OptionalToAliasedOptionalWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::optional optional_to_aliased_optional_with_changes = {}; + if (value.has_value()) { + try { + optional_to_aliased_optional_with_changes = std::stoi(value.value()); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value.value() + "\" to number"); + } + } + yardl::binary::WriteOptional(stream_, optional_to_aliased_optional_with_changes); + break; + } + default: + evo_test::binary::WriteAliasedOptionalString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecord", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToOpenAliasImpl(evo_test::AliasedOpenGenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToOpenAlias", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedOpenGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToClosedAliasImpl(evo_test::AliasedClosedGenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToClosedAlias", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedClosedGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToHalfClosedAliasImpl(evo_test::AliasedHalfClosedGenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToHalfClosedAlias", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedHalfClosedGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedGenericRecordToAliasImpl(evo_test::AliasedOpenGenericRecord const& value) { + step_index_.set_step_offset("AliasedGenericRecordToAlias", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteAliasedHalfClosedGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedOpenGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToReversedImpl(evo_test::GenericRecordReversed const& value) { + step_index_.set_step_offset("GenericRecordToReversed", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecordReversed(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteClosedGenericRecordToUnionImpl(std::variant, std::string> const& value) { + step_index_.set_step_offset("ClosedGenericRecordToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::GenericRecord_v0 closed_generic_record_to_union = {}; + if (value.index() == 0) { + closed_generic_record_to_union = std::get<0>(value); + } + evo_test::binary::WriteGenericRecord_v0(stream_, closed_generic_record_to_union); + break; + } + default: + WriteUnion, evo_test::binary::WriteGenericRecord, std::string, yardl::binary::WriteString>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToAliasedUnionImpl(evo_test::AliasedGenericRecordOrString const& value) { + step_index_.set_step_offset("GenericRecordToAliasedUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::GenericRecord_v0 generic_record_to_aliased_union = {}; + if (value.index() == 0) { + generic_record_to_aliased_union = std::get<0>(value); + } + evo_test::binary::WriteGenericRecord_v0(stream_, generic_record_to_aliased_union); + break; + } + default: + evo_test::binary::WriteAliasedGenericRecordOrString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericUnionToReversedImpl(evo_test::GenericUnionReversed> const& value) { + step_index_.set_step_offset("GenericUnionToReversed", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant, float> generic_union_to_reversed = {}; + switch (value.index()) { + case 0: { + generic_union_to_reversed = std::get<0>(value); + break; + } + case 1: { + generic_union_to_reversed = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion, evo_test::binary::WriteGenericRecord_v0, float, yardl::binary::WriteFloatingPoint>(stream_, generic_union_to_reversed); + break; + } + default: + evo_test::binary::WriteGenericUnionReversed, evo_test::binary::WriteGenericRecord>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericUnionOfChangedRecordImpl(evo_test::GenericUnion, float> const& value) { + step_index_.set_step_offset("GenericUnionOfChangedRecord", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteAliasedClosedGenericUnion_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericUnion, evo_test::binary::WriteGenericRecord, float, yardl::binary::WriteFloatingPoint>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordImpl(evo_test::GenericParentRecord const& value) { + step_index_.set_step_offset("GenericParentRecord", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteGenericParentRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericParentRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericNestedRecordsImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericNestedRecords", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteGenericRecord_v0, evo_test::binary::WriteUnchangedGeneric_v0, evo_test::ChangedGeneric_v0, evo_test::binary::WriteChangedGeneric_v0>(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordStreamImpl(evo_test::AliasedClosedGenericRecord const& value) { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + yardl::binary::WriteBlockAndSaveOffset, evo_test::binary::WriteGenericRecord_v0>(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("GenericRecordStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordStreamImpl(std::vector const& values) { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + yardl::binary::WriteVectorAndSaveOffsets, evo_test::binary::WriteGenericRecord_v0>(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("GenericRecordStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndGenericRecordStreamImpl() { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + step_index_.add_stream_offsets("GenericRecordStream", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordStreamImpl(evo_test::GenericParentRecord const& value) { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + yardl::binary::WriteBlockAndSaveOffset, evo_test::binary::WriteGenericParentRecord_v0>(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, evo_test::binary::WriteGenericParentRecord>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("GenericParentRecordStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordStreamImpl(std::vector> const& values) { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + yardl::binary::WriteVectorAndSaveOffsets, evo_test::binary::WriteGenericParentRecord_v0>(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, evo_test::binary::WriteGenericParentRecord>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("GenericParentRecordStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndGenericParentRecordStreamImpl() { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + step_index_.add_stream_offsets("GenericParentRecordStream", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteVectorRecordWithChangesImpl(std::vector const& value) { + step_index_.set_step_offset("VectorRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteVector(stream_, value); + break; + } + default: + yardl::binary::WriteVector(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStreamedRecordWithChangesImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("StreamedRecordWithChanges", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamedRecordWithChangesImpl(std::vector const& values) { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("StreamedRecordWithChanges", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamedRecordWithChangesImpl() { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + step_index_.add_stream_offsets("StreamedRecordWithChanges", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedOptionalImpl(std::optional const& value) { + step_index_.set_step_offset("AddedOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedMapImpl(std::unordered_map const& value) { + step_index_.set_step_offset("AddedMap", stream_.Pos()); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteMap(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedRecordStreamImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("AddedRecordStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("AddedRecordStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteAddedRecordStreamImpl(std::vector const& values) { + step_index_.set_step_offset("AddedRecordStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("AddedRecordStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndAddedRecordStreamImpl() { + step_index_.set_step_offset("AddedRecordStream", stream_.Pos()); + step_index_.add_stream_offsets("AddedRecordStream", std::vector{}); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::Flush() { + stream_.Flush(); +} + +void ProtocolWithChangesIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToIntImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("Int8ToInt"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int8_t int8_to_int = {}; + yardl::binary::ReadInteger(stream_, int8_to_int); + value = static_cast(int8_to_int); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToLongImpl(int64_t& value) { + auto pos = step_index_.get_step_offset("Int8ToLong"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int8_t int8_to_long = {}; + yardl::binary::ReadInteger(stream_, int8_to_long); + value = static_cast(int8_to_long); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToUintImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("Int8ToUint"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int8_t int8_to_uint = {}; + yardl::binary::ReadInteger(stream_, int8_to_uint); + if (int8_to_uint < 0) { + throw std::runtime_error("Numeric overflow detected while converting 'int8' to 'uint32'"); + } + value = static_cast(int8_to_uint); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToUlongImpl(uint64_t& value) { + auto pos = step_index_.get_step_offset("Int8ToUlong"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int8_t int8_to_ulong = {}; + yardl::binary::ReadInteger(stream_, int8_to_ulong); + if (int8_to_ulong < 0) { + throw std::runtime_error("Numeric overflow detected while converting 'int8' to 'uint64'"); + } + value = static_cast(int8_to_ulong); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToFloatImpl(float& value) { + auto pos = step_index_.get_step_offset("Int8ToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int8_t int8_to_float = {}; + yardl::binary::ReadInteger(stream_, int8_to_float); + value = static_cast(int8_to_float); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToDoubleImpl(double& value) { + auto pos = step_index_.get_step_offset("Int8ToDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int8_t int8_to_double = {}; + yardl::binary::ReadInteger(stream_, int8_to_double); + value = static_cast(int8_to_double); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToUintImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("IntToUint"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int32_t int_to_uint = {}; + yardl::binary::ReadInteger(stream_, int_to_uint); + if (int_to_uint < 0) { + throw std::runtime_error("Numeric overflow detected while converting 'int32' to 'uint32'"); + } + value = static_cast(int_to_uint); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToLongImpl(int64_t& value) { + auto pos = step_index_.get_step_offset("IntToLong"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int32_t int_to_long = {}; + yardl::binary::ReadInteger(stream_, int_to_long); + value = static_cast(int_to_long); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToFloatImpl(float& value) { + auto pos = step_index_.get_step_offset("IntToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int32_t int_to_float = {}; + yardl::binary::ReadInteger(stream_, int_to_float); + value = static_cast(int_to_float); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToDoubleImpl(double& value) { + auto pos = step_index_.get_step_offset("IntToDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int32_t int_to_double = {}; + yardl::binary::ReadInteger(stream_, int_to_double); + value = static_cast(int_to_double); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUintToUlongImpl(uint64_t& value) { + auto pos = step_index_.get_step_offset("UintToUlong"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + uint32_t uint_to_ulong = {}; + yardl::binary::ReadInteger(stream_, uint_to_ulong); + value = static_cast(uint_to_ulong); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUintToFloatImpl(float& value) { + auto pos = step_index_.get_step_offset("UintToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + uint32_t uint_to_float = {}; + yardl::binary::ReadInteger(stream_, uint_to_float); + value = static_cast(uint_to_float); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUintToDoubleImpl(double& value) { + auto pos = step_index_.get_step_offset("UintToDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + uint32_t uint_to_double = {}; + yardl::binary::ReadInteger(stream_, uint_to_double); + value = static_cast(uint_to_double); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadFloatToDoubleImpl(double& value) { + auto pos = step_index_.get_step_offset("FloatToDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + float float_to_double = {}; + yardl::binary::ReadFloatingPoint(stream_, float_to_double); + value = static_cast(float_to_double); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadComplexFloatToComplexDoubleImpl(std::complex& value) { + auto pos = step_index_.get_step_offset("ComplexFloatToComplexDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::complex complex_float_to_complex_double = {}; + yardl::binary::ReadFloatingPoint(stream_, complex_float_to_complex_double); + value = std::complex(complex_float_to_complex_double); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("IntToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int32_t int_to_string = {}; + yardl::binary::ReadInteger(stream_, int_to_string); + value = std::to_string(int_to_string); + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUintToStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("UintToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + uint32_t uint_to_string = {}; + yardl::binary::ReadInteger(stream_, uint_to_string); + value = std::to_string(uint_to_string); + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadLongToStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("LongToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int64_t long_to_string = {}; + yardl::binary::ReadInteger(stream_, long_to_string); + value = std::to_string(long_to_string); + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUlongToStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("UlongToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + uint64_t ulong_to_string = {}; + yardl::binary::ReadInteger(stream_, ulong_to_string); + value = std::to_string(ulong_to_string); + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadFloatToStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("FloatToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + float float_to_string = {}; + yardl::binary::ReadFloatingPoint(stream_, float_to_string); + value = std::to_string(float_to_string); + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadDoubleToStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("DoubleToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + double double_to_string = {}; + yardl::binary::ReadFloatingPoint(stream_, double_to_string); + value = std::to_string(double_to_string); + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToOptionalImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("IntToOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int32_t int_to_optional = {}; + yardl::binary::ReadInteger(stream_, int_to_optional); + value = int_to_optional; + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadFloatToOptionalImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("FloatToOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + float float_to_optional = {}; + yardl::binary::ReadFloatingPoint(stream_, float_to_optional); + value = float_to_optional; + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadStringToOptionalImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("StringToOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::string string_to_optional = {}; + yardl::binary::ReadString(stream_, string_to_optional); + value = string_to_optional; + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("IntToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + int32_t int_to_union = {}; + yardl::binary::ReadInteger(stream_, int_to_union); + value = int_to_union; + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadFloatToUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("FloatToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + float float_to_union = {}; + yardl::binary::ReadFloatingPoint(stream_, float_to_union); + value = float_to_union; + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadStringToUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("StringToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::string string_to_union = {}; + yardl::binary::ReadString(stream_, string_to_union); + value = string_to_union; + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalIntToFloatImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalIntToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::optional optional_int_to_float = {}; + yardl::binary::ReadOptional(stream_, optional_int_to_float); + if (optional_int_to_float.has_value()) { + value = static_cast(optional_int_to_float.value()); + } + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalFloatToStringImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalFloatToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::optional optional_float_to_string = {}; + yardl::binary::ReadOptional(stream_, optional_float_to_string); + if (optional_float_to_string.has_value()) { + value = std::to_string(optional_float_to_string.value()); + } + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAliasedLongToStringImpl(evo_test::AliasedLongToString& value) { + auto pos = step_index_.get_step_offset("AliasedLongToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadAliasedLongToString_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedLongToString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadStringToAliasedStringImpl(evo_test::AliasedString& value) { + auto pos = step_index_.get_step_offset("StringToAliasedString"); + stream_.Seek(pos); + evo_test::binary::ReadAliasedString(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadStringToAliasedIntImpl(evo_test::AliasedInt& value) { + auto pos = step_index_.get_step_offset("StringToAliasedInt"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::string string_to_aliased_int = {}; + yardl::binary::ReadString(stream_, string_to_aliased_int); + try { + value = std::stoi(string_to_aliased_int); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + string_to_aliased_int + "\" to number"); + } + break; + } + default: + evo_test::binary::ReadAliasedInt(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadEnumToAliasedEnumImpl(evo_test::AliasedEnum& value) { + auto pos = step_index_.get_step_offset("EnumToAliasedEnum"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadEnum(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedEnum(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalIntToUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("OptionalIntToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::optional optional_int_to_union = {}; + yardl::binary::ReadOptional(stream_, optional_int_to_union); + if (optional_int_to_union.has_value()) { + value = optional_int_to_union.value(); + } else { + value = std::monostate{}; + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalRecordToUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("OptionalRecordToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::optional optional_record_to_union = {}; + yardl::binary::ReadOptional(stream_, optional_record_to_union); + if (optional_record_to_union.has_value()) { + value = optional_record_to_union.value(); + } else { + value = std::monostate{}; + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordWithChangesImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges& value) { + auto pos = step_index_.get_step_offset("AliasedRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadAliasedRecordWithChanges_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToRenamedRecordImpl(evo_test::RenamedRecord& value) { + auto pos = step_index_.get_step_offset("RecordToRenamedRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRenamedRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRenamedRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedRecordImpl(evo_test::AliasedRecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedAliasImpl(evo_test::AliasOfAliasedRecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasOfAliasedRecordWithChanges(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(std::string& value) { + if (!step_index_.offset_within_stream("StreamIntToStringToFloat", "VectorIntToStringToFloat", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamIntToStringToFloat")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + int32_t stream_int_to_string_to_float = {}; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, stream_int_to_string_to_float); + if (read_block_successful) { + value = std::to_string(stream_int_to_string_to_float); + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamIntToStringToFloat", "VectorIntToStringToFloat", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamIntToStringToFloat")); + } + switch (version_) { + case Version::v0: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, stream_int_to_string_to_float); + values.resize(stream_int_to_string_to_float.size()); + for (size_t i = 0; i < stream_int_to_string_to_float.size(); i++) { + std::string item = {}; + item = std::to_string(stream_int_to_string_to_float[i]); + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(std::string& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamIntToStringToFloat", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + int32_t stream_int_to_string_to_float = {}; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, stream_int_to_string_to_float); + if (read_block_successful) { + value = std::to_string(stream_int_to_string_to_float); + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamIntToStringToFloat", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, stream_int_to_string_to_float); + values.resize(stream_int_to_string_to_float.size()); + for (size_t i = 0; i < stream_int_to_string_to_float.size(); i++) { + std::string item = {}; + item = std::to_string(stream_int_to_string_to_float[i]); + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamIntToStringToFloatImpl() { + return step_index_.get_stream_count("StreamIntToStringToFloat"); +} + +void ProtocolWithChangesIndexedReader::ReadVectorIntToStringToFloatImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("VectorIntToStringToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::vector vector_int_to_string_to_float = {}; + yardl::binary::ReadVector(stream_, vector_int_to_string_to_float); + value.resize(vector_int_to_string_to_float.size()); + for (size_t i = 0; i < vector_int_to_string_to_float.size(); i++) { + std::string item = {}; + item = std::to_string(vector_int_to_string_to_float[i]); + value[i] = item; + } + break; + } + default: + yardl::binary::ReadVector(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntFloatUnionReorderedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("IntFloatUnionReordered"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant int_float_union_reordered = {}; + ReadUnion(stream_, int_float_union_reordered); + switch (int_float_union_reordered.index()) { + case 0: { + value = std::get<0>(int_float_union_reordered); + break; + } + case 1: { + value = std::get<1>(int_float_union_reordered); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadVectorUnionReorderedImpl(std::vector>& value) { + auto pos = step_index_.get_step_offset("VectorUnionReordered"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::vector> vector_union_reordered = {}; + yardl::binary::ReadVector, ReadUnion>(stream_, vector_union_reordered); + value.resize(vector_union_reordered.size()); + for (size_t i = 0; i < vector_union_reordered.size(); i++) { + std::variant item = {}; + switch (vector_union_reordered[i].index()) { + case 0: { + item = std::get<0>(vector_union_reordered[i]); + break; + } + case 1: { + item = std::get<1>(vector_union_reordered[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + value[i] = item; + } + break; + } + default: + yardl::binary::ReadVector, ReadUnion>(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::variant& value) { + if (!step_index_.offset_within_stream("StreamUnionReordered", "IntToUnionStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamUnionReordered")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant stream_union_reordered = {}; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, stream_union_reordered); + if (read_block_successful) { + switch (stream_union_reordered.index()) { + case 0: { + value = std::get<0>(stream_union_reordered); + break; + } + case 1: { + value = std::get<1>(stream_union_reordered); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("StreamUnionReordered", "IntToUnionStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamUnionReordered")); + } + switch (version_) { + case Version::v0: { + std::vector> stream_union_reordered = {}; + stream_union_reordered.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, stream_union_reordered); + values.resize(stream_union_reordered.size()); + for (size_t i = 0; i < stream_union_reordered.size(); i++) { + std::variant item = {}; + switch (stream_union_reordered[i].index()) { + case 0: { + item = std::get<0>(stream_union_reordered[i]); + break; + } + case 1: { + item = std::get<1>(stream_union_reordered[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamUnionReordered", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant stream_union_reordered = {}; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, stream_union_reordered); + if (read_block_successful) { + switch (stream_union_reordered.index()) { + case 0: { + value = std::get<0>(stream_union_reordered); + break; + } + case 1: { + value = std::get<1>(stream_union_reordered); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamUnionReordered", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + std::vector> stream_union_reordered = {}; + stream_union_reordered.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, stream_union_reordered); + values.resize(stream_union_reordered.size()); + for (size_t i = 0; i < stream_union_reordered.size(); i++) { + std::variant item = {}; + switch (stream_union_reordered[i].index()) { + case 0: { + item = std::get<0>(stream_union_reordered[i]); + break; + } + case 1: { + item = std::get<1>(stream_union_reordered[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamUnionReorderedImpl() { + return step_index_.get_stream_count("StreamUnionReordered"); +} + +bool ProtocolWithChangesIndexedReader::ReadIntToUnionStreamImpl(int32_t& value) { + if (!step_index_.offset_within_stream("IntToUnionStream", "UnionStreamTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntToUnionStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + int32_t int_to_union_stream = {}; + value = std::move(int_to_union_stream); + return false; + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadIntToUnionStreamImpl(std::vector& values) { + if (!step_index_.offset_within_stream("IntToUnionStream", "UnionStreamTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntToUnionStream")); + } + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadIntToUnionStreamImpl(int32_t& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntToUnionStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + int32_t int_to_union_stream = {}; + value = std::move(int_to_union_stream); + return false; + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadIntToUnionStreamImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntToUnionStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountIntToUnionStreamImpl() { + return step_index_.get_stream_count("IntToUnionStream"); +} + +bool ProtocolWithChangesIndexedReader::ReadUnionStreamTypeChangeImpl(std::variant& value) { + if (!step_index_.offset_within_stream("UnionStreamTypeChange", "StreamOfAliasTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("UnionStreamTypeChange")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant union_stream_type_change = {}; + value = std::move(union_stream_type_change); + return false; + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadUnionStreamTypeChangeImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("UnionStreamTypeChange", "StreamOfAliasTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("UnionStreamTypeChange")); + } + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadUnionStreamTypeChangeImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("UnionStreamTypeChange", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant union_stream_type_change = {}; + value = std::move(union_stream_type_change); + return false; + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadUnionStreamTypeChangeImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("UnionStreamTypeChange", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountUnionStreamTypeChangeImpl() { + return step_index_.get_stream_count("UnionStreamTypeChange"); +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value) { + if (!step_index_.offset_within_stream("StreamOfAliasTypeChange", "Rlink", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfAliasTypeChange")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamOfAliasTypeChange", "Rlink", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfAliasTypeChange")); + } + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfAliasTypeChange", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfAliasTypeChange", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamOfAliasTypeChangeImpl() { + return step_index_.get_stream_count("StreamOfAliasTypeChange"); +} + +void ProtocolWithChangesIndexedReader::ReadRlinkImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("Rlink"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRXImpl(evo_test::RX& value) { + auto pos = step_index_.get_step_offset("RlinkRX"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRX(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRYImpl(evo_test::RY& value) { + auto pos = step_index_.get_step_offset("RlinkRY"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRY(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRZImpl(evo_test::RZ& value) { + auto pos = step_index_.get_step_offset("RlinkRZ"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRZ(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRLinkImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RaRLink"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRA_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRXImpl(evo_test::RX& value) { + auto pos = step_index_.get_step_offset("RaRX"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRA_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRX(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRYImpl(evo_test::RY& value) { + auto pos = step_index_.get_step_offset("RaRY"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRA_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRY(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRZImpl(evo_test::RZ& value) { + auto pos = step_index_.get_step_offset("RaRZ"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRA_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRZ(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRLinkImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RbRLink"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRB_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRXImpl(evo_test::RX& value) { + auto pos = step_index_.get_step_offset("RbRX"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRB_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRX(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRYImpl(evo_test::RY& value) { + auto pos = step_index_.get_step_offset("RbRY"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRB_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRY(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRZImpl(evo_test::RZ& value) { + auto pos = step_index_.get_step_offset("RbRZ"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRB_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRZ(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRLinkImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RcRLink"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRC_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRXImpl(evo_test::RX& value) { + auto pos = step_index_.get_step_offset("RcRX"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRC_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRX(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRYImpl(evo_test::RY& value) { + auto pos = step_index_.get_step_offset("RcRY"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRC_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRY(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRZImpl(evo_test::RZ& value) { + auto pos = step_index_.get_step_offset("RcRZ"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRC_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRZ(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRNewImpl(evo_test::RNew& value) { + auto pos = step_index_.get_step_offset("RlinkRNew"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRLink_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRNew(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRNewImpl(evo_test::RNew& value) { + auto pos = step_index_.get_step_offset("RaRNew"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRA_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRNew(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRNewImpl(evo_test::RNew& value) { + auto pos = step_index_.get_step_offset("RbRNew"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRB_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRNew(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRNewImpl(evo_test::RNew& value) { + auto pos = step_index_.get_step_offset("RcRNew"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRC_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadRNew(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRUnionImpl(evo_test::RUnion& value) { + auto pos = step_index_.get_step_offset("RlinkRUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::RC_v0 rlink_r_union = {}; + evo_test::binary::ReadRC_v0(stream_, rlink_r_union); + value = rlink_r_union; + break; + } + default: + evo_test::binary::ReadRUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRUnionImpl(evo_test::RUnion& value) { + auto pos = step_index_.get_step_offset("RaRUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::RC_v0 ra_r_union = {}; + evo_test::binary::ReadRC_v0(stream_, ra_r_union); + value = ra_r_union; + break; + } + default: + evo_test::binary::ReadRUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRUnionImpl(evo_test::RUnion& value) { + auto pos = step_index_.get_step_offset("RbRUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::RC_v0 rb_r_union = {}; + evo_test::binary::ReadRC_v0(stream_, rb_r_union); + value = rb_r_union; + break; + } + default: + evo_test::binary::ReadRUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRUnionImpl(evo_test::RUnion& value) { + auto pos = step_index_.get_step_offset("RcRUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::RC_v0 rc_r_union = {}; + evo_test::binary::ReadRC_v0(stream_, rc_r_union); + value = rc_r_union; + break; + } + default: + evo_test::binary::ReadRUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalRecordWithChangesImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadOptional(stream_, value); + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAliasedOptionalRecordWithChangesImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("AliasedOptionalRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadOptional(stream_, value); + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionRecordWithChangesImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_record_with_changes = {}; + ReadUnion(stream_, union_record_with_changes); + switch (union_record_with_changes.index()) { + case 0: { + value = std::get<0>(union_record_with_changes); + break; + } + case 1: { + value = std::get<1>(union_record_with_changes); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithSameTypesetImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithSameTypeset"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_with_same_typeset = {}; + ReadUnion(stream_, union_with_same_typeset); + switch (union_with_same_typeset.index()) { + case 0: { + value = std::get<0>(union_with_same_typeset); + break; + } + case 1: { + value = std::get<1>(union_with_same_typeset); + break; + } + case 2: { + value = std::get<2>(union_with_same_typeset); + break; + } + case 3: { + value = std::get<3>(union_with_same_typeset); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithTypesAddedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithTypesAdded"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_with_types_added = {}; + ReadUnion(stream_, union_with_types_added); + switch (union_with_types_added.index()) { + case 0: { + value = std::get<0>(union_with_types_added); + break; + } + case 1: { + value = std::get<1>(union_with_types_added); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithTypesRemovedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithTypesRemoved"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_with_types_removed = {}; + ReadUnion(stream_, union_with_types_removed); + switch (union_with_types_removed.index()) { + case 0: { + value = std::get<0>(union_with_types_removed); + break; + } + case 1: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32", "float32", "string"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'RecordWithChanges | string'"); + break; + } + case 2: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32", "float32", "string"}; + throw std::runtime_error("Source type '" + source_types[2] + "' incompatible with target union type 'RecordWithChanges | string'"); + break; + } + case 3: { + value = std::get<3>(union_with_types_removed); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToOptionalImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("RecordToOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges_v0 record_to_optional = {}; + evo_test::binary::ReadRecordWithChanges_v0(stream_, record_to_optional); + value = record_to_optional; + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedOptionalImpl(evo_test::AliasedOptionalRecord& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges_v0 record_to_aliased_optional = {}; + evo_test::binary::ReadRecordWithChanges_v0(stream_, record_to_aliased_optional); + value = record_to_aliased_optional; + break; + } + default: + evo_test::binary::ReadAliasedOptionalRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("RecordToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges_v0 record_to_union = {}; + evo_test::binary::ReadRecordWithChanges_v0(stream_, record_to_union); + value = record_to_union; + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedUnionImpl(evo_test::AliasedRecordOrString& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges_v0 record_to_aliased_union = {}; + evo_test::binary::ReadRecordWithChanges_v0(stream_, record_to_aliased_union); + value = record_to_aliased_union; + break; + } + default: + evo_test::binary::ReadAliasedRecordOrString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionToAliasedUnionImpl(evo_test::AliasedRecordOrInt& value) { + auto pos = step_index_.get_step_offset("UnionToAliasedUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_to_aliased_union = {}; + ReadUnion(stream_, union_to_aliased_union); + switch (union_to_aliased_union.index()) { + case 0: { + value = std::get<0>(union_to_aliased_union); + break; + } + case 1: { + value = std::get<1>(union_to_aliased_union); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + evo_test::binary::ReadAliasedRecordOrInt(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionToAliasedUnionWithChangesImpl(evo_test::AliasedRecordOrString& value) { + auto pos = step_index_.get_step_offset("UnionToAliasedUnionWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_to_aliased_union_with_changes = {}; + ReadUnion(stream_, union_to_aliased_union_with_changes); + switch (union_to_aliased_union_with_changes.index()) { + case 0: { + value = std::get<0>(union_to_aliased_union_with_changes); + break; + } + case 1: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'RecordWithChanges | string'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + evo_test::binary::ReadAliasedRecordOrString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalToAliasedOptionalImpl(evo_test::AliasedOptionalRecord& value) { + auto pos = step_index_.get_step_offset("OptionalToAliasedOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadOptional(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedOptionalRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalToAliasedOptionalWithChangesImpl(evo_test::AliasedOptionalString& value) { + auto pos = step_index_.get_step_offset("OptionalToAliasedOptionalWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::optional optional_to_aliased_optional_with_changes = {}; + yardl::binary::ReadOptional(stream_, optional_to_aliased_optional_with_changes); + if (optional_to_aliased_optional_with_changes.has_value()) { + value = std::to_string(optional_to_aliased_optional_with_changes.value()); + } + break; + } + default: + evo_test::binary::ReadAliasedOptionalString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToOpenAliasImpl(evo_test::AliasedOpenGenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToOpenAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedOpenGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToClosedAliasImpl(evo_test::AliasedClosedGenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToClosedAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedClosedGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToHalfClosedAliasImpl(evo_test::AliasedHalfClosedGenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToHalfClosedAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedHalfClosedGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAliasedGenericRecordToAliasImpl(evo_test::AliasedOpenGenericRecord& value) { + auto pos = step_index_.get_step_offset("AliasedGenericRecordToAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadAliasedHalfClosedGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedOpenGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToReversedImpl(evo_test::GenericRecordReversed& value) { + auto pos = step_index_.get_step_offset("GenericRecordToReversed"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadGenericRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecordReversed(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadClosedGenericRecordToUnionImpl(std::variant, std::string>& value) { + auto pos = step_index_.get_step_offset("ClosedGenericRecordToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::GenericRecord_v0 closed_generic_record_to_union = {}; + evo_test::binary::ReadGenericRecord_v0(stream_, closed_generic_record_to_union); + value = closed_generic_record_to_union; + break; + } + default: + ReadUnion, evo_test::binary::ReadGenericRecord, std::string, yardl::binary::ReadString>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToAliasedUnionImpl(evo_test::AliasedGenericRecordOrString& value) { + auto pos = step_index_.get_step_offset("GenericRecordToAliasedUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::GenericRecord_v0 generic_record_to_aliased_union = {}; + evo_test::binary::ReadGenericRecord_v0(stream_, generic_record_to_aliased_union); + value = generic_record_to_aliased_union; + break; + } + default: + evo_test::binary::ReadAliasedGenericRecordOrString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericUnionToReversedImpl(evo_test::GenericUnionReversed>& value) { + auto pos = step_index_.get_step_offset("GenericUnionToReversed"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant, float> generic_union_to_reversed = {}; + ReadUnion, evo_test::binary::ReadGenericRecord_v0, float, yardl::binary::ReadFloatingPoint>(stream_, generic_union_to_reversed); + switch (generic_union_to_reversed.index()) { + case 0: { + value = std::get<0>(generic_union_to_reversed); + break; + } + case 1: { + value = std::get<1>(generic_union_to_reversed); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + evo_test::binary::ReadGenericUnionReversed, evo_test::binary::ReadGenericRecord>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericUnionOfChangedRecordImpl(evo_test::GenericUnion, float>& value) { + auto pos = step_index_.get_step_offset("GenericUnionOfChangedRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadAliasedClosedGenericUnion_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericUnion, evo_test::binary::ReadGenericRecord, float, yardl::binary::ReadFloatingPoint>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericParentRecordImpl(evo_test::GenericParentRecord& value) { + auto pos = step_index_.get_step_offset("GenericParentRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadGenericParentRecord_v0(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericParentRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericNestedRecordsImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericNestedRecords"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadGenericRecord_v0, evo_test::binary::ReadUnchangedGeneric_v0, evo_test::ChangedGeneric_v0, evo_test::binary::ReadChangedGeneric_v0>(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecord(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(evo_test::AliasedClosedGenericRecord& value) { + if (!step_index_.offset_within_stream("GenericRecordStream", "GenericParentRecordStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericRecordStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericRecord_v0>(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(std::vector& values) { + if (!step_index_.offset_within_stream("GenericRecordStream", "GenericParentRecordStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericRecordStream")); + } + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericRecord_v0>(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(evo_test::AliasedClosedGenericRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericRecordStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericRecord_v0>(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericRecordStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericRecord_v0>(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountGenericRecordStreamImpl() { + return step_index_.get_stream_count("GenericRecordStream"); +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value) { + if (!step_index_.offset_within_stream("GenericParentRecordStream", "VectorRecordWithChanges", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericParentRecordStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord_v0>(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("GenericParentRecordStream", "VectorRecordWithChanges", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericParentRecordStream")); + } + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord_v0>(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericParentRecordStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord_v0>(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericParentRecordStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord_v0>(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountGenericParentRecordStreamImpl() { + return step_index_.get_stream_count("GenericParentRecordStream"); +} + +void ProtocolWithChangesIndexedReader::ReadVectorRecordWithChangesImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("VectorRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadVector(stream_, value); + break; + } + default: + yardl::binary::ReadVector(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value) { + if (!step_index_.offset_within_stream("StreamedRecordWithChanges", "AddedOptional", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamedRecordWithChanges")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamedRecordWithChanges", "AddedOptional", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamedRecordWithChanges")); + } + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamedRecordWithChanges", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamedRecordWithChanges", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamedRecordWithChangesImpl() { + return step_index_.get_stream_count("StreamedRecordWithChanges"); +} + +void ProtocolWithChangesIndexedReader::ReadAddedOptionalImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("AddedOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::optional added_optional = {}; + value = std::move(added_optional); + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAddedMapImpl(std::unordered_map& value) { + auto pos = step_index_.get_step_offset("AddedMap"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::unordered_map added_map = {}; + value = std::move(added_map); + break; + } + default: + yardl::binary::ReadMap(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value) { + if (!step_index_.offset_within_stream("AddedRecordStream", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("AddedRecordStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges added_record_stream = {}; + value = std::move(added_record_stream); + return false; + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedRecordStreamImpl(std::vector& values) { + if (!step_index_.offset_within_stream("AddedRecordStream", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("AddedRecordStream")); + } + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("AddedRecordStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges added_record_stream = {}; + value = std::move(added_record_stream); + return false; + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedRecordStreamImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("AddedRecordStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountAddedRecordStreamImpl() { + return step_index_.get_stream_count("AddedRecordStream"); +} + +void ProtocolWithChangesIndexedReader::CloseImpl() { +} + void UnusedProtocolWriter::WriteRecordsImpl(evo_test::UnchangedRecord const& value) { yardl::binary::WriteBlock(stream_, value); } @@ -4910,5 +9315,83 @@ void UnusedProtocolReader::CloseImpl() { stream_.VerifyFinished(); } +void UnusedProtocolIndexedWriter::WriteRecordsImpl(evo_test::UnchangedRecord const& value) { + step_index_.set_step_offset("Records", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("Records", item_offset); +} + +void UnusedProtocolIndexedWriter::WriteRecordsImpl(std::vector const& values) { + step_index_.set_step_offset("Records", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("Records", item_offsets); +} + +void UnusedProtocolIndexedWriter::EndRecordsImpl() { + step_index_.set_step_offset("Records", stream_.Pos()); + step_index_.add_stream_offsets("Records", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void UnusedProtocolIndexedWriter::Flush() { + stream_.Flush(); +} + +void UnusedProtocolIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool UnusedProtocolIndexedReader::ReadRecordsImpl(evo_test::UnchangedRecord& value) { + if (!step_index_.offset_within_stream("Records", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Records")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool UnusedProtocolIndexedReader::ReadRecordsImpl(std::vector& values) { + if (!step_index_.offset_within_stream("Records", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Records")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool UnusedProtocolIndexedReader::ReadRecordsImpl(evo_test::UnchangedRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Records", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool UnusedProtocolIndexedReader::ReadRecordsImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Records", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t UnusedProtocolIndexedReader::CountRecordsImpl() { + return step_index_.get_stream_count("Records"); +} + +void UnusedProtocolIndexedReader::CloseImpl() { +} + } // namespace evo_test::binary diff --git a/cpp/evolution/v1/generated/binary/protocols.h b/cpp/evolution/v1/generated/binary/protocols.h index 7df5f26..6b276ae 100644 --- a/cpp/evolution/v1/generated/binary/protocols.h +++ b/cpp/evolution/v1/generated/binary/protocols.h @@ -154,6 +154,148 @@ class ProtocolWithChangesWriter : public evo_test::ProtocolWithChangesWriterBase Version version_; }; +// Binary indexed writer for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedWriter : public evo_test::ProtocolWithChangesWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ProtocolWithChangesIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, evo_test::ProtocolWithChangesWriterBase::SchemaFromVersion(version)), version_(version) {} + + ProtocolWithChangesIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, evo_test::ProtocolWithChangesWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteInt8ToIntImpl(int32_t const& value) override; + void WriteInt8ToLongImpl(int64_t const& value) override; + void WriteInt8ToUintImpl(uint32_t const& value) override; + void WriteInt8ToUlongImpl(uint64_t const& value) override; + void WriteInt8ToFloatImpl(float const& value) override; + void WriteInt8ToDoubleImpl(double const& value) override; + void WriteIntToUintImpl(uint32_t const& value) override; + void WriteIntToLongImpl(int64_t const& value) override; + void WriteIntToFloatImpl(float const& value) override; + void WriteIntToDoubleImpl(double const& value) override; + void WriteUintToUlongImpl(uint64_t const& value) override; + void WriteUintToFloatImpl(float const& value) override; + void WriteUintToDoubleImpl(double const& value) override; + void WriteFloatToDoubleImpl(double const& value) override; + void WriteComplexFloatToComplexDoubleImpl(std::complex const& value) override; + void WriteIntToStringImpl(std::string const& value) override; + void WriteUintToStringImpl(std::string const& value) override; + void WriteLongToStringImpl(std::string const& value) override; + void WriteUlongToStringImpl(std::string const& value) override; + void WriteFloatToStringImpl(std::string const& value) override; + void WriteDoubleToStringImpl(std::string const& value) override; + void WriteIntToOptionalImpl(std::optional const& value) override; + void WriteFloatToOptionalImpl(std::optional const& value) override; + void WriteStringToOptionalImpl(std::optional const& value) override; + void WriteIntToUnionImpl(std::variant const& value) override; + void WriteFloatToUnionImpl(std::variant const& value) override; + void WriteStringToUnionImpl(std::variant const& value) override; + void WriteOptionalIntToFloatImpl(std::optional const& value) override; + void WriteOptionalFloatToStringImpl(std::optional const& value) override; + void WriteAliasedLongToStringImpl(evo_test::AliasedLongToString const& value) override; + void WriteStringToAliasedStringImpl(evo_test::AliasedString const& value) override; + void WriteStringToAliasedIntImpl(evo_test::AliasedInt const& value) override; + void WriteEnumToAliasedEnumImpl(evo_test::AliasedEnum const& value) override; + void WriteOptionalIntToUnionImpl(std::variant const& value) override; + void WriteOptionalRecordToUnionImpl(std::variant const& value) override; + void WriteRecordWithChangesImpl(evo_test::RecordWithChanges const& value) override; + void WriteAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges const& value) override; + void WriteRecordToRenamedRecordImpl(evo_test::RenamedRecord const& value) override; + void WriteRecordToAliasedRecordImpl(evo_test::AliasedRecordWithChanges const& value) override; + void WriteRecordToAliasedAliasImpl(evo_test::AliasOfAliasedRecordWithChanges const& value) override; + // Stream and Vector type changes + void WriteStreamIntToStringToFloatImpl(std::string const& value) override; + void WriteStreamIntToStringToFloatImpl(std::vector const& values) override; + void EndStreamIntToStringToFloatImpl() override; + void WriteVectorIntToStringToFloatImpl(std::vector const& value) override; + void WriteIntFloatUnionReorderedImpl(std::variant const& value) override; + void WriteVectorUnionReorderedImpl(std::vector> const& value) override; + void WriteStreamUnionReorderedImpl(std::variant const& value) override; + void WriteStreamUnionReorderedImpl(std::vector> const& values) override; + void EndStreamUnionReorderedImpl() override; + void WriteIntToUnionStreamImpl(int32_t const& value) override; + void WriteIntToUnionStreamImpl(std::vector const& values) override; + void EndIntToUnionStreamImpl() override; + void WriteUnionStreamTypeChangeImpl(std::variant const& value) override; + void WriteUnionStreamTypeChangeImpl(std::vector> const& values) override; + void EndUnionStreamTypeChangeImpl() override; + void WriteStreamOfAliasTypeChangeImpl(evo_test::StreamItem const& value) override; + void WriteStreamOfAliasTypeChangeImpl(std::vector const& values) override; + void EndStreamOfAliasTypeChangeImpl() override; + // Comprehensive NamedType changes + void WriteRlinkImpl(evo_test::RLink const& value) override; + void WriteRlinkRXImpl(evo_test::RX const& value) override; + void WriteRlinkRYImpl(evo_test::RY const& value) override; + void WriteRlinkRZImpl(evo_test::RZ const& value) override; + void WriteRaRLinkImpl(evo_test::RLink const& value) override; + void WriteRaRXImpl(evo_test::RX const& value) override; + void WriteRaRYImpl(evo_test::RY const& value) override; + void WriteRaRZImpl(evo_test::RZ const& value) override; + void WriteRbRLinkImpl(evo_test::RLink const& value) override; + void WriteRbRXImpl(evo_test::RX const& value) override; + void WriteRbRYImpl(evo_test::RY const& value) override; + void WriteRbRZImpl(evo_test::RZ const& value) override; + void WriteRcRLinkImpl(evo_test::RLink const& value) override; + void WriteRcRXImpl(evo_test::RX const& value) override; + void WriteRcRYImpl(evo_test::RY const& value) override; + void WriteRcRZImpl(evo_test::RZ const& value) override; + void WriteRlinkRNewImpl(evo_test::RNew const& value) override; + void WriteRaRNewImpl(evo_test::RNew const& value) override; + void WriteRbRNewImpl(evo_test::RNew const& value) override; + void WriteRcRNewImpl(evo_test::RNew const& value) override; + void WriteRlinkRUnionImpl(evo_test::RUnion const& value) override; + void WriteRaRUnionImpl(evo_test::RUnion const& value) override; + void WriteRbRUnionImpl(evo_test::RUnion const& value) override; + void WriteRcRUnionImpl(evo_test::RUnion const& value) override; + void WriteOptionalRecordWithChangesImpl(std::optional const& value) override; + void WriteAliasedOptionalRecordWithChangesImpl(std::optional const& value) override; + void WriteUnionRecordWithChangesImpl(std::variant const& value) override; + void WriteUnionWithSameTypesetImpl(std::variant const& value) override; + void WriteUnionWithTypesAddedImpl(std::variant const& value) override; + void WriteUnionWithTypesRemovedImpl(std::variant const& value) override; + void WriteRecordToOptionalImpl(std::optional const& value) override; + void WriteRecordToAliasedOptionalImpl(evo_test::AliasedOptionalRecord const& value) override; + void WriteRecordToUnionImpl(std::variant const& value) override; + void WriteRecordToAliasedUnionImpl(evo_test::AliasedRecordOrString const& value) override; + void WriteUnionToAliasedUnionImpl(evo_test::AliasedRecordOrInt const& value) override; + void WriteUnionToAliasedUnionWithChangesImpl(evo_test::AliasedRecordOrString const& value) override; + void WriteOptionalToAliasedOptionalImpl(evo_test::AliasedOptionalRecord const& value) override; + void WriteOptionalToAliasedOptionalWithChangesImpl(evo_test::AliasedOptionalString const& value) override; + void WriteGenericRecordImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordToOpenAliasImpl(evo_test::AliasedOpenGenericRecord const& value) override; + void WriteGenericRecordToClosedAliasImpl(evo_test::AliasedClosedGenericRecord const& value) override; + void WriteGenericRecordToHalfClosedAliasImpl(evo_test::AliasedHalfClosedGenericRecord const& value) override; + void WriteAliasedGenericRecordToAliasImpl(evo_test::AliasedOpenGenericRecord const& value) override; + void WriteGenericRecordToReversedImpl(evo_test::GenericRecordReversed const& value) override; + void WriteClosedGenericRecordToUnionImpl(std::variant, std::string> const& value) override; + void WriteGenericRecordToAliasedUnionImpl(evo_test::AliasedGenericRecordOrString const& value) override; + void WriteGenericUnionToReversedImpl(evo_test::GenericUnionReversed> const& value) override; + void WriteGenericUnionOfChangedRecordImpl(evo_test::GenericUnion, float> const& value) override; + void WriteGenericParentRecordImpl(evo_test::GenericParentRecord const& value) override; + void WriteGenericNestedRecordsImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordStreamImpl(evo_test::AliasedClosedGenericRecord const& value) override; + void WriteGenericRecordStreamImpl(std::vector const& values) override; + void EndGenericRecordStreamImpl() override; + void WriteGenericParentRecordStreamImpl(evo_test::GenericParentRecord const& value) override; + void WriteGenericParentRecordStreamImpl(std::vector> const& values) override; + void EndGenericParentRecordStreamImpl() override; + void WriteVectorRecordWithChangesImpl(std::vector const& value) override; + void WriteStreamedRecordWithChangesImpl(evo_test::RecordWithChanges const& value) override; + void WriteStreamedRecordWithChangesImpl(std::vector const& values) override; + void EndStreamedRecordWithChangesImpl() override; + void WriteAddedOptionalImpl(std::optional const& value) override; + void WriteAddedMapImpl(std::unordered_map const& value) override; + void WriteAddedRecordStreamImpl(evo_test::RecordWithChanges const& value) override; + void WriteAddedRecordStreamImpl(std::vector const& values) override; + void EndAddedRecordStreamImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the ProtocolWithChanges protocol. class ProtocolWithChangesReader : public evo_test::ProtocolWithChangesReaderBase, yardl::binary::BinaryReader { public: @@ -288,6 +430,167 @@ class ProtocolWithChangesReader : public evo_test::ProtocolWithChangesReaderBase size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedReader : public evo_test::ProtocolWithChangesIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ProtocolWithChangesIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(evo_test::ProtocolWithChangesIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ProtocolWithChangesIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(evo_test::ProtocolWithChangesIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadInt8ToIntImpl(int32_t& value) override; + void ReadInt8ToLongImpl(int64_t& value) override; + void ReadInt8ToUintImpl(uint32_t& value) override; + void ReadInt8ToUlongImpl(uint64_t& value) override; + void ReadInt8ToFloatImpl(float& value) override; + void ReadInt8ToDoubleImpl(double& value) override; + void ReadIntToUintImpl(uint32_t& value) override; + void ReadIntToLongImpl(int64_t& value) override; + void ReadIntToFloatImpl(float& value) override; + void ReadIntToDoubleImpl(double& value) override; + void ReadUintToUlongImpl(uint64_t& value) override; + void ReadUintToFloatImpl(float& value) override; + void ReadUintToDoubleImpl(double& value) override; + void ReadFloatToDoubleImpl(double& value) override; + void ReadComplexFloatToComplexDoubleImpl(std::complex& value) override; + void ReadIntToStringImpl(std::string& value) override; + void ReadUintToStringImpl(std::string& value) override; + void ReadLongToStringImpl(std::string& value) override; + void ReadUlongToStringImpl(std::string& value) override; + void ReadFloatToStringImpl(std::string& value) override; + void ReadDoubleToStringImpl(std::string& value) override; + void ReadIntToOptionalImpl(std::optional& value) override; + void ReadFloatToOptionalImpl(std::optional& value) override; + void ReadStringToOptionalImpl(std::optional& value) override; + void ReadIntToUnionImpl(std::variant& value) override; + void ReadFloatToUnionImpl(std::variant& value) override; + void ReadStringToUnionImpl(std::variant& value) override; + void ReadOptionalIntToFloatImpl(std::optional& value) override; + void ReadOptionalFloatToStringImpl(std::optional& value) override; + void ReadAliasedLongToStringImpl(evo_test::AliasedLongToString& value) override; + void ReadStringToAliasedStringImpl(evo_test::AliasedString& value) override; + void ReadStringToAliasedIntImpl(evo_test::AliasedInt& value) override; + void ReadEnumToAliasedEnumImpl(evo_test::AliasedEnum& value) override; + void ReadOptionalIntToUnionImpl(std::variant& value) override; + void ReadOptionalRecordToUnionImpl(std::variant& value) override; + void ReadRecordWithChangesImpl(evo_test::RecordWithChanges& value) override; + void ReadAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges& value) override; + void ReadRecordToRenamedRecordImpl(evo_test::RenamedRecord& value) override; + void ReadRecordToAliasedRecordImpl(evo_test::AliasedRecordWithChanges& value) override; + void ReadRecordToAliasedAliasImpl(evo_test::AliasOfAliasedRecordWithChanges& value) override; + bool ReadStreamIntToStringToFloatImpl(std::string& value) override; + bool ReadStreamIntToStringToFloatImpl(std::vector& values) override; + bool ReadStreamIntToStringToFloatImpl(std::string& value, size_t idx) override; + bool ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) override; + size_t CountStreamIntToStringToFloatImpl() override; + void ReadVectorIntToStringToFloatImpl(std::vector& value) override; + void ReadIntFloatUnionReorderedImpl(std::variant& value) override; + void ReadVectorUnionReorderedImpl(std::vector>& value) override; + bool ReadStreamUnionReorderedImpl(std::variant& value) override; + bool ReadStreamUnionReorderedImpl(std::vector>& values) override; + bool ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) override; + bool ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) override; + size_t CountStreamUnionReorderedImpl() override; + bool ReadIntToUnionStreamImpl(int32_t& value) override; + bool ReadIntToUnionStreamImpl(std::vector& values) override; + bool ReadIntToUnionStreamImpl(int32_t& value, size_t idx) override; + bool ReadIntToUnionStreamImpl(std::vector& values, size_t idx) override; + size_t CountIntToUnionStreamImpl() override; + bool ReadUnionStreamTypeChangeImpl(std::variant& value) override; + bool ReadUnionStreamTypeChangeImpl(std::vector>& values) override; + bool ReadUnionStreamTypeChangeImpl(std::variant& value, size_t idx) override; + bool ReadUnionStreamTypeChangeImpl(std::vector>& values, size_t idx) override; + size_t CountUnionStreamTypeChangeImpl() override; + bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value) override; + bool ReadStreamOfAliasTypeChangeImpl(std::vector& values) override; + bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) override; + bool ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) override; + size_t CountStreamOfAliasTypeChangeImpl() override; + void ReadRlinkImpl(evo_test::RLink& value) override; + void ReadRlinkRXImpl(evo_test::RX& value) override; + void ReadRlinkRYImpl(evo_test::RY& value) override; + void ReadRlinkRZImpl(evo_test::RZ& value) override; + void ReadRaRLinkImpl(evo_test::RLink& value) override; + void ReadRaRXImpl(evo_test::RX& value) override; + void ReadRaRYImpl(evo_test::RY& value) override; + void ReadRaRZImpl(evo_test::RZ& value) override; + void ReadRbRLinkImpl(evo_test::RLink& value) override; + void ReadRbRXImpl(evo_test::RX& value) override; + void ReadRbRYImpl(evo_test::RY& value) override; + void ReadRbRZImpl(evo_test::RZ& value) override; + void ReadRcRLinkImpl(evo_test::RLink& value) override; + void ReadRcRXImpl(evo_test::RX& value) override; + void ReadRcRYImpl(evo_test::RY& value) override; + void ReadRcRZImpl(evo_test::RZ& value) override; + void ReadRlinkRNewImpl(evo_test::RNew& value) override; + void ReadRaRNewImpl(evo_test::RNew& value) override; + void ReadRbRNewImpl(evo_test::RNew& value) override; + void ReadRcRNewImpl(evo_test::RNew& value) override; + void ReadRlinkRUnionImpl(evo_test::RUnion& value) override; + void ReadRaRUnionImpl(evo_test::RUnion& value) override; + void ReadRbRUnionImpl(evo_test::RUnion& value) override; + void ReadRcRUnionImpl(evo_test::RUnion& value) override; + void ReadOptionalRecordWithChangesImpl(std::optional& value) override; + void ReadAliasedOptionalRecordWithChangesImpl(std::optional& value) override; + void ReadUnionRecordWithChangesImpl(std::variant& value) override; + void ReadUnionWithSameTypesetImpl(std::variant& value) override; + void ReadUnionWithTypesAddedImpl(std::variant& value) override; + void ReadUnionWithTypesRemovedImpl(std::variant& value) override; + void ReadRecordToOptionalImpl(std::optional& value) override; + void ReadRecordToAliasedOptionalImpl(evo_test::AliasedOptionalRecord& value) override; + void ReadRecordToUnionImpl(std::variant& value) override; + void ReadRecordToAliasedUnionImpl(evo_test::AliasedRecordOrString& value) override; + void ReadUnionToAliasedUnionImpl(evo_test::AliasedRecordOrInt& value) override; + void ReadUnionToAliasedUnionWithChangesImpl(evo_test::AliasedRecordOrString& value) override; + void ReadOptionalToAliasedOptionalImpl(evo_test::AliasedOptionalRecord& value) override; + void ReadOptionalToAliasedOptionalWithChangesImpl(evo_test::AliasedOptionalString& value) override; + void ReadGenericRecordImpl(evo_test::GenericRecord& value) override; + void ReadGenericRecordToOpenAliasImpl(evo_test::AliasedOpenGenericRecord& value) override; + void ReadGenericRecordToClosedAliasImpl(evo_test::AliasedClosedGenericRecord& value) override; + void ReadGenericRecordToHalfClosedAliasImpl(evo_test::AliasedHalfClosedGenericRecord& value) override; + void ReadAliasedGenericRecordToAliasImpl(evo_test::AliasedOpenGenericRecord& value) override; + void ReadGenericRecordToReversedImpl(evo_test::GenericRecordReversed& value) override; + void ReadClosedGenericRecordToUnionImpl(std::variant, std::string>& value) override; + void ReadGenericRecordToAliasedUnionImpl(evo_test::AliasedGenericRecordOrString& value) override; + void ReadGenericUnionToReversedImpl(evo_test::GenericUnionReversed>& value) override; + void ReadGenericUnionOfChangedRecordImpl(evo_test::GenericUnion, float>& value) override; + void ReadGenericParentRecordImpl(evo_test::GenericParentRecord& value) override; + void ReadGenericNestedRecordsImpl(evo_test::GenericRecord& value) override; + bool ReadGenericRecordStreamImpl(evo_test::AliasedClosedGenericRecord& value) override; + bool ReadGenericRecordStreamImpl(std::vector& values) override; + bool ReadGenericRecordStreamImpl(evo_test::AliasedClosedGenericRecord& value, size_t idx) override; + bool ReadGenericRecordStreamImpl(std::vector& values, size_t idx) override; + size_t CountGenericRecordStreamImpl() override; + bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value) override; + bool ReadGenericParentRecordStreamImpl(std::vector>& values) override; + bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) override; + bool ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) override; + size_t CountGenericParentRecordStreamImpl() override; + void ReadVectorRecordWithChangesImpl(std::vector& value) override; + bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value) override; + bool ReadStreamedRecordWithChangesImpl(std::vector& values) override; + bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) override; + bool ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) override; + size_t CountStreamedRecordWithChangesImpl() override; + void ReadAddedOptionalImpl(std::optional& value) override; + void ReadAddedMapImpl(std::unordered_map& value) override; + bool ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value) override; + bool ReadAddedRecordStreamImpl(std::vector& values) override; + bool ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value, size_t idx) override; + bool ReadAddedRecordStreamImpl(std::vector& values, size_t idx) override; + size_t CountAddedRecordStreamImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the UnusedProtocol protocol. class UnusedProtocolWriter : public evo_test::UnusedProtocolWriterBase, yardl::binary::BinaryWriter { public: @@ -308,6 +611,26 @@ class UnusedProtocolWriter : public evo_test::UnusedProtocolWriterBase, yardl::b Version version_; }; +// Binary indexed writer for the UnusedProtocol protocol. +class UnusedProtocolIndexedWriter : public evo_test::UnusedProtocolWriterBase, yardl::binary::BinaryIndexedWriter { + public: + UnusedProtocolIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, evo_test::UnusedProtocolWriterBase::SchemaFromVersion(version)), version_(version) {} + + UnusedProtocolIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, evo_test::UnusedProtocolWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteRecordsImpl(evo_test::UnchangedRecord const& value) override; + void WriteRecordsImpl(std::vector const& values) override; + void EndRecordsImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the UnusedProtocol protocol. class UnusedProtocolReader : public evo_test::UnusedProtocolReaderBase, yardl::binary::BinaryReader { public: @@ -330,4 +653,29 @@ class UnusedProtocolReader : public evo_test::UnusedProtocolReaderBase, yardl::b size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the UnusedProtocol protocol. +class UnusedProtocolIndexedReader : public evo_test::UnusedProtocolIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + UnusedProtocolIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(evo_test::UnusedProtocolIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + UnusedProtocolIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(evo_test::UnusedProtocolIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadRecordsImpl(evo_test::UnchangedRecord& value) override; + bool ReadRecordsImpl(std::vector& values) override; + bool ReadRecordsImpl(evo_test::UnchangedRecord& value, size_t idx) override; + bool ReadRecordsImpl(std::vector& values, size_t idx) override; + size_t CountRecordsImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + } // namespace evo_test::binary diff --git a/cpp/evolution/v1/generated/protocols.cc b/cpp/evolution/v1/generated/protocols.cc index 409dbe2..4cae645 100644 --- a/cpp/evolution/v1/generated/protocols.cc +++ b/cpp/evolution/v1/generated/protocols.cc @@ -9,345 +9,6 @@ #endif namespace evo_test { -namespace { -void ProtocolWithChangesWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInt8ToInt()"; break; - case 1: expected_method = "WriteInt8ToLong()"; break; - case 2: expected_method = "WriteInt8ToUint()"; break; - case 3: expected_method = "WriteInt8ToUlong()"; break; - case 4: expected_method = "WriteInt8ToFloat()"; break; - case 5: expected_method = "WriteInt8ToDouble()"; break; - case 6: expected_method = "WriteIntToUint()"; break; - case 7: expected_method = "WriteIntToLong()"; break; - case 8: expected_method = "WriteIntToFloat()"; break; - case 9: expected_method = "WriteIntToDouble()"; break; - case 10: expected_method = "WriteUintToUlong()"; break; - case 11: expected_method = "WriteUintToFloat()"; break; - case 12: expected_method = "WriteUintToDouble()"; break; - case 13: expected_method = "WriteFloatToDouble()"; break; - case 14: expected_method = "WriteComplexFloatToComplexDouble()"; break; - case 15: expected_method = "WriteIntToString()"; break; - case 16: expected_method = "WriteUintToString()"; break; - case 17: expected_method = "WriteLongToString()"; break; - case 18: expected_method = "WriteUlongToString()"; break; - case 19: expected_method = "WriteFloatToString()"; break; - case 20: expected_method = "WriteDoubleToString()"; break; - case 21: expected_method = "WriteIntToOptional()"; break; - case 22: expected_method = "WriteFloatToOptional()"; break; - case 23: expected_method = "WriteStringToOptional()"; break; - case 24: expected_method = "WriteIntToUnion()"; break; - case 25: expected_method = "WriteFloatToUnion()"; break; - case 26: expected_method = "WriteStringToUnion()"; break; - case 27: expected_method = "WriteOptionalIntToFloat()"; break; - case 28: expected_method = "WriteOptionalFloatToString()"; break; - case 29: expected_method = "WriteAliasedLongToString()"; break; - case 30: expected_method = "WriteStringToAliasedString()"; break; - case 31: expected_method = "WriteStringToAliasedInt()"; break; - case 32: expected_method = "WriteEnumToAliasedEnum()"; break; - case 33: expected_method = "WriteOptionalIntToUnion()"; break; - case 34: expected_method = "WriteOptionalRecordToUnion()"; break; - case 35: expected_method = "WriteRecordWithChanges()"; break; - case 36: expected_method = "WriteAliasedRecordWithChanges()"; break; - case 37: expected_method = "WriteRecordToRenamedRecord()"; break; - case 38: expected_method = "WriteRecordToAliasedRecord()"; break; - case 39: expected_method = "WriteRecordToAliasedAlias()"; break; - case 40: expected_method = "WriteStreamIntToStringToFloat() or EndStreamIntToStringToFloat()"; break; - case 41: expected_method = "WriteVectorIntToStringToFloat()"; break; - case 42: expected_method = "WriteIntFloatUnionReordered()"; break; - case 43: expected_method = "WriteVectorUnionReordered()"; break; - case 44: expected_method = "WriteStreamUnionReordered() or EndStreamUnionReordered()"; break; - case 45: expected_method = "WriteIntToUnionStream() or EndIntToUnionStream()"; break; - case 46: expected_method = "WriteUnionStreamTypeChange() or EndUnionStreamTypeChange()"; break; - case 47: expected_method = "WriteStreamOfAliasTypeChange() or EndStreamOfAliasTypeChange()"; break; - case 48: expected_method = "WriteRlink()"; break; - case 49: expected_method = "WriteRlinkRX()"; break; - case 50: expected_method = "WriteRlinkRY()"; break; - case 51: expected_method = "WriteRlinkRZ()"; break; - case 52: expected_method = "WriteRaRLink()"; break; - case 53: expected_method = "WriteRaRX()"; break; - case 54: expected_method = "WriteRaRY()"; break; - case 55: expected_method = "WriteRaRZ()"; break; - case 56: expected_method = "WriteRbRLink()"; break; - case 57: expected_method = "WriteRbRX()"; break; - case 58: expected_method = "WriteRbRY()"; break; - case 59: expected_method = "WriteRbRZ()"; break; - case 60: expected_method = "WriteRcRLink()"; break; - case 61: expected_method = "WriteRcRX()"; break; - case 62: expected_method = "WriteRcRY()"; break; - case 63: expected_method = "WriteRcRZ()"; break; - case 64: expected_method = "WriteRlinkRNew()"; break; - case 65: expected_method = "WriteRaRNew()"; break; - case 66: expected_method = "WriteRbRNew()"; break; - case 67: expected_method = "WriteRcRNew()"; break; - case 68: expected_method = "WriteRlinkRUnion()"; break; - case 69: expected_method = "WriteRaRUnion()"; break; - case 70: expected_method = "WriteRbRUnion()"; break; - case 71: expected_method = "WriteRcRUnion()"; break; - case 72: expected_method = "WriteOptionalRecordWithChanges()"; break; - case 73: expected_method = "WriteAliasedOptionalRecordWithChanges()"; break; - case 74: expected_method = "WriteUnionRecordWithChanges()"; break; - case 75: expected_method = "WriteUnionWithSameTypeset()"; break; - case 76: expected_method = "WriteUnionWithTypesAdded()"; break; - case 77: expected_method = "WriteUnionWithTypesRemoved()"; break; - case 78: expected_method = "WriteRecordToOptional()"; break; - case 79: expected_method = "WriteRecordToAliasedOptional()"; break; - case 80: expected_method = "WriteRecordToUnion()"; break; - case 81: expected_method = "WriteRecordToAliasedUnion()"; break; - case 82: expected_method = "WriteUnionToAliasedUnion()"; break; - case 83: expected_method = "WriteUnionToAliasedUnionWithChanges()"; break; - case 84: expected_method = "WriteOptionalToAliasedOptional()"; break; - case 85: expected_method = "WriteOptionalToAliasedOptionalWithChanges()"; break; - case 86: expected_method = "WriteGenericRecord()"; break; - case 87: expected_method = "WriteGenericRecordToOpenAlias()"; break; - case 88: expected_method = "WriteGenericRecordToClosedAlias()"; break; - case 89: expected_method = "WriteGenericRecordToHalfClosedAlias()"; break; - case 90: expected_method = "WriteAliasedGenericRecordToAlias()"; break; - case 91: expected_method = "WriteGenericRecordToReversed()"; break; - case 92: expected_method = "WriteClosedGenericRecordToUnion()"; break; - case 93: expected_method = "WriteGenericRecordToAliasedUnion()"; break; - case 94: expected_method = "WriteGenericUnionToReversed()"; break; - case 95: expected_method = "WriteGenericUnionOfChangedRecord()"; break; - case 96: expected_method = "WriteGenericParentRecord()"; break; - case 97: expected_method = "WriteGenericNestedRecords()"; break; - case 98: expected_method = "WriteGenericRecordStream() or EndGenericRecordStream()"; break; - case 99: expected_method = "WriteGenericParentRecordStream() or EndGenericParentRecordStream()"; break; - case 100: expected_method = "WriteVectorRecordWithChanges()"; break; - case 101: expected_method = "WriteStreamedRecordWithChanges() or EndStreamedRecordWithChanges()"; break; - case 102: expected_method = "WriteAddedOptional()"; break; - case 103: expected_method = "WriteAddedMap()"; break; - case 104: expected_method = "WriteAddedRecordStream() or EndAddedRecordStream()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteInt8ToInt()"; break; - case 1: attempted_method = "WriteInt8ToLong()"; break; - case 2: attempted_method = "WriteInt8ToUint()"; break; - case 3: attempted_method = "WriteInt8ToUlong()"; break; - case 4: attempted_method = "WriteInt8ToFloat()"; break; - case 5: attempted_method = "WriteInt8ToDouble()"; break; - case 6: attempted_method = "WriteIntToUint()"; break; - case 7: attempted_method = "WriteIntToLong()"; break; - case 8: attempted_method = "WriteIntToFloat()"; break; - case 9: attempted_method = "WriteIntToDouble()"; break; - case 10: attempted_method = "WriteUintToUlong()"; break; - case 11: attempted_method = "WriteUintToFloat()"; break; - case 12: attempted_method = "WriteUintToDouble()"; break; - case 13: attempted_method = "WriteFloatToDouble()"; break; - case 14: attempted_method = "WriteComplexFloatToComplexDouble()"; break; - case 15: attempted_method = "WriteIntToString()"; break; - case 16: attempted_method = "WriteUintToString()"; break; - case 17: attempted_method = "WriteLongToString()"; break; - case 18: attempted_method = "WriteUlongToString()"; break; - case 19: attempted_method = "WriteFloatToString()"; break; - case 20: attempted_method = "WriteDoubleToString()"; break; - case 21: attempted_method = "WriteIntToOptional()"; break; - case 22: attempted_method = "WriteFloatToOptional()"; break; - case 23: attempted_method = "WriteStringToOptional()"; break; - case 24: attempted_method = "WriteIntToUnion()"; break; - case 25: attempted_method = "WriteFloatToUnion()"; break; - case 26: attempted_method = "WriteStringToUnion()"; break; - case 27: attempted_method = "WriteOptionalIntToFloat()"; break; - case 28: attempted_method = "WriteOptionalFloatToString()"; break; - case 29: attempted_method = "WriteAliasedLongToString()"; break; - case 30: attempted_method = "WriteStringToAliasedString()"; break; - case 31: attempted_method = "WriteStringToAliasedInt()"; break; - case 32: attempted_method = "WriteEnumToAliasedEnum()"; break; - case 33: attempted_method = "WriteOptionalIntToUnion()"; break; - case 34: attempted_method = "WriteOptionalRecordToUnion()"; break; - case 35: attempted_method = "WriteRecordWithChanges()"; break; - case 36: attempted_method = "WriteAliasedRecordWithChanges()"; break; - case 37: attempted_method = "WriteRecordToRenamedRecord()"; break; - case 38: attempted_method = "WriteRecordToAliasedRecord()"; break; - case 39: attempted_method = "WriteRecordToAliasedAlias()"; break; - case 40: attempted_method = end ? "EndStreamIntToStringToFloat()" : "WriteStreamIntToStringToFloat()"; break; - case 41: attempted_method = "WriteVectorIntToStringToFloat()"; break; - case 42: attempted_method = "WriteIntFloatUnionReordered()"; break; - case 43: attempted_method = "WriteVectorUnionReordered()"; break; - case 44: attempted_method = end ? "EndStreamUnionReordered()" : "WriteStreamUnionReordered()"; break; - case 45: attempted_method = end ? "EndIntToUnionStream()" : "WriteIntToUnionStream()"; break; - case 46: attempted_method = end ? "EndUnionStreamTypeChange()" : "WriteUnionStreamTypeChange()"; break; - case 47: attempted_method = end ? "EndStreamOfAliasTypeChange()" : "WriteStreamOfAliasTypeChange()"; break; - case 48: attempted_method = "WriteRlink()"; break; - case 49: attempted_method = "WriteRlinkRX()"; break; - case 50: attempted_method = "WriteRlinkRY()"; break; - case 51: attempted_method = "WriteRlinkRZ()"; break; - case 52: attempted_method = "WriteRaRLink()"; break; - case 53: attempted_method = "WriteRaRX()"; break; - case 54: attempted_method = "WriteRaRY()"; break; - case 55: attempted_method = "WriteRaRZ()"; break; - case 56: attempted_method = "WriteRbRLink()"; break; - case 57: attempted_method = "WriteRbRX()"; break; - case 58: attempted_method = "WriteRbRY()"; break; - case 59: attempted_method = "WriteRbRZ()"; break; - case 60: attempted_method = "WriteRcRLink()"; break; - case 61: attempted_method = "WriteRcRX()"; break; - case 62: attempted_method = "WriteRcRY()"; break; - case 63: attempted_method = "WriteRcRZ()"; break; - case 64: attempted_method = "WriteRlinkRNew()"; break; - case 65: attempted_method = "WriteRaRNew()"; break; - case 66: attempted_method = "WriteRbRNew()"; break; - case 67: attempted_method = "WriteRcRNew()"; break; - case 68: attempted_method = "WriteRlinkRUnion()"; break; - case 69: attempted_method = "WriteRaRUnion()"; break; - case 70: attempted_method = "WriteRbRUnion()"; break; - case 71: attempted_method = "WriteRcRUnion()"; break; - case 72: attempted_method = "WriteOptionalRecordWithChanges()"; break; - case 73: attempted_method = "WriteAliasedOptionalRecordWithChanges()"; break; - case 74: attempted_method = "WriteUnionRecordWithChanges()"; break; - case 75: attempted_method = "WriteUnionWithSameTypeset()"; break; - case 76: attempted_method = "WriteUnionWithTypesAdded()"; break; - case 77: attempted_method = "WriteUnionWithTypesRemoved()"; break; - case 78: attempted_method = "WriteRecordToOptional()"; break; - case 79: attempted_method = "WriteRecordToAliasedOptional()"; break; - case 80: attempted_method = "WriteRecordToUnion()"; break; - case 81: attempted_method = "WriteRecordToAliasedUnion()"; break; - case 82: attempted_method = "WriteUnionToAliasedUnion()"; break; - case 83: attempted_method = "WriteUnionToAliasedUnionWithChanges()"; break; - case 84: attempted_method = "WriteOptionalToAliasedOptional()"; break; - case 85: attempted_method = "WriteOptionalToAliasedOptionalWithChanges()"; break; - case 86: attempted_method = "WriteGenericRecord()"; break; - case 87: attempted_method = "WriteGenericRecordToOpenAlias()"; break; - case 88: attempted_method = "WriteGenericRecordToClosedAlias()"; break; - case 89: attempted_method = "WriteGenericRecordToHalfClosedAlias()"; break; - case 90: attempted_method = "WriteAliasedGenericRecordToAlias()"; break; - case 91: attempted_method = "WriteGenericRecordToReversed()"; break; - case 92: attempted_method = "WriteClosedGenericRecordToUnion()"; break; - case 93: attempted_method = "WriteGenericRecordToAliasedUnion()"; break; - case 94: attempted_method = "WriteGenericUnionToReversed()"; break; - case 95: attempted_method = "WriteGenericUnionOfChangedRecord()"; break; - case 96: attempted_method = "WriteGenericParentRecord()"; break; - case 97: attempted_method = "WriteGenericNestedRecords()"; break; - case 98: attempted_method = end ? "EndGenericRecordStream()" : "WriteGenericRecordStream()"; break; - case 99: attempted_method = end ? "EndGenericParentRecordStream()" : "WriteGenericParentRecordStream()"; break; - case 100: attempted_method = "WriteVectorRecordWithChanges()"; break; - case 101: attempted_method = end ? "EndStreamedRecordWithChanges()" : "WriteStreamedRecordWithChanges()"; break; - case 102: attempted_method = "WriteAddedOptional()"; break; - case 103: attempted_method = "WriteAddedMap()"; break; - case 104: attempted_method = end ? "EndAddedRecordStream()" : "WriteAddedRecordStream()"; break; - case 105: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ProtocolWithChangesReaderBaseInvalidState(uint8_t attempted, uint8_t current) { - auto f = [](uint8_t i) -> std::string { - switch (i/2) { - case 0: return "ReadInt8ToInt()"; - case 1: return "ReadInt8ToLong()"; - case 2: return "ReadInt8ToUint()"; - case 3: return "ReadInt8ToUlong()"; - case 4: return "ReadInt8ToFloat()"; - case 5: return "ReadInt8ToDouble()"; - case 6: return "ReadIntToUint()"; - case 7: return "ReadIntToLong()"; - case 8: return "ReadIntToFloat()"; - case 9: return "ReadIntToDouble()"; - case 10: return "ReadUintToUlong()"; - case 11: return "ReadUintToFloat()"; - case 12: return "ReadUintToDouble()"; - case 13: return "ReadFloatToDouble()"; - case 14: return "ReadComplexFloatToComplexDouble()"; - case 15: return "ReadIntToString()"; - case 16: return "ReadUintToString()"; - case 17: return "ReadLongToString()"; - case 18: return "ReadUlongToString()"; - case 19: return "ReadFloatToString()"; - case 20: return "ReadDoubleToString()"; - case 21: return "ReadIntToOptional()"; - case 22: return "ReadFloatToOptional()"; - case 23: return "ReadStringToOptional()"; - case 24: return "ReadIntToUnion()"; - case 25: return "ReadFloatToUnion()"; - case 26: return "ReadStringToUnion()"; - case 27: return "ReadOptionalIntToFloat()"; - case 28: return "ReadOptionalFloatToString()"; - case 29: return "ReadAliasedLongToString()"; - case 30: return "ReadStringToAliasedString()"; - case 31: return "ReadStringToAliasedInt()"; - case 32: return "ReadEnumToAliasedEnum()"; - case 33: return "ReadOptionalIntToUnion()"; - case 34: return "ReadOptionalRecordToUnion()"; - case 35: return "ReadRecordWithChanges()"; - case 36: return "ReadAliasedRecordWithChanges()"; - case 37: return "ReadRecordToRenamedRecord()"; - case 38: return "ReadRecordToAliasedRecord()"; - case 39: return "ReadRecordToAliasedAlias()"; - case 40: return "ReadStreamIntToStringToFloat()"; - case 41: return "ReadVectorIntToStringToFloat()"; - case 42: return "ReadIntFloatUnionReordered()"; - case 43: return "ReadVectorUnionReordered()"; - case 44: return "ReadStreamUnionReordered()"; - case 45: return "ReadIntToUnionStream()"; - case 46: return "ReadUnionStreamTypeChange()"; - case 47: return "ReadStreamOfAliasTypeChange()"; - case 48: return "ReadRlink()"; - case 49: return "ReadRlinkRX()"; - case 50: return "ReadRlinkRY()"; - case 51: return "ReadRlinkRZ()"; - case 52: return "ReadRaRLink()"; - case 53: return "ReadRaRX()"; - case 54: return "ReadRaRY()"; - case 55: return "ReadRaRZ()"; - case 56: return "ReadRbRLink()"; - case 57: return "ReadRbRX()"; - case 58: return "ReadRbRY()"; - case 59: return "ReadRbRZ()"; - case 60: return "ReadRcRLink()"; - case 61: return "ReadRcRX()"; - case 62: return "ReadRcRY()"; - case 63: return "ReadRcRZ()"; - case 64: return "ReadRlinkRNew()"; - case 65: return "ReadRaRNew()"; - case 66: return "ReadRbRNew()"; - case 67: return "ReadRcRNew()"; - case 68: return "ReadRlinkRUnion()"; - case 69: return "ReadRaRUnion()"; - case 70: return "ReadRbRUnion()"; - case 71: return "ReadRcRUnion()"; - case 72: return "ReadOptionalRecordWithChanges()"; - case 73: return "ReadAliasedOptionalRecordWithChanges()"; - case 74: return "ReadUnionRecordWithChanges()"; - case 75: return "ReadUnionWithSameTypeset()"; - case 76: return "ReadUnionWithTypesAdded()"; - case 77: return "ReadUnionWithTypesRemoved()"; - case 78: return "ReadRecordToOptional()"; - case 79: return "ReadRecordToAliasedOptional()"; - case 80: return "ReadRecordToUnion()"; - case 81: return "ReadRecordToAliasedUnion()"; - case 82: return "ReadUnionToAliasedUnion()"; - case 83: return "ReadUnionToAliasedUnionWithChanges()"; - case 84: return "ReadOptionalToAliasedOptional()"; - case 85: return "ReadOptionalToAliasedOptionalWithChanges()"; - case 86: return "ReadGenericRecord()"; - case 87: return "ReadGenericRecordToOpenAlias()"; - case 88: return "ReadGenericRecordToClosedAlias()"; - case 89: return "ReadGenericRecordToHalfClosedAlias()"; - case 90: return "ReadAliasedGenericRecordToAlias()"; - case 91: return "ReadGenericRecordToReversed()"; - case 92: return "ReadClosedGenericRecordToUnion()"; - case 93: return "ReadGenericRecordToAliasedUnion()"; - case 94: return "ReadGenericUnionToReversed()"; - case 95: return "ReadGenericUnionOfChangedRecord()"; - case 96: return "ReadGenericParentRecord()"; - case 97: return "ReadGenericNestedRecords()"; - case 98: return "ReadGenericRecordStream()"; - case 99: return "ReadGenericParentRecordStream()"; - case 100: return "ReadVectorRecordWithChanges()"; - case 101: return "ReadStreamedRecordWithChanges()"; - case 102: return "ReadAddedOptional()"; - case 103: return "ReadAddedMap()"; - case 104: return "ReadAddedRecordStream()"; - case 105: return "Close()"; - default: return ""; - } - }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); -} - -} // namespace - std::string ProtocolWithChangesWriterBase::schema_ = R"({"protocol":{"name":"ProtocolWithChanges","sequence":[{"name":"int8ToInt","type":"int32"},{"name":"int8ToLong","type":"int64"},{"name":"int8ToUint","type":"uint32"},{"name":"int8ToUlong","type":"uint64"},{"name":"int8ToFloat","type":"float32"},{"name":"int8ToDouble","type":"float64"},{"name":"intToUint","type":"uint32"},{"name":"intToLong","type":"int64"},{"name":"intToFloat","type":"float32"},{"name":"intToDouble","type":"float64"},{"name":"uintToUlong","type":"uint64"},{"name":"uintToFloat","type":"float32"},{"name":"uintToDouble","type":"float64"},{"name":"floatToDouble","type":"float64"},{"name":"complexFloatToComplexDouble","type":"complexfloat64"},{"name":"intToString","type":"string"},{"name":"uintToString","type":"string"},{"name":"longToString","type":"string"},{"name":"ulongToString","type":"string"},{"name":"floatToString","type":"string"},{"name":"doubleToString","type":"string"},{"name":"intToOptional","type":[null,"int32"]},{"name":"floatToOptional","type":[null,"float32"]},{"name":"stringToOptional","type":[null,"string"]},{"name":"intToUnion","type":[{"tag":"int32","type":"int32"},{"tag":"bool","type":"bool"}]},{"name":"floatToUnion","type":[{"tag":"float32","type":"float32"},{"tag":"bool","type":"bool"}]},{"name":"stringToUnion","type":[{"tag":"string","type":"string"},{"tag":"bool","type":"bool"}]},{"name":"optionalIntToFloat","type":[null,"float32"]},{"name":"optionalFloatToString","type":[null,"string"]},{"name":"aliasedLongToString","type":"EvoTest.AliasedLongToString"},{"name":"stringToAliasedString","type":"EvoTest.AliasedString"},{"name":"stringToAliasedInt","type":"EvoTest.AliasedInt"},{"name":"enumToAliasedEnum","type":"EvoTest.AliasedEnum"},{"name":"optionalIntToUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"string","type":"string"}]},{"name":"optionalRecordToUnion","type":[null,{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"string","type":"string"}]},{"name":"recordWithChanges","type":"EvoTest.RecordWithChanges"},{"name":"aliasedRecordWithChanges","type":"EvoTest.AliasedRecordWithChanges"},{"name":"recordToRenamedRecord","type":"EvoTest.RenamedRecord"},{"name":"recordToAliasedRecord","type":"EvoTest.AliasedRecordWithChanges"},{"name":"recordToAliasedAlias","type":"EvoTest.AliasOfAliasedRecordWithChanges"},{"name":"streamIntToStringToFloat","type":{"stream":{"items":"string"}}},{"name":"vectorIntToStringToFloat","type":{"vector":{"items":"string"}}},{"name":"intFloatUnionReordered","type":[{"tag":"float32","type":"float32"},{"tag":"int32","type":"int32"}]},{"name":"vectorUnionReordered","type":{"vector":{"items":[{"tag":"float32","type":"float32"},{"tag":"int32","type":"int32"}]}}},{"name":"streamUnionReordered","type":{"stream":{"items":[{"tag":"string","type":"string"},{"tag":"int32","type":"int32"}]}}},{"name":"intToUnionStream","type":{"stream":{"items":"int32"}}},{"name":"unionStreamTypeChange","type":{"stream":{"items":[{"tag":"int32","type":"int32"},{"tag":"bool","type":"bool"}]}}},{"name":"streamOfAliasTypeChange","type":{"stream":{"items":"EvoTest.StreamItem"}}},{"name":"rlink","type":"EvoTest.RLink"},{"name":"rlinkRX","type":"EvoTest.RX"},{"name":"rlinkRY","type":"EvoTest.RY"},{"name":"rlinkRZ","type":"EvoTest.RZ"},{"name":"raRLink","type":"EvoTest.RLink"},{"name":"raRX","type":"EvoTest.RX"},{"name":"raRY","type":"EvoTest.RY"},{"name":"raRZ","type":"EvoTest.RZ"},{"name":"rbRLink","type":"EvoTest.RLink"},{"name":"rbRX","type":"EvoTest.RX"},{"name":"rbRY","type":"EvoTest.RY"},{"name":"rbRZ","type":"EvoTest.RZ"},{"name":"rcRLink","type":"EvoTest.RLink"},{"name":"rcRX","type":"EvoTest.RX"},{"name":"rcRY","type":"EvoTest.RY"},{"name":"rcRZ","type":"EvoTest.RZ"},{"name":"rlinkRNew","type":"EvoTest.RNew"},{"name":"raRNew","type":"EvoTest.RNew"},{"name":"rbRNew","type":"EvoTest.RNew"},{"name":"rcRNew","type":"EvoTest.RNew"},{"name":"rlinkRUnion","type":"EvoTest.RUnion"},{"name":"raRUnion","type":"EvoTest.RUnion"},{"name":"rbRUnion","type":"EvoTest.RUnion"},{"name":"rcRUnion","type":"EvoTest.RUnion"},{"name":"optionalRecordWithChanges","type":[null,"EvoTest.RecordWithChanges"]},{"name":"aliasedOptionalRecordWithChanges","type":[null,"EvoTest.AliasedRecordWithChanges"]},{"name":"unionRecordWithChanges","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"}]},{"name":"unionWithSameTypeset","type":[{"tag":"float32","type":"float32"},{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"string","type":"string"},{"tag":"int32","type":"int32"}]},{"name":"unionWithTypesAdded","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"},{"tag":"string","type":"string"}]},{"name":"unionWithTypesRemoved","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"string","type":"string"}]},{"name":"recordToOptional","type":[null,"EvoTest.RecordWithChanges"]},{"name":"recordToAliasedOptional","type":"EvoTest.AliasedOptionalRecord"},{"name":"recordToUnion","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"string","type":"string"}]},{"name":"recordToAliasedUnion","type":"EvoTest.AliasedRecordOrString"},{"name":"unionToAliasedUnion","type":"EvoTest.AliasedRecordOrInt"},{"name":"unionToAliasedUnionWithChanges","type":"EvoTest.AliasedRecordOrString"},{"name":"optionalToAliasedOptional","type":"EvoTest.AliasedOptionalRecord"},{"name":"optionalToAliasedOptionalWithChanges","type":"EvoTest.AliasedOptionalString"},{"name":"genericRecord","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToOpenAlias","type":{"name":"EvoTest.AliasedOpenGenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToClosedAlias","type":"EvoTest.AliasedClosedGenericRecord"},{"name":"genericRecordToHalfClosedAlias","type":{"name":"EvoTest.AliasedHalfClosedGenericRecord","typeArguments":["int32"]}},{"name":"aliasedGenericRecordToAlias","type":{"name":"EvoTest.AliasedOpenGenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToReversed","type":{"name":"EvoTest.GenericRecordReversed","typeArguments":["string","int32"]}},{"name":"closedGenericRecordToUnion","type":[{"tag":"r","explicitTag":true,"type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"tag":"s","explicitTag":true,"type":"string"}]},{"name":"genericRecordToAliasedUnion","type":"EvoTest.AliasedGenericRecordOrString"},{"name":"genericUnionToReversed","type":{"name":"EvoTest.GenericUnionReversed","typeArguments":["float32",{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}]}},{"name":"genericUnionOfChangedRecord","type":{"name":"EvoTest.GenericUnion","typeArguments":[{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]},"float32"]}},{"name":"genericParentRecord","type":{"name":"EvoTest.GenericParentRecord","typeArguments":["int32"]}},{"name":"genericNestedRecords","type":{"name":"EvoTest.GenericRecord","typeArguments":["EvoTest.Unchanged","EvoTest.Changed"]}},{"name":"genericRecordStream","type":{"stream":{"items":"EvoTest.AliasedClosedGenericRecord"}}},{"name":"genericParentRecordStream","type":{"stream":{"items":{"name":"EvoTest.GenericParentRecord","typeArguments":["int32"]}}}},{"name":"vectorRecordWithChanges","type":{"vector":{"items":"EvoTest.RecordWithChanges"}}},{"name":"streamedRecordWithChanges","type":{"stream":{"items":"EvoTest.RecordWithChanges"}}},{"name":"addedOptional","type":[null,"EvoTest.RecordWithChanges"]},{"name":"addedMap","type":{"map":{"keys":"string","values":"string"}}},{"name":"addedRecordStream","type":{"stream":{"items":"EvoTest.RecordWithChanges"}}}]},"types":[{"name":"AliasOfAliasedRecordWithChanges","type":"EvoTest.AliasedRecordWithChanges"},{"name":"AliasedClosedGenericRecord","type":{"name":"EvoTest.AliasedHalfClosedGenericRecord","typeArguments":["int32"]}},{"name":"AliasedClosedGenericUnion","type":{"name":"EvoTest.AliasedHalfClosedGenericUnion","typeArguments":[{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}]}},{"name":"AliasedEnum","type":"EvoTest.GrowingEnum"},{"name":"AliasedGenericRecordOrString","type":[{"tag":"r","explicitTag":true,"type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"tag":"s","explicitTag":true,"type":"string"}]},{"name":"AliasedHalfClosedGenericRecord","typeParameters":["T"],"type":{"name":"EvoTest.AliasedOpenGenericRecord","typeArguments":["T","string"]}},{"name":"AliasedHalfClosedGenericUnion","typeParameters":["T"],"type":{"name":"EvoTest.AliasedOpenGenericUnion","typeArguments":["T","float32"]}},{"name":"AliasedInt","type":"int32"},{"name":"AliasedLongToString","type":"string"},{"name":"AliasedOpenGenericRecord","typeParameters":["A","B"],"type":{"name":"EvoTest.GenericRecord","typeArguments":["A","B"]}},{"name":"AliasedOpenGenericUnion","typeParameters":["A","B"],"type":{"name":"EvoTest.GenericUnion","typeArguments":["A","B"]}},{"name":"AliasedOptionalRecord","type":[null,"EvoTest.RecordWithChanges"]},{"name":"AliasedOptionalString","type":[null,"string"]},{"name":"AliasedRecordOrInt","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"}]},{"name":"AliasedRecordOrString","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"string","type":"string"}]},{"name":"AliasedRecordWithChanges","type":"EvoTest.RecordWithChanges"},{"name":"AliasedString","type":"string"},{"name":"Changed","type":{"name":"EvoTest.ChangedGeneric","typeArguments":["string","int32"]}},{"name":"ChangedGeneric","typeParameters":["I","J"],"type":{"name":"EvoTest.OldChangedGeneric","typeArguments":["I","J"]}},{"name":"DeprecatedRecord","fields":[{"name":"s","type":"string"},{"name":"i","type":"int32"}]},{"name":"GenericParentRecord","typeParameters":["T"],"fields":[{"name":"record","type":{"name":"EvoTest.AliasedHalfClosedGenericRecord","typeArguments":["T"]}},{"name":"recordOfUnion","type":{"name":"EvoTest.AliasedOpenGenericRecord","typeArguments":[{"name":"EvoTest.AliasedOpenGenericUnion","typeArguments":["T","float32"]},"string"]}},{"name":"unionOfRecord","type":"EvoTest.AliasedClosedGenericUnion"}]},{"name":"GenericRecord","typeParameters":["T1","T2"],"fields":[{"name":"field2","type":"T2"},{"name":"field1","type":"T1"},{"name":"added","type":[null,"bool"]}]},{"name":"GenericRecordReversed","typeParameters":["X","Y"],"type":{"name":"EvoTest.GenericRecord","typeArguments":["Y","X"]}},{"name":"GenericUnion","typeParameters":["T1","T2"],"type":{"name":"EvoTest.GenericUnion2","typeArguments":["T1","T2"]}},{"name":"GenericUnion2","typeParameters":["X","Y"],"type":[{"tag":"X","type":"X"},{"tag":"Y","type":"Y"}]},{"name":"GenericUnionReversed","typeParameters":["T","U"],"type":{"name":"EvoTest.GenericUnion2","typeArguments":["U","T"]}},{"name":"GrowingEnum","base":"uint16","values":[{"symbol":"a","value":0},{"symbol":"b","value":1},{"symbol":"c","value":2},{"symbol":"d","value":3}]},{"name":"OldChangedGeneric","typeParameters":["Y","Z"],"fields":[{"name":"y","type":[null,"Y"]},{"name":"z","type":[null,{"name":"EvoTest.OldUnchangedGeneric","typeArguments":["Z"]}]}]},{"name":"OldUnchangedGeneric","typeParameters":["T2"],"fields":[{"name":"field","type":"T2"}]},{"name":"RLink","type":"EvoTest.RNew"},{"name":"RNew","type":"EvoTest.RY"},{"name":"RUnion","type":[{"tag":"RX","type":"EvoTest.RX"},{"tag":"string","type":"string"}]},{"name":"RX","type":"EvoTest.RLink"},{"name":"RY","type":"EvoTest.RZ"},{"name":"RZ","fields":[{"name":"subject","type":"int32"}]},{"name":"RecordWithChanges","fields":[{"name":"floatToDouble","type":"float64"},{"name":"unchangedRecord","type":"EvoTest.UnchangedRecord"},{"name":"intToLong","type":"int64"},{"name":"optionalLongToString","type":[null,"string"]}]},{"name":"RenamedRecord","type":"EvoTest.DeprecatedRecord"},{"name":"StreamItem","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"RenamedRecord","type":"EvoTest.RenamedRecord"}]},{"name":"Unchanged","type":{"name":"EvoTest.UnchangedGeneric","typeArguments":["int32"]}},{"name":"UnchangedGeneric","typeParameters":["A"],"type":{"name":"EvoTest.OldUnchangedGeneric","typeArguments":["A"]}},{"name":"UnchangedRecord","fields":[{"name":"name","type":"string"},{"name":"age","type":"int32"},{"name":"meta","type":{"map":{"keys":"string","values":"float64"}}}]}]})"; std::vector ProtocolWithChangesWriterBase::previous_schemas_ = { @@ -362,9 +23,10 @@ std::string ProtocolWithChangesWriterBase::SchemaFromVersion(Version version) { } } + void ProtocolWithChangesWriterBase::WriteInt8ToInt(int32_t const& value) { if (unlikely(state_ != 0)) { - ProtocolWithChangesWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteInt8ToIntImpl(value); @@ -373,7 +35,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToInt(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToLong(int64_t const& value) { if (unlikely(state_ != 1)) { - ProtocolWithChangesWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteInt8ToLongImpl(value); @@ -382,7 +44,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToLong(int64_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToUint(uint32_t const& value) { if (unlikely(state_ != 2)) { - ProtocolWithChangesWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteInt8ToUintImpl(value); @@ -391,7 +53,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToUint(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToUlong(uint64_t const& value) { if (unlikely(state_ != 3)) { - ProtocolWithChangesWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteInt8ToUlongImpl(value); @@ -400,7 +62,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToUlong(uint64_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToFloat(float const& value) { if (unlikely(state_ != 4)) { - ProtocolWithChangesWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } WriteInt8ToFloatImpl(value); @@ -409,7 +71,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToFloat(float const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToDouble(double const& value) { if (unlikely(state_ != 5)) { - ProtocolWithChangesWriterBaseInvalidState(5, false, state_); + InvalidState(5, false); } WriteInt8ToDoubleImpl(value); @@ -418,7 +80,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToDouble(double const& value) { void ProtocolWithChangesWriterBase::WriteIntToUint(uint32_t const& value) { if (unlikely(state_ != 6)) { - ProtocolWithChangesWriterBaseInvalidState(6, false, state_); + InvalidState(6, false); } WriteIntToUintImpl(value); @@ -427,7 +89,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUint(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToLong(int64_t const& value) { if (unlikely(state_ != 7)) { - ProtocolWithChangesWriterBaseInvalidState(7, false, state_); + InvalidState(7, false); } WriteIntToLongImpl(value); @@ -436,7 +98,7 @@ void ProtocolWithChangesWriterBase::WriteIntToLong(int64_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToFloat(float const& value) { if (unlikely(state_ != 8)) { - ProtocolWithChangesWriterBaseInvalidState(8, false, state_); + InvalidState(8, false); } WriteIntToFloatImpl(value); @@ -445,7 +107,7 @@ void ProtocolWithChangesWriterBase::WriteIntToFloat(float const& value) { void ProtocolWithChangesWriterBase::WriteIntToDouble(double const& value) { if (unlikely(state_ != 9)) { - ProtocolWithChangesWriterBaseInvalidState(9, false, state_); + InvalidState(9, false); } WriteIntToDoubleImpl(value); @@ -454,7 +116,7 @@ void ProtocolWithChangesWriterBase::WriteIntToDouble(double const& value) { void ProtocolWithChangesWriterBase::WriteUintToUlong(uint64_t const& value) { if (unlikely(state_ != 10)) { - ProtocolWithChangesWriterBaseInvalidState(10, false, state_); + InvalidState(10, false); } WriteUintToUlongImpl(value); @@ -463,7 +125,7 @@ void ProtocolWithChangesWriterBase::WriteUintToUlong(uint64_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToFloat(float const& value) { if (unlikely(state_ != 11)) { - ProtocolWithChangesWriterBaseInvalidState(11, false, state_); + InvalidState(11, false); } WriteUintToFloatImpl(value); @@ -472,7 +134,7 @@ void ProtocolWithChangesWriterBase::WriteUintToFloat(float const& value) { void ProtocolWithChangesWriterBase::WriteUintToDouble(double const& value) { if (unlikely(state_ != 12)) { - ProtocolWithChangesWriterBaseInvalidState(12, false, state_); + InvalidState(12, false); } WriteUintToDoubleImpl(value); @@ -481,7 +143,7 @@ void ProtocolWithChangesWriterBase::WriteUintToDouble(double const& value) { void ProtocolWithChangesWriterBase::WriteFloatToDouble(double const& value) { if (unlikely(state_ != 13)) { - ProtocolWithChangesWriterBaseInvalidState(13, false, state_); + InvalidState(13, false); } WriteFloatToDoubleImpl(value); @@ -490,7 +152,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToDouble(double const& value) { void ProtocolWithChangesWriterBase::WriteComplexFloatToComplexDouble(std::complex const& value) { if (unlikely(state_ != 14)) { - ProtocolWithChangesWriterBaseInvalidState(14, false, state_); + InvalidState(14, false); } WriteComplexFloatToComplexDoubleImpl(value); @@ -499,7 +161,7 @@ void ProtocolWithChangesWriterBase::WriteComplexFloatToComplexDouble(std::comple void ProtocolWithChangesWriterBase::WriteIntToString(std::string const& value) { if (unlikely(state_ != 15)) { - ProtocolWithChangesWriterBaseInvalidState(15, false, state_); + InvalidState(15, false); } WriteIntToStringImpl(value); @@ -508,7 +170,7 @@ void ProtocolWithChangesWriterBase::WriteIntToString(std::string const& value) { void ProtocolWithChangesWriterBase::WriteUintToString(std::string const& value) { if (unlikely(state_ != 16)) { - ProtocolWithChangesWriterBaseInvalidState(16, false, state_); + InvalidState(16, false); } WriteUintToStringImpl(value); @@ -517,7 +179,7 @@ void ProtocolWithChangesWriterBase::WriteUintToString(std::string const& value) void ProtocolWithChangesWriterBase::WriteLongToString(std::string const& value) { if (unlikely(state_ != 17)) { - ProtocolWithChangesWriterBaseInvalidState(17, false, state_); + InvalidState(17, false); } WriteLongToStringImpl(value); @@ -526,7 +188,7 @@ void ProtocolWithChangesWriterBase::WriteLongToString(std::string const& value) void ProtocolWithChangesWriterBase::WriteUlongToString(std::string const& value) { if (unlikely(state_ != 18)) { - ProtocolWithChangesWriterBaseInvalidState(18, false, state_); + InvalidState(18, false); } WriteUlongToStringImpl(value); @@ -535,7 +197,7 @@ void ProtocolWithChangesWriterBase::WriteUlongToString(std::string const& value) void ProtocolWithChangesWriterBase::WriteFloatToString(std::string const& value) { if (unlikely(state_ != 19)) { - ProtocolWithChangesWriterBaseInvalidState(19, false, state_); + InvalidState(19, false); } WriteFloatToStringImpl(value); @@ -544,7 +206,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToString(std::string const& value) void ProtocolWithChangesWriterBase::WriteDoubleToString(std::string const& value) { if (unlikely(state_ != 20)) { - ProtocolWithChangesWriterBaseInvalidState(20, false, state_); + InvalidState(20, false); } WriteDoubleToStringImpl(value); @@ -553,7 +215,7 @@ void ProtocolWithChangesWriterBase::WriteDoubleToString(std::string const& value void ProtocolWithChangesWriterBase::WriteIntToOptional(std::optional const& value) { if (unlikely(state_ != 21)) { - ProtocolWithChangesWriterBaseInvalidState(21, false, state_); + InvalidState(21, false); } WriteIntToOptionalImpl(value); @@ -562,7 +224,7 @@ void ProtocolWithChangesWriterBase::WriteIntToOptional(std::optional co void ProtocolWithChangesWriterBase::WriteFloatToOptional(std::optional const& value) { if (unlikely(state_ != 22)) { - ProtocolWithChangesWriterBaseInvalidState(22, false, state_); + InvalidState(22, false); } WriteFloatToOptionalImpl(value); @@ -571,7 +233,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToOptional(std::optional co void ProtocolWithChangesWriterBase::WriteStringToOptional(std::optional const& value) { if (unlikely(state_ != 23)) { - ProtocolWithChangesWriterBaseInvalidState(23, false, state_); + InvalidState(23, false); } WriteStringToOptionalImpl(value); @@ -580,7 +242,7 @@ void ProtocolWithChangesWriterBase::WriteStringToOptional(std::optional const& value) { if (unlikely(state_ != 24)) { - ProtocolWithChangesWriterBaseInvalidState(24, false, state_); + InvalidState(24, false); } WriteIntToUnionImpl(value); @@ -589,7 +251,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUnion(std::variant void ProtocolWithChangesWriterBase::WriteFloatToUnion(std::variant const& value) { if (unlikely(state_ != 25)) { - ProtocolWithChangesWriterBaseInvalidState(25, false, state_); + InvalidState(25, false); } WriteFloatToUnionImpl(value); @@ -598,7 +260,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToUnion(std::variant void ProtocolWithChangesWriterBase::WriteStringToUnion(std::variant const& value) { if (unlikely(state_ != 26)) { - ProtocolWithChangesWriterBaseInvalidState(26, false, state_); + InvalidState(26, false); } WriteStringToUnionImpl(value); @@ -607,7 +269,7 @@ void ProtocolWithChangesWriterBase::WriteStringToUnion(std::variant const& value) { if (unlikely(state_ != 27)) { - ProtocolWithChangesWriterBaseInvalidState(27, false, state_); + InvalidState(27, false); } WriteOptionalIntToFloatImpl(value); @@ -616,7 +278,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalIntToFloat(std::optional void ProtocolWithChangesWriterBase::WriteOptionalFloatToString(std::optional const& value) { if (unlikely(state_ != 28)) { - ProtocolWithChangesWriterBaseInvalidState(28, false, state_); + InvalidState(28, false); } WriteOptionalFloatToStringImpl(value); @@ -625,7 +287,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalFloatToString(std::optional const& value) { if (unlikely(state_ != 33)) { - ProtocolWithChangesWriterBaseInvalidState(33, false, state_); + InvalidState(33, false); } WriteOptionalIntToUnionImpl(value); @@ -670,7 +332,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalIntToUnion(std::variant const& value) { if (unlikely(state_ != 34)) { - ProtocolWithChangesWriterBaseInvalidState(34, false, state_); + InvalidState(34, false); } WriteOptionalRecordToUnionImpl(value); @@ -679,7 +341,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalRecordToUnion(std::variant const& values) { if (unlikely(state_ != 40)) { - ProtocolWithChangesWriterBaseInvalidState(40, false, state_); + InvalidState(40, false); } WriteStreamIntToStringToFloatImpl(values); @@ -740,7 +402,7 @@ void ProtocolWithChangesWriterBase::WriteStreamIntToStringToFloat(std::vector const& value) { if (unlikely(state_ != 41)) { - ProtocolWithChangesWriterBaseInvalidState(41, false, state_); + InvalidState(41, false); } WriteVectorIntToStringToFloatImpl(value); @@ -765,7 +427,7 @@ void ProtocolWithChangesWriterBase::WriteVectorIntToStringToFloat(std::vector const& value) { if (unlikely(state_ != 42)) { - ProtocolWithChangesWriterBaseInvalidState(42, false, state_); + InvalidState(42, false); } WriteIntFloatUnionReorderedImpl(value); @@ -774,7 +436,7 @@ void ProtocolWithChangesWriterBase::WriteIntFloatUnionReordered(std::variant> const& value) { if (unlikely(state_ != 43)) { - ProtocolWithChangesWriterBaseInvalidState(43, false, state_); + InvalidState(43, false); } WriteVectorUnionReorderedImpl(value); @@ -783,7 +445,7 @@ void ProtocolWithChangesWriterBase::WriteVectorUnionReordered(std::vector const& value) { if (unlikely(state_ != 44)) { - ProtocolWithChangesWriterBaseInvalidState(44, false, state_); + InvalidState(44, false); } WriteStreamUnionReorderedImpl(value); @@ -791,7 +453,7 @@ void ProtocolWithChangesWriterBase::WriteStreamUnionReordered(std::variant> const& values) { if (unlikely(state_ != 44)) { - ProtocolWithChangesWriterBaseInvalidState(44, false, state_); + InvalidState(44, false); } WriteStreamUnionReorderedImpl(values); @@ -799,7 +461,7 @@ void ProtocolWithChangesWriterBase::WriteStreamUnionReordered(std::vector const& values) { if (unlikely(state_ != 45)) { - ProtocolWithChangesWriterBaseInvalidState(45, false, state_); + InvalidState(45, false); } WriteIntToUnionStreamImpl(values); @@ -831,7 +493,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUnionStream(std::vector c void ProtocolWithChangesWriterBase::EndIntToUnionStream() { if (unlikely(state_ != 45)) { - ProtocolWithChangesWriterBaseInvalidState(45, true, state_); + InvalidState(45, true); } EndIntToUnionStreamImpl(); @@ -847,7 +509,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUnionStreamImpl(std::vector const& value) { if (unlikely(state_ != 46)) { - ProtocolWithChangesWriterBaseInvalidState(46, false, state_); + InvalidState(46, false); } WriteUnionStreamTypeChangeImpl(value); @@ -855,7 +517,7 @@ void ProtocolWithChangesWriterBase::WriteUnionStreamTypeChange(std::variant> const& values) { if (unlikely(state_ != 46)) { - ProtocolWithChangesWriterBaseInvalidState(46, false, state_); + InvalidState(46, false); } WriteUnionStreamTypeChangeImpl(values); @@ -863,7 +525,7 @@ void ProtocolWithChangesWriterBase::WriteUnionStreamTypeChange(std::vector const& values) { if (unlikely(state_ != 47)) { - ProtocolWithChangesWriterBaseInvalidState(47, false, state_); + InvalidState(47, false); } WriteStreamOfAliasTypeChangeImpl(values); @@ -895,7 +557,7 @@ void ProtocolWithChangesWriterBase::WriteStreamOfAliasTypeChange(std::vector const& value) { if (unlikely(state_ != 72)) { - ProtocolWithChangesWriterBaseInvalidState(72, false, state_); + InvalidState(72, false); } WriteOptionalRecordWithChangesImpl(value); @@ -1136,7 +798,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalRecordWithChanges(std::optional void ProtocolWithChangesWriterBase::WriteAliasedOptionalRecordWithChanges(std::optional const& value) { if (unlikely(state_ != 73)) { - ProtocolWithChangesWriterBaseInvalidState(73, false, state_); + InvalidState(73, false); } WriteAliasedOptionalRecordWithChangesImpl(value); @@ -1145,7 +807,7 @@ void ProtocolWithChangesWriterBase::WriteAliasedOptionalRecordWithChanges(std::o void ProtocolWithChangesWriterBase::WriteUnionRecordWithChanges(std::variant const& value) { if (unlikely(state_ != 74)) { - ProtocolWithChangesWriterBaseInvalidState(74, false, state_); + InvalidState(74, false); } WriteUnionRecordWithChangesImpl(value); @@ -1154,7 +816,7 @@ void ProtocolWithChangesWriterBase::WriteUnionRecordWithChanges(std::variant const& value) { if (unlikely(state_ != 75)) { - ProtocolWithChangesWriterBaseInvalidState(75, false, state_); + InvalidState(75, false); } WriteUnionWithSameTypesetImpl(value); @@ -1163,7 +825,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithSameTypeset(std::variant const& value) { if (unlikely(state_ != 76)) { - ProtocolWithChangesWriterBaseInvalidState(76, false, state_); + InvalidState(76, false); } WriteUnionWithTypesAddedImpl(value); @@ -1172,7 +834,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithTypesAdded(std::variant const& value) { if (unlikely(state_ != 77)) { - ProtocolWithChangesWriterBaseInvalidState(77, false, state_); + InvalidState(77, false); } WriteUnionWithTypesRemovedImpl(value); @@ -1181,7 +843,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithTypesRemoved(std::variant const& value) { if (unlikely(state_ != 78)) { - ProtocolWithChangesWriterBaseInvalidState(78, false, state_); + InvalidState(78, false); } WriteRecordToOptionalImpl(value); @@ -1190,7 +852,7 @@ void ProtocolWithChangesWriterBase::WriteRecordToOptional(std::optional const& value) { if (unlikely(state_ != 80)) { - ProtocolWithChangesWriterBaseInvalidState(80, false, state_); + InvalidState(80, false); } WriteRecordToUnionImpl(value); @@ -1208,7 +870,7 @@ void ProtocolWithChangesWriterBase::WriteRecordToUnion(std::variant const& value) { if (unlikely(state_ != 86)) { - ProtocolWithChangesWriterBaseInvalidState(86, false, state_); + InvalidState(86, false); } WriteGenericRecordImpl(value); @@ -1262,7 +924,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecord(evo_test::GenericRecord const& value) { if (unlikely(state_ != 87)) { - ProtocolWithChangesWriterBaseInvalidState(87, false, state_); + InvalidState(87, false); } WriteGenericRecordToOpenAliasImpl(value); @@ -1271,7 +933,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToOpenAlias(evo_test::Alia void ProtocolWithChangesWriterBase::WriteGenericRecordToClosedAlias(evo_test::AliasedClosedGenericRecord const& value) { if (unlikely(state_ != 88)) { - ProtocolWithChangesWriterBaseInvalidState(88, false, state_); + InvalidState(88, false); } WriteGenericRecordToClosedAliasImpl(value); @@ -1280,7 +942,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToClosedAlias(evo_test::Al void ProtocolWithChangesWriterBase::WriteGenericRecordToHalfClosedAlias(evo_test::AliasedHalfClosedGenericRecord const& value) { if (unlikely(state_ != 89)) { - ProtocolWithChangesWriterBaseInvalidState(89, false, state_); + InvalidState(89, false); } WriteGenericRecordToHalfClosedAliasImpl(value); @@ -1289,7 +951,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToHalfClosedAlias(evo_test void ProtocolWithChangesWriterBase::WriteAliasedGenericRecordToAlias(evo_test::AliasedOpenGenericRecord const& value) { if (unlikely(state_ != 90)) { - ProtocolWithChangesWriterBaseInvalidState(90, false, state_); + InvalidState(90, false); } WriteAliasedGenericRecordToAliasImpl(value); @@ -1298,7 +960,7 @@ void ProtocolWithChangesWriterBase::WriteAliasedGenericRecordToAlias(evo_test::A void ProtocolWithChangesWriterBase::WriteGenericRecordToReversed(evo_test::GenericRecordReversed const& value) { if (unlikely(state_ != 91)) { - ProtocolWithChangesWriterBaseInvalidState(91, false, state_); + InvalidState(91, false); } WriteGenericRecordToReversedImpl(value); @@ -1307,7 +969,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToReversed(evo_test::Gener void ProtocolWithChangesWriterBase::WriteClosedGenericRecordToUnion(std::variant, std::string> const& value) { if (unlikely(state_ != 92)) { - ProtocolWithChangesWriterBaseInvalidState(92, false, state_); + InvalidState(92, false); } WriteClosedGenericRecordToUnionImpl(value); @@ -1316,7 +978,7 @@ void ProtocolWithChangesWriterBase::WriteClosedGenericRecordToUnion(std::variant void ProtocolWithChangesWriterBase::WriteGenericRecordToAliasedUnion(evo_test::AliasedGenericRecordOrString const& value) { if (unlikely(state_ != 93)) { - ProtocolWithChangesWriterBaseInvalidState(93, false, state_); + InvalidState(93, false); } WriteGenericRecordToAliasedUnionImpl(value); @@ -1325,7 +987,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToAliasedUnion(evo_test::A void ProtocolWithChangesWriterBase::WriteGenericUnionToReversed(evo_test::GenericUnionReversed> const& value) { if (unlikely(state_ != 94)) { - ProtocolWithChangesWriterBaseInvalidState(94, false, state_); + InvalidState(94, false); } WriteGenericUnionToReversedImpl(value); @@ -1334,7 +996,7 @@ void ProtocolWithChangesWriterBase::WriteGenericUnionToReversed(evo_test::Generi void ProtocolWithChangesWriterBase::WriteGenericUnionOfChangedRecord(evo_test::GenericUnion, float> const& value) { if (unlikely(state_ != 95)) { - ProtocolWithChangesWriterBaseInvalidState(95, false, state_); + InvalidState(95, false); } WriteGenericUnionOfChangedRecordImpl(value); @@ -1343,7 +1005,7 @@ void ProtocolWithChangesWriterBase::WriteGenericUnionOfChangedRecord(evo_test::G void ProtocolWithChangesWriterBase::WriteGenericParentRecord(evo_test::GenericParentRecord const& value) { if (unlikely(state_ != 96)) { - ProtocolWithChangesWriterBaseInvalidState(96, false, state_); + InvalidState(96, false); } WriteGenericParentRecordImpl(value); @@ -1352,7 +1014,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecord(evo_test::GenericPa void ProtocolWithChangesWriterBase::WriteGenericNestedRecords(evo_test::GenericRecord const& value) { if (unlikely(state_ != 97)) { - ProtocolWithChangesWriterBaseInvalidState(97, false, state_); + InvalidState(97, false); } WriteGenericNestedRecordsImpl(value); @@ -1361,7 +1023,7 @@ void ProtocolWithChangesWriterBase::WriteGenericNestedRecords(evo_test::GenericR void ProtocolWithChangesWriterBase::WriteGenericRecordStream(evo_test::AliasedClosedGenericRecord const& value) { if (unlikely(state_ != 98)) { - ProtocolWithChangesWriterBaseInvalidState(98, false, state_); + InvalidState(98, false); } WriteGenericRecordStreamImpl(value); @@ -1369,7 +1031,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordStream(evo_test::AliasedCl void ProtocolWithChangesWriterBase::WriteGenericRecordStream(std::vector const& values) { if (unlikely(state_ != 98)) { - ProtocolWithChangesWriterBaseInvalidState(98, false, state_); + InvalidState(98, false); } WriteGenericRecordStreamImpl(values); @@ -1377,7 +1039,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordStream(std::vector const& value) { if (unlikely(state_ != 99)) { - ProtocolWithChangesWriterBaseInvalidState(99, false, state_); + InvalidState(99, false); } WriteGenericParentRecordStreamImpl(value); @@ -1401,7 +1063,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(evo_test::Gen void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(std::vector> const& values) { if (unlikely(state_ != 99)) { - ProtocolWithChangesWriterBaseInvalidState(99, false, state_); + InvalidState(99, false); } WriteGenericParentRecordStreamImpl(values); @@ -1409,7 +1071,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(std::vector const& value) { if (unlikely(state_ != 100)) { - ProtocolWithChangesWriterBaseInvalidState(100, false, state_); + InvalidState(100, false); } WriteVectorRecordWithChangesImpl(value); @@ -1434,7 +1096,7 @@ void ProtocolWithChangesWriterBase::WriteVectorRecordWithChanges(std::vector const& values) { if (unlikely(state_ != 101)) { - ProtocolWithChangesWriterBaseInvalidState(101, false, state_); + InvalidState(101, false); } WriteStreamedRecordWithChangesImpl(values); @@ -1450,7 +1112,7 @@ void ProtocolWithChangesWriterBase::WriteStreamedRecordWithChanges(std::vector const& value) { if (unlikely(state_ != 102)) { - ProtocolWithChangesWriterBaseInvalidState(102, false, state_); + InvalidState(102, false); } WriteAddedOptionalImpl(value); @@ -1475,7 +1137,7 @@ void ProtocolWithChangesWriterBase::WriteAddedOptional(std::optional const& value) { if (unlikely(state_ != 103)) { - ProtocolWithChangesWriterBaseInvalidState(103, false, state_); + InvalidState(103, false); } WriteAddedMapImpl(value); @@ -1484,7 +1146,7 @@ void ProtocolWithChangesWriterBase::WriteAddedMap(std::unordered_map const& values) { if (unlikely(state_ != 104)) { - ProtocolWithChangesWriterBaseInvalidState(104, false, state_); + InvalidState(104, false); } WriteAddedRecordStreamImpl(values); @@ -1500,7 +1162,7 @@ void ProtocolWithChangesWriterBase::WriteAddedRecordStream(std::vector& value) { if (unlikely(state_ != 28)) { - ProtocolWithChangesReaderBaseInvalidState(28, state_); + InvalidState(28); } ReadComplexFloatToComplexDoubleImpl(value); @@ -1672,7 +1556,7 @@ void ProtocolWithChangesReaderBase::ReadComplexFloatToComplexDouble(std::complex void ProtocolWithChangesReaderBase::ReadIntToString(std::string& value) { if (unlikely(state_ != 30)) { - ProtocolWithChangesReaderBaseInvalidState(30, state_); + InvalidState(30); } ReadIntToStringImpl(value); @@ -1681,7 +1565,7 @@ void ProtocolWithChangesReaderBase::ReadIntToString(std::string& value) { void ProtocolWithChangesReaderBase::ReadUintToString(std::string& value) { if (unlikely(state_ != 32)) { - ProtocolWithChangesReaderBaseInvalidState(32, state_); + InvalidState(32); } ReadUintToStringImpl(value); @@ -1690,7 +1574,7 @@ void ProtocolWithChangesReaderBase::ReadUintToString(std::string& value) { void ProtocolWithChangesReaderBase::ReadLongToString(std::string& value) { if (unlikely(state_ != 34)) { - ProtocolWithChangesReaderBaseInvalidState(34, state_); + InvalidState(34); } ReadLongToStringImpl(value); @@ -1699,7 +1583,7 @@ void ProtocolWithChangesReaderBase::ReadLongToString(std::string& value) { void ProtocolWithChangesReaderBase::ReadUlongToString(std::string& value) { if (unlikely(state_ != 36)) { - ProtocolWithChangesReaderBaseInvalidState(36, state_); + InvalidState(36); } ReadUlongToStringImpl(value); @@ -1708,7 +1592,7 @@ void ProtocolWithChangesReaderBase::ReadUlongToString(std::string& value) { void ProtocolWithChangesReaderBase::ReadFloatToString(std::string& value) { if (unlikely(state_ != 38)) { - ProtocolWithChangesReaderBaseInvalidState(38, state_); + InvalidState(38); } ReadFloatToStringImpl(value); @@ -1717,7 +1601,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToString(std::string& value) { void ProtocolWithChangesReaderBase::ReadDoubleToString(std::string& value) { if (unlikely(state_ != 40)) { - ProtocolWithChangesReaderBaseInvalidState(40, state_); + InvalidState(40); } ReadDoubleToStringImpl(value); @@ -1726,7 +1610,7 @@ void ProtocolWithChangesReaderBase::ReadDoubleToString(std::string& value) { void ProtocolWithChangesReaderBase::ReadIntToOptional(std::optional& value) { if (unlikely(state_ != 42)) { - ProtocolWithChangesReaderBaseInvalidState(42, state_); + InvalidState(42); } ReadIntToOptionalImpl(value); @@ -1735,7 +1619,7 @@ void ProtocolWithChangesReaderBase::ReadIntToOptional(std::optional& va void ProtocolWithChangesReaderBase::ReadFloatToOptional(std::optional& value) { if (unlikely(state_ != 44)) { - ProtocolWithChangesReaderBaseInvalidState(44, state_); + InvalidState(44); } ReadFloatToOptionalImpl(value); @@ -1744,7 +1628,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToOptional(std::optional& va void ProtocolWithChangesReaderBase::ReadStringToOptional(std::optional& value) { if (unlikely(state_ != 46)) { - ProtocolWithChangesReaderBaseInvalidState(46, state_); + InvalidState(46); } ReadStringToOptionalImpl(value); @@ -1753,7 +1637,7 @@ void ProtocolWithChangesReaderBase::ReadStringToOptional(std::optional& value) { if (unlikely(state_ != 48)) { - ProtocolWithChangesReaderBaseInvalidState(48, state_); + InvalidState(48); } ReadIntToUnionImpl(value); @@ -1762,7 +1646,7 @@ void ProtocolWithChangesReaderBase::ReadIntToUnion(std::variant& void ProtocolWithChangesReaderBase::ReadFloatToUnion(std::variant& value) { if (unlikely(state_ != 50)) { - ProtocolWithChangesReaderBaseInvalidState(50, state_); + InvalidState(50); } ReadFloatToUnionImpl(value); @@ -1771,7 +1655,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToUnion(std::variant& void ProtocolWithChangesReaderBase::ReadStringToUnion(std::variant& value) { if (unlikely(state_ != 52)) { - ProtocolWithChangesReaderBaseInvalidState(52, state_); + InvalidState(52); } ReadStringToUnionImpl(value); @@ -1780,7 +1664,7 @@ void ProtocolWithChangesReaderBase::ReadStringToUnion(std::variant& value) { if (unlikely(state_ != 54)) { - ProtocolWithChangesReaderBaseInvalidState(54, state_); + InvalidState(54); } ReadOptionalIntToFloatImpl(value); @@ -1789,7 +1673,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalIntToFloat(std::optional& void ProtocolWithChangesReaderBase::ReadOptionalFloatToString(std::optional& value) { if (unlikely(state_ != 56)) { - ProtocolWithChangesReaderBaseInvalidState(56, state_); + InvalidState(56); } ReadOptionalFloatToStringImpl(value); @@ -1798,7 +1682,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalFloatToString(std::optional& value) { if (unlikely(state_ != 66)) { - ProtocolWithChangesReaderBaseInvalidState(66, state_); + InvalidState(66); } ReadOptionalIntToUnionImpl(value); @@ -1843,7 +1727,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalIntToUnion(std::variant& value) { if (unlikely(state_ != 68)) { - ProtocolWithChangesReaderBaseInvalidState(68, state_); + InvalidState(68); } ReadOptionalRecordToUnionImpl(value); @@ -1852,7 +1736,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalRecordToUnion(std::variant& value) { if (unlikely(state_ != 84)) { - ProtocolWithChangesReaderBaseInvalidState(84, state_); + InvalidState(84); } ReadIntFloatUnionReorderedImpl(value); @@ -1973,7 +1857,7 @@ void ProtocolWithChangesReaderBase::ReadIntFloatUnionReordered(std::variant>& value) { if (unlikely(state_ != 86)) { - ProtocolWithChangesReaderBaseInvalidState(86, state_); + InvalidState(86); } ReadVectorUnionReorderedImpl(value); @@ -1986,7 +1870,7 @@ bool ProtocolWithChangesReaderBase::ReadStreamUnionReordered(std::variant& v if (state_ == 89) { state_ = 90; } else { - ProtocolWithChangesReaderBaseInvalidState(90, state_); + InvalidState(90); } } @@ -2105,7 +1989,7 @@ bool ProtocolWithChangesReaderBase::ReadUnionStreamTypeChange(std::variant& value) { if (unlikely(state_ != 144)) { - ProtocolWithChangesReaderBaseInvalidState(144, state_); + InvalidState(144); } ReadOptionalRecordWithChangesImpl(value); @@ -2451,7 +2335,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalRecordWithChanges(std::optional< void ProtocolWithChangesReaderBase::ReadAliasedOptionalRecordWithChanges(std::optional& value) { if (unlikely(state_ != 146)) { - ProtocolWithChangesReaderBaseInvalidState(146, state_); + InvalidState(146); } ReadAliasedOptionalRecordWithChangesImpl(value); @@ -2460,7 +2344,7 @@ void ProtocolWithChangesReaderBase::ReadAliasedOptionalRecordWithChanges(std::op void ProtocolWithChangesReaderBase::ReadUnionRecordWithChanges(std::variant& value) { if (unlikely(state_ != 148)) { - ProtocolWithChangesReaderBaseInvalidState(148, state_); + InvalidState(148); } ReadUnionRecordWithChangesImpl(value); @@ -2469,7 +2353,7 @@ void ProtocolWithChangesReaderBase::ReadUnionRecordWithChanges(std::variant& value) { if (unlikely(state_ != 150)) { - ProtocolWithChangesReaderBaseInvalidState(150, state_); + InvalidState(150); } ReadUnionWithSameTypesetImpl(value); @@ -2478,7 +2362,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithSameTypeset(std::variant& value) { if (unlikely(state_ != 152)) { - ProtocolWithChangesReaderBaseInvalidState(152, state_); + InvalidState(152); } ReadUnionWithTypesAddedImpl(value); @@ -2487,7 +2371,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithTypesAdded(std::variant& value) { if (unlikely(state_ != 154)) { - ProtocolWithChangesReaderBaseInvalidState(154, state_); + InvalidState(154); } ReadUnionWithTypesRemovedImpl(value); @@ -2496,7 +2380,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithTypesRemoved(std::variant& value) { if (unlikely(state_ != 156)) { - ProtocolWithChangesReaderBaseInvalidState(156, state_); + InvalidState(156); } ReadRecordToOptionalImpl(value); @@ -2505,7 +2389,7 @@ void ProtocolWithChangesReaderBase::ReadRecordToOptional(std::optional& value) { if (unlikely(state_ != 160)) { - ProtocolWithChangesReaderBaseInvalidState(160, state_); + InvalidState(160); } ReadRecordToUnionImpl(value); @@ -2523,7 +2407,7 @@ void ProtocolWithChangesReaderBase::ReadRecordToUnion(std::variant& value) { if (unlikely(state_ != 172)) { - ProtocolWithChangesReaderBaseInvalidState(172, state_); + InvalidState(172); } ReadGenericRecordImpl(value); @@ -2577,7 +2461,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecord(evo_test::GenericRecord& value) { if (unlikely(state_ != 174)) { - ProtocolWithChangesReaderBaseInvalidState(174, state_); + InvalidState(174); } ReadGenericRecordToOpenAliasImpl(value); @@ -2586,7 +2470,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToOpenAlias(evo_test::Alias void ProtocolWithChangesReaderBase::ReadGenericRecordToClosedAlias(evo_test::AliasedClosedGenericRecord& value) { if (unlikely(state_ != 176)) { - ProtocolWithChangesReaderBaseInvalidState(176, state_); + InvalidState(176); } ReadGenericRecordToClosedAliasImpl(value); @@ -2595,7 +2479,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToClosedAlias(evo_test::Ali void ProtocolWithChangesReaderBase::ReadGenericRecordToHalfClosedAlias(evo_test::AliasedHalfClosedGenericRecord& value) { if (unlikely(state_ != 178)) { - ProtocolWithChangesReaderBaseInvalidState(178, state_); + InvalidState(178); } ReadGenericRecordToHalfClosedAliasImpl(value); @@ -2604,7 +2488,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToHalfClosedAlias(evo_test: void ProtocolWithChangesReaderBase::ReadAliasedGenericRecordToAlias(evo_test::AliasedOpenGenericRecord& value) { if (unlikely(state_ != 180)) { - ProtocolWithChangesReaderBaseInvalidState(180, state_); + InvalidState(180); } ReadAliasedGenericRecordToAliasImpl(value); @@ -2613,7 +2497,7 @@ void ProtocolWithChangesReaderBase::ReadAliasedGenericRecordToAlias(evo_test::Al void ProtocolWithChangesReaderBase::ReadGenericRecordToReversed(evo_test::GenericRecordReversed& value) { if (unlikely(state_ != 182)) { - ProtocolWithChangesReaderBaseInvalidState(182, state_); + InvalidState(182); } ReadGenericRecordToReversedImpl(value); @@ -2622,7 +2506,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToReversed(evo_test::Generi void ProtocolWithChangesReaderBase::ReadClosedGenericRecordToUnion(std::variant, std::string>& value) { if (unlikely(state_ != 184)) { - ProtocolWithChangesReaderBaseInvalidState(184, state_); + InvalidState(184); } ReadClosedGenericRecordToUnionImpl(value); @@ -2631,7 +2515,7 @@ void ProtocolWithChangesReaderBase::ReadClosedGenericRecordToUnion(std::variant< void ProtocolWithChangesReaderBase::ReadGenericRecordToAliasedUnion(evo_test::AliasedGenericRecordOrString& value) { if (unlikely(state_ != 186)) { - ProtocolWithChangesReaderBaseInvalidState(186, state_); + InvalidState(186); } ReadGenericRecordToAliasedUnionImpl(value); @@ -2640,7 +2524,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToAliasedUnion(evo_test::Al void ProtocolWithChangesReaderBase::ReadGenericUnionToReversed(evo_test::GenericUnionReversed>& value) { if (unlikely(state_ != 188)) { - ProtocolWithChangesReaderBaseInvalidState(188, state_); + InvalidState(188); } ReadGenericUnionToReversedImpl(value); @@ -2649,7 +2533,7 @@ void ProtocolWithChangesReaderBase::ReadGenericUnionToReversed(evo_test::Generic void ProtocolWithChangesReaderBase::ReadGenericUnionOfChangedRecord(evo_test::GenericUnion, float>& value) { if (unlikely(state_ != 190)) { - ProtocolWithChangesReaderBaseInvalidState(190, state_); + InvalidState(190); } ReadGenericUnionOfChangedRecordImpl(value); @@ -2658,7 +2542,7 @@ void ProtocolWithChangesReaderBase::ReadGenericUnionOfChangedRecord(evo_test::Ge void ProtocolWithChangesReaderBase::ReadGenericParentRecord(evo_test::GenericParentRecord& value) { if (unlikely(state_ != 192)) { - ProtocolWithChangesReaderBaseInvalidState(192, state_); + InvalidState(192); } ReadGenericParentRecordImpl(value); @@ -2667,7 +2551,7 @@ void ProtocolWithChangesReaderBase::ReadGenericParentRecord(evo_test::GenericPar void ProtocolWithChangesReaderBase::ReadGenericNestedRecords(evo_test::GenericRecord& value) { if (unlikely(state_ != 194)) { - ProtocolWithChangesReaderBaseInvalidState(194, state_); + InvalidState(194); } ReadGenericNestedRecordsImpl(value); @@ -2680,7 +2564,7 @@ bool ProtocolWithChangesReaderBase::ReadGenericRecordStream(evo_test::AliasedClo state_ = 198; return false; } - ProtocolWithChangesReaderBaseInvalidState(196, state_); + InvalidState(196); } bool result = ReadGenericRecordStreamImpl(value); @@ -2700,7 +2584,7 @@ bool ProtocolWithChangesReaderBase::ReadGenericRecordStream(std::vector& value) { if (unlikely(state_ != 206)) { - ProtocolWithChangesReaderBaseInvalidState(206, state_); + InvalidState(206); } ReadAddedMapImpl(value); @@ -2885,7 +2769,7 @@ bool ProtocolWithChangesReaderBase::ReadAddedRecordStream(evo_test::RecordWithCh state_ = 210; return false; } - ProtocolWithChangesReaderBaseInvalidState(208, state_); + InvalidState(208); } bool result = ReadAddedRecordStreamImpl(value); @@ -2905,7 +2789,7 @@ bool ProtocolWithChangesReaderBase::ReadAddedRecordStream(std::vector value; - ReadAliasedGenericRecordToAlias(value); - writer.WriteAliasedGenericRecordToAlias(value); + { + evo_test::AliasedOpenGenericRecord value; + ReadAliasedGenericRecordToAlias(value); + writer.WriteAliasedGenericRecordToAlias(value); + } + { + evo_test::GenericRecordReversed value; + ReadGenericRecordToReversed(value); + writer.WriteGenericRecordToReversed(value); + } + { + std::variant, std::string> value; + ReadClosedGenericRecordToUnion(value); + writer.WriteClosedGenericRecordToUnion(value); + } + { + evo_test::AliasedGenericRecordOrString value; + ReadGenericRecordToAliasedUnion(value); + writer.WriteGenericRecordToAliasedUnion(value); + } + { + evo_test::GenericUnionReversed> value; + ReadGenericUnionToReversed(value); + writer.WriteGenericUnionToReversed(value); + } + { + evo_test::GenericUnion, float> value; + ReadGenericUnionOfChangedRecord(value); + writer.WriteGenericUnionOfChangedRecord(value); + } + { + evo_test::GenericParentRecord value; + ReadGenericParentRecord(value); + writer.WriteGenericParentRecord(value); + } + { + evo_test::GenericRecord value; + ReadGenericNestedRecords(value); + writer.WriteGenericNestedRecords(value); + } + if (generic_record_stream_buffer_size > 1) { + std::vector values; + values.reserve(generic_record_stream_buffer_size); + while(ReadGenericRecordStream(values)) { + writer.WriteGenericRecordStream(values); + } + writer.EndGenericRecordStream(); + } else { + evo_test::AliasedClosedGenericRecord value; + while(ReadGenericRecordStream(value)) { + writer.WriteGenericRecordStream(value); + } + writer.EndGenericRecordStream(); + } + if (generic_parent_record_stream_buffer_size > 1) { + std::vector> values; + values.reserve(generic_parent_record_stream_buffer_size); + while(ReadGenericParentRecordStream(values)) { + writer.WriteGenericParentRecordStream(values); + } + writer.EndGenericParentRecordStream(); + } else { + evo_test::GenericParentRecord value; + while(ReadGenericParentRecordStream(value)) { + writer.WriteGenericParentRecordStream(value); + } + writer.EndGenericParentRecordStream(); + } + { + std::vector value; + ReadVectorRecordWithChanges(value); + writer.WriteVectorRecordWithChanges(value); + } + if (streamed_record_with_changes_buffer_size > 1) { + std::vector values; + values.reserve(streamed_record_with_changes_buffer_size); + while(ReadStreamedRecordWithChanges(values)) { + writer.WriteStreamedRecordWithChanges(values); + } + writer.EndStreamedRecordWithChanges(); + } else { + evo_test::RecordWithChanges value; + while(ReadStreamedRecordWithChanges(value)) { + writer.WriteStreamedRecordWithChanges(value); + } + writer.EndStreamedRecordWithChanges(); + } + { + std::optional value; + ReadAddedOptional(value); + writer.WriteAddedOptional(value); + } + { + std::unordered_map value; + ReadAddedMap(value); + writer.WriteAddedMap(value); + } + if (added_record_stream_buffer_size > 1) { + std::vector values; + values.reserve(added_record_stream_buffer_size); + while(ReadAddedRecordStream(values)) { + writer.WriteAddedRecordStream(values); + } + writer.EndAddedRecordStream(); + } else { + evo_test::RecordWithChanges value; + while(ReadAddedRecordStream(value)) { + writer.WriteAddedRecordStream(value); + } + writer.EndAddedRecordStream(); + } +} + +void ProtocolWithChangesReaderBase::InvalidState(uint8_t attempted) { + auto f = [](uint8_t i) -> std::string { + switch (i/2) { + case 0: return "ReadInt8ToInt()"; + case 1: return "ReadInt8ToLong()"; + case 2: return "ReadInt8ToUint()"; + case 3: return "ReadInt8ToUlong()"; + case 4: return "ReadInt8ToFloat()"; + case 5: return "ReadInt8ToDouble()"; + case 6: return "ReadIntToUint()"; + case 7: return "ReadIntToLong()"; + case 8: return "ReadIntToFloat()"; + case 9: return "ReadIntToDouble()"; + case 10: return "ReadUintToUlong()"; + case 11: return "ReadUintToFloat()"; + case 12: return "ReadUintToDouble()"; + case 13: return "ReadFloatToDouble()"; + case 14: return "ReadComplexFloatToComplexDouble()"; + case 15: return "ReadIntToString()"; + case 16: return "ReadUintToString()"; + case 17: return "ReadLongToString()"; + case 18: return "ReadUlongToString()"; + case 19: return "ReadFloatToString()"; + case 20: return "ReadDoubleToString()"; + case 21: return "ReadIntToOptional()"; + case 22: return "ReadFloatToOptional()"; + case 23: return "ReadStringToOptional()"; + case 24: return "ReadIntToUnion()"; + case 25: return "ReadFloatToUnion()"; + case 26: return "ReadStringToUnion()"; + case 27: return "ReadOptionalIntToFloat()"; + case 28: return "ReadOptionalFloatToString()"; + case 29: return "ReadAliasedLongToString()"; + case 30: return "ReadStringToAliasedString()"; + case 31: return "ReadStringToAliasedInt()"; + case 32: return "ReadEnumToAliasedEnum()"; + case 33: return "ReadOptionalIntToUnion()"; + case 34: return "ReadOptionalRecordToUnion()"; + case 35: return "ReadRecordWithChanges()"; + case 36: return "ReadAliasedRecordWithChanges()"; + case 37: return "ReadRecordToRenamedRecord()"; + case 38: return "ReadRecordToAliasedRecord()"; + case 39: return "ReadRecordToAliasedAlias()"; + case 40: return "ReadStreamIntToStringToFloat()"; + case 41: return "ReadVectorIntToStringToFloat()"; + case 42: return "ReadIntFloatUnionReordered()"; + case 43: return "ReadVectorUnionReordered()"; + case 44: return "ReadStreamUnionReordered()"; + case 45: return "ReadIntToUnionStream()"; + case 46: return "ReadUnionStreamTypeChange()"; + case 47: return "ReadStreamOfAliasTypeChange()"; + case 48: return "ReadRlink()"; + case 49: return "ReadRlinkRX()"; + case 50: return "ReadRlinkRY()"; + case 51: return "ReadRlinkRZ()"; + case 52: return "ReadRaRLink()"; + case 53: return "ReadRaRX()"; + case 54: return "ReadRaRY()"; + case 55: return "ReadRaRZ()"; + case 56: return "ReadRbRLink()"; + case 57: return "ReadRbRX()"; + case 58: return "ReadRbRY()"; + case 59: return "ReadRbRZ()"; + case 60: return "ReadRcRLink()"; + case 61: return "ReadRcRX()"; + case 62: return "ReadRcRY()"; + case 63: return "ReadRcRZ()"; + case 64: return "ReadRlinkRNew()"; + case 65: return "ReadRaRNew()"; + case 66: return "ReadRbRNew()"; + case 67: return "ReadRcRNew()"; + case 68: return "ReadRlinkRUnion()"; + case 69: return "ReadRaRUnion()"; + case 70: return "ReadRbRUnion()"; + case 71: return "ReadRcRUnion()"; + case 72: return "ReadOptionalRecordWithChanges()"; + case 73: return "ReadAliasedOptionalRecordWithChanges()"; + case 74: return "ReadUnionRecordWithChanges()"; + case 75: return "ReadUnionWithSameTypeset()"; + case 76: return "ReadUnionWithTypesAdded()"; + case 77: return "ReadUnionWithTypesRemoved()"; + case 78: return "ReadRecordToOptional()"; + case 79: return "ReadRecordToAliasedOptional()"; + case 80: return "ReadRecordToUnion()"; + case 81: return "ReadRecordToAliasedUnion()"; + case 82: return "ReadUnionToAliasedUnion()"; + case 83: return "ReadUnionToAliasedUnionWithChanges()"; + case 84: return "ReadOptionalToAliasedOptional()"; + case 85: return "ReadOptionalToAliasedOptionalWithChanges()"; + case 86: return "ReadGenericRecord()"; + case 87: return "ReadGenericRecordToOpenAlias()"; + case 88: return "ReadGenericRecordToClosedAlias()"; + case 89: return "ReadGenericRecordToHalfClosedAlias()"; + case 90: return "ReadAliasedGenericRecordToAlias()"; + case 91: return "ReadGenericRecordToReversed()"; + case 92: return "ReadClosedGenericRecordToUnion()"; + case 93: return "ReadGenericRecordToAliasedUnion()"; + case 94: return "ReadGenericUnionToReversed()"; + case 95: return "ReadGenericUnionOfChangedRecord()"; + case 96: return "ReadGenericParentRecord()"; + case 97: return "ReadGenericNestedRecords()"; + case 98: return "ReadGenericRecordStream()"; + case 99: return "ReadGenericParentRecordStream()"; + case 100: return "ReadVectorRecordWithChanges()"; + case 101: return "ReadStreamedRecordWithChanges()"; + case 102: return "ReadAddedOptional()"; + case 103: return "ReadAddedMap()"; + case 104: return "ReadAddedRecordStream()"; + case 105: return "Close()"; + default: return ""; + } + }; + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamIntToStringToFloat(std::string& value, size_t idx) { + return ReadStreamIntToStringToFloatImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamIntToStringToFloat(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamIntToStringToFloatImpl(values, idx)) { + return values.size() > 0; } - { - evo_test::GenericRecordReversed value; - ReadGenericRecordToReversed(value); - writer.WriteGenericRecordToReversed(value); + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamIntToStringToFloat() { + return CountStreamIntToStringToFloatImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamUnionReordered(std::variant& value, size_t idx) { + return ReadStreamUnionReorderedImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamUnionReordered(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); } - { - std::variant, std::string> value; - ReadClosedGenericRecordToUnion(value); - writer.WriteClosedGenericRecordToUnion(value); + if (!ReadStreamUnionReorderedImpl(values, idx)) { + return values.size() > 0; } - { - evo_test::AliasedGenericRecordOrString value; - ReadGenericRecordToAliasedUnion(value); - writer.WriteGenericRecordToAliasedUnion(value); + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamUnionReordered() { + return CountStreamUnionReorderedImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadIntToUnionStream(int32_t& value, size_t idx) { + return ReadIntToUnionStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadIntToUnionStream(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); } - { - evo_test::GenericUnionReversed> value; - ReadGenericUnionToReversed(value); - writer.WriteGenericUnionToReversed(value); + if (!ReadIntToUnionStreamImpl(values, idx)) { + return values.size() > 0; } - { - evo_test::GenericUnion, float> value; - ReadGenericUnionOfChangedRecord(value); - writer.WriteGenericUnionOfChangedRecord(value); + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountIntToUnionStream() { + return CountIntToUnionStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadUnionStreamTypeChange(std::variant& value, size_t idx) { + return ReadUnionStreamTypeChangeImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadUnionStreamTypeChange(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); } - { - evo_test::GenericParentRecord value; - ReadGenericParentRecord(value); - writer.WriteGenericParentRecord(value); + if (!ReadUnionStreamTypeChangeImpl(values, idx)) { + return values.size() > 0; } - { - evo_test::GenericRecord value; - ReadGenericNestedRecords(value); - writer.WriteGenericNestedRecords(value); + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountUnionStreamTypeChange() { + return CountUnionStreamTypeChangeImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamOfAliasTypeChange(evo_test::StreamItem& value, size_t idx) { + return ReadStreamOfAliasTypeChangeImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamOfAliasTypeChange(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); } - if (generic_record_stream_buffer_size > 1) { - std::vector values; - values.reserve(generic_record_stream_buffer_size); - while(ReadGenericRecordStream(values)) { - writer.WriteGenericRecordStream(values); - } - writer.EndGenericRecordStream(); - } else { - evo_test::AliasedClosedGenericRecord value; - while(ReadGenericRecordStream(value)) { - writer.WriteGenericRecordStream(value); - } - writer.EndGenericRecordStream(); + if (!ReadStreamOfAliasTypeChangeImpl(values, idx)) { + return values.size() > 0; } - if (generic_parent_record_stream_buffer_size > 1) { - std::vector> values; - values.reserve(generic_parent_record_stream_buffer_size); - while(ReadGenericParentRecordStream(values)) { - writer.WriteGenericParentRecordStream(values); - } - writer.EndGenericParentRecordStream(); - } else { - evo_test::GenericParentRecord value; - while(ReadGenericParentRecordStream(value)) { - writer.WriteGenericParentRecordStream(value); - } - writer.EndGenericParentRecordStream(); + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamOfAliasTypeChange() { + return CountStreamOfAliasTypeChangeImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericRecordStream(evo_test::AliasedClosedGenericRecord& value, size_t idx) { + return ReadGenericRecordStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericRecordStream(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); } - { - std::vector value; - ReadVectorRecordWithChanges(value); - writer.WriteVectorRecordWithChanges(value); + if (!ReadGenericRecordStreamImpl(values, idx)) { + return values.size() > 0; } - if (streamed_record_with_changes_buffer_size > 1) { - std::vector values; - values.reserve(streamed_record_with_changes_buffer_size); - while(ReadStreamedRecordWithChanges(values)) { - writer.WriteStreamedRecordWithChanges(values); - } - writer.EndStreamedRecordWithChanges(); - } else { - evo_test::RecordWithChanges value; - while(ReadStreamedRecordWithChanges(value)) { - writer.WriteStreamedRecordWithChanges(value); - } - writer.EndStreamedRecordWithChanges(); + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountGenericRecordStream() { + return CountGenericRecordStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericParentRecordStream(evo_test::GenericParentRecord& value, size_t idx) { + return ReadGenericParentRecordStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericParentRecordStream(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); } - { - std::optional value; - ReadAddedOptional(value); - writer.WriteAddedOptional(value); + if (!ReadGenericParentRecordStreamImpl(values, idx)) { + return values.size() > 0; } - { - std::unordered_map value; - ReadAddedMap(value); - writer.WriteAddedMap(value); + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountGenericParentRecordStream() { + return CountGenericParentRecordStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamedRecordWithChanges(evo_test::RecordWithChanges& value, size_t idx) { + return ReadStreamedRecordWithChangesImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamedRecordWithChanges(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); } - if (added_record_stream_buffer_size > 1) { - std::vector values; - values.reserve(added_record_stream_buffer_size); - while(ReadAddedRecordStream(values)) { - writer.WriteAddedRecordStream(values); - } - writer.EndAddedRecordStream(); - } else { - evo_test::RecordWithChanges value; - while(ReadAddedRecordStream(value)) { - writer.WriteAddedRecordStream(value); - } - writer.EndAddedRecordStream(); + if (!ReadStreamedRecordWithChangesImpl(values, idx)) { + return values.size() > 0; } + return true; } -namespace { -void UnusedProtocolWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteRecords() or EndRecords()"; break; +size_t ProtocolWithChangesIndexedReaderBase::CountStreamedRecordWithChanges() { + return CountStreamedRecordWithChangesImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadAddedRecordStream(evo_test::RecordWithChanges& value, size_t idx) { + return ReadAddedRecordStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadAddedRecordStream(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndRecords()" : "WriteRecords()"; break; - case 1: attempted_method = "Close()"; break; + if (!ReadAddedRecordStreamImpl(values, idx)) { + return values.size() > 0; } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); + return true; } -void UnusedProtocolReaderBaseInvalidState(uint8_t attempted, uint8_t current) { - auto f = [](uint8_t i) -> std::string { - switch (i/2) { - case 0: return "ReadRecords()"; - case 1: return "Close()"; - default: return ""; - } - }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); +size_t ProtocolWithChangesIndexedReaderBase::CountAddedRecordStream() { + return CountAddedRecordStreamImpl(); +} + +void ProtocolWithChangesIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string UnusedProtocolWriterBase::schema_ = R"({"protocol":{"name":"UnusedProtocol","sequence":[{"name":"records","type":{"stream":{"items":"EvoTest.UnchangedRecord"}}}]},"types":[{"name":"UnchangedRecord","fields":[{"name":"name","type":"string"},{"name":"age","type":"int32"},{"name":"meta","type":{"map":{"keys":"string","values":"float64"}}}]}]})"; @@ -3594,9 +3735,10 @@ std::string UnusedProtocolWriterBase::SchemaFromVersion(Version version) { } } + void UnusedProtocolWriterBase::WriteRecords(evo_test::UnchangedRecord const& value) { if (unlikely(state_ != 0)) { - UnusedProtocolWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteRecordsImpl(value); @@ -3604,7 +3746,7 @@ void UnusedProtocolWriterBase::WriteRecords(evo_test::UnchangedRecord const& val void UnusedProtocolWriterBase::WriteRecords(std::vector const& values) { if (unlikely(state_ != 0)) { - UnusedProtocolWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteRecordsImpl(values); @@ -3612,7 +3754,7 @@ void UnusedProtocolWriterBase::WriteRecords(std::vector UnusedProtocolReaderBase::previous_schemas_ = UnusedProtocolWriterBase::previous_schemas_; @@ -3647,13 +3802,14 @@ Version UnusedProtocolReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol UnusedProtocol."); } + bool UnusedProtocolReaderBase::ReadRecords(evo_test::UnchangedRecord& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - UnusedProtocolReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadRecordsImpl(value); @@ -3673,7 +3829,7 @@ bool UnusedProtocolReaderBase::ReadRecords(std::vector 1) { std::vector values; @@ -3728,4 +3885,39 @@ void UnusedProtocolReaderBase::CopyTo(UnusedProtocolWriterBase& writer, size_t r writer.EndRecords(); } } + +void UnusedProtocolReaderBase::InvalidState(uint8_t attempted) { + auto f = [](uint8_t i) -> std::string { + switch (i/2) { + case 0: return "ReadRecords()"; + case 1: return "Close()"; + default: return ""; + } + }; + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool UnusedProtocolIndexedReaderBase::ReadRecords(evo_test::UnchangedRecord& value, size_t idx) { + return ReadRecordsImpl(value, idx); +} + +bool UnusedProtocolIndexedReaderBase::ReadRecords(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadRecordsImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t UnusedProtocolIndexedReaderBase::CountRecords() { + return CountRecordsImpl(); +} + +void UnusedProtocolIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; +} + } // namespace evo_test diff --git a/cpp/evolution/v1/generated/protocols.h b/cpp/evolution/v1/generated/protocols.h index 739e1d4..fc57d50 100644 --- a/cpp/evolution/v1/generated/protocols.h +++ b/cpp/evolution/v1/generated/protocols.h @@ -542,9 +542,11 @@ class ProtocolWithChangesWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ProtocolWithChangesReaderBase; + friend class ProtocolWithChangesIndexedReaderBase; }; // Abstract reader for the ProtocolWithChanges protocol. @@ -1025,9 +1027,94 @@ class ProtocolWithChangesReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedReaderBase : public ProtocolWithChangesReaderBase { + public: + // Stream and Vector type changes + using ProtocolWithChangesReaderBase::ReadStreamIntToStringToFloat; + [[nodiscard]] bool ReadStreamIntToStringToFloat(std::string& value, size_t idx); + [[nodiscard]] bool ReadStreamIntToStringToFloat(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamIntToStringToFloat(); + + using ProtocolWithChangesReaderBase::ReadStreamUnionReordered; + [[nodiscard]] bool ReadStreamUnionReordered(std::variant& value, size_t idx); + [[nodiscard]] bool ReadStreamUnionReordered(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountStreamUnionReordered(); + + using ProtocolWithChangesReaderBase::ReadIntToUnionStream; + [[nodiscard]] bool ReadIntToUnionStream(int32_t& value, size_t idx); + [[nodiscard]] bool ReadIntToUnionStream(std::vector& values, size_t idx); + [[nodiscard]] size_t CountIntToUnionStream(); + + using ProtocolWithChangesReaderBase::ReadUnionStreamTypeChange; + [[nodiscard]] bool ReadUnionStreamTypeChange(std::variant& value, size_t idx); + [[nodiscard]] bool ReadUnionStreamTypeChange(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountUnionStreamTypeChange(); + + using ProtocolWithChangesReaderBase::ReadStreamOfAliasTypeChange; + [[nodiscard]] bool ReadStreamOfAliasTypeChange(evo_test::StreamItem& value, size_t idx); + [[nodiscard]] bool ReadStreamOfAliasTypeChange(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamOfAliasTypeChange(); + + using ProtocolWithChangesReaderBase::ReadGenericRecordStream; + [[nodiscard]] bool ReadGenericRecordStream(evo_test::AliasedClosedGenericRecord& value, size_t idx); + [[nodiscard]] bool ReadGenericRecordStream(std::vector& values, size_t idx); + [[nodiscard]] size_t CountGenericRecordStream(); + + using ProtocolWithChangesReaderBase::ReadGenericParentRecordStream; + [[nodiscard]] bool ReadGenericParentRecordStream(evo_test::GenericParentRecord& value, size_t idx); + [[nodiscard]] bool ReadGenericParentRecordStream(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountGenericParentRecordStream(); + + using ProtocolWithChangesReaderBase::ReadStreamedRecordWithChanges; + [[nodiscard]] bool ReadStreamedRecordWithChanges(evo_test::RecordWithChanges& value, size_t idx); + [[nodiscard]] bool ReadStreamedRecordWithChanges(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamedRecordWithChanges(); + + using ProtocolWithChangesReaderBase::ReadAddedRecordStream; + [[nodiscard]] bool ReadAddedRecordStream(evo_test::RecordWithChanges& value, size_t idx); + [[nodiscard]] bool ReadAddedRecordStream(std::vector& values, size_t idx); + [[nodiscard]] size_t CountAddedRecordStream(); + + virtual ~ProtocolWithChangesIndexedReaderBase() = default; + + protected: + virtual bool ReadStreamIntToStringToFloatImpl(std::string& value, size_t idx) = 0; + virtual bool ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamIntToStringToFloatImpl() = 0; + virtual bool ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountStreamUnionReorderedImpl() = 0; + virtual bool ReadIntToUnionStreamImpl(int32_t& value, size_t idx) = 0; + virtual bool ReadIntToUnionStreamImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountIntToUnionStreamImpl() = 0; + virtual bool ReadUnionStreamTypeChangeImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadUnionStreamTypeChangeImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountUnionStreamTypeChangeImpl() = 0; + virtual bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) = 0; + virtual bool ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamOfAliasTypeChangeImpl() = 0; + virtual bool ReadGenericRecordStreamImpl(evo_test::AliasedClosedGenericRecord& value, size_t idx) = 0; + virtual bool ReadGenericRecordStreamImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountGenericRecordStreamImpl() = 0; + virtual bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) = 0; + virtual bool ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountGenericParentRecordStreamImpl() = 0; + virtual bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) = 0; + virtual bool ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamedRecordWithChangesImpl() = 0; + virtual bool ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value, size_t idx) = 0; + virtual bool ReadAddedRecordStreamImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountAddedRecordStreamImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the UnusedProtocol protocol. class UnusedProtocolWriterBase { public: @@ -1063,9 +1150,11 @@ class UnusedProtocolWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class UnusedProtocolReaderBase; + friend class UnusedProtocolIndexedReaderBase; }; // Abstract reader for the UnusedProtocol protocol. @@ -1095,6 +1184,26 @@ class UnusedProtocolReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; + +// Abstract Indexed reader for the UnusedProtocol protocol. +class UnusedProtocolIndexedReaderBase : public UnusedProtocolReaderBase { + public: + using UnusedProtocolReaderBase::ReadRecords; + [[nodiscard]] bool ReadRecords(evo_test::UnchangedRecord& value, size_t idx); + [[nodiscard]] bool ReadRecords(std::vector& values, size_t idx); + [[nodiscard]] size_t CountRecords(); + + virtual ~UnusedProtocolIndexedReaderBase() = default; + + protected: + virtual bool ReadRecordsImpl(evo_test::UnchangedRecord& value, size_t idx) = 0; + virtual bool ReadRecordsImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountRecordsImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; } // namespace evo_test diff --git a/cpp/evolution/v2/generated/binary/protocols.cc b/cpp/evolution/v2/generated/binary/protocols.cc index fe0f7e8..81acc64 100644 --- a/cpp/evolution/v2/generated/binary/protocols.cc +++ b/cpp/evolution/v2/generated/binary/protocols.cc @@ -5385,5 +5385,5328 @@ void ProtocolWithChangesReader::CloseImpl() { stream_.VerifyFinished(); } +void ProtocolWithChangesIndexedWriter::WriteInt8ToIntImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToInt", stream_.Pos()); + switch (version_) { + case Version::v1: { + int32_t int8_to_int = {}; + int8_to_int = static_cast(value); + yardl::binary::WriteInteger(stream_, int8_to_int); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToLongImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToLong", stream_.Pos()); + switch (version_) { + case Version::v1: { + int64_t int8_to_long = {}; + int8_to_long = static_cast(value); + yardl::binary::WriteInteger(stream_, int8_to_long); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToUintImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToUint", stream_.Pos()); + switch (version_) { + case Version::v1: { + uint32_t int8_to_uint = {}; + if (value < 0) { + throw std::runtime_error("Numeric overflow detected while converting 'int8' to 'uint32'"); + } + int8_to_uint = static_cast(value); + yardl::binary::WriteInteger(stream_, int8_to_uint); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToUlongImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToUlong", stream_.Pos()); + switch (version_) { + case Version::v1: { + uint64_t int8_to_ulong = {}; + if (value < 0) { + throw std::runtime_error("Numeric overflow detected while converting 'int8' to 'uint64'"); + } + int8_to_ulong = static_cast(value); + yardl::binary::WriteInteger(stream_, int8_to_ulong); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToFloatImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToFloat", stream_.Pos()); + switch (version_) { + case Version::v1: { + float int8_to_float = {}; + int8_to_float = static_cast(value); + yardl::binary::WriteFloatingPoint(stream_, int8_to_float); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteInt8ToDoubleImpl(int8_t const& value) { + step_index_.set_step_offset("Int8ToDouble", stream_.Pos()); + switch (version_) { + case Version::v1: { + double int8_to_double = {}; + int8_to_double = static_cast(value); + yardl::binary::WriteFloatingPoint(stream_, int8_to_double); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUintImpl(int32_t const& value) { + step_index_.set_step_offset("IntToUint", stream_.Pos()); + switch (version_) { + case Version::v1: { + uint32_t int_to_uint = {}; + if (value < 0) { + throw std::runtime_error("Numeric overflow detected while converting 'int32' to 'uint32'"); + } + int_to_uint = static_cast(value); + yardl::binary::WriteInteger(stream_, int_to_uint); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToLongImpl(int32_t const& value) { + step_index_.set_step_offset("IntToLong", stream_.Pos()); + switch (version_) { + case Version::v1: { + int64_t int_to_long = {}; + int_to_long = static_cast(value); + yardl::binary::WriteInteger(stream_, int_to_long); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToFloatImpl(int32_t const& value) { + step_index_.set_step_offset("IntToFloat", stream_.Pos()); + switch (version_) { + case Version::v1: { + float int_to_float = {}; + int_to_float = static_cast(value); + yardl::binary::WriteFloatingPoint(stream_, int_to_float); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToDoubleImpl(int32_t const& value) { + step_index_.set_step_offset("IntToDouble", stream_.Pos()); + switch (version_) { + case Version::v1: { + double int_to_double = {}; + int_to_double = static_cast(value); + yardl::binary::WriteFloatingPoint(stream_, int_to_double); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUintToUlongImpl(uint32_t const& value) { + step_index_.set_step_offset("UintToUlong", stream_.Pos()); + switch (version_) { + case Version::v1: { + uint64_t uint_to_ulong = {}; + uint_to_ulong = static_cast(value); + yardl::binary::WriteInteger(stream_, uint_to_ulong); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUintToFloatImpl(uint32_t const& value) { + step_index_.set_step_offset("UintToFloat", stream_.Pos()); + switch (version_) { + case Version::v1: { + float uint_to_float = {}; + uint_to_float = static_cast(value); + yardl::binary::WriteFloatingPoint(stream_, uint_to_float); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUintToDoubleImpl(uint32_t const& value) { + step_index_.set_step_offset("UintToDouble", stream_.Pos()); + switch (version_) { + case Version::v1: { + double uint_to_double = {}; + uint_to_double = static_cast(value); + yardl::binary::WriteFloatingPoint(stream_, uint_to_double); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToDoubleImpl(float const& value) { + step_index_.set_step_offset("FloatToDouble", stream_.Pos()); + switch (version_) { + case Version::v1: { + double float_to_double = {}; + float_to_double = static_cast(value); + yardl::binary::WriteFloatingPoint(stream_, float_to_double); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteComplexFloatToComplexDoubleImpl(std::complex const& value) { + step_index_.set_step_offset("ComplexFloatToComplexDouble", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::complex complex_float_to_complex_double = {}; + complex_float_to_complex_double = std::complex(value); + yardl::binary::WriteFloatingPoint(stream_, complex_float_to_complex_double); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToStringImpl(int32_t const& value) { + step_index_.set_step_offset("IntToString", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::string int_to_string = {}; + int_to_string = std::to_string(value); + yardl::binary::WriteString(stream_, int_to_string); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUintToStringImpl(uint32_t const& value) { + step_index_.set_step_offset("UintToString", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::string uint_to_string = {}; + uint_to_string = std::to_string(value); + yardl::binary::WriteString(stream_, uint_to_string); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteLongToStringImpl(int64_t const& value) { + step_index_.set_step_offset("LongToString", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::string long_to_string = {}; + long_to_string = std::to_string(value); + yardl::binary::WriteString(stream_, long_to_string); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUlongToStringImpl(uint64_t const& value) { + step_index_.set_step_offset("UlongToString", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::string ulong_to_string = {}; + ulong_to_string = std::to_string(value); + yardl::binary::WriteString(stream_, ulong_to_string); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToStringImpl(float const& value) { + step_index_.set_step_offset("FloatToString", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::string float_to_string = {}; + float_to_string = std::to_string(value); + yardl::binary::WriteString(stream_, float_to_string); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteDoubleToStringImpl(double const& value) { + step_index_.set_step_offset("DoubleToString", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::string double_to_string = {}; + double_to_string = std::to_string(value); + yardl::binary::WriteString(stream_, double_to_string); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToOptionalImpl(int32_t const& value) { + step_index_.set_step_offset("IntToOptional", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::optional int_to_optional = {}; + int_to_optional = value; + yardl::binary::WriteOptional(stream_, int_to_optional); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToOptionalImpl(float const& value) { + step_index_.set_step_offset("FloatToOptional", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::optional float_to_optional = {}; + float_to_optional = value; + yardl::binary::WriteOptional(stream_, float_to_optional); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStringToOptionalImpl(std::string const& value) { + step_index_.set_step_offset("StringToOptional", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::optional string_to_optional = {}; + string_to_optional = value; + yardl::binary::WriteOptional(stream_, string_to_optional); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUnionImpl(int32_t const& value) { + step_index_.set_step_offset("IntToUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant int_to_union = {}; + int_to_union = value; + WriteUnion(stream_, int_to_union); + break; + } + default: + yardl::binary::WriteInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteFloatToUnionImpl(float const& value) { + step_index_.set_step_offset("FloatToUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant float_to_union = {}; + float_to_union = value; + WriteUnion(stream_, float_to_union); + break; + } + default: + yardl::binary::WriteFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStringToUnionImpl(std::string const& value) { + step_index_.set_step_offset("StringToUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant string_to_union = {}; + string_to_union = value; + WriteUnion(stream_, string_to_union); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalIntToFloatImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalIntToFloat", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::optional optional_int_to_float = {}; + if (value.has_value()) { + optional_int_to_float = static_cast(value.value()); + } + yardl::binary::WriteOptional(stream_, optional_int_to_float); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalFloatToStringImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalFloatToString", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::optional optional_float_to_string = {}; + if (value.has_value()) { + optional_float_to_string = std::to_string(value.value()); + } + yardl::binary::WriteOptional(stream_, optional_float_to_string); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedLongToStringImpl(evo_test::AliasedLongToString const& value) { + step_index_.set_step_offset("AliasedLongToString", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteAliasedLongToString_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedLongToString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStringToAliasedStringImpl(std::string const& value) { + step_index_.set_step_offset("StringToAliasedString", stream_.Pos()); + yardl::binary::WriteString(stream_, value); +} + +void ProtocolWithChangesIndexedWriter::WriteStringToAliasedIntImpl(std::string const& value) { + step_index_.set_step_offset("StringToAliasedInt", stream_.Pos()); + switch (version_) { + case Version::v1: { + int32_t string_to_aliased_int = {}; + try { + string_to_aliased_int = std::stoi(value); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + value + "\" to number"); + } + yardl::binary::WriteInteger(stream_, string_to_aliased_int); + break; + } + default: + yardl::binary::WriteString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteEnumToAliasedEnumImpl(evo_test::GrowingEnum const& value) { + step_index_.set_step_offset("EnumToAliasedEnum", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteEnum(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::WriteAliasedEnum_v1(stream_, value); + break; + } + default: + yardl::binary::WriteEnum(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalIntToUnionImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalIntToUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant optional_int_to_union = {}; + if (value.has_value()) { + optional_int_to_union = value.value(); + } else { + optional_int_to_union = std::monostate{}; + } + WriteUnion(stream_, optional_int_to_union); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalRecordToUnionImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalRecordToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteOptional(stream_, value); + break; + } + case Version::v1: { + std::variant optional_record_to_union = {}; + if (value.has_value()) { + optional_record_to_union = value.value(); + } else { + optional_record_to_union = std::monostate{}; + } + WriteUnion(stream_, optional_record_to_union); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordWithChangesImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::WriteRecordWithChanges_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges const& value) { + step_index_.set_step_offset("AliasedRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteAliasedRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::WriteAliasedRecordWithChanges_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToRenamedRecordImpl(evo_test::RenamedRecord const& value) { + step_index_.set_step_offset("RecordToRenamedRecord", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRenamedRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRenamedRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedRecordImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedRecord", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::WriteAliasedRecordWithChanges_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedAliasImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedAlias", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::WriteAliasOfAliasedRecordWithChanges_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStreamIntToStringToFloatImpl(float const& value) { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + int32_t stream_int_to_string_to_float = {}; + if (value > std::numeric_limits::max() || value < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int32'"); + } + stream_int_to_string_to_float = static_cast(std::round(value)); + yardl::binary::WriteBlockAndSaveOffset(stream_, stream_int_to_string_to_float, item_offset); + break; + } + case Version::v1: { + std::string stream_int_to_string_to_float = {}; + stream_int_to_string_to_float = std::to_string(value); + yardl::binary::WriteBlockAndSaveOffset(stream_, stream_int_to_string_to_float, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("StreamIntToStringToFloat", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamIntToStringToFloatImpl(std::vector const& values) { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.resize(values.size()); + for (size_t i = 0; i < values.size(); i++) { + int32_t item = {}; + if (values[i] > std::numeric_limits::max() || values[i] < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int32'"); + } + item = static_cast(std::round(values[i])); + stream_int_to_string_to_float[i] = item; + } + yardl::binary::WriteVectorAndSaveOffsets(stream_, stream_int_to_string_to_float, item_offsets); + break; + } + case Version::v1: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.resize(values.size()); + for (size_t i = 0; i < values.size(); i++) { + std::string item = {}; + item = std::to_string(values[i]); + stream_int_to_string_to_float[i] = item; + } + yardl::binary::WriteVectorAndSaveOffsets(stream_, stream_int_to_string_to_float, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("StreamIntToStringToFloat", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamIntToStringToFloatImpl() { + step_index_.set_step_offset("StreamIntToStringToFloat", stream_.Pos()); + step_index_.add_stream_offsets("StreamIntToStringToFloat", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteVectorIntToStringToFloatImpl(std::vector const& value) { + step_index_.set_step_offset("VectorIntToStringToFloat", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::vector vector_int_to_string_to_float = {}; + vector_int_to_string_to_float.resize(value.size()); + for (size_t i = 0; i < value.size(); i++) { + int32_t item = {}; + if (value[i] > std::numeric_limits::max() || value[i] < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int32'"); + } + item = static_cast(std::round(value[i])); + vector_int_to_string_to_float[i] = item; + } + yardl::binary::WriteVector(stream_, vector_int_to_string_to_float); + break; + } + case Version::v1: { + std::vector vector_int_to_string_to_float = {}; + vector_int_to_string_to_float.resize(value.size()); + for (size_t i = 0; i < value.size(); i++) { + std::string item = {}; + item = std::to_string(value[i]); + vector_int_to_string_to_float[i] = item; + } + yardl::binary::WriteVector(stream_, vector_int_to_string_to_float); + break; + } + default: + yardl::binary::WriteVector(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntFloatUnionReorderedImpl(std::variant const& value) { + step_index_.set_step_offset("IntFloatUnionReordered", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant int_float_union_reordered = {}; + switch (value.index()) { + case 0: { + int_float_union_reordered = std::get<0>(value); + break; + } + case 1: { + int_float_union_reordered = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, int_float_union_reordered); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteVectorUnionReorderedImpl(std::vector> const& value) { + step_index_.set_step_offset("VectorUnionReordered", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::vector> vector_union_reordered = {}; + vector_union_reordered.resize(value.size()); + for (size_t i = 0; i < value.size(); i++) { + std::variant item = {}; + switch (value[i].index()) { + case 0: { + item = std::get<0>(value[i]); + break; + } + case 1: { + item = std::get<1>(value[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + vector_union_reordered[i] = item; + } + yardl::binary::WriteVector, WriteUnion>(stream_, vector_union_reordered); + break; + } + default: + yardl::binary::WriteVector, WriteUnion>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStreamUnionReorderedImpl(std::variant const& value) { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v1: { + std::variant stream_union_reordered = {}; + switch (value.index()) { + case 0: { + stream_union_reordered = std::get<0>(value); + break; + } + case 1: { + stream_union_reordered = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, stream_union_reordered, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("StreamUnionReordered", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamUnionReorderedImpl(std::vector> const& values) { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v1: { + std::vector> stream_union_reordered = {}; + stream_union_reordered.resize(values.size()); + for (size_t i = 0; i < values.size(); i++) { + std::variant item = {}; + switch (values[i].index()) { + case 0: { + item = std::get<0>(values[i]); + break; + } + case 1: { + item = std::get<1>(values[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + stream_union_reordered[i] = item; + } + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, stream_union_reordered, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("StreamUnionReordered", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamUnionReorderedImpl() { + step_index_.set_step_offset("StreamUnionReordered", stream_.Pos()); + step_index_.add_stream_offsets("StreamUnionReordered", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUnionStreamImpl(std::variant const& value) { + step_index_.set_step_offset("IntToUnionStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + int32_t int_to_union_stream = {}; + if (value.index() == 1) { + int_to_union_stream = std::get<1>(value); + } + yardl::binary::WriteBlockAndSaveOffset(stream_, int_to_union_stream, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("IntToUnionStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteIntToUnionStreamImpl(std::vector> const& values) { + step_index_.set_step_offset("IntToUnionStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + std::vector int_to_union_stream = {}; + int_to_union_stream.resize(values.size()); + for (size_t i = 0; i < values.size(); i++) { + int32_t item = {}; + if (values[i].index() == 1) { + item = std::get<1>(values[i]); + } + int_to_union_stream[i] = item; + } + yardl::binary::WriteVectorAndSaveOffsets(stream_, int_to_union_stream, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("IntToUnionStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndIntToUnionStreamImpl() { + step_index_.set_step_offset("IntToUnionStream", stream_.Pos()); + step_index_.add_stream_offsets("IntToUnionStream", std::vector{}); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionStreamTypeChangeImpl(std::variant const& value) { + step_index_.set_step_offset("UnionStreamTypeChange", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + std::variant union_stream_type_change = {}; + switch (value.index()) { + case 0: { + union_stream_type_change = std::get<0>(value); + break; + } + case 1: { + std::vector source_types = {"int32", "float32"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'int32 | bool'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, union_stream_type_change, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("UnionStreamTypeChange", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteUnionStreamTypeChangeImpl(std::vector> const& values) { + step_index_.set_step_offset("UnionStreamTypeChange", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + std::vector> union_stream_type_change = {}; + union_stream_type_change.resize(values.size()); + for (size_t i = 0; i < values.size(); i++) { + std::variant item = {}; + switch (values[i].index()) { + case 0: { + item = std::get<0>(values[i]); + break; + } + case 1: { + std::vector source_types = {"int32", "float32"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'int32 | bool'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + union_stream_type_change[i] = item; + } + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, union_stream_type_change, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("UnionStreamTypeChange", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndUnionStreamTypeChangeImpl() { + step_index_.set_step_offset("UnionStreamTypeChange", stream_.Pos()); + step_index_.add_stream_offsets("UnionStreamTypeChange", std::vector{}); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStreamOfAliasTypeChangeImpl(evo_test::StreamItem const& value) { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + case Version::v1: { + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("StreamOfAliasTypeChange", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamOfAliasTypeChangeImpl(std::vector const& values) { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + case Version::v1: { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("StreamOfAliasTypeChange", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamOfAliasTypeChangeImpl() { + step_index_.set_step_offset("StreamOfAliasTypeChange", stream_.Pos()); + step_index_.add_stream_offsets("StreamOfAliasTypeChange", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("Rlink", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRLink_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRXImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRX", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRX_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRYImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRY", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRY_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRZImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRZ", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRZ_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRLinkImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRLink", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRLink_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRXImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRX", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRX_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRYImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRY", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRY_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRZImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRZ", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRZ_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRLinkImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRLink", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRLink_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRXImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRX", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRX_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRYImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRY", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRY_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRZImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRZ", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRZ_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRLinkImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRLink", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRLink_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRXImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRX", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRX_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRYImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRY", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRY_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRZImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRZ", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRZ_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRNewImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRNew", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRNew_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRNewImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRNew", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRNew_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRNewImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRNew", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRNew_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRNewImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRNew", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteRNew_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRlinkRUnionImpl(evo_test::RLink const& value) { + step_index_.set_step_offset("RlinkRUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant rlink_r_union = {}; + rlink_r_union = value; + WriteUnion(stream_, rlink_r_union); + break; + } + default: + evo_test::binary::WriteRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRaRUnionImpl(evo_test::RA const& value) { + step_index_.set_step_offset("RaRUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant ra_r_union = {}; + ra_r_union = value; + WriteUnion(stream_, ra_r_union); + break; + } + default: + evo_test::binary::WriteRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRbRUnionImpl(evo_test::RB const& value) { + step_index_.set_step_offset("RbRUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant rb_r_union = {}; + rb_r_union = value; + WriteUnion(stream_, rb_r_union); + break; + } + default: + evo_test::binary::WriteRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRcRUnionImpl(evo_test::RC const& value) { + step_index_.set_step_offset("RcRUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant rc_r_union = {}; + rc_r_union = value; + WriteUnion(stream_, rc_r_union); + break; + } + default: + evo_test::binary::WriteRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalRecordWithChangesImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteOptional(stream_, value); + break; + } + case Version::v1: { + yardl::binary::WriteOptional(stream_, value); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedOptionalRecordWithChangesImpl(std::optional const& value) { + step_index_.set_step_offset("AliasedOptionalRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteOptional(stream_, value); + break; + } + case Version::v1: { + yardl::binary::WriteOptional(stream_, value); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionRecordWithChangesImpl(std::variant const& value) { + step_index_.set_step_offset("UnionRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_record_with_changes = {}; + switch (value.index()) { + case 0: { + union_record_with_changes = std::get<0>(value); + break; + } + case 1: { + union_record_with_changes = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_record_with_changes); + break; + } + case Version::v1: { + std::variant union_record_with_changes = {}; + switch (value.index()) { + case 0: { + union_record_with_changes = std::get<0>(value); + break; + } + case 1: { + union_record_with_changes = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_record_with_changes); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithSameTypesetImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithSameTypeset", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_with_same_typeset = {}; + switch (value.index()) { + case 0: { + union_with_same_typeset = std::get<0>(value); + break; + } + case 1: { + union_with_same_typeset = std::get<1>(value); + break; + } + case 2: { + union_with_same_typeset = std::get<2>(value); + break; + } + case 3: { + union_with_same_typeset = std::get<3>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_same_typeset); + break; + } + case Version::v1: { + std::variant union_with_same_typeset = {}; + switch (value.index()) { + case 0: { + union_with_same_typeset = std::get<0>(value); + break; + } + case 1: { + union_with_same_typeset = std::get<1>(value); + break; + } + case 2: { + union_with_same_typeset = std::get<2>(value); + break; + } + case 3: { + union_with_same_typeset = std::get<3>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_same_typeset); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithTypesAddedImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithTypesAdded", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_with_types_added = {}; + switch (value.index()) { + case 0: { + union_with_types_added = std::get<0>(value); + break; + } + case 1: { + union_with_types_added = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_types_added); + break; + } + case Version::v1: { + std::variant union_with_types_added = {}; + switch (value.index()) { + case 0: { + union_with_types_added = std::get<0>(value); + break; + } + case 1: { + union_with_types_added = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_types_added); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionWithTypesRemovedImpl(std::variant const& value) { + step_index_.set_step_offset("UnionWithTypesRemoved", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_with_types_removed = {}; + switch (value.index()) { + case 0: { + union_with_types_removed = std::get<0>(value); + break; + } + case 1: { + union_with_types_removed = std::get<1>(value); + break; + } + case 2: { + union_with_types_removed = std::get<2>(value); + break; + } + case 3: { + union_with_types_removed = std::get<3>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_types_removed); + break; + } + case Version::v1: { + std::variant union_with_types_removed = {}; + switch (value.index()) { + case 0: { + union_with_types_removed = std::get<0>(value); + break; + } + case 1: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32", "float32", "string"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'RecordWithChanges: RecordWithChanges_v1 | string'"); + break; + } + case 2: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32", "float32", "string"}; + throw std::runtime_error("Source type '" + source_types[2] + "' incompatible with target union type 'RecordWithChanges: RecordWithChanges_v1 | string'"); + break; + } + case 3: { + union_with_types_removed = std::get<3>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_with_types_removed); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToOptionalImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + std::optional record_to_optional = {}; + record_to_optional = value; + yardl::binary::WriteOptional(stream_, record_to_optional); + break; + } + default: + evo_test::binary::WriteRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedOptionalImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + std::optional record_to_aliased_optional = {}; + record_to_aliased_optional = value; + yardl::binary::WriteOptional(stream_, record_to_aliased_optional); + break; + } + default: + evo_test::binary::WriteRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToUnionImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + std::variant record_to_union = {}; + record_to_union = value; + WriteUnion(stream_, record_to_union); + break; + } + default: + evo_test::binary::WriteRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteRecordToAliasedUnionImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("RecordToAliasedUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + evo_test::binary::WriteRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + std::variant record_to_aliased_union = {}; + record_to_aliased_union = value; + WriteUnion(stream_, record_to_aliased_union); + break; + } + default: + evo_test::binary::WriteRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionToAliasedUnionImpl(std::variant const& value) { + step_index_.set_step_offset("UnionToAliasedUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_to_aliased_union = {}; + switch (value.index()) { + case 0: { + union_to_aliased_union = std::get<0>(value); + break; + } + case 1: { + union_to_aliased_union = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_to_aliased_union); + break; + } + case Version::v1: { + std::variant union_to_aliased_union = {}; + switch (value.index()) { + case 0: { + union_to_aliased_union = std::get<0>(value); + break; + } + case 1: { + union_to_aliased_union = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_to_aliased_union); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteUnionToAliasedUnionWithChangesImpl(std::variant const& value) { + step_index_.set_step_offset("UnionToAliasedUnionWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + std::variant union_to_aliased_union_with_changes = {}; + switch (value.index()) { + case 0: { + union_to_aliased_union_with_changes = std::get<0>(value); + break; + } + case 1: { + union_to_aliased_union_with_changes = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_to_aliased_union_with_changes); + break; + } + case Version::v1: { + std::variant union_to_aliased_union_with_changes = {}; + switch (value.index()) { + case 0: { + union_to_aliased_union_with_changes = std::get<0>(value); + break; + } + case 1: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'RecordWithChanges: RecordWithChanges_v1 | string'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion(stream_, union_to_aliased_union_with_changes); + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalToAliasedOptionalImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalToAliasedOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteOptional(stream_, value); + break; + } + case Version::v1: { + yardl::binary::WriteOptional(stream_, value); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteOptionalToAliasedOptionalWithChangesImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalToAliasedOptionalWithChanges", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::optional optional_to_aliased_optional_with_changes = {}; + if (value.has_value()) { + optional_to_aliased_optional_with_changes = std::to_string(value.value()); + } + yardl::binary::WriteOptional(stream_, optional_to_aliased_optional_with_changes); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecord", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToOpenAliasImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToOpenAlias", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteAliasedOpenGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToClosedAliasImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToClosedAlias", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteAliasedClosedGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToHalfClosedAliasImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToHalfClosedAlias", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteAliasedHalfClosedGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAliasedGenericRecordToAliasImpl(evo_test::AliasedHalfClosedGenericRecord const& value) { + step_index_.set_step_offset("AliasedGenericRecordToAlias", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteAliasedOpenGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteAliasedHalfClosedGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToReversedImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToReversed", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteGenericRecordReversed_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteClosedGenericRecordToUnionImpl(evo_test::AliasedClosedGenericRecord const& value) { + step_index_.set_step_offset("ClosedGenericRecordToUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant, std::string> closed_generic_record_to_union = {}; + closed_generic_record_to_union = value; + WriteUnion, evo_test::binary::WriteGenericRecord_v1, std::string, yardl::binary::WriteString>(stream_, closed_generic_record_to_union); + break; + } + default: + evo_test::binary::WriteAliasedClosedGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordToAliasedUnionImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordToAliasedUnion", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant, std::string> generic_record_to_aliased_union = {}; + generic_record_to_aliased_union = value; + WriteUnion, evo_test::binary::WriteGenericRecord_v1, std::string, yardl::binary::WriteString>(stream_, generic_record_to_aliased_union); + break; + } + default: + evo_test::binary::WriteGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericUnionToReversedImpl(evo_test::GenericUnion, float> const& value) { + step_index_.set_step_offset("GenericUnionToReversed", stream_.Pos()); + switch (version_) { + case Version::v1: { + std::variant, float> generic_union_to_reversed = {}; + switch (value.index()) { + case 0: { + generic_union_to_reversed = std::get<0>(value); + break; + } + case 1: { + generic_union_to_reversed = std::get<1>(value); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + WriteUnion, evo_test::binary::WriteGenericRecord_v1, float, yardl::binary::WriteFloatingPoint>(stream_, generic_union_to_reversed); + break; + } + default: + evo_test::binary::WriteGenericUnion, evo_test::binary::WriteGenericRecord, float, yardl::binary::WriteFloatingPoint>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericUnionOfChangedRecordImpl(evo_test::GenericUnion, float> const& value) { + step_index_.set_step_offset("GenericUnionOfChangedRecord", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteGenericUnion_v1, evo_test::binary::WriteGenericRecord_v1, float, yardl::binary::WriteFloatingPoint>(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericUnion, evo_test::binary::WriteGenericRecord, float, yardl::binary::WriteFloatingPoint>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordImpl(evo_test::GenericParentRecord const& value) { + step_index_.set_step_offset("GenericParentRecord", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteGenericParentRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericParentRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericNestedRecordsImpl(evo_test::GenericRecord, evo_test::ChangedGeneric> const& value) { + step_index_.set_step_offset("GenericNestedRecords", stream_.Pos()); + switch (version_) { + case Version::v1: { + evo_test::binary::WriteGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::WriteGenericRecord, evo_test::binary::WriteUnchangedGeneric, evo_test::ChangedGeneric, evo_test::binary::WriteChangedGeneric>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordStreamImpl(evo_test::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v1: { + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, evo_test::binary::WriteGenericRecord>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("GenericRecordStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericRecordStreamImpl(std::vector> const& values) { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v1: { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, evo_test::binary::WriteGenericRecord>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("GenericRecordStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndGenericRecordStreamImpl() { + step_index_.set_step_offset("GenericRecordStream", stream_.Pos()); + step_index_.add_stream_offsets("GenericRecordStream", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordStreamImpl(evo_test::GenericParentRecord const& value) { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v1: { + yardl::binary::WriteBlockAndSaveOffset, evo_test::binary::WriteGenericParentRecord_v1>(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, evo_test::binary::WriteGenericParentRecord>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("GenericParentRecordStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteGenericParentRecordStreamImpl(std::vector> const& values) { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v1: { + yardl::binary::WriteVectorAndSaveOffsets, evo_test::binary::WriteGenericParentRecord_v1>(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, evo_test::binary::WriteGenericParentRecord>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("GenericParentRecordStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndGenericParentRecordStreamImpl() { + step_index_.set_step_offset("GenericParentRecordStream", stream_.Pos()); + step_index_.add_stream_offsets("GenericParentRecordStream", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteVectorRecordWithChangesImpl(std::vector const& value) { + step_index_.set_step_offset("VectorRecordWithChanges", stream_.Pos()); + switch (version_) { + case Version::v0: { + yardl::binary::WriteVector(stream_, value); + break; + } + case Version::v1: { + yardl::binary::WriteVector(stream_, value); + break; + } + default: + yardl::binary::WriteVector(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteStreamedRecordWithChangesImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + case Version::v1: { + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("StreamedRecordWithChanges", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteStreamedRecordWithChangesImpl(std::vector const& values) { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + case Version::v1: { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("StreamedRecordWithChanges", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndStreamedRecordWithChangesImpl() { + step_index_.set_step_offset("StreamedRecordWithChanges", stream_.Pos()); + step_index_.add_stream_offsets("StreamedRecordWithChanges", std::vector{}); + switch (version_) { + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedStringVectorImpl(std::vector const& value) { + step_index_.set_step_offset("AddedStringVector", stream_.Pos()); + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + break; + } + default: + yardl::binary::WriteVector(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedOptionalImpl(std::optional const& value) { + step_index_.set_step_offset("AddedOptional", stream_.Pos()); + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + yardl::binary::WriteOptional(stream_, value); + break; + } + default: + yardl::binary::WriteOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedMapImpl(std::unordered_map const& value) { + step_index_.set_step_offset("AddedMap", stream_.Pos()); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteMap(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedUnionImpl(std::variant const& value) { + step_index_.set_step_offset("AddedUnion", stream_.Pos()); + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + break; + } + default: + WriteUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedRecordStreamImpl(evo_test::RecordWithChanges const& value) { + step_index_.set_step_offset("AddedRecordStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("AddedRecordStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteAddedRecordStreamImpl(std::vector const& values) { + step_index_.set_step_offset("AddedRecordStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("AddedRecordStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndAddedRecordStreamImpl() { + step_index_.set_step_offset("AddedRecordStream", stream_.Pos()); + step_index_.add_stream_offsets("AddedRecordStream", std::vector{}); + switch (version_) { + case Version::v0: { + break; + } + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::WriteAddedUnionStreamImpl(std::variant const& value) { + step_index_.set_step_offset("AddedUnionStream", stream_.Pos()); + size_t item_offset = 0; + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + break; + } + default: + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + break; + } + step_index_.add_stream_offset("AddedUnionStream", item_offset); +} + +void ProtocolWithChangesIndexedWriter::WriteAddedUnionStreamImpl(std::vector> const& values) { + step_index_.set_step_offset("AddedUnionStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + break; + } + default: + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + break; + } + } + step_index_.add_stream_offsets("AddedUnionStream", item_offsets); +} + +void ProtocolWithChangesIndexedWriter::EndAddedUnionStreamImpl() { + step_index_.set_step_offset("AddedUnionStream", stream_.Pos()); + step_index_.add_stream_offsets("AddedUnionStream", std::vector{}); + switch (version_) { + case Version::v0: { + break; + } + case Version::v1: { + break; + } + default: + yardl::binary::WriteInteger(stream_, 0U); + break; + } +} + +void ProtocolWithChangesIndexedWriter::Flush() { + stream_.Flush(); +} + +void ProtocolWithChangesIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToIntImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToInt"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + int32_t int8_to_int = {}; + yardl::binary::ReadInteger(stream_, int8_to_int); + if (int8_to_int > std::numeric_limits::max() || int8_to_int < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'int32' to 'int8'"); + } + value = static_cast(int8_to_int); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToLongImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToLong"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + int64_t int8_to_long = {}; + yardl::binary::ReadInteger(stream_, int8_to_long); + if (int8_to_long > std::numeric_limits::max() || int8_to_long < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'int64' to 'int8'"); + } + value = static_cast(int8_to_long); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToUintImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToUint"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + uint32_t int8_to_uint = {}; + yardl::binary::ReadInteger(stream_, int8_to_uint); + if (int8_to_uint > std::numeric_limits::max()) { + throw std::runtime_error("Numeric overflow detected while converting 'uint32' to 'int8'"); + } + value = static_cast(int8_to_uint); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToUlongImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToUlong"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + uint64_t int8_to_ulong = {}; + yardl::binary::ReadInteger(stream_, int8_to_ulong); + if (int8_to_ulong > std::numeric_limits::max()) { + throw std::runtime_error("Numeric overflow detected while converting 'uint64' to 'int8'"); + } + value = static_cast(int8_to_ulong); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToFloatImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + float int8_to_float = {}; + yardl::binary::ReadFloatingPoint(stream_, int8_to_float); + if (int8_to_float > std::numeric_limits::max() || int8_to_float < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int8'"); + } + value = static_cast(std::round(int8_to_float)); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadInt8ToDoubleImpl(int8_t& value) { + auto pos = step_index_.get_step_offset("Int8ToDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + double int8_to_double = {}; + yardl::binary::ReadFloatingPoint(stream_, int8_to_double); + if (int8_to_double > std::numeric_limits::max() || int8_to_double < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float64' to 'int8'"); + } + value = static_cast(std::round(int8_to_double)); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToUintImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToUint"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + uint32_t int_to_uint = {}; + yardl::binary::ReadInteger(stream_, int_to_uint); + if (int_to_uint > std::numeric_limits::max()) { + throw std::runtime_error("Numeric overflow detected while converting 'uint32' to 'int32'"); + } + value = static_cast(int_to_uint); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToLongImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToLong"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + int64_t int_to_long = {}; + yardl::binary::ReadInteger(stream_, int_to_long); + if (int_to_long > std::numeric_limits::max() || int_to_long < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'int64' to 'int32'"); + } + value = static_cast(int_to_long); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToFloatImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + float int_to_float = {}; + yardl::binary::ReadFloatingPoint(stream_, int_to_float); + if (int_to_float > std::numeric_limits::max() || int_to_float < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int32'"); + } + value = static_cast(std::round(int_to_float)); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToDoubleImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + double int_to_double = {}; + yardl::binary::ReadFloatingPoint(stream_, int_to_double); + if (int_to_double > std::numeric_limits::max() || int_to_double < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float64' to 'int32'"); + } + value = static_cast(std::round(int_to_double)); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUintToUlongImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("UintToUlong"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + uint64_t uint_to_ulong = {}; + yardl::binary::ReadInteger(stream_, uint_to_ulong); + if (uint_to_ulong > std::numeric_limits::max()) { + throw std::runtime_error("Numeric overflow detected while converting 'uint64' to 'uint32'"); + } + value = static_cast(uint_to_ulong); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUintToFloatImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("UintToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + float uint_to_float = {}; + yardl::binary::ReadFloatingPoint(stream_, uint_to_float); + if (uint_to_float > std::numeric_limits::max() || uint_to_float < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'uint32'"); + } + value = static_cast(std::round(uint_to_float)); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUintToDoubleImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("UintToDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + double uint_to_double = {}; + yardl::binary::ReadFloatingPoint(stream_, uint_to_double); + if (uint_to_double > std::numeric_limits::max() || uint_to_double < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float64' to 'uint32'"); + } + value = static_cast(std::round(uint_to_double)); + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadFloatToDoubleImpl(float& value) { + auto pos = step_index_.get_step_offset("FloatToDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + double float_to_double = {}; + yardl::binary::ReadFloatingPoint(stream_, float_to_double); + if (float_to_double > std::numeric_limits::max() || float_to_double < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float64' to 'float32'"); + } + value = static_cast(float_to_double); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadComplexFloatToComplexDoubleImpl(std::complex& value) { + auto pos = step_index_.get_step_offset("ComplexFloatToComplexDouble"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::complex complex_float_to_complex_double = {}; + yardl::binary::ReadFloatingPoint(stream_, complex_float_to_complex_double); + if (std::real(complex_float_to_complex_double) > std::numeric_limits::value_type>::max() || std::real(complex_float_to_complex_double) < std::numeric_limits::value_type>::lowest()) { + throw std::runtime_error("Real part overflow detected while converting 'complexfloat64' to 'complexfloat32'"); + } + if (std::imag(complex_float_to_complex_double) > std::numeric_limits::value_type>::max() || std::imag(complex_float_to_complex_double) < std::numeric_limits::value_type>::lowest()) { + throw std::runtime_error("Imaginary part overflow detected while converting 'complexfloat64' to 'complexfloat32'"); + } + value = std::complex(complex_float_to_complex_double); + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToStringImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::string int_to_string = {}; + yardl::binary::ReadString(stream_, int_to_string); + try { + value = std::stoi(int_to_string); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + int_to_string + "\" to number"); + } + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUintToStringImpl(uint32_t& value) { + auto pos = step_index_.get_step_offset("UintToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::string uint_to_string = {}; + yardl::binary::ReadString(stream_, uint_to_string); + try { + value = std::stoul(uint_to_string); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + uint_to_string + "\" to number"); + } + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadLongToStringImpl(int64_t& value) { + auto pos = step_index_.get_step_offset("LongToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::string long_to_string = {}; + yardl::binary::ReadString(stream_, long_to_string); + try { + value = std::stol(long_to_string); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + long_to_string + "\" to number"); + } + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUlongToStringImpl(uint64_t& value) { + auto pos = step_index_.get_step_offset("UlongToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::string ulong_to_string = {}; + yardl::binary::ReadString(stream_, ulong_to_string); + try { + value = std::stoul(ulong_to_string); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + ulong_to_string + "\" to number"); + } + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadFloatToStringImpl(float& value) { + auto pos = step_index_.get_step_offset("FloatToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::string float_to_string = {}; + yardl::binary::ReadString(stream_, float_to_string); + try { + value = std::stof(float_to_string); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + float_to_string + "\" to number"); + } + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadDoubleToStringImpl(double& value) { + auto pos = step_index_.get_step_offset("DoubleToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::string double_to_string = {}; + yardl::binary::ReadString(stream_, double_to_string); + try { + value = std::stod(double_to_string); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + double_to_string + "\" to number"); + } + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToOptionalImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::optional int_to_optional = {}; + yardl::binary::ReadOptional(stream_, int_to_optional); + if (int_to_optional.has_value()) { + value = int_to_optional.value(); + } + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadFloatToOptionalImpl(float& value) { + auto pos = step_index_.get_step_offset("FloatToOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::optional float_to_optional = {}; + yardl::binary::ReadOptional(stream_, float_to_optional); + if (float_to_optional.has_value()) { + value = float_to_optional.value(); + } + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadStringToOptionalImpl(std::string& value) { + auto pos = step_index_.get_step_offset("StringToOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::optional string_to_optional = {}; + yardl::binary::ReadOptional(stream_, string_to_optional); + if (string_to_optional.has_value()) { + value = string_to_optional.value(); + } + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntToUnionImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("IntToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant int_to_union = {}; + ReadUnion(stream_, int_to_union); + if (int_to_union.index() == 0) { + value = std::get<0>(int_to_union); + } + break; + } + default: + yardl::binary::ReadInteger(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadFloatToUnionImpl(float& value) { + auto pos = step_index_.get_step_offset("FloatToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant float_to_union = {}; + ReadUnion(stream_, float_to_union); + if (float_to_union.index() == 0) { + value = std::get<0>(float_to_union); + } + break; + } + default: + yardl::binary::ReadFloatingPoint(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadStringToUnionImpl(std::string& value) { + auto pos = step_index_.get_step_offset("StringToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant string_to_union = {}; + ReadUnion(stream_, string_to_union); + if (string_to_union.index() == 0) { + value = std::get<0>(string_to_union); + } + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalIntToFloatImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalIntToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::optional optional_int_to_float = {}; + yardl::binary::ReadOptional(stream_, optional_int_to_float); + if (optional_int_to_float.has_value()) { + if (optional_int_to_float.value() > std::numeric_limits::max() || optional_int_to_float.value() < std::numeric_limits::lowest()) { + throw std::runtime_error("Numeric overflow detected while converting 'float32' to 'int32'"); + } + value = static_cast(std::round(optional_int_to_float.value())); + } + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalFloatToStringImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalFloatToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::optional optional_float_to_string = {}; + yardl::binary::ReadOptional(stream_, optional_float_to_string); + if (optional_float_to_string.has_value()) { + try { + value = std::stof(optional_float_to_string.value()); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + optional_float_to_string.value() + "\" to number"); + } + } + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAliasedLongToStringImpl(evo_test::AliasedLongToString& value) { + auto pos = step_index_.get_step_offset("AliasedLongToString"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadAliasedLongToString_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedLongToString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadStringToAliasedStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("StringToAliasedString"); + stream_.Seek(pos); + yardl::binary::ReadString(stream_, value); +} + +void ProtocolWithChangesIndexedReader::ReadStringToAliasedIntImpl(std::string& value) { + auto pos = step_index_.get_step_offset("StringToAliasedInt"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + int32_t string_to_aliased_int = {}; + yardl::binary::ReadInteger(stream_, string_to_aliased_int); + value = std::to_string(string_to_aliased_int); + break; + } + default: + yardl::binary::ReadString(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadEnumToAliasedEnumImpl(evo_test::GrowingEnum& value) { + auto pos = step_index_.get_step_offset("EnumToAliasedEnum"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadEnum(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::ReadAliasedEnum_v1(stream_, value); + break; + } + default: + yardl::binary::ReadEnum(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalIntToUnionImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalIntToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant optional_int_to_union = {}; + ReadUnion(stream_, optional_int_to_union); + if (optional_int_to_union.index() == 1) { + value = std::get<1>(optional_int_to_union); + } + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalRecordToUnionImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalRecordToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadOptional(stream_, value); + break; + } + case Version::v1: { + std::variant optional_record_to_union = {}; + ReadUnion(stream_, optional_record_to_union); + if (optional_record_to_union.index() == 1) { + value = std::get<1>(optional_record_to_union); + } + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordWithChangesImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::ReadRecordWithChanges_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges& value) { + auto pos = step_index_.get_step_offset("AliasedRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadAliasedRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::ReadAliasedRecordWithChanges_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToRenamedRecordImpl(evo_test::RenamedRecord& value) { + auto pos = step_index_.get_step_offset("RecordToRenamedRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRenamedRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRenamedRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedRecordImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::ReadAliasedRecordWithChanges_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedAliasImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + evo_test::binary::ReadAliasOfAliasedRecordWithChanges_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRecordWithChanges(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(float& value) { + if (!step_index_.offset_within_stream("StreamIntToStringToFloat", "VectorIntToStringToFloat", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamIntToStringToFloat")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + int32_t stream_int_to_string_to_float = {}; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, stream_int_to_string_to_float); + if (read_block_successful) { + value = static_cast(stream_int_to_string_to_float); + } + break; + } + case Version::v1: { + std::string stream_int_to_string_to_float = {}; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, stream_int_to_string_to_float); + if (read_block_successful) { + try { + value = std::stof(stream_int_to_string_to_float); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + stream_int_to_string_to_float + "\" to number"); + } + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamIntToStringToFloat", "VectorIntToStringToFloat", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamIntToStringToFloat")); + } + switch (version_) { + case Version::v0: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, stream_int_to_string_to_float); + values.resize(stream_int_to_string_to_float.size()); + for (size_t i = 0; i < stream_int_to_string_to_float.size(); i++) { + float item = {}; + item = static_cast(stream_int_to_string_to_float[i]); + values[i] = item; + } + break; + } + case Version::v1: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, stream_int_to_string_to_float); + values.resize(stream_int_to_string_to_float.size()); + for (size_t i = 0; i < stream_int_to_string_to_float.size(); i++) { + float item = {}; + try { + item = std::stof(stream_int_to_string_to_float[i]); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + stream_int_to_string_to_float[i] + "\" to number"); + } + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(float& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamIntToStringToFloat", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + int32_t stream_int_to_string_to_float = {}; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, stream_int_to_string_to_float); + if (read_block_successful) { + value = static_cast(stream_int_to_string_to_float); + } + break; + } + case Version::v1: { + std::string stream_int_to_string_to_float = {}; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, stream_int_to_string_to_float); + if (read_block_successful) { + try { + value = std::stof(stream_int_to_string_to_float); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + stream_int_to_string_to_float + "\" to number"); + } + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamIntToStringToFloat", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, stream_int_to_string_to_float); + values.resize(stream_int_to_string_to_float.size()); + for (size_t i = 0; i < stream_int_to_string_to_float.size(); i++) { + float item = {}; + item = static_cast(stream_int_to_string_to_float[i]); + values[i] = item; + } + break; + } + case Version::v1: { + std::vector stream_int_to_string_to_float = {}; + stream_int_to_string_to_float.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, stream_int_to_string_to_float); + values.resize(stream_int_to_string_to_float.size()); + for (size_t i = 0; i < stream_int_to_string_to_float.size(); i++) { + float item = {}; + try { + item = std::stof(stream_int_to_string_to_float[i]); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + stream_int_to_string_to_float[i] + "\" to number"); + } + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamIntToStringToFloatImpl() { + return step_index_.get_stream_count("StreamIntToStringToFloat"); +} + +void ProtocolWithChangesIndexedReader::ReadVectorIntToStringToFloatImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("VectorIntToStringToFloat"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::vector vector_int_to_string_to_float = {}; + yardl::binary::ReadVector(stream_, vector_int_to_string_to_float); + value.resize(vector_int_to_string_to_float.size()); + for (size_t i = 0; i < vector_int_to_string_to_float.size(); i++) { + float item = {}; + item = static_cast(vector_int_to_string_to_float[i]); + value[i] = item; + } + break; + } + case Version::v1: { + std::vector vector_int_to_string_to_float = {}; + yardl::binary::ReadVector(stream_, vector_int_to_string_to_float); + value.resize(vector_int_to_string_to_float.size()); + for (size_t i = 0; i < vector_int_to_string_to_float.size(); i++) { + float item = {}; + try { + item = std::stof(vector_int_to_string_to_float[i]); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + vector_int_to_string_to_float[i] + "\" to number"); + } + value[i] = item; + } + break; + } + default: + yardl::binary::ReadVector(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadIntFloatUnionReorderedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("IntFloatUnionReordered"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant int_float_union_reordered = {}; + ReadUnion(stream_, int_float_union_reordered); + switch (int_float_union_reordered.index()) { + case 0: { + value = std::get<0>(int_float_union_reordered); + break; + } + case 1: { + value = std::get<1>(int_float_union_reordered); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadVectorUnionReorderedImpl(std::vector>& value) { + auto pos = step_index_.get_step_offset("VectorUnionReordered"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::vector> vector_union_reordered = {}; + yardl::binary::ReadVector, ReadUnion>(stream_, vector_union_reordered); + value.resize(vector_union_reordered.size()); + for (size_t i = 0; i < vector_union_reordered.size(); i++) { + std::variant item = {}; + switch (vector_union_reordered[i].index()) { + case 0: { + item = std::get<0>(vector_union_reordered[i]); + break; + } + case 1: { + item = std::get<1>(vector_union_reordered[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + value[i] = item; + } + break; + } + default: + yardl::binary::ReadVector, ReadUnion>(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::variant& value) { + if (!step_index_.offset_within_stream("StreamUnionReordered", "IntToUnionStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamUnionReordered")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v1: { + std::variant stream_union_reordered = {}; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, stream_union_reordered); + if (read_block_successful) { + switch (stream_union_reordered.index()) { + case 0: { + value = std::get<0>(stream_union_reordered); + break; + } + case 1: { + value = std::get<1>(stream_union_reordered); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("StreamUnionReordered", "IntToUnionStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamUnionReordered")); + } + switch (version_) { + case Version::v1: { + std::vector> stream_union_reordered = {}; + stream_union_reordered.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, stream_union_reordered); + values.resize(stream_union_reordered.size()); + for (size_t i = 0; i < stream_union_reordered.size(); i++) { + std::variant item = {}; + switch (stream_union_reordered[i].index()) { + case 0: { + item = std::get<0>(stream_union_reordered[i]); + break; + } + case 1: { + item = std::get<1>(stream_union_reordered[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamUnionReordered", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v1: { + std::variant stream_union_reordered = {}; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, stream_union_reordered); + if (read_block_successful) { + switch (stream_union_reordered.index()) { + case 0: { + value = std::get<0>(stream_union_reordered); + break; + } + case 1: { + value = std::get<1>(stream_union_reordered); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamUnionReordered", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v1: { + std::vector> stream_union_reordered = {}; + stream_union_reordered.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, stream_union_reordered); + values.resize(stream_union_reordered.size()); + for (size_t i = 0; i < stream_union_reordered.size(); i++) { + std::variant item = {}; + switch (stream_union_reordered[i].index()) { + case 0: { + item = std::get<0>(stream_union_reordered[i]); + break; + } + case 1: { + item = std::get<1>(stream_union_reordered[i]); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamUnionReorderedImpl() { + return step_index_.get_stream_count("StreamUnionReordered"); +} + +bool ProtocolWithChangesIndexedReader::ReadIntToUnionStreamImpl(std::variant& value) { + if (!step_index_.offset_within_stream("IntToUnionStream", "UnionStreamTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntToUnionStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant int_to_union_stream = {}; + value = std::move(int_to_union_stream); + return false; + break; + } + case Version::v1: { + int32_t int_to_union_stream = {}; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, int_to_union_stream); + if (read_block_successful) { + value = int_to_union_stream; + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadIntToUnionStreamImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("IntToUnionStream", "UnionStreamTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntToUnionStream")); + } + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + case Version::v1: { + std::vector int_to_union_stream = {}; + int_to_union_stream.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, int_to_union_stream); + values.resize(int_to_union_stream.size()); + for (size_t i = 0; i < int_to_union_stream.size(); i++) { + std::variant item = {}; + item = int_to_union_stream[i]; + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadIntToUnionStreamImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntToUnionStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant int_to_union_stream = {}; + value = std::move(int_to_union_stream); + return false; + break; + } + case Version::v1: { + int32_t int_to_union_stream = {}; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, int_to_union_stream); + if (read_block_successful) { + value = int_to_union_stream; + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadIntToUnionStreamImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntToUnionStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + case Version::v1: { + std::vector int_to_union_stream = {}; + int_to_union_stream.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, int_to_union_stream); + values.resize(int_to_union_stream.size()); + for (size_t i = 0; i < int_to_union_stream.size(); i++) { + std::variant item = {}; + item = int_to_union_stream[i]; + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountIntToUnionStreamImpl() { + return step_index_.get_stream_count("IntToUnionStream"); +} + +bool ProtocolWithChangesIndexedReader::ReadUnionStreamTypeChangeImpl(std::variant& value) { + if (!step_index_.offset_within_stream("UnionStreamTypeChange", "StreamOfAliasTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("UnionStreamTypeChange")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant union_stream_type_change = {}; + value = std::move(union_stream_type_change); + return false; + break; + } + case Version::v1: { + std::variant union_stream_type_change = {}; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, union_stream_type_change); + if (read_block_successful) { + switch (union_stream_type_change.index()) { + case 0: { + value = std::get<0>(union_stream_type_change); + break; + } + case 1: { + std::vector source_types = {"int32", "bool"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'int32 | float32'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadUnionStreamTypeChangeImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("UnionStreamTypeChange", "StreamOfAliasTypeChange", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("UnionStreamTypeChange")); + } + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + case Version::v1: { + std::vector> union_stream_type_change = {}; + union_stream_type_change.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, union_stream_type_change); + values.resize(union_stream_type_change.size()); + for (size_t i = 0; i < union_stream_type_change.size(); i++) { + std::variant item = {}; + switch (union_stream_type_change[i].index()) { + case 0: { + item = std::get<0>(union_stream_type_change[i]); + break; + } + case 1: { + std::vector source_types = {"int32", "bool"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'int32 | float32'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadUnionStreamTypeChangeImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("UnionStreamTypeChange", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant union_stream_type_change = {}; + value = std::move(union_stream_type_change); + return false; + break; + } + case Version::v1: { + std::variant union_stream_type_change = {}; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, union_stream_type_change); + if (read_block_successful) { + switch (union_stream_type_change.index()) { + case 0: { + value = std::get<0>(union_stream_type_change); + break; + } + case 1: { + std::vector source_types = {"int32", "bool"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'int32 | float32'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + } + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadUnionStreamTypeChangeImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("UnionStreamTypeChange", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + case Version::v1: { + std::vector> union_stream_type_change = {}; + union_stream_type_change.reserve(values.capacity()); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, union_stream_type_change); + values.resize(union_stream_type_change.size()); + for (size_t i = 0; i < union_stream_type_change.size(); i++) { + std::variant item = {}; + switch (union_stream_type_change[i].index()) { + case 0: { + item = std::get<0>(union_stream_type_change[i]); + break; + } + case 1: { + std::vector source_types = {"int32", "bool"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'int32 | float32'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + values[i] = item; + } + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountUnionStreamTypeChangeImpl() { + return step_index_.get_stream_count("UnionStreamTypeChange"); +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value) { + if (!step_index_.offset_within_stream("StreamOfAliasTypeChange", "Rlink", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfAliasTypeChange")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamOfAliasTypeChange", "Rlink", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfAliasTypeChange")); + } + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + case Version::v1: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfAliasTypeChange", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfAliasTypeChange", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + case Version::v1: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamOfAliasTypeChangeImpl() { + return step_index_.get_stream_count("StreamOfAliasTypeChange"); +} + +void ProtocolWithChangesIndexedReader::ReadRlinkImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("Rlink"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRLink_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRXImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRX"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRX_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRYImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRY"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRY_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRZImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRZ"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRZ_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRLinkImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRLink"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRLink_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRXImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRX"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRX_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRYImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRY"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRY_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRZImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRZ"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRZ_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRLinkImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRLink"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRLink_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRXImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRX"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRX_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRYImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRY"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRY_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRZImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRZ"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRZ_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRLinkImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRLink"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRLink_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRXImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRX"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRX_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRYImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRY"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRY_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRZImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRZ"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRZ_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRNewImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRNew"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRNew_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRNewImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRNew"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRNew_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRNewImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRNew"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRNew_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRNewImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRNew"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadRNew_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRlinkRUnionImpl(evo_test::RLink& value) { + auto pos = step_index_.get_step_offset("RlinkRUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant rlink_r_union = {}; + ReadUnion(stream_, rlink_r_union); + if (rlink_r_union.index() == 0) { + value = std::get<0>(rlink_r_union); + } + break; + } + default: + evo_test::binary::ReadRLink(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRaRUnionImpl(evo_test::RA& value) { + auto pos = step_index_.get_step_offset("RaRUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant ra_r_union = {}; + ReadUnion(stream_, ra_r_union); + if (ra_r_union.index() == 0) { + value = std::get<0>(ra_r_union); + } + break; + } + default: + evo_test::binary::ReadRA(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRbRUnionImpl(evo_test::RB& value) { + auto pos = step_index_.get_step_offset("RbRUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant rb_r_union = {}; + ReadUnion(stream_, rb_r_union); + if (rb_r_union.index() == 0) { + value = std::get<0>(rb_r_union); + } + break; + } + default: + evo_test::binary::ReadRB(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRcRUnionImpl(evo_test::RC& value) { + auto pos = step_index_.get_step_offset("RcRUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant rc_r_union = {}; + ReadUnion(stream_, rc_r_union); + if (rc_r_union.index() == 0) { + value = std::get<0>(rc_r_union); + } + break; + } + default: + evo_test::binary::ReadRC(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalRecordWithChangesImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadOptional(stream_, value); + break; + } + case Version::v1: { + yardl::binary::ReadOptional(stream_, value); + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAliasedOptionalRecordWithChangesImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("AliasedOptionalRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadOptional(stream_, value); + break; + } + case Version::v1: { + yardl::binary::ReadOptional(stream_, value); + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionRecordWithChangesImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_record_with_changes = {}; + ReadUnion(stream_, union_record_with_changes); + switch (union_record_with_changes.index()) { + case 0: { + value = std::get<0>(union_record_with_changes); + break; + } + case 1: { + value = std::get<1>(union_record_with_changes); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + case Version::v1: { + std::variant union_record_with_changes = {}; + ReadUnion(stream_, union_record_with_changes); + switch (union_record_with_changes.index()) { + case 0: { + value = std::get<0>(union_record_with_changes); + break; + } + case 1: { + value = std::get<1>(union_record_with_changes); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithSameTypesetImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithSameTypeset"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_with_same_typeset = {}; + ReadUnion(stream_, union_with_same_typeset); + switch (union_with_same_typeset.index()) { + case 0: { + value = std::get<0>(union_with_same_typeset); + break; + } + case 1: { + value = std::get<1>(union_with_same_typeset); + break; + } + case 2: { + value = std::get<2>(union_with_same_typeset); + break; + } + case 3: { + value = std::get<3>(union_with_same_typeset); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + case Version::v1: { + std::variant union_with_same_typeset = {}; + ReadUnion(stream_, union_with_same_typeset); + switch (union_with_same_typeset.index()) { + case 0: { + value = std::get<0>(union_with_same_typeset); + break; + } + case 1: { + value = std::get<1>(union_with_same_typeset); + break; + } + case 2: { + value = std::get<2>(union_with_same_typeset); + break; + } + case 3: { + value = std::get<3>(union_with_same_typeset); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithTypesAddedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithTypesAdded"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_with_types_added = {}; + ReadUnion(stream_, union_with_types_added); + switch (union_with_types_added.index()) { + case 0: { + value = std::get<0>(union_with_types_added); + break; + } + case 1: { + value = std::get<1>(union_with_types_added); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + case Version::v1: { + std::variant union_with_types_added = {}; + ReadUnion(stream_, union_with_types_added); + switch (union_with_types_added.index()) { + case 0: { + value = std::get<0>(union_with_types_added); + break; + } + case 1: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32", "float32", "string"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'RecordWithChanges | float32'"); + break; + } + case 2: { + value = std::get<2>(union_with_types_added); + break; + } + case 3: { + std::vector source_types = {"EvoTest.RecordWithChanges", "int32", "float32", "string"}; + throw std::runtime_error("Source type '" + source_types[3] + "' incompatible with target union type 'RecordWithChanges | float32'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionWithTypesRemovedImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionWithTypesRemoved"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_with_types_removed = {}; + ReadUnion(stream_, union_with_types_removed); + switch (union_with_types_removed.index()) { + case 0: { + value = std::get<0>(union_with_types_removed); + break; + } + case 1: { + value = std::get<1>(union_with_types_removed); + break; + } + case 2: { + value = std::get<2>(union_with_types_removed); + break; + } + case 3: { + value = std::get<3>(union_with_types_removed); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + case Version::v1: { + std::variant union_with_types_removed = {}; + ReadUnion(stream_, union_with_types_removed); + switch (union_with_types_removed.index()) { + case 0: { + value = std::get<0>(union_with_types_removed); + break; + } + case 1: { + value = std::get<1>(union_with_types_removed); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToOptionalImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + std::optional record_to_optional = {}; + yardl::binary::ReadOptional(stream_, record_to_optional); + if (record_to_optional.has_value()) { + value = record_to_optional.value(); + } + break; + } + default: + evo_test::binary::ReadRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedOptionalImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + std::optional record_to_aliased_optional = {}; + yardl::binary::ReadOptional(stream_, record_to_aliased_optional); + if (record_to_aliased_optional.has_value()) { + value = record_to_aliased_optional.value(); + } + break; + } + default: + evo_test::binary::ReadRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToUnionImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + std::variant record_to_union = {}; + ReadUnion(stream_, record_to_union); + if (record_to_union.index() == 0) { + value = std::get<0>(record_to_union); + } + break; + } + default: + evo_test::binary::ReadRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadRecordToAliasedUnionImpl(evo_test::RecordWithChanges& value) { + auto pos = step_index_.get_step_offset("RecordToAliasedUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + evo_test::binary::ReadRecordWithChanges_v0(stream_, value); + break; + } + case Version::v1: { + std::variant record_to_aliased_union = {}; + ReadUnion(stream_, record_to_aliased_union); + if (record_to_aliased_union.index() == 0) { + value = std::get<0>(record_to_aliased_union); + } + break; + } + default: + evo_test::binary::ReadRecordWithChanges(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionToAliasedUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionToAliasedUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_to_aliased_union = {}; + ReadUnion(stream_, union_to_aliased_union); + switch (union_to_aliased_union.index()) { + case 0: { + value = std::get<0>(union_to_aliased_union); + break; + } + case 1: { + value = std::get<1>(union_to_aliased_union); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + case Version::v1: { + std::variant union_to_aliased_union = {}; + ReadUnion(stream_, union_to_aliased_union); + switch (union_to_aliased_union.index()) { + case 0: { + value = std::get<0>(union_to_aliased_union); + break; + } + case 1: { + value = std::get<1>(union_to_aliased_union); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadUnionToAliasedUnionWithChangesImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("UnionToAliasedUnionWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant union_to_aliased_union_with_changes = {}; + ReadUnion(stream_, union_to_aliased_union_with_changes); + switch (union_to_aliased_union_with_changes.index()) { + case 0: { + value = std::get<0>(union_to_aliased_union_with_changes); + break; + } + case 1: { + value = std::get<1>(union_to_aliased_union_with_changes); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + case Version::v1: { + std::variant union_to_aliased_union_with_changes = {}; + ReadUnion(stream_, union_to_aliased_union_with_changes); + switch (union_to_aliased_union_with_changes.index()) { + case 0: { + value = std::get<0>(union_to_aliased_union_with_changes); + break; + } + case 1: { + std::vector source_types = {"EvoTest.RecordWithChanges", "string"}; + throw std::runtime_error("Source type '" + source_types[1] + "' incompatible with target union type 'RecordWithChanges | int32'"); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalToAliasedOptionalImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalToAliasedOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadOptional(stream_, value); + break; + } + case Version::v1: { + yardl::binary::ReadOptional(stream_, value); + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadOptionalToAliasedOptionalWithChangesImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalToAliasedOptionalWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::optional optional_to_aliased_optional_with_changes = {}; + yardl::binary::ReadOptional(stream_, optional_to_aliased_optional_with_changes); + if (optional_to_aliased_optional_with_changes.has_value()) { + try { + value = std::stoi(optional_to_aliased_optional_with_changes.value()); + } catch (...) { + throw std::runtime_error("Unable to convert string \"" + optional_to_aliased_optional_with_changes.value() + "\" to number"); + } + } + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToOpenAliasImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToOpenAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadAliasedOpenGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToClosedAliasImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToClosedAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadAliasedClosedGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToHalfClosedAliasImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToHalfClosedAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadAliasedHalfClosedGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAliasedGenericRecordToAliasImpl(evo_test::AliasedHalfClosedGenericRecord& value) { + auto pos = step_index_.get_step_offset("AliasedGenericRecordToAlias"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadAliasedOpenGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadAliasedHalfClosedGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToReversedImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToReversed"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadGenericRecordReversed_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadClosedGenericRecordToUnionImpl(evo_test::AliasedClosedGenericRecord& value) { + auto pos = step_index_.get_step_offset("ClosedGenericRecordToUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant, std::string> closed_generic_record_to_union = {}; + ReadUnion, evo_test::binary::ReadGenericRecord_v1, std::string, yardl::binary::ReadString>(stream_, closed_generic_record_to_union); + if (closed_generic_record_to_union.index() == 0) { + value = std::get<0>(closed_generic_record_to_union); + } + break; + } + default: + evo_test::binary::ReadAliasedClosedGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericRecordToAliasedUnionImpl(evo_test::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecordToAliasedUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant, std::string> generic_record_to_aliased_union = {}; + ReadUnion, evo_test::binary::ReadGenericRecord_v1, std::string, yardl::binary::ReadString>(stream_, generic_record_to_aliased_union); + if (generic_record_to_aliased_union.index() == 0) { + value = std::get<0>(generic_record_to_aliased_union); + } + break; + } + default: + evo_test::binary::ReadGenericRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericUnionToReversedImpl(evo_test::GenericUnion, float>& value) { + auto pos = step_index_.get_step_offset("GenericUnionToReversed"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + std::variant, float> generic_union_to_reversed = {}; + ReadUnion, evo_test::binary::ReadGenericRecord_v1, float, yardl::binary::ReadFloatingPoint>(stream_, generic_union_to_reversed); + switch (generic_union_to_reversed.index()) { + case 0: { + value = std::get<0>(generic_union_to_reversed); + break; + } + case 1: { + value = std::get<1>(generic_union_to_reversed); + break; + } + default: throw std::runtime_error("Invalid union index."); + } + break; + } + default: + evo_test::binary::ReadGenericUnion, evo_test::binary::ReadGenericRecord, float, yardl::binary::ReadFloatingPoint>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericUnionOfChangedRecordImpl(evo_test::GenericUnion, float>& value) { + auto pos = step_index_.get_step_offset("GenericUnionOfChangedRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadGenericUnion_v1, evo_test::binary::ReadGenericRecord_v1, float, yardl::binary::ReadFloatingPoint>(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericUnion, evo_test::binary::ReadGenericRecord, float, yardl::binary::ReadFloatingPoint>(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericParentRecordImpl(evo_test::GenericParentRecord& value) { + auto pos = step_index_.get_step_offset("GenericParentRecord"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadGenericParentRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericParentRecord(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadGenericNestedRecordsImpl(evo_test::GenericRecord, evo_test::ChangedGeneric>& value) { + auto pos = step_index_.get_step_offset("GenericNestedRecords"); + stream_.Seek(pos); + switch (version_) { + case Version::v1: { + evo_test::binary::ReadGenericRecord_v1(stream_, value); + break; + } + default: + evo_test::binary::ReadGenericRecord, evo_test::binary::ReadUnchangedGeneric, evo_test::ChangedGeneric, evo_test::binary::ReadChangedGeneric>(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(evo_test::GenericRecord& value) { + if (!step_index_.offset_within_stream("GenericRecordStream", "GenericParentRecordStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericRecordStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericRecord>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("GenericRecordStream", "GenericParentRecordStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericRecordStream")); + } + switch (version_) { + case Version::v1: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericRecord>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(evo_test::GenericRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericRecordStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericRecord>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericRecordStreamImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericRecordStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v1: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericRecord>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountGenericRecordStreamImpl() { + return step_index_.get_stream_count("GenericRecordStream"); +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value) { + if (!step_index_.offset_within_stream("GenericParentRecordStream", "VectorRecordWithChanges", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericParentRecordStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord_v1>(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("GenericParentRecordStream", "VectorRecordWithChanges", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("GenericParentRecordStream")); + } + switch (version_) { + case Version::v1: { + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord_v1>(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericParentRecordStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord_v1>(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("GenericParentRecordStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v1: { + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord_v1>(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, evo_test::binary::ReadGenericParentRecord>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountGenericParentRecordStreamImpl() { + return step_index_.get_stream_count("GenericParentRecordStream"); +} + +void ProtocolWithChangesIndexedReader::ReadVectorRecordWithChangesImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("VectorRecordWithChanges"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + yardl::binary::ReadVector(stream_, value); + break; + } + case Version::v1: { + yardl::binary::ReadVector(stream_, value); + break; + } + default: + yardl::binary::ReadVector(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value) { + if (!step_index_.offset_within_stream("StreamedRecordWithChanges", "AddedStringVector", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamedRecordWithChanges")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(std::vector& values) { + if (!step_index_.offset_within_stream("StreamedRecordWithChanges", "AddedStringVector", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamedRecordWithChanges")); + } + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + case Version::v1: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamedRecordWithChanges", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamedRecordWithChanges", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + case Version::v1: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountStreamedRecordWithChangesImpl() { + return step_index_.get_stream_count("StreamedRecordWithChanges"); +} + +void ProtocolWithChangesIndexedReader::ReadAddedStringVectorImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("AddedStringVector"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::vector added_string_vector = {}; + value = std::move(added_string_vector); + break; + } + case Version::v1: { + std::vector added_string_vector = {}; + value = std::move(added_string_vector); + break; + } + default: + yardl::binary::ReadVector(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAddedOptionalImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("AddedOptional"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::optional added_optional = {}; + value = std::move(added_optional); + break; + } + case Version::v1: { + yardl::binary::ReadOptional(stream_, value); + break; + } + default: + yardl::binary::ReadOptional(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAddedMapImpl(std::unordered_map& value) { + auto pos = step_index_.get_step_offset("AddedMap"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::unordered_map added_map = {}; + value = std::move(added_map); + break; + } + default: + yardl::binary::ReadMap(stream_, value); + break; + } +} + +void ProtocolWithChangesIndexedReader::ReadAddedUnionImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("AddedUnion"); + stream_.Seek(pos); + switch (version_) { + case Version::v0: { + std::variant added_union = {}; + value = std::move(added_union); + break; + } + case Version::v1: { + std::variant added_union = {}; + value = std::move(added_union); + break; + } + default: + ReadUnion(stream_, value); + break; + } +} + +bool ProtocolWithChangesIndexedReader::ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value) { + if (!step_index_.offset_within_stream("AddedRecordStream", "AddedUnionStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("AddedRecordStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges added_record_stream = {}; + value = std::move(added_record_stream); + return false; + break; + } + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedRecordStreamImpl(std::vector& values) { + if (!step_index_.offset_within_stream("AddedRecordStream", "AddedUnionStream", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("AddedRecordStream")); + } + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + case Version::v1: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("AddedRecordStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + evo_test::RecordWithChanges added_record_stream = {}; + value = std::move(added_record_stream); + return false; + break; + } + case Version::v1: { + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + default: + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedRecordStreamImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("AddedRecordStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + case Version::v1: { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + default: + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountAddedRecordStreamImpl() { + return step_index_.get_stream_count("AddedRecordStream"); +} + +bool ProtocolWithChangesIndexedReader::ReadAddedUnionStreamImpl(std::variant& value) { + if (!step_index_.offset_within_stream("AddedUnionStream", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("AddedUnionStream")); + } + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant added_union_stream = {}; + value = std::move(added_union_stream); + return false; + break; + } + case Version::v1: { + std::variant added_union_stream = {}; + value = std::move(added_union_stream); + return false; + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedUnionStreamImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("AddedUnionStream", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("AddedUnionStream")); + } + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + case Version::v1: { + values.clear(); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedUnionStreamImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("AddedUnionStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + switch (version_) { + case Version::v0: { + std::variant added_union_stream = {}; + value = std::move(added_union_stream); + return false; + break; + } + case Version::v1: { + std::variant added_union_stream = {}; + value = std::move(added_union_stream); + return false; + break; + } + default: + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + break; + } + return read_block_successful; +} + +bool ProtocolWithChangesIndexedReader::ReadAddedUnionStreamImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("AddedUnionStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + switch (version_) { + case Version::v0: { + values.clear(); + break; + } + case Version::v1: { + values.clear(); + break; + } + default: + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + break; + } + return current_block_remaining_ != 0; +} + +size_t ProtocolWithChangesIndexedReader::CountAddedUnionStreamImpl() { + return step_index_.get_stream_count("AddedUnionStream"); +} + +void ProtocolWithChangesIndexedReader::CloseImpl() { +} + } // namespace evo_test::binary diff --git a/cpp/evolution/v2/generated/binary/protocols.h b/cpp/evolution/v2/generated/binary/protocols.h index 964fa9e..cc31d40 100644 --- a/cpp/evolution/v2/generated/binary/protocols.h +++ b/cpp/evolution/v2/generated/binary/protocols.h @@ -159,6 +159,153 @@ class ProtocolWithChangesWriter : public evo_test::ProtocolWithChangesWriterBase Version version_; }; +// Binary indexed writer for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedWriter : public evo_test::ProtocolWithChangesWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ProtocolWithChangesIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, evo_test::ProtocolWithChangesWriterBase::SchemaFromVersion(version)), version_(version) {} + + ProtocolWithChangesIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, evo_test::ProtocolWithChangesWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteInt8ToIntImpl(int8_t const& value) override; + void WriteInt8ToLongImpl(int8_t const& value) override; + void WriteInt8ToUintImpl(int8_t const& value) override; + void WriteInt8ToUlongImpl(int8_t const& value) override; + void WriteInt8ToFloatImpl(int8_t const& value) override; + void WriteInt8ToDoubleImpl(int8_t const& value) override; + void WriteIntToUintImpl(int32_t const& value) override; + void WriteIntToLongImpl(int32_t const& value) override; + void WriteIntToFloatImpl(int32_t const& value) override; + void WriteIntToDoubleImpl(int32_t const& value) override; + void WriteUintToUlongImpl(uint32_t const& value) override; + void WriteUintToFloatImpl(uint32_t const& value) override; + void WriteUintToDoubleImpl(uint32_t const& value) override; + void WriteFloatToDoubleImpl(float const& value) override; + void WriteComplexFloatToComplexDoubleImpl(std::complex const& value) override; + void WriteIntToStringImpl(int32_t const& value) override; + void WriteUintToStringImpl(uint32_t const& value) override; + void WriteLongToStringImpl(int64_t const& value) override; + void WriteUlongToStringImpl(uint64_t const& value) override; + void WriteFloatToStringImpl(float const& value) override; + void WriteDoubleToStringImpl(double const& value) override; + void WriteIntToOptionalImpl(int32_t const& value) override; + void WriteFloatToOptionalImpl(float const& value) override; + void WriteStringToOptionalImpl(std::string const& value) override; + void WriteIntToUnionImpl(int32_t const& value) override; + void WriteFloatToUnionImpl(float const& value) override; + void WriteStringToUnionImpl(std::string const& value) override; + void WriteOptionalIntToFloatImpl(std::optional const& value) override; + void WriteOptionalFloatToStringImpl(std::optional const& value) override; + void WriteAliasedLongToStringImpl(evo_test::AliasedLongToString const& value) override; + void WriteStringToAliasedStringImpl(std::string const& value) override; + void WriteStringToAliasedIntImpl(std::string const& value) override; + void WriteEnumToAliasedEnumImpl(evo_test::GrowingEnum const& value) override; + void WriteOptionalIntToUnionImpl(std::optional const& value) override; + void WriteOptionalRecordToUnionImpl(std::optional const& value) override; + void WriteRecordWithChangesImpl(evo_test::RecordWithChanges const& value) override; + void WriteAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges const& value) override; + void WriteRecordToRenamedRecordImpl(evo_test::RenamedRecord const& value) override; + void WriteRecordToAliasedRecordImpl(evo_test::RecordWithChanges const& value) override; + void WriteRecordToAliasedAliasImpl(evo_test::RecordWithChanges const& value) override; + // Stream and Vector type changes + void WriteStreamIntToStringToFloatImpl(float const& value) override; + void WriteStreamIntToStringToFloatImpl(std::vector const& values) override; + void EndStreamIntToStringToFloatImpl() override; + void WriteVectorIntToStringToFloatImpl(std::vector const& value) override; + void WriteIntFloatUnionReorderedImpl(std::variant const& value) override; + void WriteVectorUnionReorderedImpl(std::vector> const& value) override; + void WriteStreamUnionReorderedImpl(std::variant const& value) override; + void WriteStreamUnionReorderedImpl(std::vector> const& values) override; + void EndStreamUnionReorderedImpl() override; + void WriteIntToUnionStreamImpl(std::variant const& value) override; + void WriteIntToUnionStreamImpl(std::vector> const& values) override; + void EndIntToUnionStreamImpl() override; + void WriteUnionStreamTypeChangeImpl(std::variant const& value) override; + void WriteUnionStreamTypeChangeImpl(std::vector> const& values) override; + void EndUnionStreamTypeChangeImpl() override; + void WriteStreamOfAliasTypeChangeImpl(evo_test::StreamItem const& value) override; + void WriteStreamOfAliasTypeChangeImpl(std::vector const& values) override; + void EndStreamOfAliasTypeChangeImpl() override; + // Comprehensive NamedType changes + void WriteRlinkImpl(evo_test::RLink const& value) override; + void WriteRlinkRXImpl(evo_test::RLink const& value) override; + void WriteRlinkRYImpl(evo_test::RLink const& value) override; + void WriteRlinkRZImpl(evo_test::RLink const& value) override; + void WriteRaRLinkImpl(evo_test::RA const& value) override; + void WriteRaRXImpl(evo_test::RA const& value) override; + void WriteRaRYImpl(evo_test::RA const& value) override; + void WriteRaRZImpl(evo_test::RA const& value) override; + void WriteRbRLinkImpl(evo_test::RB const& value) override; + void WriteRbRXImpl(evo_test::RB const& value) override; + void WriteRbRYImpl(evo_test::RB const& value) override; + void WriteRbRZImpl(evo_test::RB const& value) override; + void WriteRcRLinkImpl(evo_test::RC const& value) override; + void WriteRcRXImpl(evo_test::RC const& value) override; + void WriteRcRYImpl(evo_test::RC const& value) override; + void WriteRcRZImpl(evo_test::RC const& value) override; + void WriteRlinkRNewImpl(evo_test::RLink const& value) override; + void WriteRaRNewImpl(evo_test::RA const& value) override; + void WriteRbRNewImpl(evo_test::RB const& value) override; + void WriteRcRNewImpl(evo_test::RC const& value) override; + void WriteRlinkRUnionImpl(evo_test::RLink const& value) override; + void WriteRaRUnionImpl(evo_test::RA const& value) override; + void WriteRbRUnionImpl(evo_test::RB const& value) override; + void WriteRcRUnionImpl(evo_test::RC const& value) override; + void WriteOptionalRecordWithChangesImpl(std::optional const& value) override; + void WriteAliasedOptionalRecordWithChangesImpl(std::optional const& value) override; + void WriteUnionRecordWithChangesImpl(std::variant const& value) override; + void WriteUnionWithSameTypesetImpl(std::variant const& value) override; + void WriteUnionWithTypesAddedImpl(std::variant const& value) override; + void WriteUnionWithTypesRemovedImpl(std::variant const& value) override; + void WriteRecordToOptionalImpl(evo_test::RecordWithChanges const& value) override; + void WriteRecordToAliasedOptionalImpl(evo_test::RecordWithChanges const& value) override; + void WriteRecordToUnionImpl(evo_test::RecordWithChanges const& value) override; + void WriteRecordToAliasedUnionImpl(evo_test::RecordWithChanges const& value) override; + void WriteUnionToAliasedUnionImpl(std::variant const& value) override; + void WriteUnionToAliasedUnionWithChangesImpl(std::variant const& value) override; + void WriteOptionalToAliasedOptionalImpl(std::optional const& value) override; + void WriteOptionalToAliasedOptionalWithChangesImpl(std::optional const& value) override; + void WriteGenericRecordImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordToOpenAliasImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordToClosedAliasImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordToHalfClosedAliasImpl(evo_test::GenericRecord const& value) override; + void WriteAliasedGenericRecordToAliasImpl(evo_test::AliasedHalfClosedGenericRecord const& value) override; + void WriteGenericRecordToReversedImpl(evo_test::GenericRecord const& value) override; + void WriteClosedGenericRecordToUnionImpl(evo_test::AliasedClosedGenericRecord const& value) override; + void WriteGenericRecordToAliasedUnionImpl(evo_test::GenericRecord const& value) override; + void WriteGenericUnionToReversedImpl(evo_test::GenericUnion, float> const& value) override; + void WriteGenericUnionOfChangedRecordImpl(evo_test::GenericUnion, float> const& value) override; + void WriteGenericParentRecordImpl(evo_test::GenericParentRecord const& value) override; + void WriteGenericNestedRecordsImpl(evo_test::GenericRecord, evo_test::ChangedGeneric> const& value) override; + void WriteGenericRecordStreamImpl(evo_test::GenericRecord const& value) override; + void WriteGenericRecordStreamImpl(std::vector> const& values) override; + void EndGenericRecordStreamImpl() override; + void WriteGenericParentRecordStreamImpl(evo_test::GenericParentRecord const& value) override; + void WriteGenericParentRecordStreamImpl(std::vector> const& values) override; + void EndGenericParentRecordStreamImpl() override; + void WriteVectorRecordWithChangesImpl(std::vector const& value) override; + void WriteStreamedRecordWithChangesImpl(evo_test::RecordWithChanges const& value) override; + void WriteStreamedRecordWithChangesImpl(std::vector const& values) override; + void EndStreamedRecordWithChangesImpl() override; + void WriteAddedStringVectorImpl(std::vector const& value) override; + void WriteAddedOptionalImpl(std::optional const& value) override; + void WriteAddedMapImpl(std::unordered_map const& value) override; + void WriteAddedUnionImpl(std::variant const& value) override; + void WriteAddedRecordStreamImpl(evo_test::RecordWithChanges const& value) override; + void WriteAddedRecordStreamImpl(std::vector const& values) override; + void EndAddedRecordStreamImpl() override; + void WriteAddedUnionStreamImpl(std::variant const& value) override; + void WriteAddedUnionStreamImpl(std::vector> const& values) override; + void EndAddedUnionStreamImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the ProtocolWithChanges protocol. class ProtocolWithChangesReader : public evo_test::ProtocolWithChangesReaderBase, yardl::binary::BinaryReader { public: @@ -297,4 +444,172 @@ class ProtocolWithChangesReader : public evo_test::ProtocolWithChangesReaderBase size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedReader : public evo_test::ProtocolWithChangesIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ProtocolWithChangesIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(evo_test::ProtocolWithChangesIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ProtocolWithChangesIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(evo_test::ProtocolWithChangesIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadInt8ToIntImpl(int8_t& value) override; + void ReadInt8ToLongImpl(int8_t& value) override; + void ReadInt8ToUintImpl(int8_t& value) override; + void ReadInt8ToUlongImpl(int8_t& value) override; + void ReadInt8ToFloatImpl(int8_t& value) override; + void ReadInt8ToDoubleImpl(int8_t& value) override; + void ReadIntToUintImpl(int32_t& value) override; + void ReadIntToLongImpl(int32_t& value) override; + void ReadIntToFloatImpl(int32_t& value) override; + void ReadIntToDoubleImpl(int32_t& value) override; + void ReadUintToUlongImpl(uint32_t& value) override; + void ReadUintToFloatImpl(uint32_t& value) override; + void ReadUintToDoubleImpl(uint32_t& value) override; + void ReadFloatToDoubleImpl(float& value) override; + void ReadComplexFloatToComplexDoubleImpl(std::complex& value) override; + void ReadIntToStringImpl(int32_t& value) override; + void ReadUintToStringImpl(uint32_t& value) override; + void ReadLongToStringImpl(int64_t& value) override; + void ReadUlongToStringImpl(uint64_t& value) override; + void ReadFloatToStringImpl(float& value) override; + void ReadDoubleToStringImpl(double& value) override; + void ReadIntToOptionalImpl(int32_t& value) override; + void ReadFloatToOptionalImpl(float& value) override; + void ReadStringToOptionalImpl(std::string& value) override; + void ReadIntToUnionImpl(int32_t& value) override; + void ReadFloatToUnionImpl(float& value) override; + void ReadStringToUnionImpl(std::string& value) override; + void ReadOptionalIntToFloatImpl(std::optional& value) override; + void ReadOptionalFloatToStringImpl(std::optional& value) override; + void ReadAliasedLongToStringImpl(evo_test::AliasedLongToString& value) override; + void ReadStringToAliasedStringImpl(std::string& value) override; + void ReadStringToAliasedIntImpl(std::string& value) override; + void ReadEnumToAliasedEnumImpl(evo_test::GrowingEnum& value) override; + void ReadOptionalIntToUnionImpl(std::optional& value) override; + void ReadOptionalRecordToUnionImpl(std::optional& value) override; + void ReadRecordWithChangesImpl(evo_test::RecordWithChanges& value) override; + void ReadAliasedRecordWithChangesImpl(evo_test::AliasedRecordWithChanges& value) override; + void ReadRecordToRenamedRecordImpl(evo_test::RenamedRecord& value) override; + void ReadRecordToAliasedRecordImpl(evo_test::RecordWithChanges& value) override; + void ReadRecordToAliasedAliasImpl(evo_test::RecordWithChanges& value) override; + bool ReadStreamIntToStringToFloatImpl(float& value) override; + bool ReadStreamIntToStringToFloatImpl(std::vector& values) override; + bool ReadStreamIntToStringToFloatImpl(float& value, size_t idx) override; + bool ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) override; + size_t CountStreamIntToStringToFloatImpl() override; + void ReadVectorIntToStringToFloatImpl(std::vector& value) override; + void ReadIntFloatUnionReorderedImpl(std::variant& value) override; + void ReadVectorUnionReorderedImpl(std::vector>& value) override; + bool ReadStreamUnionReorderedImpl(std::variant& value) override; + bool ReadStreamUnionReorderedImpl(std::vector>& values) override; + bool ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) override; + bool ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) override; + size_t CountStreamUnionReorderedImpl() override; + bool ReadIntToUnionStreamImpl(std::variant& value) override; + bool ReadIntToUnionStreamImpl(std::vector>& values) override; + bool ReadIntToUnionStreamImpl(std::variant& value, size_t idx) override; + bool ReadIntToUnionStreamImpl(std::vector>& values, size_t idx) override; + size_t CountIntToUnionStreamImpl() override; + bool ReadUnionStreamTypeChangeImpl(std::variant& value) override; + bool ReadUnionStreamTypeChangeImpl(std::vector>& values) override; + bool ReadUnionStreamTypeChangeImpl(std::variant& value, size_t idx) override; + bool ReadUnionStreamTypeChangeImpl(std::vector>& values, size_t idx) override; + size_t CountUnionStreamTypeChangeImpl() override; + bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value) override; + bool ReadStreamOfAliasTypeChangeImpl(std::vector& values) override; + bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) override; + bool ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) override; + size_t CountStreamOfAliasTypeChangeImpl() override; + void ReadRlinkImpl(evo_test::RLink& value) override; + void ReadRlinkRXImpl(evo_test::RLink& value) override; + void ReadRlinkRYImpl(evo_test::RLink& value) override; + void ReadRlinkRZImpl(evo_test::RLink& value) override; + void ReadRaRLinkImpl(evo_test::RA& value) override; + void ReadRaRXImpl(evo_test::RA& value) override; + void ReadRaRYImpl(evo_test::RA& value) override; + void ReadRaRZImpl(evo_test::RA& value) override; + void ReadRbRLinkImpl(evo_test::RB& value) override; + void ReadRbRXImpl(evo_test::RB& value) override; + void ReadRbRYImpl(evo_test::RB& value) override; + void ReadRbRZImpl(evo_test::RB& value) override; + void ReadRcRLinkImpl(evo_test::RC& value) override; + void ReadRcRXImpl(evo_test::RC& value) override; + void ReadRcRYImpl(evo_test::RC& value) override; + void ReadRcRZImpl(evo_test::RC& value) override; + void ReadRlinkRNewImpl(evo_test::RLink& value) override; + void ReadRaRNewImpl(evo_test::RA& value) override; + void ReadRbRNewImpl(evo_test::RB& value) override; + void ReadRcRNewImpl(evo_test::RC& value) override; + void ReadRlinkRUnionImpl(evo_test::RLink& value) override; + void ReadRaRUnionImpl(evo_test::RA& value) override; + void ReadRbRUnionImpl(evo_test::RB& value) override; + void ReadRcRUnionImpl(evo_test::RC& value) override; + void ReadOptionalRecordWithChangesImpl(std::optional& value) override; + void ReadAliasedOptionalRecordWithChangesImpl(std::optional& value) override; + void ReadUnionRecordWithChangesImpl(std::variant& value) override; + void ReadUnionWithSameTypesetImpl(std::variant& value) override; + void ReadUnionWithTypesAddedImpl(std::variant& value) override; + void ReadUnionWithTypesRemovedImpl(std::variant& value) override; + void ReadRecordToOptionalImpl(evo_test::RecordWithChanges& value) override; + void ReadRecordToAliasedOptionalImpl(evo_test::RecordWithChanges& value) override; + void ReadRecordToUnionImpl(evo_test::RecordWithChanges& value) override; + void ReadRecordToAliasedUnionImpl(evo_test::RecordWithChanges& value) override; + void ReadUnionToAliasedUnionImpl(std::variant& value) override; + void ReadUnionToAliasedUnionWithChangesImpl(std::variant& value) override; + void ReadOptionalToAliasedOptionalImpl(std::optional& value) override; + void ReadOptionalToAliasedOptionalWithChangesImpl(std::optional& value) override; + void ReadGenericRecordImpl(evo_test::GenericRecord& value) override; + void ReadGenericRecordToOpenAliasImpl(evo_test::GenericRecord& value) override; + void ReadGenericRecordToClosedAliasImpl(evo_test::GenericRecord& value) override; + void ReadGenericRecordToHalfClosedAliasImpl(evo_test::GenericRecord& value) override; + void ReadAliasedGenericRecordToAliasImpl(evo_test::AliasedHalfClosedGenericRecord& value) override; + void ReadGenericRecordToReversedImpl(evo_test::GenericRecord& value) override; + void ReadClosedGenericRecordToUnionImpl(evo_test::AliasedClosedGenericRecord& value) override; + void ReadGenericRecordToAliasedUnionImpl(evo_test::GenericRecord& value) override; + void ReadGenericUnionToReversedImpl(evo_test::GenericUnion, float>& value) override; + void ReadGenericUnionOfChangedRecordImpl(evo_test::GenericUnion, float>& value) override; + void ReadGenericParentRecordImpl(evo_test::GenericParentRecord& value) override; + void ReadGenericNestedRecordsImpl(evo_test::GenericRecord, evo_test::ChangedGeneric>& value) override; + bool ReadGenericRecordStreamImpl(evo_test::GenericRecord& value) override; + bool ReadGenericRecordStreamImpl(std::vector>& values) override; + bool ReadGenericRecordStreamImpl(evo_test::GenericRecord& value, size_t idx) override; + bool ReadGenericRecordStreamImpl(std::vector>& values, size_t idx) override; + size_t CountGenericRecordStreamImpl() override; + bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value) override; + bool ReadGenericParentRecordStreamImpl(std::vector>& values) override; + bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) override; + bool ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) override; + size_t CountGenericParentRecordStreamImpl() override; + void ReadVectorRecordWithChangesImpl(std::vector& value) override; + bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value) override; + bool ReadStreamedRecordWithChangesImpl(std::vector& values) override; + bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) override; + bool ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) override; + size_t CountStreamedRecordWithChangesImpl() override; + void ReadAddedStringVectorImpl(std::vector& value) override; + void ReadAddedOptionalImpl(std::optional& value) override; + void ReadAddedMapImpl(std::unordered_map& value) override; + void ReadAddedUnionImpl(std::variant& value) override; + bool ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value) override; + bool ReadAddedRecordStreamImpl(std::vector& values) override; + bool ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value, size_t idx) override; + bool ReadAddedRecordStreamImpl(std::vector& values, size_t idx) override; + size_t CountAddedRecordStreamImpl() override; + bool ReadAddedUnionStreamImpl(std::variant& value) override; + bool ReadAddedUnionStreamImpl(std::vector>& values) override; + bool ReadAddedUnionStreamImpl(std::variant& value, size_t idx) override; + bool ReadAddedUnionStreamImpl(std::vector>& values, size_t idx) override; + size_t CountAddedUnionStreamImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + } // namespace evo_test::binary diff --git a/cpp/evolution/v2/generated/protocols.cc b/cpp/evolution/v2/generated/protocols.cc index a696926..7d30d14 100644 --- a/cpp/evolution/v2/generated/protocols.cc +++ b/cpp/evolution/v2/generated/protocols.cc @@ -9,354 +9,6 @@ #endif namespace evo_test { -namespace { -void ProtocolWithChangesWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInt8ToInt()"; break; - case 1: expected_method = "WriteInt8ToLong()"; break; - case 2: expected_method = "WriteInt8ToUint()"; break; - case 3: expected_method = "WriteInt8ToUlong()"; break; - case 4: expected_method = "WriteInt8ToFloat()"; break; - case 5: expected_method = "WriteInt8ToDouble()"; break; - case 6: expected_method = "WriteIntToUint()"; break; - case 7: expected_method = "WriteIntToLong()"; break; - case 8: expected_method = "WriteIntToFloat()"; break; - case 9: expected_method = "WriteIntToDouble()"; break; - case 10: expected_method = "WriteUintToUlong()"; break; - case 11: expected_method = "WriteUintToFloat()"; break; - case 12: expected_method = "WriteUintToDouble()"; break; - case 13: expected_method = "WriteFloatToDouble()"; break; - case 14: expected_method = "WriteComplexFloatToComplexDouble()"; break; - case 15: expected_method = "WriteIntToString()"; break; - case 16: expected_method = "WriteUintToString()"; break; - case 17: expected_method = "WriteLongToString()"; break; - case 18: expected_method = "WriteUlongToString()"; break; - case 19: expected_method = "WriteFloatToString()"; break; - case 20: expected_method = "WriteDoubleToString()"; break; - case 21: expected_method = "WriteIntToOptional()"; break; - case 22: expected_method = "WriteFloatToOptional()"; break; - case 23: expected_method = "WriteStringToOptional()"; break; - case 24: expected_method = "WriteIntToUnion()"; break; - case 25: expected_method = "WriteFloatToUnion()"; break; - case 26: expected_method = "WriteStringToUnion()"; break; - case 27: expected_method = "WriteOptionalIntToFloat()"; break; - case 28: expected_method = "WriteOptionalFloatToString()"; break; - case 29: expected_method = "WriteAliasedLongToString()"; break; - case 30: expected_method = "WriteStringToAliasedString()"; break; - case 31: expected_method = "WriteStringToAliasedInt()"; break; - case 32: expected_method = "WriteEnumToAliasedEnum()"; break; - case 33: expected_method = "WriteOptionalIntToUnion()"; break; - case 34: expected_method = "WriteOptionalRecordToUnion()"; break; - case 35: expected_method = "WriteRecordWithChanges()"; break; - case 36: expected_method = "WriteAliasedRecordWithChanges()"; break; - case 37: expected_method = "WriteRecordToRenamedRecord()"; break; - case 38: expected_method = "WriteRecordToAliasedRecord()"; break; - case 39: expected_method = "WriteRecordToAliasedAlias()"; break; - case 40: expected_method = "WriteStreamIntToStringToFloat() or EndStreamIntToStringToFloat()"; break; - case 41: expected_method = "WriteVectorIntToStringToFloat()"; break; - case 42: expected_method = "WriteIntFloatUnionReordered()"; break; - case 43: expected_method = "WriteVectorUnionReordered()"; break; - case 44: expected_method = "WriteStreamUnionReordered() or EndStreamUnionReordered()"; break; - case 45: expected_method = "WriteIntToUnionStream() or EndIntToUnionStream()"; break; - case 46: expected_method = "WriteUnionStreamTypeChange() or EndUnionStreamTypeChange()"; break; - case 47: expected_method = "WriteStreamOfAliasTypeChange() or EndStreamOfAliasTypeChange()"; break; - case 48: expected_method = "WriteRlink()"; break; - case 49: expected_method = "WriteRlinkRX()"; break; - case 50: expected_method = "WriteRlinkRY()"; break; - case 51: expected_method = "WriteRlinkRZ()"; break; - case 52: expected_method = "WriteRaRLink()"; break; - case 53: expected_method = "WriteRaRX()"; break; - case 54: expected_method = "WriteRaRY()"; break; - case 55: expected_method = "WriteRaRZ()"; break; - case 56: expected_method = "WriteRbRLink()"; break; - case 57: expected_method = "WriteRbRX()"; break; - case 58: expected_method = "WriteRbRY()"; break; - case 59: expected_method = "WriteRbRZ()"; break; - case 60: expected_method = "WriteRcRLink()"; break; - case 61: expected_method = "WriteRcRX()"; break; - case 62: expected_method = "WriteRcRY()"; break; - case 63: expected_method = "WriteRcRZ()"; break; - case 64: expected_method = "WriteRlinkRNew()"; break; - case 65: expected_method = "WriteRaRNew()"; break; - case 66: expected_method = "WriteRbRNew()"; break; - case 67: expected_method = "WriteRcRNew()"; break; - case 68: expected_method = "WriteRlinkRUnion()"; break; - case 69: expected_method = "WriteRaRUnion()"; break; - case 70: expected_method = "WriteRbRUnion()"; break; - case 71: expected_method = "WriteRcRUnion()"; break; - case 72: expected_method = "WriteOptionalRecordWithChanges()"; break; - case 73: expected_method = "WriteAliasedOptionalRecordWithChanges()"; break; - case 74: expected_method = "WriteUnionRecordWithChanges()"; break; - case 75: expected_method = "WriteUnionWithSameTypeset()"; break; - case 76: expected_method = "WriteUnionWithTypesAdded()"; break; - case 77: expected_method = "WriteUnionWithTypesRemoved()"; break; - case 78: expected_method = "WriteRecordToOptional()"; break; - case 79: expected_method = "WriteRecordToAliasedOptional()"; break; - case 80: expected_method = "WriteRecordToUnion()"; break; - case 81: expected_method = "WriteRecordToAliasedUnion()"; break; - case 82: expected_method = "WriteUnionToAliasedUnion()"; break; - case 83: expected_method = "WriteUnionToAliasedUnionWithChanges()"; break; - case 84: expected_method = "WriteOptionalToAliasedOptional()"; break; - case 85: expected_method = "WriteOptionalToAliasedOptionalWithChanges()"; break; - case 86: expected_method = "WriteGenericRecord()"; break; - case 87: expected_method = "WriteGenericRecordToOpenAlias()"; break; - case 88: expected_method = "WriteGenericRecordToClosedAlias()"; break; - case 89: expected_method = "WriteGenericRecordToHalfClosedAlias()"; break; - case 90: expected_method = "WriteAliasedGenericRecordToAlias()"; break; - case 91: expected_method = "WriteGenericRecordToReversed()"; break; - case 92: expected_method = "WriteClosedGenericRecordToUnion()"; break; - case 93: expected_method = "WriteGenericRecordToAliasedUnion()"; break; - case 94: expected_method = "WriteGenericUnionToReversed()"; break; - case 95: expected_method = "WriteGenericUnionOfChangedRecord()"; break; - case 96: expected_method = "WriteGenericParentRecord()"; break; - case 97: expected_method = "WriteGenericNestedRecords()"; break; - case 98: expected_method = "WriteGenericRecordStream() or EndGenericRecordStream()"; break; - case 99: expected_method = "WriteGenericParentRecordStream() or EndGenericParentRecordStream()"; break; - case 100: expected_method = "WriteVectorRecordWithChanges()"; break; - case 101: expected_method = "WriteStreamedRecordWithChanges() or EndStreamedRecordWithChanges()"; break; - case 102: expected_method = "WriteAddedStringVector()"; break; - case 103: expected_method = "WriteAddedOptional()"; break; - case 104: expected_method = "WriteAddedMap()"; break; - case 105: expected_method = "WriteAddedUnion()"; break; - case 106: expected_method = "WriteAddedRecordStream() or EndAddedRecordStream()"; break; - case 107: expected_method = "WriteAddedUnionStream() or EndAddedUnionStream()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteInt8ToInt()"; break; - case 1: attempted_method = "WriteInt8ToLong()"; break; - case 2: attempted_method = "WriteInt8ToUint()"; break; - case 3: attempted_method = "WriteInt8ToUlong()"; break; - case 4: attempted_method = "WriteInt8ToFloat()"; break; - case 5: attempted_method = "WriteInt8ToDouble()"; break; - case 6: attempted_method = "WriteIntToUint()"; break; - case 7: attempted_method = "WriteIntToLong()"; break; - case 8: attempted_method = "WriteIntToFloat()"; break; - case 9: attempted_method = "WriteIntToDouble()"; break; - case 10: attempted_method = "WriteUintToUlong()"; break; - case 11: attempted_method = "WriteUintToFloat()"; break; - case 12: attempted_method = "WriteUintToDouble()"; break; - case 13: attempted_method = "WriteFloatToDouble()"; break; - case 14: attempted_method = "WriteComplexFloatToComplexDouble()"; break; - case 15: attempted_method = "WriteIntToString()"; break; - case 16: attempted_method = "WriteUintToString()"; break; - case 17: attempted_method = "WriteLongToString()"; break; - case 18: attempted_method = "WriteUlongToString()"; break; - case 19: attempted_method = "WriteFloatToString()"; break; - case 20: attempted_method = "WriteDoubleToString()"; break; - case 21: attempted_method = "WriteIntToOptional()"; break; - case 22: attempted_method = "WriteFloatToOptional()"; break; - case 23: attempted_method = "WriteStringToOptional()"; break; - case 24: attempted_method = "WriteIntToUnion()"; break; - case 25: attempted_method = "WriteFloatToUnion()"; break; - case 26: attempted_method = "WriteStringToUnion()"; break; - case 27: attempted_method = "WriteOptionalIntToFloat()"; break; - case 28: attempted_method = "WriteOptionalFloatToString()"; break; - case 29: attempted_method = "WriteAliasedLongToString()"; break; - case 30: attempted_method = "WriteStringToAliasedString()"; break; - case 31: attempted_method = "WriteStringToAliasedInt()"; break; - case 32: attempted_method = "WriteEnumToAliasedEnum()"; break; - case 33: attempted_method = "WriteOptionalIntToUnion()"; break; - case 34: attempted_method = "WriteOptionalRecordToUnion()"; break; - case 35: attempted_method = "WriteRecordWithChanges()"; break; - case 36: attempted_method = "WriteAliasedRecordWithChanges()"; break; - case 37: attempted_method = "WriteRecordToRenamedRecord()"; break; - case 38: attempted_method = "WriteRecordToAliasedRecord()"; break; - case 39: attempted_method = "WriteRecordToAliasedAlias()"; break; - case 40: attempted_method = end ? "EndStreamIntToStringToFloat()" : "WriteStreamIntToStringToFloat()"; break; - case 41: attempted_method = "WriteVectorIntToStringToFloat()"; break; - case 42: attempted_method = "WriteIntFloatUnionReordered()"; break; - case 43: attempted_method = "WriteVectorUnionReordered()"; break; - case 44: attempted_method = end ? "EndStreamUnionReordered()" : "WriteStreamUnionReordered()"; break; - case 45: attempted_method = end ? "EndIntToUnionStream()" : "WriteIntToUnionStream()"; break; - case 46: attempted_method = end ? "EndUnionStreamTypeChange()" : "WriteUnionStreamTypeChange()"; break; - case 47: attempted_method = end ? "EndStreamOfAliasTypeChange()" : "WriteStreamOfAliasTypeChange()"; break; - case 48: attempted_method = "WriteRlink()"; break; - case 49: attempted_method = "WriteRlinkRX()"; break; - case 50: attempted_method = "WriteRlinkRY()"; break; - case 51: attempted_method = "WriteRlinkRZ()"; break; - case 52: attempted_method = "WriteRaRLink()"; break; - case 53: attempted_method = "WriteRaRX()"; break; - case 54: attempted_method = "WriteRaRY()"; break; - case 55: attempted_method = "WriteRaRZ()"; break; - case 56: attempted_method = "WriteRbRLink()"; break; - case 57: attempted_method = "WriteRbRX()"; break; - case 58: attempted_method = "WriteRbRY()"; break; - case 59: attempted_method = "WriteRbRZ()"; break; - case 60: attempted_method = "WriteRcRLink()"; break; - case 61: attempted_method = "WriteRcRX()"; break; - case 62: attempted_method = "WriteRcRY()"; break; - case 63: attempted_method = "WriteRcRZ()"; break; - case 64: attempted_method = "WriteRlinkRNew()"; break; - case 65: attempted_method = "WriteRaRNew()"; break; - case 66: attempted_method = "WriteRbRNew()"; break; - case 67: attempted_method = "WriteRcRNew()"; break; - case 68: attempted_method = "WriteRlinkRUnion()"; break; - case 69: attempted_method = "WriteRaRUnion()"; break; - case 70: attempted_method = "WriteRbRUnion()"; break; - case 71: attempted_method = "WriteRcRUnion()"; break; - case 72: attempted_method = "WriteOptionalRecordWithChanges()"; break; - case 73: attempted_method = "WriteAliasedOptionalRecordWithChanges()"; break; - case 74: attempted_method = "WriteUnionRecordWithChanges()"; break; - case 75: attempted_method = "WriteUnionWithSameTypeset()"; break; - case 76: attempted_method = "WriteUnionWithTypesAdded()"; break; - case 77: attempted_method = "WriteUnionWithTypesRemoved()"; break; - case 78: attempted_method = "WriteRecordToOptional()"; break; - case 79: attempted_method = "WriteRecordToAliasedOptional()"; break; - case 80: attempted_method = "WriteRecordToUnion()"; break; - case 81: attempted_method = "WriteRecordToAliasedUnion()"; break; - case 82: attempted_method = "WriteUnionToAliasedUnion()"; break; - case 83: attempted_method = "WriteUnionToAliasedUnionWithChanges()"; break; - case 84: attempted_method = "WriteOptionalToAliasedOptional()"; break; - case 85: attempted_method = "WriteOptionalToAliasedOptionalWithChanges()"; break; - case 86: attempted_method = "WriteGenericRecord()"; break; - case 87: attempted_method = "WriteGenericRecordToOpenAlias()"; break; - case 88: attempted_method = "WriteGenericRecordToClosedAlias()"; break; - case 89: attempted_method = "WriteGenericRecordToHalfClosedAlias()"; break; - case 90: attempted_method = "WriteAliasedGenericRecordToAlias()"; break; - case 91: attempted_method = "WriteGenericRecordToReversed()"; break; - case 92: attempted_method = "WriteClosedGenericRecordToUnion()"; break; - case 93: attempted_method = "WriteGenericRecordToAliasedUnion()"; break; - case 94: attempted_method = "WriteGenericUnionToReversed()"; break; - case 95: attempted_method = "WriteGenericUnionOfChangedRecord()"; break; - case 96: attempted_method = "WriteGenericParentRecord()"; break; - case 97: attempted_method = "WriteGenericNestedRecords()"; break; - case 98: attempted_method = end ? "EndGenericRecordStream()" : "WriteGenericRecordStream()"; break; - case 99: attempted_method = end ? "EndGenericParentRecordStream()" : "WriteGenericParentRecordStream()"; break; - case 100: attempted_method = "WriteVectorRecordWithChanges()"; break; - case 101: attempted_method = end ? "EndStreamedRecordWithChanges()" : "WriteStreamedRecordWithChanges()"; break; - case 102: attempted_method = "WriteAddedStringVector()"; break; - case 103: attempted_method = "WriteAddedOptional()"; break; - case 104: attempted_method = "WriteAddedMap()"; break; - case 105: attempted_method = "WriteAddedUnion()"; break; - case 106: attempted_method = end ? "EndAddedRecordStream()" : "WriteAddedRecordStream()"; break; - case 107: attempted_method = end ? "EndAddedUnionStream()" : "WriteAddedUnionStream()"; break; - case 108: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ProtocolWithChangesReaderBaseInvalidState(uint8_t attempted, uint8_t current) { - auto f = [](uint8_t i) -> std::string { - switch (i/2) { - case 0: return "ReadInt8ToInt()"; - case 1: return "ReadInt8ToLong()"; - case 2: return "ReadInt8ToUint()"; - case 3: return "ReadInt8ToUlong()"; - case 4: return "ReadInt8ToFloat()"; - case 5: return "ReadInt8ToDouble()"; - case 6: return "ReadIntToUint()"; - case 7: return "ReadIntToLong()"; - case 8: return "ReadIntToFloat()"; - case 9: return "ReadIntToDouble()"; - case 10: return "ReadUintToUlong()"; - case 11: return "ReadUintToFloat()"; - case 12: return "ReadUintToDouble()"; - case 13: return "ReadFloatToDouble()"; - case 14: return "ReadComplexFloatToComplexDouble()"; - case 15: return "ReadIntToString()"; - case 16: return "ReadUintToString()"; - case 17: return "ReadLongToString()"; - case 18: return "ReadUlongToString()"; - case 19: return "ReadFloatToString()"; - case 20: return "ReadDoubleToString()"; - case 21: return "ReadIntToOptional()"; - case 22: return "ReadFloatToOptional()"; - case 23: return "ReadStringToOptional()"; - case 24: return "ReadIntToUnion()"; - case 25: return "ReadFloatToUnion()"; - case 26: return "ReadStringToUnion()"; - case 27: return "ReadOptionalIntToFloat()"; - case 28: return "ReadOptionalFloatToString()"; - case 29: return "ReadAliasedLongToString()"; - case 30: return "ReadStringToAliasedString()"; - case 31: return "ReadStringToAliasedInt()"; - case 32: return "ReadEnumToAliasedEnum()"; - case 33: return "ReadOptionalIntToUnion()"; - case 34: return "ReadOptionalRecordToUnion()"; - case 35: return "ReadRecordWithChanges()"; - case 36: return "ReadAliasedRecordWithChanges()"; - case 37: return "ReadRecordToRenamedRecord()"; - case 38: return "ReadRecordToAliasedRecord()"; - case 39: return "ReadRecordToAliasedAlias()"; - case 40: return "ReadStreamIntToStringToFloat()"; - case 41: return "ReadVectorIntToStringToFloat()"; - case 42: return "ReadIntFloatUnionReordered()"; - case 43: return "ReadVectorUnionReordered()"; - case 44: return "ReadStreamUnionReordered()"; - case 45: return "ReadIntToUnionStream()"; - case 46: return "ReadUnionStreamTypeChange()"; - case 47: return "ReadStreamOfAliasTypeChange()"; - case 48: return "ReadRlink()"; - case 49: return "ReadRlinkRX()"; - case 50: return "ReadRlinkRY()"; - case 51: return "ReadRlinkRZ()"; - case 52: return "ReadRaRLink()"; - case 53: return "ReadRaRX()"; - case 54: return "ReadRaRY()"; - case 55: return "ReadRaRZ()"; - case 56: return "ReadRbRLink()"; - case 57: return "ReadRbRX()"; - case 58: return "ReadRbRY()"; - case 59: return "ReadRbRZ()"; - case 60: return "ReadRcRLink()"; - case 61: return "ReadRcRX()"; - case 62: return "ReadRcRY()"; - case 63: return "ReadRcRZ()"; - case 64: return "ReadRlinkRNew()"; - case 65: return "ReadRaRNew()"; - case 66: return "ReadRbRNew()"; - case 67: return "ReadRcRNew()"; - case 68: return "ReadRlinkRUnion()"; - case 69: return "ReadRaRUnion()"; - case 70: return "ReadRbRUnion()"; - case 71: return "ReadRcRUnion()"; - case 72: return "ReadOptionalRecordWithChanges()"; - case 73: return "ReadAliasedOptionalRecordWithChanges()"; - case 74: return "ReadUnionRecordWithChanges()"; - case 75: return "ReadUnionWithSameTypeset()"; - case 76: return "ReadUnionWithTypesAdded()"; - case 77: return "ReadUnionWithTypesRemoved()"; - case 78: return "ReadRecordToOptional()"; - case 79: return "ReadRecordToAliasedOptional()"; - case 80: return "ReadRecordToUnion()"; - case 81: return "ReadRecordToAliasedUnion()"; - case 82: return "ReadUnionToAliasedUnion()"; - case 83: return "ReadUnionToAliasedUnionWithChanges()"; - case 84: return "ReadOptionalToAliasedOptional()"; - case 85: return "ReadOptionalToAliasedOptionalWithChanges()"; - case 86: return "ReadGenericRecord()"; - case 87: return "ReadGenericRecordToOpenAlias()"; - case 88: return "ReadGenericRecordToClosedAlias()"; - case 89: return "ReadGenericRecordToHalfClosedAlias()"; - case 90: return "ReadAliasedGenericRecordToAlias()"; - case 91: return "ReadGenericRecordToReversed()"; - case 92: return "ReadClosedGenericRecordToUnion()"; - case 93: return "ReadGenericRecordToAliasedUnion()"; - case 94: return "ReadGenericUnionToReversed()"; - case 95: return "ReadGenericUnionOfChangedRecord()"; - case 96: return "ReadGenericParentRecord()"; - case 97: return "ReadGenericNestedRecords()"; - case 98: return "ReadGenericRecordStream()"; - case 99: return "ReadGenericParentRecordStream()"; - case 100: return "ReadVectorRecordWithChanges()"; - case 101: return "ReadStreamedRecordWithChanges()"; - case 102: return "ReadAddedStringVector()"; - case 103: return "ReadAddedOptional()"; - case 104: return "ReadAddedMap()"; - case 105: return "ReadAddedUnion()"; - case 106: return "ReadAddedRecordStream()"; - case 107: return "ReadAddedUnionStream()"; - case 108: return "Close()"; - default: return ""; - } - }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); -} - -} // namespace - std::string ProtocolWithChangesWriterBase::schema_ = R"({"protocol":{"name":"ProtocolWithChanges","sequence":[{"name":"int8ToInt","type":"int8"},{"name":"int8ToLong","type":"int8"},{"name":"int8ToUint","type":"int8"},{"name":"int8ToUlong","type":"int8"},{"name":"int8ToFloat","type":"int8"},{"name":"int8ToDouble","type":"int8"},{"name":"intToUint","type":"int32"},{"name":"intToLong","type":"int32"},{"name":"intToFloat","type":"int32"},{"name":"intToDouble","type":"int32"},{"name":"uintToUlong","type":"uint32"},{"name":"uintToFloat","type":"uint32"},{"name":"uintToDouble","type":"uint32"},{"name":"floatToDouble","type":"float32"},{"name":"complexFloatToComplexDouble","type":"complexfloat32"},{"name":"intToString","type":"int32"},{"name":"uintToString","type":"uint32"},{"name":"longToString","type":"int64"},{"name":"ulongToString","type":"uint64"},{"name":"floatToString","type":"float32"},{"name":"doubleToString","type":"float64"},{"name":"intToOptional","type":"int32"},{"name":"floatToOptional","type":"float32"},{"name":"stringToOptional","type":"string"},{"name":"intToUnion","type":"int32"},{"name":"floatToUnion","type":"float32"},{"name":"stringToUnion","type":"string"},{"name":"optionalIntToFloat","type":[null,"int32"]},{"name":"optionalFloatToString","type":[null,"float32"]},{"name":"aliasedLongToString","type":"EvoTest.AliasedLongToString"},{"name":"stringToAliasedString","type":"string"},{"name":"stringToAliasedInt","type":"string"},{"name":"enumToAliasedEnum","type":"EvoTest.GrowingEnum"},{"name":"optionalIntToUnion","type":[null,"int32"]},{"name":"optionalRecordToUnion","type":[null,"EvoTest.RecordWithChanges"]},{"name":"recordWithChanges","type":"EvoTest.RecordWithChanges"},{"name":"aliasedRecordWithChanges","type":"EvoTest.AliasedRecordWithChanges"},{"name":"recordToRenamedRecord","type":"EvoTest.RenamedRecord"},{"name":"recordToAliasedRecord","type":"EvoTest.RecordWithChanges"},{"name":"recordToAliasedAlias","type":"EvoTest.RecordWithChanges"},{"name":"streamIntToStringToFloat","type":{"stream":{"items":"float32"}}},{"name":"vectorIntToStringToFloat","type":{"vector":{"items":"float32"}}},{"name":"intFloatUnionReordered","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"vectorUnionReordered","type":{"vector":{"items":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]}}},{"name":"streamUnionReordered","type":{"stream":{"items":[{"tag":"int32","type":"int32"},{"tag":"string","type":"string"}]}}},{"name":"intToUnionStream","type":{"stream":{"items":[{"tag":"string","type":"string"},{"tag":"int32","type":"int32"}]}}},{"name":"unionStreamTypeChange","type":{"stream":{"items":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]}}},{"name":"streamOfAliasTypeChange","type":{"stream":{"items":"EvoTest.StreamItem"}}},{"name":"rlink","type":"EvoTest.RLink"},{"name":"rlinkRX","type":"EvoTest.RLink"},{"name":"rlinkRY","type":"EvoTest.RLink"},{"name":"rlinkRZ","type":"EvoTest.RLink"},{"name":"raRLink","type":"EvoTest.RA"},{"name":"raRX","type":"EvoTest.RA"},{"name":"raRY","type":"EvoTest.RA"},{"name":"raRZ","type":"EvoTest.RA"},{"name":"rbRLink","type":"EvoTest.RB"},{"name":"rbRX","type":"EvoTest.RB"},{"name":"rbRY","type":"EvoTest.RB"},{"name":"rbRZ","type":"EvoTest.RB"},{"name":"rcRLink","type":"EvoTest.RC"},{"name":"rcRX","type":"EvoTest.RC"},{"name":"rcRY","type":"EvoTest.RC"},{"name":"rcRZ","type":"EvoTest.RC"},{"name":"rlinkRNew","type":"EvoTest.RLink"},{"name":"raRNew","type":"EvoTest.RA"},{"name":"rbRNew","type":"EvoTest.RB"},{"name":"rcRNew","type":"EvoTest.RC"},{"name":"rlinkRUnion","type":"EvoTest.RLink"},{"name":"raRUnion","type":"EvoTest.RA"},{"name":"rbRUnion","type":"EvoTest.RB"},{"name":"rcRUnion","type":"EvoTest.RC"},{"name":"optionalRecordWithChanges","type":[null,"EvoTest.RecordWithChanges"]},{"name":"aliasedOptionalRecordWithChanges","type":[null,"EvoTest.AliasedRecordWithChanges"]},{"name":"unionRecordWithChanges","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"}]},{"name":"unionWithSameTypeset","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"},{"tag":"string","type":"string"}]},{"name":"unionWithTypesAdded","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"float32","type":"float32"}]},{"name":"unionWithTypesRemoved","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"},{"tag":"string","type":"string"}]},{"name":"recordToOptional","type":"EvoTest.RecordWithChanges"},{"name":"recordToAliasedOptional","type":"EvoTest.RecordWithChanges"},{"name":"recordToUnion","type":"EvoTest.RecordWithChanges"},{"name":"recordToAliasedUnion","type":"EvoTest.RecordWithChanges"},{"name":"unionToAliasedUnion","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"}]},{"name":"unionToAliasedUnionWithChanges","type":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"int32","type":"int32"}]},{"name":"optionalToAliasedOptional","type":[null,"EvoTest.RecordWithChanges"]},{"name":"optionalToAliasedOptionalWithChanges","type":[null,"int32"]},{"name":"genericRecord","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToOpenAlias","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToClosedAlias","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericRecordToHalfClosedAlias","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"aliasedGenericRecordToAlias","type":{"name":"EvoTest.AliasedHalfClosedGenericRecord","typeArguments":["int32"]}},{"name":"genericRecordToReversed","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"closedGenericRecordToUnion","type":"EvoTest.AliasedClosedGenericRecord"},{"name":"genericRecordToAliasedUnion","type":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}},{"name":"genericUnionToReversed","type":{"name":"EvoTest.GenericUnion","typeArguments":[{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]},"float32"]}},{"name":"genericUnionOfChangedRecord","type":{"name":"EvoTest.GenericUnion","typeArguments":[{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]},"float32"]}},{"name":"genericParentRecord","type":{"name":"EvoTest.GenericParentRecord","typeArguments":["int32"]}},{"name":"genericNestedRecords","type":{"name":"EvoTest.GenericRecord","typeArguments":[{"name":"EvoTest.UnchangedGeneric","typeArguments":["int32"]},{"name":"EvoTest.ChangedGeneric","typeArguments":["string","int32"]}]}},{"name":"genericRecordStream","type":{"stream":{"items":{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]}}}},{"name":"genericParentRecordStream","type":{"stream":{"items":{"name":"EvoTest.GenericParentRecord","typeArguments":["int32"]}}}},{"name":"vectorRecordWithChanges","type":{"vector":{"items":"EvoTest.RecordWithChanges"}}},{"name":"streamedRecordWithChanges","type":{"stream":{"items":"EvoTest.RecordWithChanges"}}},{"name":"addedStringVector","type":{"vector":{"items":"EvoTest.AliasedString"}}},{"name":"addedOptional","type":[null,"EvoTest.RecordWithChanges"]},{"name":"addedMap","type":{"map":{"keys":"string","values":"string"}}},{"name":"addedUnion","type":[null,{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"string","type":"string"}]},{"name":"addedRecordStream","type":{"stream":{"items":"EvoTest.RecordWithChanges"}}},{"name":"addedUnionStream","type":{"stream":{"items":[{"tag":"RecordWithChanges","type":"EvoTest.RecordWithChanges"},{"tag":"RenamedRecord","type":"EvoTest.RenamedRecord"}]}}}]},"types":[{"name":"AliasedClosedGenericRecord","type":{"name":"EvoTest.AliasedHalfClosedGenericRecord","typeArguments":["int32"]}},{"name":"AliasedHalfClosedGenericRecord","typeParameters":["T"],"type":{"name":"EvoTest.GenericRecord","typeArguments":["T","string"]}},{"name":"AliasedLongToString","type":"int64"},{"name":"AliasedRecordWithChanges","type":"EvoTest.RecordWithChanges"},{"name":"AliasedString","type":"string"},{"name":"ChangedGeneric","typeParameters":["Y","Z"],"fields":[{"name":"y","type":"Y"},{"name":"z","type":{"name":"EvoTest.UnchangedGeneric","typeArguments":["Z"]}}]},{"name":"GenericParentRecord","typeParameters":["T"],"fields":[{"name":"record","type":{"name":"EvoTest.GenericRecord","typeArguments":["T","string"]}},{"name":"recordOfUnion","type":{"name":"EvoTest.GenericRecord","typeArguments":[{"name":"EvoTest.GenericUnion","typeArguments":["T","float32"]},"string"]}},{"name":"unionOfRecord","type":{"name":"EvoTest.GenericUnion","typeArguments":[{"name":"EvoTest.GenericRecord","typeArguments":["int32","string"]},"float32"]}}]},{"name":"GenericRecord","typeParameters":["T1","T2"],"fields":[{"name":"removed","type":[null,"bool"]},{"name":"field1","type":"T1"},{"name":"field2","type":"T2"}]},{"name":"GenericUnion","typeParameters":["T1","T2"],"type":[{"tag":"T1","type":"T1"},{"tag":"T2","type":"T2"}]},{"name":"GrowingEnum","base":"uint16","values":[{"symbol":"a","value":0},{"symbol":"b","value":1},{"symbol":"c","value":2},{"symbol":"d","value":3},{"symbol":"e","value":42}]},{"name":"RA","type":"EvoTest.RB"},{"name":"RB","type":"EvoTest.RC"},{"name":"RC","fields":[{"name":"subject","type":"string"}]},{"name":"RLink","type":"EvoTest.RA"},{"name":"RecordWithChanges","fields":[{"name":"intToLong","type":"int32"},{"name":"deprecatedVector","type":{"vector":{"items":"int32"}}},{"name":"floatToDouble","type":"float32"},{"name":"deprecatedArray","type":{"array":{"items":"uint8","dimensions":[{"length":7}]}}},{"name":"optionalLongToString","type":[null,"int64"]},{"name":"deprecatedMap","type":{"map":{"keys":"string","values":{"vector":{"items":"int32"}}}}},{"name":"unchangedRecord","type":"EvoTest.UnchangedRecord"}]},{"name":"RenamedRecord","fields":[{"name":"i","type":"int32"},{"name":"s","type":"string"}]},{"name":"StreamItem","type":"EvoTest.RecordWithChanges"},{"name":"UnchangedGeneric","typeParameters":["T2"],"fields":[{"name":"field","type":"T2"}]},{"name":"UnchangedRecord","fields":[{"name":"name","type":"string"},{"name":"age","type":"int32"},{"name":"meta","type":{"map":{"keys":"string","values":"float64"}}}]}]})"; std::vector ProtocolWithChangesWriterBase::previous_schemas_ = { @@ -373,9 +25,10 @@ std::string ProtocolWithChangesWriterBase::SchemaFromVersion(Version version) { } } + void ProtocolWithChangesWriterBase::WriteInt8ToInt(int8_t const& value) { if (unlikely(state_ != 0)) { - ProtocolWithChangesWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteInt8ToIntImpl(value); @@ -384,7 +37,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToInt(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToLong(int8_t const& value) { if (unlikely(state_ != 1)) { - ProtocolWithChangesWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteInt8ToLongImpl(value); @@ -393,7 +46,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToLong(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToUint(int8_t const& value) { if (unlikely(state_ != 2)) { - ProtocolWithChangesWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteInt8ToUintImpl(value); @@ -402,7 +55,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToUint(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToUlong(int8_t const& value) { if (unlikely(state_ != 3)) { - ProtocolWithChangesWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteInt8ToUlongImpl(value); @@ -411,7 +64,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToUlong(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToFloat(int8_t const& value) { if (unlikely(state_ != 4)) { - ProtocolWithChangesWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } WriteInt8ToFloatImpl(value); @@ -420,7 +73,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToFloat(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteInt8ToDouble(int8_t const& value) { if (unlikely(state_ != 5)) { - ProtocolWithChangesWriterBaseInvalidState(5, false, state_); + InvalidState(5, false); } WriteInt8ToDoubleImpl(value); @@ -429,7 +82,7 @@ void ProtocolWithChangesWriterBase::WriteInt8ToDouble(int8_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToUint(int32_t const& value) { if (unlikely(state_ != 6)) { - ProtocolWithChangesWriterBaseInvalidState(6, false, state_); + InvalidState(6, false); } WriteIntToUintImpl(value); @@ -438,7 +91,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUint(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToLong(int32_t const& value) { if (unlikely(state_ != 7)) { - ProtocolWithChangesWriterBaseInvalidState(7, false, state_); + InvalidState(7, false); } WriteIntToLongImpl(value); @@ -447,7 +100,7 @@ void ProtocolWithChangesWriterBase::WriteIntToLong(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToFloat(int32_t const& value) { if (unlikely(state_ != 8)) { - ProtocolWithChangesWriterBaseInvalidState(8, false, state_); + InvalidState(8, false); } WriteIntToFloatImpl(value); @@ -456,7 +109,7 @@ void ProtocolWithChangesWriterBase::WriteIntToFloat(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteIntToDouble(int32_t const& value) { if (unlikely(state_ != 9)) { - ProtocolWithChangesWriterBaseInvalidState(9, false, state_); + InvalidState(9, false); } WriteIntToDoubleImpl(value); @@ -465,7 +118,7 @@ void ProtocolWithChangesWriterBase::WriteIntToDouble(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToUlong(uint32_t const& value) { if (unlikely(state_ != 10)) { - ProtocolWithChangesWriterBaseInvalidState(10, false, state_); + InvalidState(10, false); } WriteUintToUlongImpl(value); @@ -474,7 +127,7 @@ void ProtocolWithChangesWriterBase::WriteUintToUlong(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToFloat(uint32_t const& value) { if (unlikely(state_ != 11)) { - ProtocolWithChangesWriterBaseInvalidState(11, false, state_); + InvalidState(11, false); } WriteUintToFloatImpl(value); @@ -483,7 +136,7 @@ void ProtocolWithChangesWriterBase::WriteUintToFloat(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToDouble(uint32_t const& value) { if (unlikely(state_ != 12)) { - ProtocolWithChangesWriterBaseInvalidState(12, false, state_); + InvalidState(12, false); } WriteUintToDoubleImpl(value); @@ -492,7 +145,7 @@ void ProtocolWithChangesWriterBase::WriteUintToDouble(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteFloatToDouble(float const& value) { if (unlikely(state_ != 13)) { - ProtocolWithChangesWriterBaseInvalidState(13, false, state_); + InvalidState(13, false); } WriteFloatToDoubleImpl(value); @@ -501,7 +154,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToDouble(float const& value) { void ProtocolWithChangesWriterBase::WriteComplexFloatToComplexDouble(std::complex const& value) { if (unlikely(state_ != 14)) { - ProtocolWithChangesWriterBaseInvalidState(14, false, state_); + InvalidState(14, false); } WriteComplexFloatToComplexDoubleImpl(value); @@ -510,7 +163,7 @@ void ProtocolWithChangesWriterBase::WriteComplexFloatToComplexDouble(std::comple void ProtocolWithChangesWriterBase::WriteIntToString(int32_t const& value) { if (unlikely(state_ != 15)) { - ProtocolWithChangesWriterBaseInvalidState(15, false, state_); + InvalidState(15, false); } WriteIntToStringImpl(value); @@ -519,7 +172,7 @@ void ProtocolWithChangesWriterBase::WriteIntToString(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteUintToString(uint32_t const& value) { if (unlikely(state_ != 16)) { - ProtocolWithChangesWriterBaseInvalidState(16, false, state_); + InvalidState(16, false); } WriteUintToStringImpl(value); @@ -528,7 +181,7 @@ void ProtocolWithChangesWriterBase::WriteUintToString(uint32_t const& value) { void ProtocolWithChangesWriterBase::WriteLongToString(int64_t const& value) { if (unlikely(state_ != 17)) { - ProtocolWithChangesWriterBaseInvalidState(17, false, state_); + InvalidState(17, false); } WriteLongToStringImpl(value); @@ -537,7 +190,7 @@ void ProtocolWithChangesWriterBase::WriteLongToString(int64_t const& value) { void ProtocolWithChangesWriterBase::WriteUlongToString(uint64_t const& value) { if (unlikely(state_ != 18)) { - ProtocolWithChangesWriterBaseInvalidState(18, false, state_); + InvalidState(18, false); } WriteUlongToStringImpl(value); @@ -546,7 +199,7 @@ void ProtocolWithChangesWriterBase::WriteUlongToString(uint64_t const& value) { void ProtocolWithChangesWriterBase::WriteFloatToString(float const& value) { if (unlikely(state_ != 19)) { - ProtocolWithChangesWriterBaseInvalidState(19, false, state_); + InvalidState(19, false); } WriteFloatToStringImpl(value); @@ -555,7 +208,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToString(float const& value) { void ProtocolWithChangesWriterBase::WriteDoubleToString(double const& value) { if (unlikely(state_ != 20)) { - ProtocolWithChangesWriterBaseInvalidState(20, false, state_); + InvalidState(20, false); } WriteDoubleToStringImpl(value); @@ -564,7 +217,7 @@ void ProtocolWithChangesWriterBase::WriteDoubleToString(double const& value) { void ProtocolWithChangesWriterBase::WriteIntToOptional(int32_t const& value) { if (unlikely(state_ != 21)) { - ProtocolWithChangesWriterBaseInvalidState(21, false, state_); + InvalidState(21, false); } WriteIntToOptionalImpl(value); @@ -573,7 +226,7 @@ void ProtocolWithChangesWriterBase::WriteIntToOptional(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteFloatToOptional(float const& value) { if (unlikely(state_ != 22)) { - ProtocolWithChangesWriterBaseInvalidState(22, false, state_); + InvalidState(22, false); } WriteFloatToOptionalImpl(value); @@ -582,7 +235,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToOptional(float const& value) { void ProtocolWithChangesWriterBase::WriteStringToOptional(std::string const& value) { if (unlikely(state_ != 23)) { - ProtocolWithChangesWriterBaseInvalidState(23, false, state_); + InvalidState(23, false); } WriteStringToOptionalImpl(value); @@ -591,7 +244,7 @@ void ProtocolWithChangesWriterBase::WriteStringToOptional(std::string const& val void ProtocolWithChangesWriterBase::WriteIntToUnion(int32_t const& value) { if (unlikely(state_ != 24)) { - ProtocolWithChangesWriterBaseInvalidState(24, false, state_); + InvalidState(24, false); } WriteIntToUnionImpl(value); @@ -600,7 +253,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUnion(int32_t const& value) { void ProtocolWithChangesWriterBase::WriteFloatToUnion(float const& value) { if (unlikely(state_ != 25)) { - ProtocolWithChangesWriterBaseInvalidState(25, false, state_); + InvalidState(25, false); } WriteFloatToUnionImpl(value); @@ -609,7 +262,7 @@ void ProtocolWithChangesWriterBase::WriteFloatToUnion(float const& value) { void ProtocolWithChangesWriterBase::WriteStringToUnion(std::string const& value) { if (unlikely(state_ != 26)) { - ProtocolWithChangesWriterBaseInvalidState(26, false, state_); + InvalidState(26, false); } WriteStringToUnionImpl(value); @@ -618,7 +271,7 @@ void ProtocolWithChangesWriterBase::WriteStringToUnion(std::string const& value) void ProtocolWithChangesWriterBase::WriteOptionalIntToFloat(std::optional const& value) { if (unlikely(state_ != 27)) { - ProtocolWithChangesWriterBaseInvalidState(27, false, state_); + InvalidState(27, false); } WriteOptionalIntToFloatImpl(value); @@ -627,7 +280,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalIntToFloat(std::optional const& value) { if (unlikely(state_ != 28)) { - ProtocolWithChangesWriterBaseInvalidState(28, false, state_); + InvalidState(28, false); } WriteOptionalFloatToStringImpl(value); @@ -636,7 +289,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalFloatToString(std::optional const& value) { if (unlikely(state_ != 33)) { - ProtocolWithChangesWriterBaseInvalidState(33, false, state_); + InvalidState(33, false); } WriteOptionalIntToUnionImpl(value); @@ -681,7 +334,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalIntToUnion(std::optional const& value) { if (unlikely(state_ != 34)) { - ProtocolWithChangesWriterBaseInvalidState(34, false, state_); + InvalidState(34, false); } WriteOptionalRecordToUnionImpl(value); @@ -690,7 +343,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalRecordToUnion(std::optional const& values) { if (unlikely(state_ != 40)) { - ProtocolWithChangesWriterBaseInvalidState(40, false, state_); + InvalidState(40, false); } WriteStreamIntToStringToFloatImpl(values); @@ -751,7 +404,7 @@ void ProtocolWithChangesWriterBase::WriteStreamIntToStringToFloat(std::vector const& value) { if (unlikely(state_ != 41)) { - ProtocolWithChangesWriterBaseInvalidState(41, false, state_); + InvalidState(41, false); } WriteVectorIntToStringToFloatImpl(value); @@ -776,7 +429,7 @@ void ProtocolWithChangesWriterBase::WriteVectorIntToStringToFloat(std::vector const& value) { if (unlikely(state_ != 42)) { - ProtocolWithChangesWriterBaseInvalidState(42, false, state_); + InvalidState(42, false); } WriteIntFloatUnionReorderedImpl(value); @@ -785,7 +438,7 @@ void ProtocolWithChangesWriterBase::WriteIntFloatUnionReordered(std::variant> const& value) { if (unlikely(state_ != 43)) { - ProtocolWithChangesWriterBaseInvalidState(43, false, state_); + InvalidState(43, false); } WriteVectorUnionReorderedImpl(value); @@ -794,7 +447,7 @@ void ProtocolWithChangesWriterBase::WriteVectorUnionReordered(std::vector const& value) { if (unlikely(state_ != 44)) { - ProtocolWithChangesWriterBaseInvalidState(44, false, state_); + InvalidState(44, false); } WriteStreamUnionReorderedImpl(value); @@ -802,7 +455,7 @@ void ProtocolWithChangesWriterBase::WriteStreamUnionReordered(std::variant> const& values) { if (unlikely(state_ != 44)) { - ProtocolWithChangesWriterBaseInvalidState(44, false, state_); + InvalidState(44, false); } WriteStreamUnionReorderedImpl(values); @@ -810,7 +463,7 @@ void ProtocolWithChangesWriterBase::WriteStreamUnionReordered(std::vector const& value) { if (unlikely(state_ != 45)) { - ProtocolWithChangesWriterBaseInvalidState(45, false, state_); + InvalidState(45, false); } WriteIntToUnionStreamImpl(value); @@ -834,7 +487,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUnionStream(std::variant> const& values) { if (unlikely(state_ != 45)) { - ProtocolWithChangesWriterBaseInvalidState(45, false, state_); + InvalidState(45, false); } WriteIntToUnionStreamImpl(values); @@ -842,7 +495,7 @@ void ProtocolWithChangesWriterBase::WriteIntToUnionStream(std::vector const& value) { if (unlikely(state_ != 46)) { - ProtocolWithChangesWriterBaseInvalidState(46, false, state_); + InvalidState(46, false); } WriteUnionStreamTypeChangeImpl(value); @@ -866,7 +519,7 @@ void ProtocolWithChangesWriterBase::WriteUnionStreamTypeChange(std::variant> const& values) { if (unlikely(state_ != 46)) { - ProtocolWithChangesWriterBaseInvalidState(46, false, state_); + InvalidState(46, false); } WriteUnionStreamTypeChangeImpl(values); @@ -874,7 +527,7 @@ void ProtocolWithChangesWriterBase::WriteUnionStreamTypeChange(std::vector const& values) { if (unlikely(state_ != 47)) { - ProtocolWithChangesWriterBaseInvalidState(47, false, state_); + InvalidState(47, false); } WriteStreamOfAliasTypeChangeImpl(values); @@ -906,7 +559,7 @@ void ProtocolWithChangesWriterBase::WriteStreamOfAliasTypeChange(std::vector const& value) { if (unlikely(state_ != 72)) { - ProtocolWithChangesWriterBaseInvalidState(72, false, state_); + InvalidState(72, false); } WriteOptionalRecordWithChangesImpl(value); @@ -1147,7 +800,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalRecordWithChanges(std::optional void ProtocolWithChangesWriterBase::WriteAliasedOptionalRecordWithChanges(std::optional const& value) { if (unlikely(state_ != 73)) { - ProtocolWithChangesWriterBaseInvalidState(73, false, state_); + InvalidState(73, false); } WriteAliasedOptionalRecordWithChangesImpl(value); @@ -1156,7 +809,7 @@ void ProtocolWithChangesWriterBase::WriteAliasedOptionalRecordWithChanges(std::o void ProtocolWithChangesWriterBase::WriteUnionRecordWithChanges(std::variant const& value) { if (unlikely(state_ != 74)) { - ProtocolWithChangesWriterBaseInvalidState(74, false, state_); + InvalidState(74, false); } WriteUnionRecordWithChangesImpl(value); @@ -1165,7 +818,7 @@ void ProtocolWithChangesWriterBase::WriteUnionRecordWithChanges(std::variant const& value) { if (unlikely(state_ != 75)) { - ProtocolWithChangesWriterBaseInvalidState(75, false, state_); + InvalidState(75, false); } WriteUnionWithSameTypesetImpl(value); @@ -1174,7 +827,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithSameTypeset(std::variant const& value) { if (unlikely(state_ != 76)) { - ProtocolWithChangesWriterBaseInvalidState(76, false, state_); + InvalidState(76, false); } WriteUnionWithTypesAddedImpl(value); @@ -1183,7 +836,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithTypesAdded(std::variant const& value) { if (unlikely(state_ != 77)) { - ProtocolWithChangesWriterBaseInvalidState(77, false, state_); + InvalidState(77, false); } WriteUnionWithTypesRemovedImpl(value); @@ -1192,7 +845,7 @@ void ProtocolWithChangesWriterBase::WriteUnionWithTypesRemoved(std::variant const& value) { if (unlikely(state_ != 82)) { - ProtocolWithChangesWriterBaseInvalidState(82, false, state_); + InvalidState(82, false); } WriteUnionToAliasedUnionImpl(value); @@ -1237,7 +890,7 @@ void ProtocolWithChangesWriterBase::WriteUnionToAliasedUnion(std::variant const& value) { if (unlikely(state_ != 83)) { - ProtocolWithChangesWriterBaseInvalidState(83, false, state_); + InvalidState(83, false); } WriteUnionToAliasedUnionWithChangesImpl(value); @@ -1246,7 +899,7 @@ void ProtocolWithChangesWriterBase::WriteUnionToAliasedUnionWithChanges(std::var void ProtocolWithChangesWriterBase::WriteOptionalToAliasedOptional(std::optional const& value) { if (unlikely(state_ != 84)) { - ProtocolWithChangesWriterBaseInvalidState(84, false, state_); + InvalidState(84, false); } WriteOptionalToAliasedOptionalImpl(value); @@ -1255,7 +908,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalToAliasedOptional(std::optional void ProtocolWithChangesWriterBase::WriteOptionalToAliasedOptionalWithChanges(std::optional const& value) { if (unlikely(state_ != 85)) { - ProtocolWithChangesWriterBaseInvalidState(85, false, state_); + InvalidState(85, false); } WriteOptionalToAliasedOptionalWithChangesImpl(value); @@ -1264,7 +917,7 @@ void ProtocolWithChangesWriterBase::WriteOptionalToAliasedOptionalWithChanges(st void ProtocolWithChangesWriterBase::WriteGenericRecord(evo_test::GenericRecord const& value) { if (unlikely(state_ != 86)) { - ProtocolWithChangesWriterBaseInvalidState(86, false, state_); + InvalidState(86, false); } WriteGenericRecordImpl(value); @@ -1273,7 +926,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecord(evo_test::GenericRecord const& value) { if (unlikely(state_ != 87)) { - ProtocolWithChangesWriterBaseInvalidState(87, false, state_); + InvalidState(87, false); } WriteGenericRecordToOpenAliasImpl(value); @@ -1282,7 +935,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToOpenAlias(evo_test::Gene void ProtocolWithChangesWriterBase::WriteGenericRecordToClosedAlias(evo_test::GenericRecord const& value) { if (unlikely(state_ != 88)) { - ProtocolWithChangesWriterBaseInvalidState(88, false, state_); + InvalidState(88, false); } WriteGenericRecordToClosedAliasImpl(value); @@ -1291,7 +944,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToClosedAlias(evo_test::Ge void ProtocolWithChangesWriterBase::WriteGenericRecordToHalfClosedAlias(evo_test::GenericRecord const& value) { if (unlikely(state_ != 89)) { - ProtocolWithChangesWriterBaseInvalidState(89, false, state_); + InvalidState(89, false); } WriteGenericRecordToHalfClosedAliasImpl(value); @@ -1300,7 +953,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToHalfClosedAlias(evo_test void ProtocolWithChangesWriterBase::WriteAliasedGenericRecordToAlias(evo_test::AliasedHalfClosedGenericRecord const& value) { if (unlikely(state_ != 90)) { - ProtocolWithChangesWriterBaseInvalidState(90, false, state_); + InvalidState(90, false); } WriteAliasedGenericRecordToAliasImpl(value); @@ -1309,7 +962,7 @@ void ProtocolWithChangesWriterBase::WriteAliasedGenericRecordToAlias(evo_test::A void ProtocolWithChangesWriterBase::WriteGenericRecordToReversed(evo_test::GenericRecord const& value) { if (unlikely(state_ != 91)) { - ProtocolWithChangesWriterBaseInvalidState(91, false, state_); + InvalidState(91, false); } WriteGenericRecordToReversedImpl(value); @@ -1318,7 +971,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToReversed(evo_test::Gener void ProtocolWithChangesWriterBase::WriteClosedGenericRecordToUnion(evo_test::AliasedClosedGenericRecord const& value) { if (unlikely(state_ != 92)) { - ProtocolWithChangesWriterBaseInvalidState(92, false, state_); + InvalidState(92, false); } WriteClosedGenericRecordToUnionImpl(value); @@ -1327,7 +980,7 @@ void ProtocolWithChangesWriterBase::WriteClosedGenericRecordToUnion(evo_test::Al void ProtocolWithChangesWriterBase::WriteGenericRecordToAliasedUnion(evo_test::GenericRecord const& value) { if (unlikely(state_ != 93)) { - ProtocolWithChangesWriterBaseInvalidState(93, false, state_); + InvalidState(93, false); } WriteGenericRecordToAliasedUnionImpl(value); @@ -1336,7 +989,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordToAliasedUnion(evo_test::G void ProtocolWithChangesWriterBase::WriteGenericUnionToReversed(evo_test::GenericUnion, float> const& value) { if (unlikely(state_ != 94)) { - ProtocolWithChangesWriterBaseInvalidState(94, false, state_); + InvalidState(94, false); } WriteGenericUnionToReversedImpl(value); @@ -1345,7 +998,7 @@ void ProtocolWithChangesWriterBase::WriteGenericUnionToReversed(evo_test::Generi void ProtocolWithChangesWriterBase::WriteGenericUnionOfChangedRecord(evo_test::GenericUnion, float> const& value) { if (unlikely(state_ != 95)) { - ProtocolWithChangesWriterBaseInvalidState(95, false, state_); + InvalidState(95, false); } WriteGenericUnionOfChangedRecordImpl(value); @@ -1354,7 +1007,7 @@ void ProtocolWithChangesWriterBase::WriteGenericUnionOfChangedRecord(evo_test::G void ProtocolWithChangesWriterBase::WriteGenericParentRecord(evo_test::GenericParentRecord const& value) { if (unlikely(state_ != 96)) { - ProtocolWithChangesWriterBaseInvalidState(96, false, state_); + InvalidState(96, false); } WriteGenericParentRecordImpl(value); @@ -1363,7 +1016,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecord(evo_test::GenericPa void ProtocolWithChangesWriterBase::WriteGenericNestedRecords(evo_test::GenericRecord, evo_test::ChangedGeneric> const& value) { if (unlikely(state_ != 97)) { - ProtocolWithChangesWriterBaseInvalidState(97, false, state_); + InvalidState(97, false); } WriteGenericNestedRecordsImpl(value); @@ -1372,7 +1025,7 @@ void ProtocolWithChangesWriterBase::WriteGenericNestedRecords(evo_test::GenericR void ProtocolWithChangesWriterBase::WriteGenericRecordStream(evo_test::GenericRecord const& value) { if (unlikely(state_ != 98)) { - ProtocolWithChangesWriterBaseInvalidState(98, false, state_); + InvalidState(98, false); } WriteGenericRecordStreamImpl(value); @@ -1380,7 +1033,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordStream(evo_test::GenericRe void ProtocolWithChangesWriterBase::WriteGenericRecordStream(std::vector> const& values) { if (unlikely(state_ != 98)) { - ProtocolWithChangesWriterBaseInvalidState(98, false, state_); + InvalidState(98, false); } WriteGenericRecordStreamImpl(values); @@ -1388,7 +1041,7 @@ void ProtocolWithChangesWriterBase::WriteGenericRecordStream(std::vector const& value) { if (unlikely(state_ != 99)) { - ProtocolWithChangesWriterBaseInvalidState(99, false, state_); + InvalidState(99, false); } WriteGenericParentRecordStreamImpl(value); @@ -1412,7 +1065,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(evo_test::Gen void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(std::vector> const& values) { if (unlikely(state_ != 99)) { - ProtocolWithChangesWriterBaseInvalidState(99, false, state_); + InvalidState(99, false); } WriteGenericParentRecordStreamImpl(values); @@ -1420,7 +1073,7 @@ void ProtocolWithChangesWriterBase::WriteGenericParentRecordStream(std::vector const& value) { if (unlikely(state_ != 100)) { - ProtocolWithChangesWriterBaseInvalidState(100, false, state_); + InvalidState(100, false); } WriteVectorRecordWithChangesImpl(value); @@ -1445,7 +1098,7 @@ void ProtocolWithChangesWriterBase::WriteVectorRecordWithChanges(std::vector const& values) { if (unlikely(state_ != 101)) { - ProtocolWithChangesWriterBaseInvalidState(101, false, state_); + InvalidState(101, false); } WriteStreamedRecordWithChangesImpl(values); @@ -1461,7 +1114,7 @@ void ProtocolWithChangesWriterBase::WriteStreamedRecordWithChanges(std::vector const& value) { if (unlikely(state_ != 102)) { - ProtocolWithChangesWriterBaseInvalidState(102, false, state_); + InvalidState(102, false); } WriteAddedStringVectorImpl(value); @@ -1486,7 +1139,7 @@ void ProtocolWithChangesWriterBase::WriteAddedStringVector(std::vector const& value) { if (unlikely(state_ != 103)) { - ProtocolWithChangesWriterBaseInvalidState(103, false, state_); + InvalidState(103, false); } WriteAddedOptionalImpl(value); @@ -1495,7 +1148,7 @@ void ProtocolWithChangesWriterBase::WriteAddedOptional(std::optional const& value) { if (unlikely(state_ != 104)) { - ProtocolWithChangesWriterBaseInvalidState(104, false, state_); + InvalidState(104, false); } WriteAddedMapImpl(value); @@ -1504,7 +1157,7 @@ void ProtocolWithChangesWriterBase::WriteAddedMap(std::unordered_map const& value) { if (unlikely(state_ != 105)) { - ProtocolWithChangesWriterBaseInvalidState(105, false, state_); + InvalidState(105, false); } WriteAddedUnionImpl(value); @@ -1513,7 +1166,7 @@ void ProtocolWithChangesWriterBase::WriteAddedUnion(std::variant const& values) { if (unlikely(state_ != 106)) { - ProtocolWithChangesWriterBaseInvalidState(106, false, state_); + InvalidState(106, false); } WriteAddedRecordStreamImpl(values); @@ -1529,7 +1182,7 @@ void ProtocolWithChangesWriterBase::WriteAddedRecordStream(std::vector const& value) { if (unlikely(state_ != 107)) { - ProtocolWithChangesWriterBaseInvalidState(107, false, state_); + InvalidState(107, false); } WriteAddedUnionStreamImpl(value); @@ -1553,7 +1206,7 @@ void ProtocolWithChangesWriterBase::WriteAddedUnionStream(std::variant> const& values) { if (unlikely(state_ != 107)) { - ProtocolWithChangesWriterBaseInvalidState(107, false, state_); + InvalidState(107, false); } WriteAddedUnionStreamImpl(values); @@ -1561,7 +1214,7 @@ void ProtocolWithChangesWriterBase::WriteAddedUnionStream(std::vector& value) { if (unlikely(state_ != 28)) { - ProtocolWithChangesReaderBaseInvalidState(28, state_); + InvalidState(28); } ReadComplexFloatToComplexDoubleImpl(value); @@ -1736,7 +1617,7 @@ void ProtocolWithChangesReaderBase::ReadComplexFloatToComplexDouble(std::complex void ProtocolWithChangesReaderBase::ReadIntToString(int32_t& value) { if (unlikely(state_ != 30)) { - ProtocolWithChangesReaderBaseInvalidState(30, state_); + InvalidState(30); } ReadIntToStringImpl(value); @@ -1745,7 +1626,7 @@ void ProtocolWithChangesReaderBase::ReadIntToString(int32_t& value) { void ProtocolWithChangesReaderBase::ReadUintToString(uint32_t& value) { if (unlikely(state_ != 32)) { - ProtocolWithChangesReaderBaseInvalidState(32, state_); + InvalidState(32); } ReadUintToStringImpl(value); @@ -1754,7 +1635,7 @@ void ProtocolWithChangesReaderBase::ReadUintToString(uint32_t& value) { void ProtocolWithChangesReaderBase::ReadLongToString(int64_t& value) { if (unlikely(state_ != 34)) { - ProtocolWithChangesReaderBaseInvalidState(34, state_); + InvalidState(34); } ReadLongToStringImpl(value); @@ -1763,7 +1644,7 @@ void ProtocolWithChangesReaderBase::ReadLongToString(int64_t& value) { void ProtocolWithChangesReaderBase::ReadUlongToString(uint64_t& value) { if (unlikely(state_ != 36)) { - ProtocolWithChangesReaderBaseInvalidState(36, state_); + InvalidState(36); } ReadUlongToStringImpl(value); @@ -1772,7 +1653,7 @@ void ProtocolWithChangesReaderBase::ReadUlongToString(uint64_t& value) { void ProtocolWithChangesReaderBase::ReadFloatToString(float& value) { if (unlikely(state_ != 38)) { - ProtocolWithChangesReaderBaseInvalidState(38, state_); + InvalidState(38); } ReadFloatToStringImpl(value); @@ -1781,7 +1662,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToString(float& value) { void ProtocolWithChangesReaderBase::ReadDoubleToString(double& value) { if (unlikely(state_ != 40)) { - ProtocolWithChangesReaderBaseInvalidState(40, state_); + InvalidState(40); } ReadDoubleToStringImpl(value); @@ -1790,7 +1671,7 @@ void ProtocolWithChangesReaderBase::ReadDoubleToString(double& value) { void ProtocolWithChangesReaderBase::ReadIntToOptional(int32_t& value) { if (unlikely(state_ != 42)) { - ProtocolWithChangesReaderBaseInvalidState(42, state_); + InvalidState(42); } ReadIntToOptionalImpl(value); @@ -1799,7 +1680,7 @@ void ProtocolWithChangesReaderBase::ReadIntToOptional(int32_t& value) { void ProtocolWithChangesReaderBase::ReadFloatToOptional(float& value) { if (unlikely(state_ != 44)) { - ProtocolWithChangesReaderBaseInvalidState(44, state_); + InvalidState(44); } ReadFloatToOptionalImpl(value); @@ -1808,7 +1689,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToOptional(float& value) { void ProtocolWithChangesReaderBase::ReadStringToOptional(std::string& value) { if (unlikely(state_ != 46)) { - ProtocolWithChangesReaderBaseInvalidState(46, state_); + InvalidState(46); } ReadStringToOptionalImpl(value); @@ -1817,7 +1698,7 @@ void ProtocolWithChangesReaderBase::ReadStringToOptional(std::string& value) { void ProtocolWithChangesReaderBase::ReadIntToUnion(int32_t& value) { if (unlikely(state_ != 48)) { - ProtocolWithChangesReaderBaseInvalidState(48, state_); + InvalidState(48); } ReadIntToUnionImpl(value); @@ -1826,7 +1707,7 @@ void ProtocolWithChangesReaderBase::ReadIntToUnion(int32_t& value) { void ProtocolWithChangesReaderBase::ReadFloatToUnion(float& value) { if (unlikely(state_ != 50)) { - ProtocolWithChangesReaderBaseInvalidState(50, state_); + InvalidState(50); } ReadFloatToUnionImpl(value); @@ -1835,7 +1716,7 @@ void ProtocolWithChangesReaderBase::ReadFloatToUnion(float& value) { void ProtocolWithChangesReaderBase::ReadStringToUnion(std::string& value) { if (unlikely(state_ != 52)) { - ProtocolWithChangesReaderBaseInvalidState(52, state_); + InvalidState(52); } ReadStringToUnionImpl(value); @@ -1844,7 +1725,7 @@ void ProtocolWithChangesReaderBase::ReadStringToUnion(std::string& value) { void ProtocolWithChangesReaderBase::ReadOptionalIntToFloat(std::optional& value) { if (unlikely(state_ != 54)) { - ProtocolWithChangesReaderBaseInvalidState(54, state_); + InvalidState(54); } ReadOptionalIntToFloatImpl(value); @@ -1853,7 +1734,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalIntToFloat(std::optional& value) { if (unlikely(state_ != 56)) { - ProtocolWithChangesReaderBaseInvalidState(56, state_); + InvalidState(56); } ReadOptionalFloatToStringImpl(value); @@ -1862,7 +1743,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalFloatToString(std::optional& value) { if (unlikely(state_ != 66)) { - ProtocolWithChangesReaderBaseInvalidState(66, state_); + InvalidState(66); } ReadOptionalIntToUnionImpl(value); @@ -1907,7 +1788,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalIntToUnion(std::optional& value) { if (unlikely(state_ != 68)) { - ProtocolWithChangesReaderBaseInvalidState(68, state_); + InvalidState(68); } ReadOptionalRecordToUnionImpl(value); @@ -1916,7 +1797,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalRecordToUnion(std::optional& value) { if (unlikely(state_ != 84)) { - ProtocolWithChangesReaderBaseInvalidState(84, state_); + InvalidState(84); } ReadIntFloatUnionReorderedImpl(value); @@ -2037,7 +1918,7 @@ void ProtocolWithChangesReaderBase::ReadIntFloatUnionReordered(std::variant>& value) { if (unlikely(state_ != 86)) { - ProtocolWithChangesReaderBaseInvalidState(86, state_); + InvalidState(86); } ReadVectorUnionReorderedImpl(value); @@ -2050,7 +1931,7 @@ bool ProtocolWithChangesReaderBase::ReadStreamUnionReordered(std::variant& value) { if (unlikely(state_ != 144)) { - ProtocolWithChangesReaderBaseInvalidState(144, state_); + InvalidState(144); } ReadOptionalRecordWithChangesImpl(value); @@ -2515,7 +2396,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalRecordWithChanges(std::optional< void ProtocolWithChangesReaderBase::ReadAliasedOptionalRecordWithChanges(std::optional& value) { if (unlikely(state_ != 146)) { - ProtocolWithChangesReaderBaseInvalidState(146, state_); + InvalidState(146); } ReadAliasedOptionalRecordWithChangesImpl(value); @@ -2524,7 +2405,7 @@ void ProtocolWithChangesReaderBase::ReadAliasedOptionalRecordWithChanges(std::op void ProtocolWithChangesReaderBase::ReadUnionRecordWithChanges(std::variant& value) { if (unlikely(state_ != 148)) { - ProtocolWithChangesReaderBaseInvalidState(148, state_); + InvalidState(148); } ReadUnionRecordWithChangesImpl(value); @@ -2533,7 +2414,7 @@ void ProtocolWithChangesReaderBase::ReadUnionRecordWithChanges(std::variant& value) { if (unlikely(state_ != 150)) { - ProtocolWithChangesReaderBaseInvalidState(150, state_); + InvalidState(150); } ReadUnionWithSameTypesetImpl(value); @@ -2542,7 +2423,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithSameTypeset(std::variant& value) { if (unlikely(state_ != 152)) { - ProtocolWithChangesReaderBaseInvalidState(152, state_); + InvalidState(152); } ReadUnionWithTypesAddedImpl(value); @@ -2551,7 +2432,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithTypesAdded(std::variant& value) { if (unlikely(state_ != 154)) { - ProtocolWithChangesReaderBaseInvalidState(154, state_); + InvalidState(154); } ReadUnionWithTypesRemovedImpl(value); @@ -2560,7 +2441,7 @@ void ProtocolWithChangesReaderBase::ReadUnionWithTypesRemoved(std::variant& value) { if (unlikely(state_ != 164)) { - ProtocolWithChangesReaderBaseInvalidState(164, state_); + InvalidState(164); } ReadUnionToAliasedUnionImpl(value); @@ -2605,7 +2486,7 @@ void ProtocolWithChangesReaderBase::ReadUnionToAliasedUnion(std::variant& value) { if (unlikely(state_ != 166)) { - ProtocolWithChangesReaderBaseInvalidState(166, state_); + InvalidState(166); } ReadUnionToAliasedUnionWithChangesImpl(value); @@ -2614,7 +2495,7 @@ void ProtocolWithChangesReaderBase::ReadUnionToAliasedUnionWithChanges(std::vari void ProtocolWithChangesReaderBase::ReadOptionalToAliasedOptional(std::optional& value) { if (unlikely(state_ != 168)) { - ProtocolWithChangesReaderBaseInvalidState(168, state_); + InvalidState(168); } ReadOptionalToAliasedOptionalImpl(value); @@ -2623,7 +2504,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalToAliasedOptional(std::optional< void ProtocolWithChangesReaderBase::ReadOptionalToAliasedOptionalWithChanges(std::optional& value) { if (unlikely(state_ != 170)) { - ProtocolWithChangesReaderBaseInvalidState(170, state_); + InvalidState(170); } ReadOptionalToAliasedOptionalWithChangesImpl(value); @@ -2632,7 +2513,7 @@ void ProtocolWithChangesReaderBase::ReadOptionalToAliasedOptionalWithChanges(std void ProtocolWithChangesReaderBase::ReadGenericRecord(evo_test::GenericRecord& value) { if (unlikely(state_ != 172)) { - ProtocolWithChangesReaderBaseInvalidState(172, state_); + InvalidState(172); } ReadGenericRecordImpl(value); @@ -2641,7 +2522,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecord(evo_test::GenericRecord& value) { if (unlikely(state_ != 174)) { - ProtocolWithChangesReaderBaseInvalidState(174, state_); + InvalidState(174); } ReadGenericRecordToOpenAliasImpl(value); @@ -2650,7 +2531,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToOpenAlias(evo_test::Gener void ProtocolWithChangesReaderBase::ReadGenericRecordToClosedAlias(evo_test::GenericRecord& value) { if (unlikely(state_ != 176)) { - ProtocolWithChangesReaderBaseInvalidState(176, state_); + InvalidState(176); } ReadGenericRecordToClosedAliasImpl(value); @@ -2659,7 +2540,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToClosedAlias(evo_test::Gen void ProtocolWithChangesReaderBase::ReadGenericRecordToHalfClosedAlias(evo_test::GenericRecord& value) { if (unlikely(state_ != 178)) { - ProtocolWithChangesReaderBaseInvalidState(178, state_); + InvalidState(178); } ReadGenericRecordToHalfClosedAliasImpl(value); @@ -2668,7 +2549,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToHalfClosedAlias(evo_test: void ProtocolWithChangesReaderBase::ReadAliasedGenericRecordToAlias(evo_test::AliasedHalfClosedGenericRecord& value) { if (unlikely(state_ != 180)) { - ProtocolWithChangesReaderBaseInvalidState(180, state_); + InvalidState(180); } ReadAliasedGenericRecordToAliasImpl(value); @@ -2677,7 +2558,7 @@ void ProtocolWithChangesReaderBase::ReadAliasedGenericRecordToAlias(evo_test::Al void ProtocolWithChangesReaderBase::ReadGenericRecordToReversed(evo_test::GenericRecord& value) { if (unlikely(state_ != 182)) { - ProtocolWithChangesReaderBaseInvalidState(182, state_); + InvalidState(182); } ReadGenericRecordToReversedImpl(value); @@ -2686,7 +2567,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToReversed(evo_test::Generi void ProtocolWithChangesReaderBase::ReadClosedGenericRecordToUnion(evo_test::AliasedClosedGenericRecord& value) { if (unlikely(state_ != 184)) { - ProtocolWithChangesReaderBaseInvalidState(184, state_); + InvalidState(184); } ReadClosedGenericRecordToUnionImpl(value); @@ -2695,7 +2576,7 @@ void ProtocolWithChangesReaderBase::ReadClosedGenericRecordToUnion(evo_test::Ali void ProtocolWithChangesReaderBase::ReadGenericRecordToAliasedUnion(evo_test::GenericRecord& value) { if (unlikely(state_ != 186)) { - ProtocolWithChangesReaderBaseInvalidState(186, state_); + InvalidState(186); } ReadGenericRecordToAliasedUnionImpl(value); @@ -2704,7 +2585,7 @@ void ProtocolWithChangesReaderBase::ReadGenericRecordToAliasedUnion(evo_test::Ge void ProtocolWithChangesReaderBase::ReadGenericUnionToReversed(evo_test::GenericUnion, float>& value) { if (unlikely(state_ != 188)) { - ProtocolWithChangesReaderBaseInvalidState(188, state_); + InvalidState(188); } ReadGenericUnionToReversedImpl(value); @@ -2713,7 +2594,7 @@ void ProtocolWithChangesReaderBase::ReadGenericUnionToReversed(evo_test::Generic void ProtocolWithChangesReaderBase::ReadGenericUnionOfChangedRecord(evo_test::GenericUnion, float>& value) { if (unlikely(state_ != 190)) { - ProtocolWithChangesReaderBaseInvalidState(190, state_); + InvalidState(190); } ReadGenericUnionOfChangedRecordImpl(value); @@ -2722,7 +2603,7 @@ void ProtocolWithChangesReaderBase::ReadGenericUnionOfChangedRecord(evo_test::Ge void ProtocolWithChangesReaderBase::ReadGenericParentRecord(evo_test::GenericParentRecord& value) { if (unlikely(state_ != 192)) { - ProtocolWithChangesReaderBaseInvalidState(192, state_); + InvalidState(192); } ReadGenericParentRecordImpl(value); @@ -2731,7 +2612,7 @@ void ProtocolWithChangesReaderBase::ReadGenericParentRecord(evo_test::GenericPar void ProtocolWithChangesReaderBase::ReadGenericNestedRecords(evo_test::GenericRecord, evo_test::ChangedGeneric>& value) { if (unlikely(state_ != 194)) { - ProtocolWithChangesReaderBaseInvalidState(194, state_); + InvalidState(194); } ReadGenericNestedRecordsImpl(value); @@ -2744,7 +2625,7 @@ bool ProtocolWithChangesReaderBase::ReadGenericRecordStream(evo_test::GenericRec state_ = 198; return false; } - ProtocolWithChangesReaderBaseInvalidState(196, state_); + InvalidState(196); } bool result = ReadGenericRecordStreamImpl(value); @@ -2764,7 +2645,7 @@ bool ProtocolWithChangesReaderBase::ReadGenericRecordStream(std::vector& value) { if (unlikely(state_ != 206)) { - ProtocolWithChangesReaderBaseInvalidState(206, state_); + InvalidState(206); } ReadAddedOptionalImpl(value); @@ -2945,7 +2826,7 @@ void ProtocolWithChangesReaderBase::ReadAddedOptional(std::optional& value) { if (unlikely(state_ != 208)) { - ProtocolWithChangesReaderBaseInvalidState(208, state_); + InvalidState(208); } ReadAddedMapImpl(value); @@ -2954,7 +2835,7 @@ void ProtocolWithChangesReaderBase::ReadAddedMap(std::unordered_map& value) { if (unlikely(state_ != 210)) { - ProtocolWithChangesReaderBaseInvalidState(210, state_); + InvalidState(210); } ReadAddedUnionImpl(value); @@ -2967,7 +2848,7 @@ bool ProtocolWithChangesReaderBase::ReadAddedRecordStream(evo_test::RecordWithCh state_ = 214; return false; } - ProtocolWithChangesReaderBaseInvalidState(212, state_); + InvalidState(212); } bool result = ReadAddedRecordStreamImpl(value); @@ -2987,7 +2868,7 @@ bool ProtocolWithChangesReaderBase::ReadAddedRecordStream(std::vector std::string { + switch (i/2) { + case 0: return "ReadInt8ToInt()"; + case 1: return "ReadInt8ToLong()"; + case 2: return "ReadInt8ToUint()"; + case 3: return "ReadInt8ToUlong()"; + case 4: return "ReadInt8ToFloat()"; + case 5: return "ReadInt8ToDouble()"; + case 6: return "ReadIntToUint()"; + case 7: return "ReadIntToLong()"; + case 8: return "ReadIntToFloat()"; + case 9: return "ReadIntToDouble()"; + case 10: return "ReadUintToUlong()"; + case 11: return "ReadUintToFloat()"; + case 12: return "ReadUintToDouble()"; + case 13: return "ReadFloatToDouble()"; + case 14: return "ReadComplexFloatToComplexDouble()"; + case 15: return "ReadIntToString()"; + case 16: return "ReadUintToString()"; + case 17: return "ReadLongToString()"; + case 18: return "ReadUlongToString()"; + case 19: return "ReadFloatToString()"; + case 20: return "ReadDoubleToString()"; + case 21: return "ReadIntToOptional()"; + case 22: return "ReadFloatToOptional()"; + case 23: return "ReadStringToOptional()"; + case 24: return "ReadIntToUnion()"; + case 25: return "ReadFloatToUnion()"; + case 26: return "ReadStringToUnion()"; + case 27: return "ReadOptionalIntToFloat()"; + case 28: return "ReadOptionalFloatToString()"; + case 29: return "ReadAliasedLongToString()"; + case 30: return "ReadStringToAliasedString()"; + case 31: return "ReadStringToAliasedInt()"; + case 32: return "ReadEnumToAliasedEnum()"; + case 33: return "ReadOptionalIntToUnion()"; + case 34: return "ReadOptionalRecordToUnion()"; + case 35: return "ReadRecordWithChanges()"; + case 36: return "ReadAliasedRecordWithChanges()"; + case 37: return "ReadRecordToRenamedRecord()"; + case 38: return "ReadRecordToAliasedRecord()"; + case 39: return "ReadRecordToAliasedAlias()"; + case 40: return "ReadStreamIntToStringToFloat()"; + case 41: return "ReadVectorIntToStringToFloat()"; + case 42: return "ReadIntFloatUnionReordered()"; + case 43: return "ReadVectorUnionReordered()"; + case 44: return "ReadStreamUnionReordered()"; + case 45: return "ReadIntToUnionStream()"; + case 46: return "ReadUnionStreamTypeChange()"; + case 47: return "ReadStreamOfAliasTypeChange()"; + case 48: return "ReadRlink()"; + case 49: return "ReadRlinkRX()"; + case 50: return "ReadRlinkRY()"; + case 51: return "ReadRlinkRZ()"; + case 52: return "ReadRaRLink()"; + case 53: return "ReadRaRX()"; + case 54: return "ReadRaRY()"; + case 55: return "ReadRaRZ()"; + case 56: return "ReadRbRLink()"; + case 57: return "ReadRbRX()"; + case 58: return "ReadRbRY()"; + case 59: return "ReadRbRZ()"; + case 60: return "ReadRcRLink()"; + case 61: return "ReadRcRX()"; + case 62: return "ReadRcRY()"; + case 63: return "ReadRcRZ()"; + case 64: return "ReadRlinkRNew()"; + case 65: return "ReadRaRNew()"; + case 66: return "ReadRbRNew()"; + case 67: return "ReadRcRNew()"; + case 68: return "ReadRlinkRUnion()"; + case 69: return "ReadRaRUnion()"; + case 70: return "ReadRbRUnion()"; + case 71: return "ReadRcRUnion()"; + case 72: return "ReadOptionalRecordWithChanges()"; + case 73: return "ReadAliasedOptionalRecordWithChanges()"; + case 74: return "ReadUnionRecordWithChanges()"; + case 75: return "ReadUnionWithSameTypeset()"; + case 76: return "ReadUnionWithTypesAdded()"; + case 77: return "ReadUnionWithTypesRemoved()"; + case 78: return "ReadRecordToOptional()"; + case 79: return "ReadRecordToAliasedOptional()"; + case 80: return "ReadRecordToUnion()"; + case 81: return "ReadRecordToAliasedUnion()"; + case 82: return "ReadUnionToAliasedUnion()"; + case 83: return "ReadUnionToAliasedUnionWithChanges()"; + case 84: return "ReadOptionalToAliasedOptional()"; + case 85: return "ReadOptionalToAliasedOptionalWithChanges()"; + case 86: return "ReadGenericRecord()"; + case 87: return "ReadGenericRecordToOpenAlias()"; + case 88: return "ReadGenericRecordToClosedAlias()"; + case 89: return "ReadGenericRecordToHalfClosedAlias()"; + case 90: return "ReadAliasedGenericRecordToAlias()"; + case 91: return "ReadGenericRecordToReversed()"; + case 92: return "ReadClosedGenericRecordToUnion()"; + case 93: return "ReadGenericRecordToAliasedUnion()"; + case 94: return "ReadGenericUnionToReversed()"; + case 95: return "ReadGenericUnionOfChangedRecord()"; + case 96: return "ReadGenericParentRecord()"; + case 97: return "ReadGenericNestedRecords()"; + case 98: return "ReadGenericRecordStream()"; + case 99: return "ReadGenericParentRecordStream()"; + case 100: return "ReadVectorRecordWithChanges()"; + case 101: return "ReadStreamedRecordWithChanges()"; + case 102: return "ReadAddedStringVector()"; + case 103: return "ReadAddedOptional()"; + case 104: return "ReadAddedMap()"; + case 105: return "ReadAddedUnion()"; + case 106: return "ReadAddedRecordStream()"; + case 107: return "ReadAddedUnionStream()"; + case 108: return "Close()"; + default: return ""; + } + }; + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamIntToStringToFloat(float& value, size_t idx) { + return ReadStreamIntToStringToFloatImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamIntToStringToFloat(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamIntToStringToFloatImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamIntToStringToFloat() { + return CountStreamIntToStringToFloatImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamUnionReordered(std::variant& value, size_t idx) { + return ReadStreamUnionReorderedImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamUnionReordered(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamUnionReorderedImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamUnionReordered() { + return CountStreamUnionReorderedImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadIntToUnionStream(std::variant& value, size_t idx) { + return ReadIntToUnionStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadIntToUnionStream(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadIntToUnionStreamImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountIntToUnionStream() { + return CountIntToUnionStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadUnionStreamTypeChange(std::variant& value, size_t idx) { + return ReadUnionStreamTypeChangeImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadUnionStreamTypeChange(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadUnionStreamTypeChangeImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountUnionStreamTypeChange() { + return CountUnionStreamTypeChangeImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamOfAliasTypeChange(evo_test::StreamItem& value, size_t idx) { + return ReadStreamOfAliasTypeChangeImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamOfAliasTypeChange(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamOfAliasTypeChangeImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamOfAliasTypeChange() { + return CountStreamOfAliasTypeChangeImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericRecordStream(evo_test::GenericRecord& value, size_t idx) { + return ReadGenericRecordStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericRecordStream(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadGenericRecordStreamImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountGenericRecordStream() { + return CountGenericRecordStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericParentRecordStream(evo_test::GenericParentRecord& value, size_t idx) { + return ReadGenericParentRecordStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadGenericParentRecordStream(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadGenericParentRecordStreamImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountGenericParentRecordStream() { + return CountGenericParentRecordStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamedRecordWithChanges(evo_test::RecordWithChanges& value, size_t idx) { + return ReadStreamedRecordWithChangesImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadStreamedRecordWithChanges(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamedRecordWithChangesImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountStreamedRecordWithChanges() { + return CountStreamedRecordWithChangesImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadAddedRecordStream(evo_test::RecordWithChanges& value, size_t idx) { + return ReadAddedRecordStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadAddedRecordStream(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadAddedRecordStreamImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountAddedRecordStream() { + return CountAddedRecordStreamImpl(); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadAddedUnionStream(std::variant& value, size_t idx) { + return ReadAddedUnionStreamImpl(value, idx); +} + +bool ProtocolWithChangesIndexedReaderBase::ReadAddedUnionStream(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadAddedUnionStreamImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithChangesIndexedReaderBase::CountAddedUnionStream() { + return CountAddedUnionStreamImpl(); +} + +void ProtocolWithChangesIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; +} + } // namespace evo_test diff --git a/cpp/evolution/v2/generated/protocols.h b/cpp/evolution/v2/generated/protocols.h index 8af2bca..3817cce 100644 --- a/cpp/evolution/v2/generated/protocols.h +++ b/cpp/evolution/v2/generated/protocols.h @@ -565,9 +565,11 @@ class ProtocolWithChangesWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ProtocolWithChangesReaderBase; + friend class ProtocolWithChangesIndexedReaderBase; }; // Abstract reader for the ProtocolWithChanges protocol. @@ -1064,6 +1066,99 @@ class ProtocolWithChangesReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; + +// Abstract Indexed reader for the ProtocolWithChanges protocol. +class ProtocolWithChangesIndexedReaderBase : public ProtocolWithChangesReaderBase { + public: + // Stream and Vector type changes + using ProtocolWithChangesReaderBase::ReadStreamIntToStringToFloat; + [[nodiscard]] bool ReadStreamIntToStringToFloat(float& value, size_t idx); + [[nodiscard]] bool ReadStreamIntToStringToFloat(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamIntToStringToFloat(); + + using ProtocolWithChangesReaderBase::ReadStreamUnionReordered; + [[nodiscard]] bool ReadStreamUnionReordered(std::variant& value, size_t idx); + [[nodiscard]] bool ReadStreamUnionReordered(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountStreamUnionReordered(); + + using ProtocolWithChangesReaderBase::ReadIntToUnionStream; + [[nodiscard]] bool ReadIntToUnionStream(std::variant& value, size_t idx); + [[nodiscard]] bool ReadIntToUnionStream(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountIntToUnionStream(); + + using ProtocolWithChangesReaderBase::ReadUnionStreamTypeChange; + [[nodiscard]] bool ReadUnionStreamTypeChange(std::variant& value, size_t idx); + [[nodiscard]] bool ReadUnionStreamTypeChange(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountUnionStreamTypeChange(); + + using ProtocolWithChangesReaderBase::ReadStreamOfAliasTypeChange; + [[nodiscard]] bool ReadStreamOfAliasTypeChange(evo_test::StreamItem& value, size_t idx); + [[nodiscard]] bool ReadStreamOfAliasTypeChange(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamOfAliasTypeChange(); + + using ProtocolWithChangesReaderBase::ReadGenericRecordStream; + [[nodiscard]] bool ReadGenericRecordStream(evo_test::GenericRecord& value, size_t idx); + [[nodiscard]] bool ReadGenericRecordStream(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountGenericRecordStream(); + + using ProtocolWithChangesReaderBase::ReadGenericParentRecordStream; + [[nodiscard]] bool ReadGenericParentRecordStream(evo_test::GenericParentRecord& value, size_t idx); + [[nodiscard]] bool ReadGenericParentRecordStream(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountGenericParentRecordStream(); + + using ProtocolWithChangesReaderBase::ReadStreamedRecordWithChanges; + [[nodiscard]] bool ReadStreamedRecordWithChanges(evo_test::RecordWithChanges& value, size_t idx); + [[nodiscard]] bool ReadStreamedRecordWithChanges(std::vector& values, size_t idx); + [[nodiscard]] size_t CountStreamedRecordWithChanges(); + + using ProtocolWithChangesReaderBase::ReadAddedRecordStream; + [[nodiscard]] bool ReadAddedRecordStream(evo_test::RecordWithChanges& value, size_t idx); + [[nodiscard]] bool ReadAddedRecordStream(std::vector& values, size_t idx); + [[nodiscard]] size_t CountAddedRecordStream(); + + using ProtocolWithChangesReaderBase::ReadAddedUnionStream; + [[nodiscard]] bool ReadAddedUnionStream(std::variant& value, size_t idx); + [[nodiscard]] bool ReadAddedUnionStream(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountAddedUnionStream(); + + virtual ~ProtocolWithChangesIndexedReaderBase() = default; + + protected: + virtual bool ReadStreamIntToStringToFloatImpl(float& value, size_t idx) = 0; + virtual bool ReadStreamIntToStringToFloatImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamIntToStringToFloatImpl() = 0; + virtual bool ReadStreamUnionReorderedImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadStreamUnionReorderedImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountStreamUnionReorderedImpl() = 0; + virtual bool ReadIntToUnionStreamImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadIntToUnionStreamImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountIntToUnionStreamImpl() = 0; + virtual bool ReadUnionStreamTypeChangeImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadUnionStreamTypeChangeImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountUnionStreamTypeChangeImpl() = 0; + virtual bool ReadStreamOfAliasTypeChangeImpl(evo_test::StreamItem& value, size_t idx) = 0; + virtual bool ReadStreamOfAliasTypeChangeImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamOfAliasTypeChangeImpl() = 0; + virtual bool ReadGenericRecordStreamImpl(evo_test::GenericRecord& value, size_t idx) = 0; + virtual bool ReadGenericRecordStreamImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountGenericRecordStreamImpl() = 0; + virtual bool ReadGenericParentRecordStreamImpl(evo_test::GenericParentRecord& value, size_t idx) = 0; + virtual bool ReadGenericParentRecordStreamImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountGenericParentRecordStreamImpl() = 0; + virtual bool ReadStreamedRecordWithChangesImpl(evo_test::RecordWithChanges& value, size_t idx) = 0; + virtual bool ReadStreamedRecordWithChangesImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountStreamedRecordWithChangesImpl() = 0; + virtual bool ReadAddedRecordStreamImpl(evo_test::RecordWithChanges& value, size_t idx) = 0; + virtual bool ReadAddedRecordStreamImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountAddedRecordStreamImpl() = 0; + virtual bool ReadAddedUnionStreamImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadAddedUnionStreamImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountAddedUnionStreamImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; } // namespace evo_test diff --git a/cpp/test/generated/binary/protocols.cc b/cpp/test/generated/binary/protocols.cc index 656c571..e39b47d 100644 --- a/cpp/test/generated/binary/protocols.cc +++ b/cpp/test/generated/binary/protocols.cc @@ -2923,6 +2923,84 @@ void BenchmarkFloat256x256Reader::CloseImpl() { stream_.VerifyFinished(); } +void BenchmarkFloat256x256IndexedWriter::WriteFloat256x256Impl(yardl::FixedNDArray const& value) { + step_index_.set_step_offset("Float256x256", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, yardl::binary::WriteFixedNDArray>(stream_, value, item_offset); + step_index_.add_stream_offset("Float256x256", item_offset); +} + +void BenchmarkFloat256x256IndexedWriter::WriteFloat256x256Impl(std::vector> const& values) { + step_index_.set_step_offset("Float256x256", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, yardl::binary::WriteFixedNDArray>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("Float256x256", item_offsets); +} + +void BenchmarkFloat256x256IndexedWriter::EndFloat256x256Impl() { + step_index_.set_step_offset("Float256x256", stream_.Pos()); + step_index_.add_stream_offsets("Float256x256", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void BenchmarkFloat256x256IndexedWriter::Flush() { + stream_.Flush(); +} + +void BenchmarkFloat256x256IndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool BenchmarkFloat256x256IndexedReader::ReadFloat256x256Impl(yardl::FixedNDArray& value) { + if (!step_index_.offset_within_stream("Float256x256", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Float256x256")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkFloat256x256IndexedReader::ReadFloat256x256Impl(std::vector>& values) { + if (!step_index_.offset_within_stream("Float256x256", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Float256x256")); + } + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool BenchmarkFloat256x256IndexedReader::ReadFloat256x256Impl(yardl::FixedNDArray& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Float256x256", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkFloat256x256IndexedReader::ReadFloat256x256Impl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Float256x256", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t BenchmarkFloat256x256IndexedReader::CountFloat256x256Impl() { + return step_index_.get_stream_count("Float256x256"); +} + +void BenchmarkFloat256x256IndexedReader::CloseImpl() { +} + void BenchmarkInt256x256Writer::WriteInt256x256Impl(yardl::FixedNDArray const& value) { yardl::binary::WriteBlock, yardl::binary::WriteFixedNDArray>(stream_, value); } @@ -2960,6 +3038,84 @@ void BenchmarkInt256x256Reader::CloseImpl() { stream_.VerifyFinished(); } +void BenchmarkInt256x256IndexedWriter::WriteInt256x256Impl(yardl::FixedNDArray const& value) { + step_index_.set_step_offset("Int256x256", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, yardl::binary::WriteFixedNDArray>(stream_, value, item_offset); + step_index_.add_stream_offset("Int256x256", item_offset); +} + +void BenchmarkInt256x256IndexedWriter::WriteInt256x256Impl(std::vector> const& values) { + step_index_.set_step_offset("Int256x256", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, yardl::binary::WriteFixedNDArray>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("Int256x256", item_offsets); +} + +void BenchmarkInt256x256IndexedWriter::EndInt256x256Impl() { + step_index_.set_step_offset("Int256x256", stream_.Pos()); + step_index_.add_stream_offsets("Int256x256", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void BenchmarkInt256x256IndexedWriter::Flush() { + stream_.Flush(); +} + +void BenchmarkInt256x256IndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool BenchmarkInt256x256IndexedReader::ReadInt256x256Impl(yardl::FixedNDArray& value) { + if (!step_index_.offset_within_stream("Int256x256", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Int256x256")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkInt256x256IndexedReader::ReadInt256x256Impl(std::vector>& values) { + if (!step_index_.offset_within_stream("Int256x256", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Int256x256")); + } + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool BenchmarkInt256x256IndexedReader::ReadInt256x256Impl(yardl::FixedNDArray& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Int256x256", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkInt256x256IndexedReader::ReadInt256x256Impl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Int256x256", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t BenchmarkInt256x256IndexedReader::CountInt256x256Impl() { + return step_index_.get_stream_count("Int256x256"); +} + +void BenchmarkInt256x256IndexedReader::CloseImpl() { +} + void BenchmarkFloatVlenWriter::WriteFloatArrayImpl(yardl::NDArray const& value) { yardl::binary::WriteBlock, yardl::binary::WriteNDArray>(stream_, value); } @@ -2997,6 +3153,84 @@ void BenchmarkFloatVlenReader::CloseImpl() { stream_.VerifyFinished(); } +void BenchmarkFloatVlenIndexedWriter::WriteFloatArrayImpl(yardl::NDArray const& value) { + step_index_.set_step_offset("FloatArray", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, yardl::binary::WriteNDArray>(stream_, value, item_offset); + step_index_.add_stream_offset("FloatArray", item_offset); +} + +void BenchmarkFloatVlenIndexedWriter::WriteFloatArrayImpl(std::vector> const& values) { + step_index_.set_step_offset("FloatArray", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, yardl::binary::WriteNDArray>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("FloatArray", item_offsets); +} + +void BenchmarkFloatVlenIndexedWriter::EndFloatArrayImpl() { + step_index_.set_step_offset("FloatArray", stream_.Pos()); + step_index_.add_stream_offsets("FloatArray", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void BenchmarkFloatVlenIndexedWriter::Flush() { + stream_.Flush(); +} + +void BenchmarkFloatVlenIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool BenchmarkFloatVlenIndexedReader::ReadFloatArrayImpl(yardl::NDArray& value) { + if (!step_index_.offset_within_stream("FloatArray", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("FloatArray")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkFloatVlenIndexedReader::ReadFloatArrayImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("FloatArray", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("FloatArray")); + } + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool BenchmarkFloatVlenIndexedReader::ReadFloatArrayImpl(yardl::NDArray& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("FloatArray", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkFloatVlenIndexedReader::ReadFloatArrayImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("FloatArray", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t BenchmarkFloatVlenIndexedReader::CountFloatArrayImpl() { + return step_index_.get_stream_count("FloatArray"); +} + +void BenchmarkFloatVlenIndexedReader::CloseImpl() { +} + void BenchmarkSmallRecordWriter::WriteSmallRecordImpl(test_model::SmallBenchmarkRecord const& value) { yardl::binary::WriteBlock(stream_, value); } @@ -3034,6 +3268,84 @@ void BenchmarkSmallRecordReader::CloseImpl() { stream_.VerifyFinished(); } +void BenchmarkSmallRecordIndexedWriter::WriteSmallRecordImpl(test_model::SmallBenchmarkRecord const& value) { + step_index_.set_step_offset("SmallRecord", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("SmallRecord", item_offset); +} + +void BenchmarkSmallRecordIndexedWriter::WriteSmallRecordImpl(std::vector const& values) { + step_index_.set_step_offset("SmallRecord", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("SmallRecord", item_offsets); +} + +void BenchmarkSmallRecordIndexedWriter::EndSmallRecordImpl() { + step_index_.set_step_offset("SmallRecord", stream_.Pos()); + step_index_.add_stream_offsets("SmallRecord", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void BenchmarkSmallRecordIndexedWriter::Flush() { + stream_.Flush(); +} + +void BenchmarkSmallRecordIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool BenchmarkSmallRecordIndexedReader::ReadSmallRecordImpl(test_model::SmallBenchmarkRecord& value) { + if (!step_index_.offset_within_stream("SmallRecord", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("SmallRecord")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkSmallRecordIndexedReader::ReadSmallRecordImpl(std::vector& values) { + if (!step_index_.offset_within_stream("SmallRecord", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("SmallRecord")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool BenchmarkSmallRecordIndexedReader::ReadSmallRecordImpl(test_model::SmallBenchmarkRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("SmallRecord", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkSmallRecordIndexedReader::ReadSmallRecordImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("SmallRecord", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t BenchmarkSmallRecordIndexedReader::CountSmallRecordImpl() { + return step_index_.get_stream_count("SmallRecord"); +} + +void BenchmarkSmallRecordIndexedReader::CloseImpl() { +} + void BenchmarkSmallRecordWithOptionalsWriter::WriteSmallRecordImpl(test_model::SimpleEncodingCounters const& value) { yardl::binary::WriteBlock(stream_, value); } @@ -3071,6 +3383,84 @@ void BenchmarkSmallRecordWithOptionalsReader::CloseImpl() { stream_.VerifyFinished(); } +void BenchmarkSmallRecordWithOptionalsIndexedWriter::WriteSmallRecordImpl(test_model::SimpleEncodingCounters const& value) { + step_index_.set_step_offset("SmallRecord", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("SmallRecord", item_offset); +} + +void BenchmarkSmallRecordWithOptionalsIndexedWriter::WriteSmallRecordImpl(std::vector const& values) { + step_index_.set_step_offset("SmallRecord", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("SmallRecord", item_offsets); +} + +void BenchmarkSmallRecordWithOptionalsIndexedWriter::EndSmallRecordImpl() { + step_index_.set_step_offset("SmallRecord", stream_.Pos()); + step_index_.add_stream_offsets("SmallRecord", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void BenchmarkSmallRecordWithOptionalsIndexedWriter::Flush() { + stream_.Flush(); +} + +void BenchmarkSmallRecordWithOptionalsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool BenchmarkSmallRecordWithOptionalsIndexedReader::ReadSmallRecordImpl(test_model::SimpleEncodingCounters& value) { + if (!step_index_.offset_within_stream("SmallRecord", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("SmallRecord")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkSmallRecordWithOptionalsIndexedReader::ReadSmallRecordImpl(std::vector& values) { + if (!step_index_.offset_within_stream("SmallRecord", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("SmallRecord")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool BenchmarkSmallRecordWithOptionalsIndexedReader::ReadSmallRecordImpl(test_model::SimpleEncodingCounters& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("SmallRecord", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkSmallRecordWithOptionalsIndexedReader::ReadSmallRecordImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("SmallRecord", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t BenchmarkSmallRecordWithOptionalsIndexedReader::CountSmallRecordImpl() { + return step_index_.get_stream_count("SmallRecord"); +} + +void BenchmarkSmallRecordWithOptionalsIndexedReader::CloseImpl() { +} + void BenchmarkSimpleMrdWriter::WriteDataImpl(std::variant> const& value) { yardl::binary::WriteBlock>, WriteUnion, image::binary::WriteImage>>(stream_, value); } @@ -3108,6 +3498,84 @@ void BenchmarkSimpleMrdReader::CloseImpl() { stream_.VerifyFinished(); } +void BenchmarkSimpleMrdIndexedWriter::WriteDataImpl(std::variant> const& value) { + step_index_.set_step_offset("Data", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset>, WriteUnion, image::binary::WriteImage>>(stream_, value, item_offset); + step_index_.add_stream_offset("Data", item_offset); +} + +void BenchmarkSimpleMrdIndexedWriter::WriteDataImpl(std::vector>> const& values) { + step_index_.set_step_offset("Data", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets>, WriteUnion, image::binary::WriteImage>>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("Data", item_offsets); +} + +void BenchmarkSimpleMrdIndexedWriter::EndDataImpl() { + step_index_.set_step_offset("Data", stream_.Pos()); + step_index_.add_stream_offsets("Data", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void BenchmarkSimpleMrdIndexedWriter::Flush() { + stream_.Flush(); +} + +void BenchmarkSimpleMrdIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool BenchmarkSimpleMrdIndexedReader::ReadDataImpl(std::variant>& value) { + if (!step_index_.offset_within_stream("Data", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Data")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock>, ReadUnion, image::binary::ReadImage>>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkSimpleMrdIndexedReader::ReadDataImpl(std::vector>>& values) { + if (!step_index_.offset_within_stream("Data", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Data")); + } + yardl::binary::ReadBlocksIntoVector>, ReadUnion, image::binary::ReadImage>>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool BenchmarkSimpleMrdIndexedReader::ReadDataImpl(std::variant>& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Data", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock>, ReadUnion, image::binary::ReadImage>>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool BenchmarkSimpleMrdIndexedReader::ReadDataImpl(std::vector>>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Data", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector>, ReadUnion, image::binary::ReadImage>>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t BenchmarkSimpleMrdIndexedReader::CountDataImpl() { + return step_index_.get_stream_count("Data"); +} + +void BenchmarkSimpleMrdIndexedReader::CloseImpl() { +} + void ScalarsWriter::WriteInt32Impl(int32_t const& value) { yardl::binary::WriteInteger(stream_, value); } @@ -3136,19 +3604,53 @@ void ScalarsReader::CloseImpl() { stream_.VerifyFinished(); } -void ScalarOptionalsWriter::WriteOptionalIntImpl(std::optional const& value) { - yardl::binary::WriteOptional(stream_, value); +void ScalarsIndexedWriter::WriteInt32Impl(int32_t const& value) { + step_index_.set_step_offset("Int32", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); } -void ScalarOptionalsWriter::WriteOptionalRecordImpl(std::optional const& value) { - yardl::binary::WriteOptional(stream_, value); +void ScalarsIndexedWriter::WriteRecordImpl(test_model::RecordWithPrimitives const& value) { + step_index_.set_step_offset("Record", stream_.Pos()); + test_model::binary::WriteRecordWithPrimitives(stream_, value); } -void ScalarOptionalsWriter::WriteRecordWithOptionalFieldsImpl(test_model::RecordWithOptionalFields const& value) { - test_model::binary::WriteRecordWithOptionalFields(stream_, value); +void ScalarsIndexedWriter::Flush() { + stream_.Flush(); } -void ScalarOptionalsWriter::WriteOptionalRecordWithOptionalFieldsImpl(std::optional const& value) { +void ScalarsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void ScalarsIndexedReader::ReadInt32Impl(int32_t& value) { + auto pos = step_index_.get_step_offset("Int32"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void ScalarsIndexedReader::ReadRecordImpl(test_model::RecordWithPrimitives& value) { + auto pos = step_index_.get_step_offset("Record"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithPrimitives(stream_, value); +} + +void ScalarsIndexedReader::CloseImpl() { +} + +void ScalarOptionalsWriter::WriteOptionalIntImpl(std::optional const& value) { + yardl::binary::WriteOptional(stream_, value); +} + +void ScalarOptionalsWriter::WriteOptionalRecordImpl(std::optional const& value) { + yardl::binary::WriteOptional(stream_, value); +} + +void ScalarOptionalsWriter::WriteRecordWithOptionalFieldsImpl(test_model::RecordWithOptionalFields const& value) { + test_model::binary::WriteRecordWithOptionalFields(stream_, value); +} + +void ScalarOptionalsWriter::WriteOptionalRecordWithOptionalFieldsImpl(std::optional const& value) { yardl::binary::WriteOptional(stream_, value); } @@ -3180,6 +3682,62 @@ void ScalarOptionalsReader::CloseImpl() { stream_.VerifyFinished(); } +void ScalarOptionalsIndexedWriter::WriteOptionalIntImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalInt", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ScalarOptionalsIndexedWriter::WriteOptionalRecordImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalRecord", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ScalarOptionalsIndexedWriter::WriteRecordWithOptionalFieldsImpl(test_model::RecordWithOptionalFields const& value) { + step_index_.set_step_offset("RecordWithOptionalFields", stream_.Pos()); + test_model::binary::WriteRecordWithOptionalFields(stream_, value); +} + +void ScalarOptionalsIndexedWriter::WriteOptionalRecordWithOptionalFieldsImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalRecordWithOptionalFields", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ScalarOptionalsIndexedWriter::Flush() { + stream_.Flush(); +} + +void ScalarOptionalsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void ScalarOptionalsIndexedReader::ReadOptionalIntImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalInt"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ScalarOptionalsIndexedReader::ReadOptionalRecordImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalRecord"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ScalarOptionalsIndexedReader::ReadRecordWithOptionalFieldsImpl(test_model::RecordWithOptionalFields& value) { + auto pos = step_index_.get_step_offset("RecordWithOptionalFields"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithOptionalFields(stream_, value); +} + +void ScalarOptionalsIndexedReader::ReadOptionalRecordWithOptionalFieldsImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("OptionalRecordWithOptionalFields"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ScalarOptionalsIndexedReader::CloseImpl() { +} + void NestedRecordsWriter::WriteTupleWithRecordsImpl(test_model::TupleWithRecords const& value) { test_model::binary::WriteTupleWithRecords(stream_, value); } @@ -3200,6 +3758,29 @@ void NestedRecordsReader::CloseImpl() { stream_.VerifyFinished(); } +void NestedRecordsIndexedWriter::WriteTupleWithRecordsImpl(test_model::TupleWithRecords const& value) { + step_index_.set_step_offset("TupleWithRecords", stream_.Pos()); + test_model::binary::WriteTupleWithRecords(stream_, value); +} + +void NestedRecordsIndexedWriter::Flush() { + stream_.Flush(); +} + +void NestedRecordsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void NestedRecordsIndexedReader::ReadTupleWithRecordsImpl(test_model::TupleWithRecords& value) { + auto pos = step_index_.get_step_offset("TupleWithRecords"); + stream_.Seek(pos); + test_model::binary::ReadTupleWithRecords(stream_, value); +} + +void NestedRecordsIndexedReader::CloseImpl() { +} + void VlensWriter::WriteIntVectorImpl(std::vector const& value) { yardl::binary::WriteVector(stream_, value); } @@ -3244,6 +3825,62 @@ void VlensReader::CloseImpl() { stream_.VerifyFinished(); } +void VlensIndexedWriter::WriteIntVectorImpl(std::vector const& value) { + step_index_.set_step_offset("IntVector", stream_.Pos()); + yardl::binary::WriteVector(stream_, value); +} + +void VlensIndexedWriter::WriteComplexVectorImpl(std::vector> const& value) { + step_index_.set_step_offset("ComplexVector", stream_.Pos()); + yardl::binary::WriteVector, yardl::binary::WriteFloatingPoint>(stream_, value); +} + +void VlensIndexedWriter::WriteRecordWithVlensImpl(test_model::RecordWithVlens const& value) { + step_index_.set_step_offset("RecordWithVlens", stream_.Pos()); + test_model::binary::WriteRecordWithVlens(stream_, value); +} + +void VlensIndexedWriter::WriteVlenOfRecordWithVlensImpl(std::vector const& value) { + step_index_.set_step_offset("VlenOfRecordWithVlens", stream_.Pos()); + yardl::binary::WriteVector(stream_, value); +} + +void VlensIndexedWriter::Flush() { + stream_.Flush(); +} + +void VlensIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void VlensIndexedReader::ReadIntVectorImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("IntVector"); + stream_.Seek(pos); + yardl::binary::ReadVector(stream_, value); +} + +void VlensIndexedReader::ReadComplexVectorImpl(std::vector>& value) { + auto pos = step_index_.get_step_offset("ComplexVector"); + stream_.Seek(pos); + yardl::binary::ReadVector, yardl::binary::ReadFloatingPoint>(stream_, value); +} + +void VlensIndexedReader::ReadRecordWithVlensImpl(test_model::RecordWithVlens& value) { + auto pos = step_index_.get_step_offset("RecordWithVlens"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithVlens(stream_, value); +} + +void VlensIndexedReader::ReadVlenOfRecordWithVlensImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("VlenOfRecordWithVlens"); + stream_.Seek(pos); + yardl::binary::ReadVector(stream_, value); +} + +void VlensIndexedReader::CloseImpl() { +} + void StringsWriter::WriteSingleStringImpl(std::string const& value) { yardl::binary::WriteString(stream_, value); } @@ -3272,6 +3909,40 @@ void StringsReader::CloseImpl() { stream_.VerifyFinished(); } +void StringsIndexedWriter::WriteSingleStringImpl(std::string const& value) { + step_index_.set_step_offset("SingleString", stream_.Pos()); + yardl::binary::WriteString(stream_, value); +} + +void StringsIndexedWriter::WriteRecWithStringImpl(test_model::RecordWithStrings const& value) { + step_index_.set_step_offset("RecWithString", stream_.Pos()); + test_model::binary::WriteRecordWithStrings(stream_, value); +} + +void StringsIndexedWriter::Flush() { + stream_.Flush(); +} + +void StringsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void StringsIndexedReader::ReadSingleStringImpl(std::string& value) { + auto pos = step_index_.get_step_offset("SingleString"); + stream_.Seek(pos); + yardl::binary::ReadString(stream_, value); +} + +void StringsIndexedReader::ReadRecWithStringImpl(test_model::RecordWithStrings& value) { + auto pos = step_index_.get_step_offset("RecWithString"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithStrings(stream_, value); +} + +void StringsIndexedReader::CloseImpl() { +} + void OptionalVectorsWriter::WriteRecordWithOptionalVectorImpl(test_model::RecordWithOptionalVector const& value) { test_model::binary::WriteRecordWithOptionalVector(stream_, value); } @@ -3292,6 +3963,29 @@ void OptionalVectorsReader::CloseImpl() { stream_.VerifyFinished(); } +void OptionalVectorsIndexedWriter::WriteRecordWithOptionalVectorImpl(test_model::RecordWithOptionalVector const& value) { + step_index_.set_step_offset("RecordWithOptionalVector", stream_.Pos()); + test_model::binary::WriteRecordWithOptionalVector(stream_, value); +} + +void OptionalVectorsIndexedWriter::Flush() { + stream_.Flush(); +} + +void OptionalVectorsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void OptionalVectorsIndexedReader::ReadRecordWithOptionalVectorImpl(test_model::RecordWithOptionalVector& value) { + auto pos = step_index_.get_step_offset("RecordWithOptionalVector"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithOptionalVector(stream_, value); +} + +void OptionalVectorsIndexedReader::CloseImpl() { +} + void FixedVectorsWriter::WriteFixedIntVectorImpl(std::array const& value) { yardl::binary::WriteArray(stream_, value); } @@ -3336,6 +4030,62 @@ void FixedVectorsReader::CloseImpl() { stream_.VerifyFinished(); } +void FixedVectorsIndexedWriter::WriteFixedIntVectorImpl(std::array const& value) { + step_index_.set_step_offset("FixedIntVector", stream_.Pos()); + yardl::binary::WriteArray(stream_, value); +} + +void FixedVectorsIndexedWriter::WriteFixedSimpleRecordVectorImpl(std::array const& value) { + step_index_.set_step_offset("FixedSimpleRecordVector", stream_.Pos()); + yardl::binary::WriteArray(stream_, value); +} + +void FixedVectorsIndexedWriter::WriteFixedRecordWithVlensVectorImpl(std::array const& value) { + step_index_.set_step_offset("FixedRecordWithVlensVector", stream_.Pos()); + yardl::binary::WriteArray(stream_, value); +} + +void FixedVectorsIndexedWriter::WriteRecordWithFixedVectorsImpl(test_model::RecordWithFixedVectors const& value) { + step_index_.set_step_offset("RecordWithFixedVectors", stream_.Pos()); + test_model::binary::WriteRecordWithFixedVectors(stream_, value); +} + +void FixedVectorsIndexedWriter::Flush() { + stream_.Flush(); +} + +void FixedVectorsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void FixedVectorsIndexedReader::ReadFixedIntVectorImpl(std::array& value) { + auto pos = step_index_.get_step_offset("FixedIntVector"); + stream_.Seek(pos); + yardl::binary::ReadArray(stream_, value); +} + +void FixedVectorsIndexedReader::ReadFixedSimpleRecordVectorImpl(std::array& value) { + auto pos = step_index_.get_step_offset("FixedSimpleRecordVector"); + stream_.Seek(pos); + yardl::binary::ReadArray(stream_, value); +} + +void FixedVectorsIndexedReader::ReadFixedRecordWithVlensVectorImpl(std::array& value) { + auto pos = step_index_.get_step_offset("FixedRecordWithVlensVector"); + stream_.Seek(pos); + yardl::binary::ReadArray(stream_, value); +} + +void FixedVectorsIndexedReader::ReadRecordWithFixedVectorsImpl(test_model::RecordWithFixedVectors& value) { + auto pos = step_index_.get_step_offset("RecordWithFixedVectors"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithFixedVectors(stream_, value); +} + +void FixedVectorsIndexedReader::CloseImpl() { +} + void StreamsWriter::WriteIntDataImpl(int32_t const& value) { yardl::binary::WriteBlock(stream_, value); } @@ -3448,96 +4198,439 @@ void StreamsReader::CloseImpl() { stream_.VerifyFinished(); } -void FixedArraysWriter::WriteIntsImpl(yardl::FixedNDArray const& value) { - yardl::binary::WriteFixedNDArray(stream_, value); +void StreamsIndexedWriter::WriteIntDataImpl(int32_t const& value) { + step_index_.set_step_offset("IntData", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("IntData", item_offset); } -void FixedArraysWriter::WriteFixedSimpleRecordArrayImpl(yardl::FixedNDArray const& value) { - yardl::binary::WriteFixedNDArray(stream_, value); +void StreamsIndexedWriter::WriteIntDataImpl(std::vector const& values) { + step_index_.set_step_offset("IntData", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("IntData", item_offsets); } -void FixedArraysWriter::WriteFixedRecordWithVlensArrayImpl(yardl::FixedNDArray const& value) { - yardl::binary::WriteFixedNDArray(stream_, value); +void StreamsIndexedWriter::EndIntDataImpl() { + step_index_.set_step_offset("IntData", stream_.Pos()); + step_index_.add_stream_offsets("IntData", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); } -void FixedArraysWriter::WriteRecordWithFixedArraysImpl(test_model::RecordWithFixedArrays const& value) { - test_model::binary::WriteRecordWithFixedArrays(stream_, value); +void StreamsIndexedWriter::WriteOptionalIntDataImpl(std::optional const& value) { + step_index_.set_step_offset("OptionalIntData", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, yardl::binary::WriteOptional>(stream_, value, item_offset); + step_index_.add_stream_offset("OptionalIntData", item_offset); } -void FixedArraysWriter::WriteNamedArrayImpl(test_model::NamedFixedNDArray const& value) { - test_model::binary::WriteNamedFixedNDArray(stream_, value); +void StreamsIndexedWriter::WriteOptionalIntDataImpl(std::vector> const& values) { + step_index_.set_step_offset("OptionalIntData", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, yardl::binary::WriteOptional>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("OptionalIntData", item_offsets); } -void FixedArraysWriter::Flush() { - stream_.Flush(); +void StreamsIndexedWriter::EndOptionalIntDataImpl() { + step_index_.set_step_offset("OptionalIntData", stream_.Pos()); + step_index_.add_stream_offsets("OptionalIntData", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); } -void FixedArraysWriter::CloseImpl() { - stream_.Flush(); +void StreamsIndexedWriter::WriteRecordWithOptionalVectorDataImpl(test_model::RecordWithOptionalVector const& value) { + step_index_.set_step_offset("RecordWithOptionalVectorData", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("RecordWithOptionalVectorData", item_offset); } -void FixedArraysReader::ReadIntsImpl(yardl::FixedNDArray& value) { - yardl::binary::ReadFixedNDArray(stream_, value); +void StreamsIndexedWriter::WriteRecordWithOptionalVectorDataImpl(std::vector const& values) { + step_index_.set_step_offset("RecordWithOptionalVectorData", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("RecordWithOptionalVectorData", item_offsets); } -void FixedArraysReader::ReadFixedSimpleRecordArrayImpl(yardl::FixedNDArray& value) { - yardl::binary::ReadFixedNDArray(stream_, value); +void StreamsIndexedWriter::EndRecordWithOptionalVectorDataImpl() { + step_index_.set_step_offset("RecordWithOptionalVectorData", stream_.Pos()); + step_index_.add_stream_offsets("RecordWithOptionalVectorData", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); } -void FixedArraysReader::ReadFixedRecordWithVlensArrayImpl(yardl::FixedNDArray& value) { - yardl::binary::ReadFixedNDArray(stream_, value); +void StreamsIndexedWriter::WriteFixedVectorImpl(std::array const& value) { + step_index_.set_step_offset("FixedVector", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, yardl::binary::WriteArray>(stream_, value, item_offset); + step_index_.add_stream_offset("FixedVector", item_offset); } -void FixedArraysReader::ReadRecordWithFixedArraysImpl(test_model::RecordWithFixedArrays& value) { - test_model::binary::ReadRecordWithFixedArrays(stream_, value); +void StreamsIndexedWriter::WriteFixedVectorImpl(std::vector> const& values) { + step_index_.set_step_offset("FixedVector", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, yardl::binary::WriteArray>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("FixedVector", item_offsets); } -void FixedArraysReader::ReadNamedArrayImpl(test_model::NamedFixedNDArray& value) { - test_model::binary::ReadNamedFixedNDArray(stream_, value); +void StreamsIndexedWriter::EndFixedVectorImpl() { + step_index_.set_step_offset("FixedVector", stream_.Pos()); + step_index_.add_stream_offsets("FixedVector", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); } -void FixedArraysReader::CloseImpl() { - stream_.VerifyFinished(); +void StreamsIndexedWriter::Flush() { + stream_.Flush(); } -void SubarraysWriter::WriteDynamicWithFixedIntSubarrayImpl(yardl::DynamicNDArray> const& value) { - yardl::binary::WriteDynamicNDArray, yardl::binary::WriteFixedNDArray>(stream_, value); +void StreamsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); } -void SubarraysWriter::WriteDynamicWithFixedFloatSubarrayImpl(yardl::DynamicNDArray> const& value) { - yardl::binary::WriteDynamicNDArray, yardl::binary::WriteFixedNDArray>(stream_, value); +bool StreamsIndexedReader::ReadIntDataImpl(int32_t& value) { + if (!step_index_.offset_within_stream("IntData", "OptionalIntData", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntData")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; } -void SubarraysWriter::WriteKnownDimCountWithFixedIntSubarrayImpl(yardl::NDArray, 1> const& value) { - yardl::binary::WriteNDArray, yardl::binary::WriteFixedNDArray, 1>(stream_, value); +bool StreamsIndexedReader::ReadIntDataImpl(std::vector& values) { + if (!step_index_.offset_within_stream("IntData", "OptionalIntData", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntData")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; } -void SubarraysWriter::WriteKnownDimCountWithFixedFloatSubarrayImpl(yardl::NDArray, 1> const& value) { - yardl::binary::WriteNDArray, yardl::binary::WriteFixedNDArray, 1>(stream_, value); +bool StreamsIndexedReader::ReadIntDataImpl(int32_t& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntData", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; } -void SubarraysWriter::WriteFixedWithFixedIntSubarrayImpl(yardl::FixedNDArray, 2> const& value) { - yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>(stream_, value); +bool StreamsIndexedReader::ReadIntDataImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntData", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; } -void SubarraysWriter::WriteFixedWithFixedFloatSubarrayImpl(yardl::FixedNDArray, 2> const& value) { - yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>(stream_, value); +size_t StreamsIndexedReader::CountIntDataImpl() { + return step_index_.get_stream_count("IntData"); } -void SubarraysWriter::WriteNestedSubarrayImpl(yardl::DynamicNDArray, 2>> const& value) { - yardl::binary::WriteDynamicNDArray, 2>, yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>>(stream_, value); +bool StreamsIndexedReader::ReadOptionalIntDataImpl(std::optional& value) { + if (!step_index_.offset_within_stream("OptionalIntData", "RecordWithOptionalVectorData", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("OptionalIntData")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadOptional>(stream_, current_block_remaining_, value); + return read_block_successful; } -void SubarraysWriter::WriteDynamicWithFixedVectorSubarrayImpl(yardl::DynamicNDArray> const& value) { - yardl::binary::WriteDynamicNDArray, yardl::binary::WriteArray>(stream_, value); +bool StreamsIndexedReader::ReadOptionalIntDataImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("OptionalIntData", "RecordWithOptionalVectorData", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("OptionalIntData")); + } + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadOptional>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; } -void SubarraysWriter::WriteGenericSubarrayImpl(test_model::Image> const& value) { - test_model::binary::WriteImage, yardl::binary::WriteFixedNDArray>(stream_, value); +bool StreamsIndexedReader::ReadOptionalIntDataImpl(std::optional& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("OptionalIntData", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadOptional>(stream_, current_block_remaining_, value); + return read_block_successful; } -void SubarraysWriter::Flush() { - stream_.Flush(); +bool StreamsIndexedReader::ReadOptionalIntDataImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("OptionalIntData", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadOptional>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StreamsIndexedReader::CountOptionalIntDataImpl() { + return step_index_.get_stream_count("OptionalIntData"); +} + +bool StreamsIndexedReader::ReadRecordWithOptionalVectorDataImpl(test_model::RecordWithOptionalVector& value) { + if (!step_index_.offset_within_stream("RecordWithOptionalVectorData", "FixedVector", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("RecordWithOptionalVectorData")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsIndexedReader::ReadRecordWithOptionalVectorDataImpl(std::vector& values) { + if (!step_index_.offset_within_stream("RecordWithOptionalVectorData", "FixedVector", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("RecordWithOptionalVectorData")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool StreamsIndexedReader::ReadRecordWithOptionalVectorDataImpl(test_model::RecordWithOptionalVector& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("RecordWithOptionalVectorData", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsIndexedReader::ReadRecordWithOptionalVectorDataImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("RecordWithOptionalVectorData", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StreamsIndexedReader::CountRecordWithOptionalVectorDataImpl() { + return step_index_.get_stream_count("RecordWithOptionalVectorData"); +} + +bool StreamsIndexedReader::ReadFixedVectorImpl(std::array& value) { + if (!step_index_.offset_within_stream("FixedVector", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("FixedVector")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsIndexedReader::ReadFixedVectorImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("FixedVector", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("FixedVector")); + } + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool StreamsIndexedReader::ReadFixedVectorImpl(std::array& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("FixedVector", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsIndexedReader::ReadFixedVectorImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("FixedVector", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StreamsIndexedReader::CountFixedVectorImpl() { + return step_index_.get_stream_count("FixedVector"); +} + +void StreamsIndexedReader::CloseImpl() { +} + +void FixedArraysWriter::WriteIntsImpl(yardl::FixedNDArray const& value) { + yardl::binary::WriteFixedNDArray(stream_, value); +} + +void FixedArraysWriter::WriteFixedSimpleRecordArrayImpl(yardl::FixedNDArray const& value) { + yardl::binary::WriteFixedNDArray(stream_, value); +} + +void FixedArraysWriter::WriteFixedRecordWithVlensArrayImpl(yardl::FixedNDArray const& value) { + yardl::binary::WriteFixedNDArray(stream_, value); +} + +void FixedArraysWriter::WriteRecordWithFixedArraysImpl(test_model::RecordWithFixedArrays const& value) { + test_model::binary::WriteRecordWithFixedArrays(stream_, value); +} + +void FixedArraysWriter::WriteNamedArrayImpl(test_model::NamedFixedNDArray const& value) { + test_model::binary::WriteNamedFixedNDArray(stream_, value); +} + +void FixedArraysWriter::Flush() { + stream_.Flush(); +} + +void FixedArraysWriter::CloseImpl() { + stream_.Flush(); +} + +void FixedArraysReader::ReadIntsImpl(yardl::FixedNDArray& value) { + yardl::binary::ReadFixedNDArray(stream_, value); +} + +void FixedArraysReader::ReadFixedSimpleRecordArrayImpl(yardl::FixedNDArray& value) { + yardl::binary::ReadFixedNDArray(stream_, value); +} + +void FixedArraysReader::ReadFixedRecordWithVlensArrayImpl(yardl::FixedNDArray& value) { + yardl::binary::ReadFixedNDArray(stream_, value); +} + +void FixedArraysReader::ReadRecordWithFixedArraysImpl(test_model::RecordWithFixedArrays& value) { + test_model::binary::ReadRecordWithFixedArrays(stream_, value); +} + +void FixedArraysReader::ReadNamedArrayImpl(test_model::NamedFixedNDArray& value) { + test_model::binary::ReadNamedFixedNDArray(stream_, value); +} + +void FixedArraysReader::CloseImpl() { + stream_.VerifyFinished(); +} + +void FixedArraysIndexedWriter::WriteIntsImpl(yardl::FixedNDArray const& value) { + step_index_.set_step_offset("Ints", stream_.Pos()); + yardl::binary::WriteFixedNDArray(stream_, value); +} + +void FixedArraysIndexedWriter::WriteFixedSimpleRecordArrayImpl(yardl::FixedNDArray const& value) { + step_index_.set_step_offset("FixedSimpleRecordArray", stream_.Pos()); + yardl::binary::WriteFixedNDArray(stream_, value); +} + +void FixedArraysIndexedWriter::WriteFixedRecordWithVlensArrayImpl(yardl::FixedNDArray const& value) { + step_index_.set_step_offset("FixedRecordWithVlensArray", stream_.Pos()); + yardl::binary::WriteFixedNDArray(stream_, value); +} + +void FixedArraysIndexedWriter::WriteRecordWithFixedArraysImpl(test_model::RecordWithFixedArrays const& value) { + step_index_.set_step_offset("RecordWithFixedArrays", stream_.Pos()); + test_model::binary::WriteRecordWithFixedArrays(stream_, value); +} + +void FixedArraysIndexedWriter::WriteNamedArrayImpl(test_model::NamedFixedNDArray const& value) { + step_index_.set_step_offset("NamedArray", stream_.Pos()); + test_model::binary::WriteNamedFixedNDArray(stream_, value); +} + +void FixedArraysIndexedWriter::Flush() { + stream_.Flush(); +} + +void FixedArraysIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void FixedArraysIndexedReader::ReadIntsImpl(yardl::FixedNDArray& value) { + auto pos = step_index_.get_step_offset("Ints"); + stream_.Seek(pos); + yardl::binary::ReadFixedNDArray(stream_, value); +} + +void FixedArraysIndexedReader::ReadFixedSimpleRecordArrayImpl(yardl::FixedNDArray& value) { + auto pos = step_index_.get_step_offset("FixedSimpleRecordArray"); + stream_.Seek(pos); + yardl::binary::ReadFixedNDArray(stream_, value); +} + +void FixedArraysIndexedReader::ReadFixedRecordWithVlensArrayImpl(yardl::FixedNDArray& value) { + auto pos = step_index_.get_step_offset("FixedRecordWithVlensArray"); + stream_.Seek(pos); + yardl::binary::ReadFixedNDArray(stream_, value); +} + +void FixedArraysIndexedReader::ReadRecordWithFixedArraysImpl(test_model::RecordWithFixedArrays& value) { + auto pos = step_index_.get_step_offset("RecordWithFixedArrays"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithFixedArrays(stream_, value); +} + +void FixedArraysIndexedReader::ReadNamedArrayImpl(test_model::NamedFixedNDArray& value) { + auto pos = step_index_.get_step_offset("NamedArray"); + stream_.Seek(pos); + test_model::binary::ReadNamedFixedNDArray(stream_, value); +} + +void FixedArraysIndexedReader::CloseImpl() { +} + +void SubarraysWriter::WriteDynamicWithFixedIntSubarrayImpl(yardl::DynamicNDArray> const& value) { + yardl::binary::WriteDynamicNDArray, yardl::binary::WriteFixedNDArray>(stream_, value); +} + +void SubarraysWriter::WriteDynamicWithFixedFloatSubarrayImpl(yardl::DynamicNDArray> const& value) { + yardl::binary::WriteDynamicNDArray, yardl::binary::WriteFixedNDArray>(stream_, value); +} + +void SubarraysWriter::WriteKnownDimCountWithFixedIntSubarrayImpl(yardl::NDArray, 1> const& value) { + yardl::binary::WriteNDArray, yardl::binary::WriteFixedNDArray, 1>(stream_, value); +} + +void SubarraysWriter::WriteKnownDimCountWithFixedFloatSubarrayImpl(yardl::NDArray, 1> const& value) { + yardl::binary::WriteNDArray, yardl::binary::WriteFixedNDArray, 1>(stream_, value); +} + +void SubarraysWriter::WriteFixedWithFixedIntSubarrayImpl(yardl::FixedNDArray, 2> const& value) { + yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>(stream_, value); +} + +void SubarraysWriter::WriteFixedWithFixedFloatSubarrayImpl(yardl::FixedNDArray, 2> const& value) { + yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>(stream_, value); +} + +void SubarraysWriter::WriteNestedSubarrayImpl(yardl::DynamicNDArray, 2>> const& value) { + yardl::binary::WriteDynamicNDArray, 2>, yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>>(stream_, value); +} + +void SubarraysWriter::WriteDynamicWithFixedVectorSubarrayImpl(yardl::DynamicNDArray> const& value) { + yardl::binary::WriteDynamicNDArray, yardl::binary::WriteArray>(stream_, value); +} + +void SubarraysWriter::WriteGenericSubarrayImpl(test_model::Image> const& value) { + test_model::binary::WriteImage, yardl::binary::WriteFixedNDArray>(stream_, value); +} + +void SubarraysWriter::Flush() { + stream_.Flush(); } void SubarraysWriter::CloseImpl() { @@ -3584,6 +4677,117 @@ void SubarraysReader::CloseImpl() { stream_.VerifyFinished(); } +void SubarraysIndexedWriter::WriteDynamicWithFixedIntSubarrayImpl(yardl::DynamicNDArray> const& value) { + step_index_.set_step_offset("DynamicWithFixedIntSubarray", stream_.Pos()); + yardl::binary::WriteDynamicNDArray, yardl::binary::WriteFixedNDArray>(stream_, value); +} + +void SubarraysIndexedWriter::WriteDynamicWithFixedFloatSubarrayImpl(yardl::DynamicNDArray> const& value) { + step_index_.set_step_offset("DynamicWithFixedFloatSubarray", stream_.Pos()); + yardl::binary::WriteDynamicNDArray, yardl::binary::WriteFixedNDArray>(stream_, value); +} + +void SubarraysIndexedWriter::WriteKnownDimCountWithFixedIntSubarrayImpl(yardl::NDArray, 1> const& value) { + step_index_.set_step_offset("KnownDimCountWithFixedIntSubarray", stream_.Pos()); + yardl::binary::WriteNDArray, yardl::binary::WriteFixedNDArray, 1>(stream_, value); +} + +void SubarraysIndexedWriter::WriteKnownDimCountWithFixedFloatSubarrayImpl(yardl::NDArray, 1> const& value) { + step_index_.set_step_offset("KnownDimCountWithFixedFloatSubarray", stream_.Pos()); + yardl::binary::WriteNDArray, yardl::binary::WriteFixedNDArray, 1>(stream_, value); +} + +void SubarraysIndexedWriter::WriteFixedWithFixedIntSubarrayImpl(yardl::FixedNDArray, 2> const& value) { + step_index_.set_step_offset("FixedWithFixedIntSubarray", stream_.Pos()); + yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>(stream_, value); +} + +void SubarraysIndexedWriter::WriteFixedWithFixedFloatSubarrayImpl(yardl::FixedNDArray, 2> const& value) { + step_index_.set_step_offset("FixedWithFixedFloatSubarray", stream_.Pos()); + yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>(stream_, value); +} + +void SubarraysIndexedWriter::WriteNestedSubarrayImpl(yardl::DynamicNDArray, 2>> const& value) { + step_index_.set_step_offset("NestedSubarray", stream_.Pos()); + yardl::binary::WriteDynamicNDArray, 2>, yardl::binary::WriteFixedNDArray, yardl::binary::WriteFixedNDArray, 2>>(stream_, value); +} + +void SubarraysIndexedWriter::WriteDynamicWithFixedVectorSubarrayImpl(yardl::DynamicNDArray> const& value) { + step_index_.set_step_offset("DynamicWithFixedVectorSubarray", stream_.Pos()); + yardl::binary::WriteDynamicNDArray, yardl::binary::WriteArray>(stream_, value); +} + +void SubarraysIndexedWriter::WriteGenericSubarrayImpl(test_model::Image> const& value) { + step_index_.set_step_offset("GenericSubarray", stream_.Pos()); + test_model::binary::WriteImage, yardl::binary::WriteFixedNDArray>(stream_, value); +} + +void SubarraysIndexedWriter::Flush() { + stream_.Flush(); +} + +void SubarraysIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void SubarraysIndexedReader::ReadDynamicWithFixedIntSubarrayImpl(yardl::DynamicNDArray>& value) { + auto pos = step_index_.get_step_offset("DynamicWithFixedIntSubarray"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray, yardl::binary::ReadFixedNDArray>(stream_, value); +} + +void SubarraysIndexedReader::ReadDynamicWithFixedFloatSubarrayImpl(yardl::DynamicNDArray>& value) { + auto pos = step_index_.get_step_offset("DynamicWithFixedFloatSubarray"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray, yardl::binary::ReadFixedNDArray>(stream_, value); +} + +void SubarraysIndexedReader::ReadKnownDimCountWithFixedIntSubarrayImpl(yardl::NDArray, 1>& value) { + auto pos = step_index_.get_step_offset("KnownDimCountWithFixedIntSubarray"); + stream_.Seek(pos); + yardl::binary::ReadNDArray, yardl::binary::ReadFixedNDArray, 1>(stream_, value); +} + +void SubarraysIndexedReader::ReadKnownDimCountWithFixedFloatSubarrayImpl(yardl::NDArray, 1>& value) { + auto pos = step_index_.get_step_offset("KnownDimCountWithFixedFloatSubarray"); + stream_.Seek(pos); + yardl::binary::ReadNDArray, yardl::binary::ReadFixedNDArray, 1>(stream_, value); +} + +void SubarraysIndexedReader::ReadFixedWithFixedIntSubarrayImpl(yardl::FixedNDArray, 2>& value) { + auto pos = step_index_.get_step_offset("FixedWithFixedIntSubarray"); + stream_.Seek(pos); + yardl::binary::ReadFixedNDArray, yardl::binary::ReadFixedNDArray, 2>(stream_, value); +} + +void SubarraysIndexedReader::ReadFixedWithFixedFloatSubarrayImpl(yardl::FixedNDArray, 2>& value) { + auto pos = step_index_.get_step_offset("FixedWithFixedFloatSubarray"); + stream_.Seek(pos); + yardl::binary::ReadFixedNDArray, yardl::binary::ReadFixedNDArray, 2>(stream_, value); +} + +void SubarraysIndexedReader::ReadNestedSubarrayImpl(yardl::DynamicNDArray, 2>>& value) { + auto pos = step_index_.get_step_offset("NestedSubarray"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray, 2>, yardl::binary::ReadFixedNDArray, yardl::binary::ReadFixedNDArray, 2>>(stream_, value); +} + +void SubarraysIndexedReader::ReadDynamicWithFixedVectorSubarrayImpl(yardl::DynamicNDArray>& value) { + auto pos = step_index_.get_step_offset("DynamicWithFixedVectorSubarray"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray, yardl::binary::ReadArray>(stream_, value); +} + +void SubarraysIndexedReader::ReadGenericSubarrayImpl(test_model::Image>& value) { + auto pos = step_index_.get_step_offset("GenericSubarray"); + stream_.Seek(pos); + test_model::binary::ReadImage, yardl::binary::ReadFixedNDArray>(stream_, value); +} + +void SubarraysIndexedReader::CloseImpl() { +} + void SubarraysInRecordsWriter::WriteWithFixedSubarraysImpl(yardl::DynamicNDArray const& value) { yardl::binary::WriteDynamicNDArray(stream_, value); } @@ -3612,6 +4816,40 @@ void SubarraysInRecordsReader::CloseImpl() { stream_.VerifyFinished(); } +void SubarraysInRecordsIndexedWriter::WriteWithFixedSubarraysImpl(yardl::DynamicNDArray const& value) { + step_index_.set_step_offset("WithFixedSubarrays", stream_.Pos()); + yardl::binary::WriteDynamicNDArray(stream_, value); +} + +void SubarraysInRecordsIndexedWriter::WriteWithVlenSubarraysImpl(yardl::DynamicNDArray const& value) { + step_index_.set_step_offset("WithVlenSubarrays", stream_.Pos()); + yardl::binary::WriteDynamicNDArray(stream_, value); +} + +void SubarraysInRecordsIndexedWriter::Flush() { + stream_.Flush(); +} + +void SubarraysInRecordsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void SubarraysInRecordsIndexedReader::ReadWithFixedSubarraysImpl(yardl::DynamicNDArray& value) { + auto pos = step_index_.get_step_offset("WithFixedSubarrays"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray(stream_, value); +} + +void SubarraysInRecordsIndexedReader::ReadWithVlenSubarraysImpl(yardl::DynamicNDArray& value) { + auto pos = step_index_.get_step_offset("WithVlenSubarrays"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray(stream_, value); +} + +void SubarraysInRecordsIndexedReader::CloseImpl() { +} + void NDArraysWriter::WriteIntsImpl(yardl::NDArray const& value) { yardl::binary::WriteNDArray(stream_, value); } @@ -3664,6 +4902,73 @@ void NDArraysReader::CloseImpl() { stream_.VerifyFinished(); } +void NDArraysIndexedWriter::WriteIntsImpl(yardl::NDArray const& value) { + step_index_.set_step_offset("Ints", stream_.Pos()); + yardl::binary::WriteNDArray(stream_, value); +} + +void NDArraysIndexedWriter::WriteSimpleRecordArrayImpl(yardl::NDArray const& value) { + step_index_.set_step_offset("SimpleRecordArray", stream_.Pos()); + yardl::binary::WriteNDArray(stream_, value); +} + +void NDArraysIndexedWriter::WriteRecordWithVlensArrayImpl(yardl::NDArray const& value) { + step_index_.set_step_offset("RecordWithVlensArray", stream_.Pos()); + yardl::binary::WriteNDArray(stream_, value); +} + +void NDArraysIndexedWriter::WriteRecordWithNDArraysImpl(test_model::RecordWithNDArrays const& value) { + step_index_.set_step_offset("RecordWithNDArrays", stream_.Pos()); + test_model::binary::WriteRecordWithNDArrays(stream_, value); +} + +void NDArraysIndexedWriter::WriteNamedArrayImpl(test_model::NamedNDArray const& value) { + step_index_.set_step_offset("NamedArray", stream_.Pos()); + test_model::binary::WriteNamedNDArray(stream_, value); +} + +void NDArraysIndexedWriter::Flush() { + stream_.Flush(); +} + +void NDArraysIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void NDArraysIndexedReader::ReadIntsImpl(yardl::NDArray& value) { + auto pos = step_index_.get_step_offset("Ints"); + stream_.Seek(pos); + yardl::binary::ReadNDArray(stream_, value); +} + +void NDArraysIndexedReader::ReadSimpleRecordArrayImpl(yardl::NDArray& value) { + auto pos = step_index_.get_step_offset("SimpleRecordArray"); + stream_.Seek(pos); + yardl::binary::ReadNDArray(stream_, value); +} + +void NDArraysIndexedReader::ReadRecordWithVlensArrayImpl(yardl::NDArray& value) { + auto pos = step_index_.get_step_offset("RecordWithVlensArray"); + stream_.Seek(pos); + yardl::binary::ReadNDArray(stream_, value); +} + +void NDArraysIndexedReader::ReadRecordWithNDArraysImpl(test_model::RecordWithNDArrays& value) { + auto pos = step_index_.get_step_offset("RecordWithNDArrays"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithNDArrays(stream_, value); +} + +void NDArraysIndexedReader::ReadNamedArrayImpl(test_model::NamedNDArray& value) { + auto pos = step_index_.get_step_offset("NamedArray"); + stream_.Seek(pos); + test_model::binary::ReadNamedNDArray(stream_, value); +} + +void NDArraysIndexedReader::CloseImpl() { +} + void NDArraysSingleDimensionWriter::WriteIntsImpl(yardl::NDArray const& value) { yardl::binary::WriteNDArray(stream_, value); } @@ -3708,6 +5013,62 @@ void NDArraysSingleDimensionReader::CloseImpl() { stream_.VerifyFinished(); } +void NDArraysSingleDimensionIndexedWriter::WriteIntsImpl(yardl::NDArray const& value) { + step_index_.set_step_offset("Ints", stream_.Pos()); + yardl::binary::WriteNDArray(stream_, value); +} + +void NDArraysSingleDimensionIndexedWriter::WriteSimpleRecordArrayImpl(yardl::NDArray const& value) { + step_index_.set_step_offset("SimpleRecordArray", stream_.Pos()); + yardl::binary::WriteNDArray(stream_, value); +} + +void NDArraysSingleDimensionIndexedWriter::WriteRecordWithVlensArrayImpl(yardl::NDArray const& value) { + step_index_.set_step_offset("RecordWithVlensArray", stream_.Pos()); + yardl::binary::WriteNDArray(stream_, value); +} + +void NDArraysSingleDimensionIndexedWriter::WriteRecordWithNDArraysImpl(test_model::RecordWithNDArraysSingleDimension const& value) { + step_index_.set_step_offset("RecordWithNDArrays", stream_.Pos()); + test_model::binary::WriteRecordWithNDArraysSingleDimension(stream_, value); +} + +void NDArraysSingleDimensionIndexedWriter::Flush() { + stream_.Flush(); +} + +void NDArraysSingleDimensionIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void NDArraysSingleDimensionIndexedReader::ReadIntsImpl(yardl::NDArray& value) { + auto pos = step_index_.get_step_offset("Ints"); + stream_.Seek(pos); + yardl::binary::ReadNDArray(stream_, value); +} + +void NDArraysSingleDimensionIndexedReader::ReadSimpleRecordArrayImpl(yardl::NDArray& value) { + auto pos = step_index_.get_step_offset("SimpleRecordArray"); + stream_.Seek(pos); + yardl::binary::ReadNDArray(stream_, value); +} + +void NDArraysSingleDimensionIndexedReader::ReadRecordWithVlensArrayImpl(yardl::NDArray& value) { + auto pos = step_index_.get_step_offset("RecordWithVlensArray"); + stream_.Seek(pos); + yardl::binary::ReadNDArray(stream_, value); +} + +void NDArraysSingleDimensionIndexedReader::ReadRecordWithNDArraysImpl(test_model::RecordWithNDArraysSingleDimension& value) { + auto pos = step_index_.get_step_offset("RecordWithNDArrays"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithNDArraysSingleDimension(stream_, value); +} + +void NDArraysSingleDimensionIndexedReader::CloseImpl() { +} + void DynamicNDArraysWriter::WriteIntsImpl(yardl::DynamicNDArray const& value) { yardl::binary::WriteDynamicNDArray(stream_, value); } @@ -3752,6 +5113,62 @@ void DynamicNDArraysReader::CloseImpl() { stream_.VerifyFinished(); } +void DynamicNDArraysIndexedWriter::WriteIntsImpl(yardl::DynamicNDArray const& value) { + step_index_.set_step_offset("Ints", stream_.Pos()); + yardl::binary::WriteDynamicNDArray(stream_, value); +} + +void DynamicNDArraysIndexedWriter::WriteSimpleRecordArrayImpl(yardl::DynamicNDArray const& value) { + step_index_.set_step_offset("SimpleRecordArray", stream_.Pos()); + yardl::binary::WriteDynamicNDArray(stream_, value); +} + +void DynamicNDArraysIndexedWriter::WriteRecordWithVlensArrayImpl(yardl::DynamicNDArray const& value) { + step_index_.set_step_offset("RecordWithVlensArray", stream_.Pos()); + yardl::binary::WriteDynamicNDArray(stream_, value); +} + +void DynamicNDArraysIndexedWriter::WriteRecordWithDynamicNDArraysImpl(test_model::RecordWithDynamicNDArrays const& value) { + step_index_.set_step_offset("RecordWithDynamicNDArrays", stream_.Pos()); + test_model::binary::WriteRecordWithDynamicNDArrays(stream_, value); +} + +void DynamicNDArraysIndexedWriter::Flush() { + stream_.Flush(); +} + +void DynamicNDArraysIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void DynamicNDArraysIndexedReader::ReadIntsImpl(yardl::DynamicNDArray& value) { + auto pos = step_index_.get_step_offset("Ints"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray(stream_, value); +} + +void DynamicNDArraysIndexedReader::ReadSimpleRecordArrayImpl(yardl::DynamicNDArray& value) { + auto pos = step_index_.get_step_offset("SimpleRecordArray"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray(stream_, value); +} + +void DynamicNDArraysIndexedReader::ReadRecordWithVlensArrayImpl(yardl::DynamicNDArray& value) { + auto pos = step_index_.get_step_offset("RecordWithVlensArray"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray(stream_, value); +} + +void DynamicNDArraysIndexedReader::ReadRecordWithDynamicNDArraysImpl(test_model::RecordWithDynamicNDArrays& value) { + auto pos = step_index_.get_step_offset("RecordWithDynamicNDArrays"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithDynamicNDArrays(stream_, value); +} + +void DynamicNDArraysIndexedReader::CloseImpl() { +} + void MultiDArraysWriter::WriteImagesImpl(yardl::NDArray const& value) { yardl::binary::WriteBlock, yardl::binary::WriteNDArray>(stream_, value); } @@ -3814,6 +5231,150 @@ void MultiDArraysReader::CloseImpl() { stream_.VerifyFinished(); } +void MultiDArraysIndexedWriter::WriteImagesImpl(yardl::NDArray const& value) { + step_index_.set_step_offset("Images", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, yardl::binary::WriteNDArray>(stream_, value, item_offset); + step_index_.add_stream_offset("Images", item_offset); +} + +void MultiDArraysIndexedWriter::WriteImagesImpl(std::vector> const& values) { + step_index_.set_step_offset("Images", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, yardl::binary::WriteNDArray>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("Images", item_offsets); +} + +void MultiDArraysIndexedWriter::EndImagesImpl() { + step_index_.set_step_offset("Images", stream_.Pos()); + step_index_.add_stream_offsets("Images", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void MultiDArraysIndexedWriter::WriteFramesImpl(yardl::FixedNDArray const& value) { + step_index_.set_step_offset("Frames", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, yardl::binary::WriteFixedNDArray>(stream_, value, item_offset); + step_index_.add_stream_offset("Frames", item_offset); +} + +void MultiDArraysIndexedWriter::WriteFramesImpl(std::vector> const& values) { + step_index_.set_step_offset("Frames", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, yardl::binary::WriteFixedNDArray>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("Frames", item_offsets); +} + +void MultiDArraysIndexedWriter::EndFramesImpl() { + step_index_.set_step_offset("Frames", stream_.Pos()); + step_index_.add_stream_offsets("Frames", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void MultiDArraysIndexedWriter::Flush() { + stream_.Flush(); +} + +void MultiDArraysIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool MultiDArraysIndexedReader::ReadImagesImpl(yardl::NDArray& value) { + if (!step_index_.offset_within_stream("Images", "Frames", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Images")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool MultiDArraysIndexedReader::ReadImagesImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("Images", "Frames", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Images")); + } + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool MultiDArraysIndexedReader::ReadImagesImpl(yardl::NDArray& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Images", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool MultiDArraysIndexedReader::ReadImagesImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Images", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t MultiDArraysIndexedReader::CountImagesImpl() { + return step_index_.get_stream_count("Images"); +} + +bool MultiDArraysIndexedReader::ReadFramesImpl(yardl::FixedNDArray& value) { + if (!step_index_.offset_within_stream("Frames", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Frames")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool MultiDArraysIndexedReader::ReadFramesImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("Frames", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Frames")); + } + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool MultiDArraysIndexedReader::ReadFramesImpl(yardl::FixedNDArray& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Frames", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool MultiDArraysIndexedReader::ReadFramesImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Frames", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t MultiDArraysIndexedReader::CountFramesImpl() { + return step_index_.get_stream_count("Frames"); +} + +void MultiDArraysIndexedReader::CloseImpl() { +} + void ComplexArraysWriter::WriteFloatsImpl(yardl::DynamicNDArray> const& value) { yardl::binary::WriteDynamicNDArray, yardl::binary::WriteFloatingPoint>(stream_, value); } @@ -3826,72 +5387,173 @@ void ComplexArraysWriter::Flush() { stream_.Flush(); } -void ComplexArraysWriter::CloseImpl() { - stream_.Flush(); +void ComplexArraysWriter::CloseImpl() { + stream_.Flush(); +} + +void ComplexArraysReader::ReadFloatsImpl(yardl::DynamicNDArray>& value) { + yardl::binary::ReadDynamicNDArray, yardl::binary::ReadFloatingPoint>(stream_, value); +} + +void ComplexArraysReader::ReadDoublesImpl(yardl::NDArray, 2>& value) { + yardl::binary::ReadNDArray, yardl::binary::ReadFloatingPoint, 2>(stream_, value); +} + +void ComplexArraysReader::CloseImpl() { + stream_.VerifyFinished(); +} + +void ComplexArraysIndexedWriter::WriteFloatsImpl(yardl::DynamicNDArray> const& value) { + step_index_.set_step_offset("Floats", stream_.Pos()); + yardl::binary::WriteDynamicNDArray, yardl::binary::WriteFloatingPoint>(stream_, value); +} + +void ComplexArraysIndexedWriter::WriteDoublesImpl(yardl::NDArray, 2> const& value) { + step_index_.set_step_offset("Doubles", stream_.Pos()); + yardl::binary::WriteNDArray, yardl::binary::WriteFloatingPoint, 2>(stream_, value); +} + +void ComplexArraysIndexedWriter::Flush() { + stream_.Flush(); +} + +void ComplexArraysIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void ComplexArraysIndexedReader::ReadFloatsImpl(yardl::DynamicNDArray>& value) { + auto pos = step_index_.get_step_offset("Floats"); + stream_.Seek(pos); + yardl::binary::ReadDynamicNDArray, yardl::binary::ReadFloatingPoint>(stream_, value); +} + +void ComplexArraysIndexedReader::ReadDoublesImpl(yardl::NDArray, 2>& value) { + auto pos = step_index_.get_step_offset("Doubles"); + stream_.Seek(pos); + yardl::binary::ReadNDArray, yardl::binary::ReadFloatingPoint, 2>(stream_, value); +} + +void ComplexArraysIndexedReader::CloseImpl() { +} + +void MapsWriter::WriteStringToIntImpl(std::unordered_map const& value) { + yardl::binary::WriteMap(stream_, value); +} + +void MapsWriter::WriteIntToStringImpl(std::unordered_map const& value) { + yardl::binary::WriteMap(stream_, value); +} + +void MapsWriter::WriteStringToUnionImpl(std::unordered_map> const& value) { + yardl::binary::WriteMap, yardl::binary::WriteString, WriteUnion>(stream_, value); +} + +void MapsWriter::WriteAliasedGenericImpl(basic_types::AliasedMap const& value) { + basic_types::binary::WriteAliasedMap(stream_, value); +} + +void MapsWriter::WriteRecordsImpl(std::vector const& value) { + yardl::binary::WriteVector(stream_, value); +} + +void MapsWriter::Flush() { + stream_.Flush(); +} + +void MapsWriter::CloseImpl() { + stream_.Flush(); +} + +void MapsReader::ReadStringToIntImpl(std::unordered_map& value) { + yardl::binary::ReadMap(stream_, value); +} + +void MapsReader::ReadIntToStringImpl(std::unordered_map& value) { + yardl::binary::ReadMap(stream_, value); +} + +void MapsReader::ReadStringToUnionImpl(std::unordered_map>& value) { + yardl::binary::ReadMap, yardl::binary::ReadString, ReadUnion>(stream_, value); } -void ComplexArraysReader::ReadFloatsImpl(yardl::DynamicNDArray>& value) { - yardl::binary::ReadDynamicNDArray, yardl::binary::ReadFloatingPoint>(stream_, value); +void MapsReader::ReadAliasedGenericImpl(basic_types::AliasedMap& value) { + basic_types::binary::ReadAliasedMap(stream_, value); } -void ComplexArraysReader::ReadDoublesImpl(yardl::NDArray, 2>& value) { - yardl::binary::ReadNDArray, yardl::binary::ReadFloatingPoint, 2>(stream_, value); +void MapsReader::ReadRecordsImpl(std::vector& value) { + yardl::binary::ReadVector(stream_, value); } -void ComplexArraysReader::CloseImpl() { +void MapsReader::CloseImpl() { stream_.VerifyFinished(); } -void MapsWriter::WriteStringToIntImpl(std::unordered_map const& value) { +void MapsIndexedWriter::WriteStringToIntImpl(std::unordered_map const& value) { + step_index_.set_step_offset("StringToInt", stream_.Pos()); yardl::binary::WriteMap(stream_, value); } -void MapsWriter::WriteIntToStringImpl(std::unordered_map const& value) { +void MapsIndexedWriter::WriteIntToStringImpl(std::unordered_map const& value) { + step_index_.set_step_offset("IntToString", stream_.Pos()); yardl::binary::WriteMap(stream_, value); } -void MapsWriter::WriteStringToUnionImpl(std::unordered_map> const& value) { +void MapsIndexedWriter::WriteStringToUnionImpl(std::unordered_map> const& value) { + step_index_.set_step_offset("StringToUnion", stream_.Pos()); yardl::binary::WriteMap, yardl::binary::WriteString, WriteUnion>(stream_, value); } -void MapsWriter::WriteAliasedGenericImpl(basic_types::AliasedMap const& value) { +void MapsIndexedWriter::WriteAliasedGenericImpl(basic_types::AliasedMap const& value) { + step_index_.set_step_offset("AliasedGeneric", stream_.Pos()); basic_types::binary::WriteAliasedMap(stream_, value); } -void MapsWriter::WriteRecordsImpl(std::vector const& value) { +void MapsIndexedWriter::WriteRecordsImpl(std::vector const& value) { + step_index_.set_step_offset("Records", stream_.Pos()); yardl::binary::WriteVector(stream_, value); } -void MapsWriter::Flush() { +void MapsIndexedWriter::Flush() { stream_.Flush(); } -void MapsWriter::CloseImpl() { +void MapsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); stream_.Flush(); } -void MapsReader::ReadStringToIntImpl(std::unordered_map& value) { +void MapsIndexedReader::ReadStringToIntImpl(std::unordered_map& value) { + auto pos = step_index_.get_step_offset("StringToInt"); + stream_.Seek(pos); yardl::binary::ReadMap(stream_, value); } -void MapsReader::ReadIntToStringImpl(std::unordered_map& value) { +void MapsIndexedReader::ReadIntToStringImpl(std::unordered_map& value) { + auto pos = step_index_.get_step_offset("IntToString"); + stream_.Seek(pos); yardl::binary::ReadMap(stream_, value); } -void MapsReader::ReadStringToUnionImpl(std::unordered_map>& value) { +void MapsIndexedReader::ReadStringToUnionImpl(std::unordered_map>& value) { + auto pos = step_index_.get_step_offset("StringToUnion"); + stream_.Seek(pos); yardl::binary::ReadMap, yardl::binary::ReadString, ReadUnion>(stream_, value); } -void MapsReader::ReadAliasedGenericImpl(basic_types::AliasedMap& value) { +void MapsIndexedReader::ReadAliasedGenericImpl(basic_types::AliasedMap& value) { + auto pos = step_index_.get_step_offset("AliasedGeneric"); + stream_.Seek(pos); basic_types::binary::ReadAliasedMap(stream_, value); } -void MapsReader::ReadRecordsImpl(std::vector& value) { +void MapsIndexedReader::ReadRecordsImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("Records"); + stream_.Seek(pos); yardl::binary::ReadVector(stream_, value); } -void MapsReader::CloseImpl() { - stream_.VerifyFinished(); +void MapsIndexedReader::CloseImpl() { } void UnionsWriter::WriteIntOrSimpleRecordImpl(std::variant const& value) { @@ -3938,6 +5600,62 @@ void UnionsReader::CloseImpl() { stream_.VerifyFinished(); } +void UnionsIndexedWriter::WriteIntOrSimpleRecordImpl(std::variant const& value) { + step_index_.set_step_offset("IntOrSimpleRecord", stream_.Pos()); + WriteUnion(stream_, value); +} + +void UnionsIndexedWriter::WriteIntOrRecordWithVlensImpl(std::variant const& value) { + step_index_.set_step_offset("IntOrRecordWithVlens", stream_.Pos()); + WriteUnion(stream_, value); +} + +void UnionsIndexedWriter::WriteMonosotateOrIntOrSimpleRecordImpl(std::variant const& value) { + step_index_.set_step_offset("MonosotateOrIntOrSimpleRecord", stream_.Pos()); + WriteUnion(stream_, value); +} + +void UnionsIndexedWriter::WriteRecordWithUnionsImpl(basic_types::RecordWithUnions const& value) { + step_index_.set_step_offset("RecordWithUnions", stream_.Pos()); + basic_types::binary::WriteRecordWithUnions(stream_, value); +} + +void UnionsIndexedWriter::Flush() { + stream_.Flush(); +} + +void UnionsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void UnionsIndexedReader::ReadIntOrSimpleRecordImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("IntOrSimpleRecord"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void UnionsIndexedReader::ReadIntOrRecordWithVlensImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("IntOrRecordWithVlens"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void UnionsIndexedReader::ReadMonosotateOrIntOrSimpleRecordImpl(std::variant& value) { + auto pos = step_index_.get_step_offset("MonosotateOrIntOrSimpleRecord"); + stream_.Seek(pos); + ReadUnion(stream_, value); +} + +void UnionsIndexedReader::ReadRecordWithUnionsImpl(basic_types::RecordWithUnions& value) { + auto pos = step_index_.get_step_offset("RecordWithUnions"); + stream_.Seek(pos); + basic_types::binary::ReadRecordWithUnions(stream_, value); +} + +void UnionsIndexedReader::CloseImpl() { +} + void StreamsOfUnionsWriter::WriteIntOrSimpleRecordImpl(std::variant const& value) { yardl::binary::WriteBlock, WriteUnion>(stream_, value); } @@ -4025,6 +5743,216 @@ void StreamsOfUnionsReader::CloseImpl() { stream_.VerifyFinished(); } +void StreamsOfUnionsIndexedWriter::WriteIntOrSimpleRecordImpl(std::variant const& value) { + step_index_.set_step_offset("IntOrSimpleRecord", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + step_index_.add_stream_offset("IntOrSimpleRecord", item_offset); +} + +void StreamsOfUnionsIndexedWriter::WriteIntOrSimpleRecordImpl(std::vector> const& values) { + step_index_.set_step_offset("IntOrSimpleRecord", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("IntOrSimpleRecord", item_offsets); +} + +void StreamsOfUnionsIndexedWriter::EndIntOrSimpleRecordImpl() { + step_index_.set_step_offset("IntOrSimpleRecord", stream_.Pos()); + step_index_.add_stream_offsets("IntOrSimpleRecord", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void StreamsOfUnionsIndexedWriter::WriteNullableIntOrSimpleRecordImpl(std::variant const& value) { + step_index_.set_step_offset("NullableIntOrSimpleRecord", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + step_index_.add_stream_offset("NullableIntOrSimpleRecord", item_offset); +} + +void StreamsOfUnionsIndexedWriter::WriteNullableIntOrSimpleRecordImpl(std::vector> const& values) { + step_index_.set_step_offset("NullableIntOrSimpleRecord", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("NullableIntOrSimpleRecord", item_offsets); +} + +void StreamsOfUnionsIndexedWriter::EndNullableIntOrSimpleRecordImpl() { + step_index_.set_step_offset("NullableIntOrSimpleRecord", stream_.Pos()); + step_index_.add_stream_offsets("NullableIntOrSimpleRecord", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void StreamsOfUnionsIndexedWriter::WriteManyCasesImpl(std::variant const& value) { + step_index_.set_step_offset("ManyCases", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, WriteUnion>(stream_, value, item_offset); + step_index_.add_stream_offset("ManyCases", item_offset); +} + +void StreamsOfUnionsIndexedWriter::WriteManyCasesImpl(std::vector> const& values) { + step_index_.set_step_offset("ManyCases", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, WriteUnion>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("ManyCases", item_offsets); +} + +void StreamsOfUnionsIndexedWriter::EndManyCasesImpl() { + step_index_.set_step_offset("ManyCases", stream_.Pos()); + step_index_.add_stream_offsets("ManyCases", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void StreamsOfUnionsIndexedWriter::Flush() { + stream_.Flush(); +} + +void StreamsOfUnionsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool StreamsOfUnionsIndexedReader::ReadIntOrSimpleRecordImpl(std::variant& value) { + if (!step_index_.offset_within_stream("IntOrSimpleRecord", "NullableIntOrSimpleRecord", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntOrSimpleRecord")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfUnionsIndexedReader::ReadIntOrSimpleRecordImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("IntOrSimpleRecord", "NullableIntOrSimpleRecord", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntOrSimpleRecord")); + } + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool StreamsOfUnionsIndexedReader::ReadIntOrSimpleRecordImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntOrSimpleRecord", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfUnionsIndexedReader::ReadIntOrSimpleRecordImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntOrSimpleRecord", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StreamsOfUnionsIndexedReader::CountIntOrSimpleRecordImpl() { + return step_index_.get_stream_count("IntOrSimpleRecord"); +} + +bool StreamsOfUnionsIndexedReader::ReadNullableIntOrSimpleRecordImpl(std::variant& value) { + if (!step_index_.offset_within_stream("NullableIntOrSimpleRecord", "ManyCases", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("NullableIntOrSimpleRecord")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfUnionsIndexedReader::ReadNullableIntOrSimpleRecordImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("NullableIntOrSimpleRecord", "ManyCases", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("NullableIntOrSimpleRecord")); + } + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool StreamsOfUnionsIndexedReader::ReadNullableIntOrSimpleRecordImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("NullableIntOrSimpleRecord", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfUnionsIndexedReader::ReadNullableIntOrSimpleRecordImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("NullableIntOrSimpleRecord", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StreamsOfUnionsIndexedReader::CountNullableIntOrSimpleRecordImpl() { + return step_index_.get_stream_count("NullableIntOrSimpleRecord"); +} + +bool StreamsOfUnionsIndexedReader::ReadManyCasesImpl(std::variant& value) { + if (!step_index_.offset_within_stream("ManyCases", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("ManyCases")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfUnionsIndexedReader::ReadManyCasesImpl(std::vector>& values) { + if (!step_index_.offset_within_stream("ManyCases", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("ManyCases")); + } + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool StreamsOfUnionsIndexedReader::ReadManyCasesImpl(std::variant& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("ManyCases", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, ReadUnion>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfUnionsIndexedReader::ReadManyCasesImpl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("ManyCases", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, ReadUnion>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StreamsOfUnionsIndexedReader::CountManyCasesImpl() { + return step_index_.get_stream_count("ManyCases"); +} + +void StreamsOfUnionsIndexedReader::CloseImpl() { +} + void EnumsWriter::WriteSingleImpl(test_model::Fruits const& value) { test_model::binary::WriteFruits(stream_, value); } @@ -4057,78 +5985,278 @@ void EnumsReader::ReadVecImpl(std::vector& value) { yardl::binary::ReadVector(stream_, value); } -void EnumsReader::ReadSizeImpl(test_model::SizeBasedEnum& value) { - yardl::binary::ReadEnum(stream_, value); +void EnumsReader::ReadSizeImpl(test_model::SizeBasedEnum& value) { + yardl::binary::ReadEnum(stream_, value); +} + +void EnumsReader::ReadRecImpl(test_model::RecordWithEnums& value) { + test_model::binary::ReadRecordWithEnums(stream_, value); +} + +void EnumsReader::CloseImpl() { + stream_.VerifyFinished(); +} + +void EnumsIndexedWriter::WriteSingleImpl(test_model::Fruits const& value) { + step_index_.set_step_offset("Single", stream_.Pos()); + test_model::binary::WriteFruits(stream_, value); +} + +void EnumsIndexedWriter::WriteVecImpl(std::vector const& value) { + step_index_.set_step_offset("Vec", stream_.Pos()); + yardl::binary::WriteVector(stream_, value); +} + +void EnumsIndexedWriter::WriteSizeImpl(test_model::SizeBasedEnum const& value) { + step_index_.set_step_offset("Size", stream_.Pos()); + yardl::binary::WriteEnum(stream_, value); +} + +void EnumsIndexedWriter::WriteRecImpl(test_model::RecordWithEnums const& value) { + step_index_.set_step_offset("Rec", stream_.Pos()); + test_model::binary::WriteRecordWithEnums(stream_, value); +} + +void EnumsIndexedWriter::Flush() { + stream_.Flush(); +} + +void EnumsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void EnumsIndexedReader::ReadSingleImpl(test_model::Fruits& value) { + auto pos = step_index_.get_step_offset("Single"); + stream_.Seek(pos); + test_model::binary::ReadFruits(stream_, value); +} + +void EnumsIndexedReader::ReadVecImpl(std::vector& value) { + auto pos = step_index_.get_step_offset("Vec"); + stream_.Seek(pos); + yardl::binary::ReadVector(stream_, value); +} + +void EnumsIndexedReader::ReadSizeImpl(test_model::SizeBasedEnum& value) { + auto pos = step_index_.get_step_offset("Size"); + stream_.Seek(pos); + yardl::binary::ReadEnum(stream_, value); +} + +void EnumsIndexedReader::ReadRecImpl(test_model::RecordWithEnums& value) { + auto pos = step_index_.get_step_offset("Rec"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithEnums(stream_, value); +} + +void EnumsIndexedReader::CloseImpl() { +} + +void FlagsWriter::WriteDaysImpl(test_model::DaysOfWeek const& value) { + yardl::binary::WriteBlock(stream_, value); +} + +void FlagsWriter::WriteDaysImpl(std::vector const& values) { + if (!values.empty()) { + yardl::binary::WriteVector(stream_, values); + } +} + +void FlagsWriter::EndDaysImpl() { + yardl::binary::WriteInteger(stream_, 0U); +} + +void FlagsWriter::WriteFormatsImpl(test_model::TextFormat const& value) { + yardl::binary::WriteBlock(stream_, value); +} + +void FlagsWriter::WriteFormatsImpl(std::vector const& values) { + if (!values.empty()) { + yardl::binary::WriteVector(stream_, values); + } +} + +void FlagsWriter::EndFormatsImpl() { + yardl::binary::WriteInteger(stream_, 0U); +} + +void FlagsWriter::Flush() { + stream_.Flush(); +} + +void FlagsWriter::CloseImpl() { + stream_.Flush(); +} + +bool FlagsReader::ReadDaysImpl(test_model::DaysOfWeek& value) { + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool FlagsReader::ReadDaysImpl(std::vector& values) { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool FlagsReader::ReadFormatsImpl(test_model::TextFormat& value) { + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; } -void EnumsReader::ReadRecImpl(test_model::RecordWithEnums& value) { - test_model::binary::ReadRecordWithEnums(stream_, value); +bool FlagsReader::ReadFormatsImpl(std::vector& values) { + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; } -void EnumsReader::CloseImpl() { +void FlagsReader::CloseImpl() { stream_.VerifyFinished(); } -void FlagsWriter::WriteDaysImpl(test_model::DaysOfWeek const& value) { - yardl::binary::WriteBlock(stream_, value); +void FlagsIndexedWriter::WriteDaysImpl(test_model::DaysOfWeek const& value) { + step_index_.set_step_offset("Days", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("Days", item_offset); } -void FlagsWriter::WriteDaysImpl(std::vector const& values) { +void FlagsIndexedWriter::WriteDaysImpl(std::vector const& values) { + step_index_.set_step_offset("Days", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); if (!values.empty()) { - yardl::binary::WriteVector(stream_, values); + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); } + step_index_.add_stream_offsets("Days", item_offsets); } -void FlagsWriter::EndDaysImpl() { +void FlagsIndexedWriter::EndDaysImpl() { + step_index_.set_step_offset("Days", stream_.Pos()); + step_index_.add_stream_offsets("Days", std::vector{}); yardl::binary::WriteInteger(stream_, 0U); } -void FlagsWriter::WriteFormatsImpl(test_model::TextFormat const& value) { - yardl::binary::WriteBlock(stream_, value); +void FlagsIndexedWriter::WriteFormatsImpl(test_model::TextFormat const& value) { + step_index_.set_step_offset("Formats", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("Formats", item_offset); } -void FlagsWriter::WriteFormatsImpl(std::vector const& values) { +void FlagsIndexedWriter::WriteFormatsImpl(std::vector const& values) { + step_index_.set_step_offset("Formats", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); if (!values.empty()) { - yardl::binary::WriteVector(stream_, values); + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); } + step_index_.add_stream_offsets("Formats", item_offsets); } -void FlagsWriter::EndFormatsImpl() { +void FlagsIndexedWriter::EndFormatsImpl() { + step_index_.set_step_offset("Formats", stream_.Pos()); + step_index_.add_stream_offsets("Formats", std::vector{}); yardl::binary::WriteInteger(stream_, 0U); } -void FlagsWriter::Flush() { +void FlagsIndexedWriter::Flush() { stream_.Flush(); } -void FlagsWriter::CloseImpl() { +void FlagsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); stream_.Flush(); } -bool FlagsReader::ReadDaysImpl(test_model::DaysOfWeek& value) { +bool FlagsIndexedReader::ReadDaysImpl(test_model::DaysOfWeek& value) { + if (!step_index_.offset_within_stream("Days", "Formats", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Days")); + } bool read_block_successful = false; read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); return read_block_successful; } -bool FlagsReader::ReadDaysImpl(std::vector& values) { +bool FlagsIndexedReader::ReadDaysImpl(std::vector& values) { + if (!step_index_.offset_within_stream("Days", "Formats", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Days")); + } yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); return current_block_remaining_ != 0; } -bool FlagsReader::ReadFormatsImpl(test_model::TextFormat& value) { +bool FlagsIndexedReader::ReadDaysImpl(test_model::DaysOfWeek& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Days", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool FlagsIndexedReader::ReadDaysImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Days", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t FlagsIndexedReader::CountDaysImpl() { + return step_index_.get_stream_count("Days"); +} + +bool FlagsIndexedReader::ReadFormatsImpl(test_model::TextFormat& value) { + if (!step_index_.offset_within_stream("Formats", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Formats")); + } bool read_block_successful = false; read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); return read_block_successful; } -bool FlagsReader::ReadFormatsImpl(std::vector& values) { +bool FlagsIndexedReader::ReadFormatsImpl(std::vector& values) { + if (!step_index_.offset_within_stream("Formats", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Formats")); + } yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); return current_block_remaining_ != 0; } -void FlagsReader::CloseImpl() { - stream_.VerifyFinished(); +bool FlagsIndexedReader::ReadFormatsImpl(test_model::TextFormat& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Formats", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool FlagsIndexedReader::ReadFormatsImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Formats", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t FlagsIndexedReader::CountFormatsImpl() { + return step_index_.get_stream_count("Formats"); +} + +void FlagsIndexedReader::CloseImpl() { } void StateTestWriter::WriteAnIntImpl(int32_t const& value) { @@ -4184,6 +6312,106 @@ void StateTestReader::CloseImpl() { stream_.VerifyFinished(); } +void StateTestIndexedWriter::WriteAnIntImpl(int32_t const& value) { + step_index_.set_step_offset("AnInt", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void StateTestIndexedWriter::WriteAStreamImpl(int32_t const& value) { + step_index_.set_step_offset("AStream", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("AStream", item_offset); +} + +void StateTestIndexedWriter::WriteAStreamImpl(std::vector const& values) { + step_index_.set_step_offset("AStream", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("AStream", item_offsets); +} + +void StateTestIndexedWriter::EndAStreamImpl() { + step_index_.set_step_offset("AStream", stream_.Pos()); + step_index_.add_stream_offsets("AStream", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void StateTestIndexedWriter::WriteAnotherIntImpl(int32_t const& value) { + step_index_.set_step_offset("AnotherInt", stream_.Pos()); + yardl::binary::WriteInteger(stream_, value); +} + +void StateTestIndexedWriter::Flush() { + stream_.Flush(); +} + +void StateTestIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void StateTestIndexedReader::ReadAnIntImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("AnInt"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +bool StateTestIndexedReader::ReadAStreamImpl(int32_t& value) { + if (!step_index_.offset_within_stream("AStream", "AnotherInt", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("AStream")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StateTestIndexedReader::ReadAStreamImpl(std::vector& values) { + if (!step_index_.offset_within_stream("AStream", "AnotherInt", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("AStream")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool StateTestIndexedReader::ReadAStreamImpl(int32_t& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("AStream", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StateTestIndexedReader::ReadAStreamImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("AStream", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StateTestIndexedReader::CountAStreamImpl() { + return step_index_.get_stream_count("AStream"); +} + +void StateTestIndexedReader::ReadAnotherIntImpl(int32_t& value) { + auto pos = step_index_.get_step_offset("AnotherInt"); + stream_.Seek(pos); + yardl::binary::ReadInteger(stream_, value); +} + +void StateTestIndexedReader::CloseImpl() { +} + void SimpleGenericsWriter::WriteFloatImageImpl(image::FloatImage const& value) { image::binary::WriteFloatImage(stream_, value); } @@ -4285,6 +6513,172 @@ void SimpleGenericsReader::CloseImpl() { stream_.VerifyFinished(); } +void SimpleGenericsIndexedWriter::WriteFloatImageImpl(image::FloatImage const& value) { + step_index_.set_step_offset("FloatImage", stream_.Pos()); + image::binary::WriteFloatImage(stream_, value); +} + +void SimpleGenericsIndexedWriter::WriteIntImageImpl(image::IntImage const& value) { + step_index_.set_step_offset("IntImage", stream_.Pos()); + image::binary::WriteIntImage(stream_, value); +} + +void SimpleGenericsIndexedWriter::WriteIntImageAlternateSyntaxImpl(test_model::Image const& value) { + step_index_.set_step_offset("IntImageAlternateSyntax", stream_.Pos()); + test_model::binary::WriteImage(stream_, value); +} + +void SimpleGenericsIndexedWriter::WriteStringImageImpl(test_model::Image const& value) { + step_index_.set_step_offset("StringImage", stream_.Pos()); + test_model::binary::WriteImage(stream_, value); +} + +void SimpleGenericsIndexedWriter::WriteIntFloatTupleImpl(tuples::Tuple const& value) { + step_index_.set_step_offset("IntFloatTuple", stream_.Pos()); + tuples::binary::WriteTuple(stream_, value); +} + +void SimpleGenericsIndexedWriter::WriteFloatFloatTupleImpl(tuples::Tuple const& value) { + step_index_.set_step_offset("FloatFloatTuple", stream_.Pos()); + tuples::binary::WriteTuple(stream_, value); +} + +void SimpleGenericsIndexedWriter::WriteIntFloatTupleAlternateSyntaxImpl(tuples::Tuple const& value) { + step_index_.set_step_offset("IntFloatTupleAlternateSyntax", stream_.Pos()); + tuples::binary::WriteTuple(stream_, value); +} + +void SimpleGenericsIndexedWriter::WriteIntStringTupleImpl(tuples::Tuple const& value) { + step_index_.set_step_offset("IntStringTuple", stream_.Pos()); + tuples::binary::WriteTuple(stream_, value); +} + +void SimpleGenericsIndexedWriter::WriteStreamOfTypeVariantsImpl(std::variant> const& value) { + step_index_.set_step_offset("StreamOfTypeVariants", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset>, WriteUnion, test_model::binary::WriteImage>>(stream_, value, item_offset); + step_index_.add_stream_offset("StreamOfTypeVariants", item_offset); +} + +void SimpleGenericsIndexedWriter::WriteStreamOfTypeVariantsImpl(std::vector>> const& values) { + step_index_.set_step_offset("StreamOfTypeVariants", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets>, WriteUnion, test_model::binary::WriteImage>>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("StreamOfTypeVariants", item_offsets); +} + +void SimpleGenericsIndexedWriter::EndStreamOfTypeVariantsImpl() { + step_index_.set_step_offset("StreamOfTypeVariants", stream_.Pos()); + step_index_.add_stream_offsets("StreamOfTypeVariants", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void SimpleGenericsIndexedWriter::Flush() { + stream_.Flush(); +} + +void SimpleGenericsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void SimpleGenericsIndexedReader::ReadFloatImageImpl(image::FloatImage& value) { + auto pos = step_index_.get_step_offset("FloatImage"); + stream_.Seek(pos); + image::binary::ReadFloatImage(stream_, value); +} + +void SimpleGenericsIndexedReader::ReadIntImageImpl(image::IntImage& value) { + auto pos = step_index_.get_step_offset("IntImage"); + stream_.Seek(pos); + image::binary::ReadIntImage(stream_, value); +} + +void SimpleGenericsIndexedReader::ReadIntImageAlternateSyntaxImpl(test_model::Image& value) { + auto pos = step_index_.get_step_offset("IntImageAlternateSyntax"); + stream_.Seek(pos); + test_model::binary::ReadImage(stream_, value); +} + +void SimpleGenericsIndexedReader::ReadStringImageImpl(test_model::Image& value) { + auto pos = step_index_.get_step_offset("StringImage"); + stream_.Seek(pos); + test_model::binary::ReadImage(stream_, value); +} + +void SimpleGenericsIndexedReader::ReadIntFloatTupleImpl(tuples::Tuple& value) { + auto pos = step_index_.get_step_offset("IntFloatTuple"); + stream_.Seek(pos); + tuples::binary::ReadTuple(stream_, value); +} + +void SimpleGenericsIndexedReader::ReadFloatFloatTupleImpl(tuples::Tuple& value) { + auto pos = step_index_.get_step_offset("FloatFloatTuple"); + stream_.Seek(pos); + tuples::binary::ReadTuple(stream_, value); +} + +void SimpleGenericsIndexedReader::ReadIntFloatTupleAlternateSyntaxImpl(tuples::Tuple& value) { + auto pos = step_index_.get_step_offset("IntFloatTupleAlternateSyntax"); + stream_.Seek(pos); + tuples::binary::ReadTuple(stream_, value); +} + +void SimpleGenericsIndexedReader::ReadIntStringTupleImpl(tuples::Tuple& value) { + auto pos = step_index_.get_step_offset("IntStringTuple"); + stream_.Seek(pos); + tuples::binary::ReadTuple(stream_, value); +} + +bool SimpleGenericsIndexedReader::ReadStreamOfTypeVariantsImpl(std::variant>& value) { + if (!step_index_.offset_within_stream("StreamOfTypeVariants", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfTypeVariants")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock>, ReadUnion, test_model::binary::ReadImage>>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool SimpleGenericsIndexedReader::ReadStreamOfTypeVariantsImpl(std::vector>>& values) { + if (!step_index_.offset_within_stream("StreamOfTypeVariants", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfTypeVariants")); + } + yardl::binary::ReadBlocksIntoVector>, ReadUnion, test_model::binary::ReadImage>>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool SimpleGenericsIndexedReader::ReadStreamOfTypeVariantsImpl(std::variant>& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfTypeVariants", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock>, ReadUnion, test_model::binary::ReadImage>>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool SimpleGenericsIndexedReader::ReadStreamOfTypeVariantsImpl(std::vector>>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfTypeVariants", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector>, ReadUnion, test_model::binary::ReadImage>>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t SimpleGenericsIndexedReader::CountStreamOfTypeVariantsImpl() { + return step_index_.get_stream_count("StreamOfTypeVariants"); +} + +void SimpleGenericsIndexedReader::CloseImpl() { +} + void AdvancedGenericsWriter::WriteFloatImageImageImpl(test_model::Image> const& value) { test_model::binary::WriteImage, test_model::binary::WriteImage>(stream_, value); } @@ -4293,48 +6687,115 @@ void AdvancedGenericsWriter::WriteGenericRecord1Impl(test_model::GenericRecord(stream_, value); } -void AdvancedGenericsWriter::WriteTupleOfOptionalsImpl(test_model::MyTuple, std::optional> const& value) { +void AdvancedGenericsWriter::WriteTupleOfOptionalsImpl(test_model::MyTuple, std::optional> const& value) { + test_model::binary::WriteMyTuple, yardl::binary::WriteOptional, std::optional, yardl::binary::WriteOptional>(stream_, value); +} + +void AdvancedGenericsWriter::WriteTupleOfOptionalsAlternateSyntaxImpl(test_model::MyTuple, std::optional> const& value) { + test_model::binary::WriteMyTuple, yardl::binary::WriteOptional, std::optional, yardl::binary::WriteOptional>(stream_, value); +} + +void AdvancedGenericsWriter::WriteTupleOfVectorsImpl(test_model::MyTuple, std::vector> const& value) { + test_model::binary::WriteMyTuple, yardl::binary::WriteVector, std::vector, yardl::binary::WriteVector>(stream_, value); +} + +void AdvancedGenericsWriter::Flush() { + stream_.Flush(); +} + +void AdvancedGenericsWriter::CloseImpl() { + stream_.Flush(); +} + +void AdvancedGenericsReader::ReadFloatImageImageImpl(test_model::Image>& value) { + test_model::binary::ReadImage, test_model::binary::ReadImage>(stream_, value); +} + +void AdvancedGenericsReader::ReadGenericRecord1Impl(test_model::GenericRecord& value) { + test_model::binary::ReadGenericRecord(stream_, value); +} + +void AdvancedGenericsReader::ReadTupleOfOptionalsImpl(test_model::MyTuple, std::optional>& value) { + test_model::binary::ReadMyTuple, yardl::binary::ReadOptional, std::optional, yardl::binary::ReadOptional>(stream_, value); +} + +void AdvancedGenericsReader::ReadTupleOfOptionalsAlternateSyntaxImpl(test_model::MyTuple, std::optional>& value) { + test_model::binary::ReadMyTuple, yardl::binary::ReadOptional, std::optional, yardl::binary::ReadOptional>(stream_, value); +} + +void AdvancedGenericsReader::ReadTupleOfVectorsImpl(test_model::MyTuple, std::vector>& value) { + test_model::binary::ReadMyTuple, yardl::binary::ReadVector, std::vector, yardl::binary::ReadVector>(stream_, value); +} + +void AdvancedGenericsReader::CloseImpl() { + stream_.VerifyFinished(); +} + +void AdvancedGenericsIndexedWriter::WriteFloatImageImageImpl(test_model::Image> const& value) { + step_index_.set_step_offset("FloatImageImage", stream_.Pos()); + test_model::binary::WriteImage, test_model::binary::WriteImage>(stream_, value); +} + +void AdvancedGenericsIndexedWriter::WriteGenericRecord1Impl(test_model::GenericRecord const& value) { + step_index_.set_step_offset("GenericRecord1", stream_.Pos()); + test_model::binary::WriteGenericRecord(stream_, value); +} + +void AdvancedGenericsIndexedWriter::WriteTupleOfOptionalsImpl(test_model::MyTuple, std::optional> const& value) { + step_index_.set_step_offset("TupleOfOptionals", stream_.Pos()); test_model::binary::WriteMyTuple, yardl::binary::WriteOptional, std::optional, yardl::binary::WriteOptional>(stream_, value); } -void AdvancedGenericsWriter::WriteTupleOfOptionalsAlternateSyntaxImpl(test_model::MyTuple, std::optional> const& value) { +void AdvancedGenericsIndexedWriter::WriteTupleOfOptionalsAlternateSyntaxImpl(test_model::MyTuple, std::optional> const& value) { + step_index_.set_step_offset("TupleOfOptionalsAlternateSyntax", stream_.Pos()); test_model::binary::WriteMyTuple, yardl::binary::WriteOptional, std::optional, yardl::binary::WriteOptional>(stream_, value); } -void AdvancedGenericsWriter::WriteTupleOfVectorsImpl(test_model::MyTuple, std::vector> const& value) { +void AdvancedGenericsIndexedWriter::WriteTupleOfVectorsImpl(test_model::MyTuple, std::vector> const& value) { + step_index_.set_step_offset("TupleOfVectors", stream_.Pos()); test_model::binary::WriteMyTuple, yardl::binary::WriteVector, std::vector, yardl::binary::WriteVector>(stream_, value); } -void AdvancedGenericsWriter::Flush() { +void AdvancedGenericsIndexedWriter::Flush() { stream_.Flush(); } -void AdvancedGenericsWriter::CloseImpl() { +void AdvancedGenericsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); stream_.Flush(); } -void AdvancedGenericsReader::ReadFloatImageImageImpl(test_model::Image>& value) { +void AdvancedGenericsIndexedReader::ReadFloatImageImageImpl(test_model::Image>& value) { + auto pos = step_index_.get_step_offset("FloatImageImage"); + stream_.Seek(pos); test_model::binary::ReadImage, test_model::binary::ReadImage>(stream_, value); } -void AdvancedGenericsReader::ReadGenericRecord1Impl(test_model::GenericRecord& value) { +void AdvancedGenericsIndexedReader::ReadGenericRecord1Impl(test_model::GenericRecord& value) { + auto pos = step_index_.get_step_offset("GenericRecord1"); + stream_.Seek(pos); test_model::binary::ReadGenericRecord(stream_, value); } -void AdvancedGenericsReader::ReadTupleOfOptionalsImpl(test_model::MyTuple, std::optional>& value) { +void AdvancedGenericsIndexedReader::ReadTupleOfOptionalsImpl(test_model::MyTuple, std::optional>& value) { + auto pos = step_index_.get_step_offset("TupleOfOptionals"); + stream_.Seek(pos); test_model::binary::ReadMyTuple, yardl::binary::ReadOptional, std::optional, yardl::binary::ReadOptional>(stream_, value); } -void AdvancedGenericsReader::ReadTupleOfOptionalsAlternateSyntaxImpl(test_model::MyTuple, std::optional>& value) { +void AdvancedGenericsIndexedReader::ReadTupleOfOptionalsAlternateSyntaxImpl(test_model::MyTuple, std::optional>& value) { + auto pos = step_index_.get_step_offset("TupleOfOptionalsAlternateSyntax"); + stream_.Seek(pos); test_model::binary::ReadMyTuple, yardl::binary::ReadOptional, std::optional, yardl::binary::ReadOptional>(stream_, value); } -void AdvancedGenericsReader::ReadTupleOfVectorsImpl(test_model::MyTuple, std::vector>& value) { +void AdvancedGenericsIndexedReader::ReadTupleOfVectorsImpl(test_model::MyTuple, std::vector>& value) { + auto pos = step_index_.get_step_offset("TupleOfVectors"); + stream_.Seek(pos); test_model::binary::ReadMyTuple, yardl::binary::ReadVector, std::vector, yardl::binary::ReadVector>(stream_, value); } -void AdvancedGenericsReader::CloseImpl() { - stream_.VerifyFinished(); +void AdvancedGenericsIndexedReader::CloseImpl() { } void AliasesWriter::WriteAliasedStringImpl(test_model::AliasedString const& value) { @@ -4446,6 +6907,183 @@ void AliasesReader::CloseImpl() { stream_.VerifyFinished(); } +void AliasesIndexedWriter::WriteAliasedStringImpl(test_model::AliasedString const& value) { + step_index_.set_step_offset("AliasedString", stream_.Pos()); + test_model::binary::WriteAliasedString(stream_, value); +} + +void AliasesIndexedWriter::WriteAliasedEnumImpl(test_model::AliasedEnum const& value) { + step_index_.set_step_offset("AliasedEnum", stream_.Pos()); + test_model::binary::WriteAliasedEnum(stream_, value); +} + +void AliasesIndexedWriter::WriteAliasedOpenGenericImpl(test_model::AliasedOpenGeneric const& value) { + step_index_.set_step_offset("AliasedOpenGeneric", stream_.Pos()); + test_model::binary::WriteAliasedOpenGeneric(stream_, value); +} + +void AliasesIndexedWriter::WriteAliasedClosedGenericImpl(test_model::AliasedClosedGeneric const& value) { + step_index_.set_step_offset("AliasedClosedGeneric", stream_.Pos()); + test_model::binary::WriteAliasedClosedGeneric(stream_, value); +} + +void AliasesIndexedWriter::WriteAliasedOptionalImpl(test_model::AliasedOptional const& value) { + step_index_.set_step_offset("AliasedOptional", stream_.Pos()); + test_model::binary::WriteAliasedOptional(stream_, value); +} + +void AliasesIndexedWriter::WriteAliasedGenericOptionalImpl(test_model::AliasedGenericOptional const& value) { + step_index_.set_step_offset("AliasedGenericOptional", stream_.Pos()); + test_model::binary::WriteAliasedGenericOptional(stream_, value); +} + +void AliasesIndexedWriter::WriteAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2 const& value) { + step_index_.set_step_offset("AliasedGenericUnion2", stream_.Pos()); + test_model::binary::WriteAliasedGenericUnion2(stream_, value); +} + +void AliasesIndexedWriter::WriteAliasedGenericVectorImpl(test_model::AliasedGenericVector const& value) { + step_index_.set_step_offset("AliasedGenericVector", stream_.Pos()); + test_model::binary::WriteAliasedGenericVector(stream_, value); +} + +void AliasesIndexedWriter::WriteAliasedGenericFixedVectorImpl(test_model::AliasedGenericFixedVector const& value) { + step_index_.set_step_offset("AliasedGenericFixedVector", stream_.Pos()); + test_model::binary::WriteAliasedGenericFixedVector(stream_, value); +} + +void AliasesIndexedWriter::WriteStreamOfAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2 const& value) { + step_index_.set_step_offset("StreamOfAliasedGenericUnion2", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset, test_model::binary::WriteAliasedGenericUnion2>(stream_, value, item_offset); + step_index_.add_stream_offset("StreamOfAliasedGenericUnion2", item_offset); +} + +void AliasesIndexedWriter::WriteStreamOfAliasedGenericUnion2Impl(std::vector> const& values) { + step_index_.set_step_offset("StreamOfAliasedGenericUnion2", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets, test_model::binary::WriteAliasedGenericUnion2>(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("StreamOfAliasedGenericUnion2", item_offsets); +} + +void AliasesIndexedWriter::EndStreamOfAliasedGenericUnion2Impl() { + step_index_.set_step_offset("StreamOfAliasedGenericUnion2", stream_.Pos()); + step_index_.add_stream_offsets("StreamOfAliasedGenericUnion2", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void AliasesIndexedWriter::Flush() { + stream_.Flush(); +} + +void AliasesIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void AliasesIndexedReader::ReadAliasedStringImpl(test_model::AliasedString& value) { + auto pos = step_index_.get_step_offset("AliasedString"); + stream_.Seek(pos); + test_model::binary::ReadAliasedString(stream_, value); +} + +void AliasesIndexedReader::ReadAliasedEnumImpl(test_model::AliasedEnum& value) { + auto pos = step_index_.get_step_offset("AliasedEnum"); + stream_.Seek(pos); + test_model::binary::ReadAliasedEnum(stream_, value); +} + +void AliasesIndexedReader::ReadAliasedOpenGenericImpl(test_model::AliasedOpenGeneric& value) { + auto pos = step_index_.get_step_offset("AliasedOpenGeneric"); + stream_.Seek(pos); + test_model::binary::ReadAliasedOpenGeneric(stream_, value); +} + +void AliasesIndexedReader::ReadAliasedClosedGenericImpl(test_model::AliasedClosedGeneric& value) { + auto pos = step_index_.get_step_offset("AliasedClosedGeneric"); + stream_.Seek(pos); + test_model::binary::ReadAliasedClosedGeneric(stream_, value); +} + +void AliasesIndexedReader::ReadAliasedOptionalImpl(test_model::AliasedOptional& value) { + auto pos = step_index_.get_step_offset("AliasedOptional"); + stream_.Seek(pos); + test_model::binary::ReadAliasedOptional(stream_, value); +} + +void AliasesIndexedReader::ReadAliasedGenericOptionalImpl(test_model::AliasedGenericOptional& value) { + auto pos = step_index_.get_step_offset("AliasedGenericOptional"); + stream_.Seek(pos); + test_model::binary::ReadAliasedGenericOptional(stream_, value); +} + +void AliasesIndexedReader::ReadAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2& value) { + auto pos = step_index_.get_step_offset("AliasedGenericUnion2"); + stream_.Seek(pos); + test_model::binary::ReadAliasedGenericUnion2(stream_, value); +} + +void AliasesIndexedReader::ReadAliasedGenericVectorImpl(test_model::AliasedGenericVector& value) { + auto pos = step_index_.get_step_offset("AliasedGenericVector"); + stream_.Seek(pos); + test_model::binary::ReadAliasedGenericVector(stream_, value); +} + +void AliasesIndexedReader::ReadAliasedGenericFixedVectorImpl(test_model::AliasedGenericFixedVector& value) { + auto pos = step_index_.get_step_offset("AliasedGenericFixedVector"); + stream_.Seek(pos); + test_model::binary::ReadAliasedGenericFixedVector(stream_, value); +} + +bool AliasesIndexedReader::ReadStreamOfAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2& value) { + if (!step_index_.offset_within_stream("StreamOfAliasedGenericUnion2", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfAliasedGenericUnion2")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, test_model::binary::ReadAliasedGenericUnion2>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool AliasesIndexedReader::ReadStreamOfAliasedGenericUnion2Impl(std::vector>& values) { + if (!step_index_.offset_within_stream("StreamOfAliasedGenericUnion2", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("StreamOfAliasedGenericUnion2")); + } + yardl::binary::ReadBlocksIntoVector, test_model::binary::ReadAliasedGenericUnion2>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool AliasesIndexedReader::ReadStreamOfAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfAliasedGenericUnion2", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, test_model::binary::ReadAliasedGenericUnion2>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool AliasesIndexedReader::ReadStreamOfAliasedGenericUnion2Impl(std::vector>& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("StreamOfAliasedGenericUnion2", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector, test_model::binary::ReadAliasedGenericUnion2>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t AliasesIndexedReader::CountStreamOfAliasedGenericUnion2Impl() { + return step_index_.get_stream_count("StreamOfAliasedGenericUnion2"); +} + +void AliasesIndexedReader::CloseImpl() { +} + void StreamsOfAliasedUnionsWriter::WriteIntOrSimpleRecordImpl(test_model::AliasedIntOrSimpleRecord const& value) { yardl::binary::WriteBlock(stream_, value); } @@ -4508,6 +7146,150 @@ void StreamsOfAliasedUnionsReader::CloseImpl() { stream_.VerifyFinished(); } +void StreamsOfAliasedUnionsIndexedWriter::WriteIntOrSimpleRecordImpl(test_model::AliasedIntOrSimpleRecord const& value) { + step_index_.set_step_offset("IntOrSimpleRecord", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("IntOrSimpleRecord", item_offset); +} + +void StreamsOfAliasedUnionsIndexedWriter::WriteIntOrSimpleRecordImpl(std::vector const& values) { + step_index_.set_step_offset("IntOrSimpleRecord", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("IntOrSimpleRecord", item_offsets); +} + +void StreamsOfAliasedUnionsIndexedWriter::EndIntOrSimpleRecordImpl() { + step_index_.set_step_offset("IntOrSimpleRecord", stream_.Pos()); + step_index_.add_stream_offsets("IntOrSimpleRecord", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void StreamsOfAliasedUnionsIndexedWriter::WriteNullableIntOrSimpleRecordImpl(test_model::AliasedNullableIntSimpleRecord const& value) { + step_index_.set_step_offset("NullableIntOrSimpleRecord", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("NullableIntOrSimpleRecord", item_offset); +} + +void StreamsOfAliasedUnionsIndexedWriter::WriteNullableIntOrSimpleRecordImpl(std::vector const& values) { + step_index_.set_step_offset("NullableIntOrSimpleRecord", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("NullableIntOrSimpleRecord", item_offsets); +} + +void StreamsOfAliasedUnionsIndexedWriter::EndNullableIntOrSimpleRecordImpl() { + step_index_.set_step_offset("NullableIntOrSimpleRecord", stream_.Pos()); + step_index_.add_stream_offsets("NullableIntOrSimpleRecord", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void StreamsOfAliasedUnionsIndexedWriter::Flush() { + stream_.Flush(); +} + +void StreamsOfAliasedUnionsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool StreamsOfAliasedUnionsIndexedReader::ReadIntOrSimpleRecordImpl(test_model::AliasedIntOrSimpleRecord& value) { + if (!step_index_.offset_within_stream("IntOrSimpleRecord", "NullableIntOrSimpleRecord", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntOrSimpleRecord")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfAliasedUnionsIndexedReader::ReadIntOrSimpleRecordImpl(std::vector& values) { + if (!step_index_.offset_within_stream("IntOrSimpleRecord", "NullableIntOrSimpleRecord", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("IntOrSimpleRecord")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool StreamsOfAliasedUnionsIndexedReader::ReadIntOrSimpleRecordImpl(test_model::AliasedIntOrSimpleRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntOrSimpleRecord", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfAliasedUnionsIndexedReader::ReadIntOrSimpleRecordImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("IntOrSimpleRecord", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StreamsOfAliasedUnionsIndexedReader::CountIntOrSimpleRecordImpl() { + return step_index_.get_stream_count("IntOrSimpleRecord"); +} + +bool StreamsOfAliasedUnionsIndexedReader::ReadNullableIntOrSimpleRecordImpl(test_model::AliasedNullableIntSimpleRecord& value) { + if (!step_index_.offset_within_stream("NullableIntOrSimpleRecord", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("NullableIntOrSimpleRecord")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfAliasedUnionsIndexedReader::ReadNullableIntOrSimpleRecordImpl(std::vector& values) { + if (!step_index_.offset_within_stream("NullableIntOrSimpleRecord", std::nullopt, stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("NullableIntOrSimpleRecord")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool StreamsOfAliasedUnionsIndexedReader::ReadNullableIntOrSimpleRecordImpl(test_model::AliasedNullableIntSimpleRecord& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("NullableIntOrSimpleRecord", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool StreamsOfAliasedUnionsIndexedReader::ReadNullableIntOrSimpleRecordImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("NullableIntOrSimpleRecord", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t StreamsOfAliasedUnionsIndexedReader::CountNullableIntOrSimpleRecordImpl() { + return step_index_.get_stream_count("NullableIntOrSimpleRecord"); +} + +void StreamsOfAliasedUnionsIndexedReader::CloseImpl() { +} + void ProtocolWithComputedFieldsWriter::WriteRecordWithComputedFieldsImpl(test_model::RecordWithComputedFields const& value) { test_model::binary::WriteRecordWithComputedFields(stream_, value); } @@ -4528,6 +7310,29 @@ void ProtocolWithComputedFieldsReader::CloseImpl() { stream_.VerifyFinished(); } +void ProtocolWithComputedFieldsIndexedWriter::WriteRecordWithComputedFieldsImpl(test_model::RecordWithComputedFields const& value) { + step_index_.set_step_offset("RecordWithComputedFields", stream_.Pos()); + test_model::binary::WriteRecordWithComputedFields(stream_, value); +} + +void ProtocolWithComputedFieldsIndexedWriter::Flush() { + stream_.Flush(); +} + +void ProtocolWithComputedFieldsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void ProtocolWithComputedFieldsIndexedReader::ReadRecordWithComputedFieldsImpl(test_model::RecordWithComputedFields& value) { + auto pos = step_index_.get_step_offset("RecordWithComputedFields"); + stream_.Seek(pos); + test_model::binary::ReadRecordWithComputedFields(stream_, value); +} + +void ProtocolWithComputedFieldsIndexedReader::CloseImpl() { +} + void ProtocolWithKeywordStepsWriter::WriteIntImpl(test_model::RecordWithKeywordFields const& value) { yardl::binary::WriteBlock(stream_, value); } @@ -4573,6 +7378,95 @@ void ProtocolWithKeywordStepsReader::CloseImpl() { stream_.VerifyFinished(); } +void ProtocolWithKeywordStepsIndexedWriter::WriteIntImpl(test_model::RecordWithKeywordFields const& value) { + step_index_.set_step_offset("Int", stream_.Pos()); + size_t item_offset = 0; + yardl::binary::WriteBlockAndSaveOffset(stream_, value, item_offset); + step_index_.add_stream_offset("Int", item_offset); +} + +void ProtocolWithKeywordStepsIndexedWriter::WriteIntImpl(std::vector const& values) { + step_index_.set_step_offset("Int", stream_.Pos()); + std::vector item_offsets; + item_offsets.reserve(values.size()); + if (!values.empty()) { + yardl::binary::WriteVectorAndSaveOffsets(stream_, values, item_offsets); + } + step_index_.add_stream_offsets("Int", item_offsets); +} + +void ProtocolWithKeywordStepsIndexedWriter::EndIntImpl() { + step_index_.set_step_offset("Int", stream_.Pos()); + step_index_.add_stream_offsets("Int", std::vector{}); + yardl::binary::WriteInteger(stream_, 0U); +} + +void ProtocolWithKeywordStepsIndexedWriter::WriteFloatImpl(test_model::EnumWithKeywordSymbols const& value) { + step_index_.set_step_offset("Float", stream_.Pos()); + yardl::binary::WriteEnum(stream_, value); +} + +void ProtocolWithKeywordStepsIndexedWriter::Flush() { + stream_.Flush(); +} + +void ProtocolWithKeywordStepsIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +bool ProtocolWithKeywordStepsIndexedReader::ReadIntImpl(test_model::RecordWithKeywordFields& value) { + if (!step_index_.offset_within_stream("Int", "Float", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Int")); + } + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithKeywordStepsIndexedReader::ReadIntImpl(std::vector& values) { + if (!step_index_.offset_within_stream("Int", "Float", stream_.Pos())) { + stream_.Seek(step_index_.get_step_offset("Int")); + } + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool ProtocolWithKeywordStepsIndexedReader::ReadIntImpl(test_model::RecordWithKeywordFields& value, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Int", idx, abs_offset, current_block_remaining_)) { + return false; + } + stream_.Seek(abs_offset); + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool ProtocolWithKeywordStepsIndexedReader::ReadIntImpl(std::vector& values, size_t idx) { + size_t abs_offset = 0; + if (!step_index_.find_stream_item("Int", idx, abs_offset, current_block_remaining_)) { + values.clear(); + return false; + } + stream_.Seek(abs_offset); + yardl::binary::ReadBlocksIntoVector(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +size_t ProtocolWithKeywordStepsIndexedReader::CountIntImpl() { + return step_index_.get_stream_count("Int"); +} + +void ProtocolWithKeywordStepsIndexedReader::ReadFloatImpl(test_model::EnumWithKeywordSymbols& value) { + auto pos = step_index_.get_step_offset("Float"); + stream_.Seek(pos); + yardl::binary::ReadEnum(stream_, value); +} + +void ProtocolWithKeywordStepsIndexedReader::CloseImpl() { +} + void ProtocolWithOptionalDateWriter::WriteRecordImpl(std::optional const& value) { yardl::binary::WriteOptional(stream_, value); } @@ -4593,5 +7487,28 @@ void ProtocolWithOptionalDateReader::CloseImpl() { stream_.VerifyFinished(); } +void ProtocolWithOptionalDateIndexedWriter::WriteRecordImpl(std::optional const& value) { + step_index_.set_step_offset("Record", stream_.Pos()); + yardl::binary::WriteOptional(stream_, value); +} + +void ProtocolWithOptionalDateIndexedWriter::Flush() { + stream_.Flush(); +} + +void ProtocolWithOptionalDateIndexedWriter::CloseImpl() { + yardl::binary::WriteIndex(stream_, step_index_); + stream_.Flush(); +} + +void ProtocolWithOptionalDateIndexedReader::ReadRecordImpl(std::optional& value) { + auto pos = step_index_.get_step_offset("Record"); + stream_.Seek(pos); + yardl::binary::ReadOptional(stream_, value); +} + +void ProtocolWithOptionalDateIndexedReader::CloseImpl() { +} + } // namespace test_model::binary diff --git a/cpp/test/generated/binary/protocols.h b/cpp/test/generated/binary/protocols.h index f5cbe40..5967b89 100644 --- a/cpp/test/generated/binary/protocols.h +++ b/cpp/test/generated/binary/protocols.h @@ -32,6 +32,26 @@ class BenchmarkFloat256x256Writer : public test_model::BenchmarkFloat256x256Writ Version version_; }; +// Binary indexed writer for the BenchmarkFloat256x256 protocol. +class BenchmarkFloat256x256IndexedWriter : public test_model::BenchmarkFloat256x256WriterBase, yardl::binary::BinaryIndexedWriter { + public: + BenchmarkFloat256x256IndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::BenchmarkFloat256x256WriterBase::SchemaFromVersion(version)), version_(version) {} + + BenchmarkFloat256x256IndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::BenchmarkFloat256x256WriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteFloat256x256Impl(yardl::FixedNDArray const& value) override; + void WriteFloat256x256Impl(std::vector> const& values) override; + void EndFloat256x256Impl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the BenchmarkFloat256x256 protocol. class BenchmarkFloat256x256Reader : public test_model::BenchmarkFloat256x256ReaderBase, yardl::binary::BinaryReader { public: @@ -54,6 +74,31 @@ class BenchmarkFloat256x256Reader : public test_model::BenchmarkFloat256x256Read size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the BenchmarkFloat256x256 protocol. +class BenchmarkFloat256x256IndexedReader : public test_model::BenchmarkFloat256x256IndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + BenchmarkFloat256x256IndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::BenchmarkFloat256x256IndexedReaderBase::VersionFromSchema(schema_read_)) {} + + BenchmarkFloat256x256IndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::BenchmarkFloat256x256IndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadFloat256x256Impl(yardl::FixedNDArray& value) override; + bool ReadFloat256x256Impl(std::vector>& values) override; + bool ReadFloat256x256Impl(yardl::FixedNDArray& value, size_t idx) override; + bool ReadFloat256x256Impl(std::vector>& values, size_t idx) override; + size_t CountFloat256x256Impl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the BenchmarkInt256x256 protocol. class BenchmarkInt256x256Writer : public test_model::BenchmarkInt256x256WriterBase, yardl::binary::BinaryWriter { public: @@ -74,6 +119,26 @@ class BenchmarkInt256x256Writer : public test_model::BenchmarkInt256x256WriterBa Version version_; }; +// Binary indexed writer for the BenchmarkInt256x256 protocol. +class BenchmarkInt256x256IndexedWriter : public test_model::BenchmarkInt256x256WriterBase, yardl::binary::BinaryIndexedWriter { + public: + BenchmarkInt256x256IndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::BenchmarkInt256x256WriterBase::SchemaFromVersion(version)), version_(version) {} + + BenchmarkInt256x256IndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::BenchmarkInt256x256WriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteInt256x256Impl(yardl::FixedNDArray const& value) override; + void WriteInt256x256Impl(std::vector> const& values) override; + void EndInt256x256Impl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the BenchmarkInt256x256 protocol. class BenchmarkInt256x256Reader : public test_model::BenchmarkInt256x256ReaderBase, yardl::binary::BinaryReader { public: @@ -96,6 +161,31 @@ class BenchmarkInt256x256Reader : public test_model::BenchmarkInt256x256ReaderBa size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the BenchmarkInt256x256 protocol. +class BenchmarkInt256x256IndexedReader : public test_model::BenchmarkInt256x256IndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + BenchmarkInt256x256IndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::BenchmarkInt256x256IndexedReaderBase::VersionFromSchema(schema_read_)) {} + + BenchmarkInt256x256IndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::BenchmarkInt256x256IndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadInt256x256Impl(yardl::FixedNDArray& value) override; + bool ReadInt256x256Impl(std::vector>& values) override; + bool ReadInt256x256Impl(yardl::FixedNDArray& value, size_t idx) override; + bool ReadInt256x256Impl(std::vector>& values, size_t idx) override; + size_t CountInt256x256Impl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the BenchmarkFloatVlen protocol. class BenchmarkFloatVlenWriter : public test_model::BenchmarkFloatVlenWriterBase, yardl::binary::BinaryWriter { public: @@ -116,6 +206,26 @@ class BenchmarkFloatVlenWriter : public test_model::BenchmarkFloatVlenWriterBase Version version_; }; +// Binary indexed writer for the BenchmarkFloatVlen protocol. +class BenchmarkFloatVlenIndexedWriter : public test_model::BenchmarkFloatVlenWriterBase, yardl::binary::BinaryIndexedWriter { + public: + BenchmarkFloatVlenIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::BenchmarkFloatVlenWriterBase::SchemaFromVersion(version)), version_(version) {} + + BenchmarkFloatVlenIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::BenchmarkFloatVlenWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteFloatArrayImpl(yardl::NDArray const& value) override; + void WriteFloatArrayImpl(std::vector> const& values) override; + void EndFloatArrayImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the BenchmarkFloatVlen protocol. class BenchmarkFloatVlenReader : public test_model::BenchmarkFloatVlenReaderBase, yardl::binary::BinaryReader { public: @@ -138,6 +248,31 @@ class BenchmarkFloatVlenReader : public test_model::BenchmarkFloatVlenReaderBase size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the BenchmarkFloatVlen protocol. +class BenchmarkFloatVlenIndexedReader : public test_model::BenchmarkFloatVlenIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + BenchmarkFloatVlenIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::BenchmarkFloatVlenIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + BenchmarkFloatVlenIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::BenchmarkFloatVlenIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadFloatArrayImpl(yardl::NDArray& value) override; + bool ReadFloatArrayImpl(std::vector>& values) override; + bool ReadFloatArrayImpl(yardl::NDArray& value, size_t idx) override; + bool ReadFloatArrayImpl(std::vector>& values, size_t idx) override; + size_t CountFloatArrayImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the BenchmarkSmallRecord protocol. class BenchmarkSmallRecordWriter : public test_model::BenchmarkSmallRecordWriterBase, yardl::binary::BinaryWriter { public: @@ -158,6 +293,26 @@ class BenchmarkSmallRecordWriter : public test_model::BenchmarkSmallRecordWriter Version version_; }; +// Binary indexed writer for the BenchmarkSmallRecord protocol. +class BenchmarkSmallRecordIndexedWriter : public test_model::BenchmarkSmallRecordWriterBase, yardl::binary::BinaryIndexedWriter { + public: + BenchmarkSmallRecordIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::BenchmarkSmallRecordWriterBase::SchemaFromVersion(version)), version_(version) {} + + BenchmarkSmallRecordIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::BenchmarkSmallRecordWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteSmallRecordImpl(test_model::SmallBenchmarkRecord const& value) override; + void WriteSmallRecordImpl(std::vector const& values) override; + void EndSmallRecordImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the BenchmarkSmallRecord protocol. class BenchmarkSmallRecordReader : public test_model::BenchmarkSmallRecordReaderBase, yardl::binary::BinaryReader { public: @@ -180,6 +335,31 @@ class BenchmarkSmallRecordReader : public test_model::BenchmarkSmallRecordReader size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the BenchmarkSmallRecord protocol. +class BenchmarkSmallRecordIndexedReader : public test_model::BenchmarkSmallRecordIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + BenchmarkSmallRecordIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::BenchmarkSmallRecordIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + BenchmarkSmallRecordIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::BenchmarkSmallRecordIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadSmallRecordImpl(test_model::SmallBenchmarkRecord& value) override; + bool ReadSmallRecordImpl(std::vector& values) override; + bool ReadSmallRecordImpl(test_model::SmallBenchmarkRecord& value, size_t idx) override; + bool ReadSmallRecordImpl(std::vector& values, size_t idx) override; + size_t CountSmallRecordImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the BenchmarkSmallRecordWithOptionals protocol. class BenchmarkSmallRecordWithOptionalsWriter : public test_model::BenchmarkSmallRecordWithOptionalsWriterBase, yardl::binary::BinaryWriter { public: @@ -200,6 +380,26 @@ class BenchmarkSmallRecordWithOptionalsWriter : public test_model::BenchmarkSmal Version version_; }; +// Binary indexed writer for the BenchmarkSmallRecordWithOptionals protocol. +class BenchmarkSmallRecordWithOptionalsIndexedWriter : public test_model::BenchmarkSmallRecordWithOptionalsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + BenchmarkSmallRecordWithOptionalsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::BenchmarkSmallRecordWithOptionalsWriterBase::SchemaFromVersion(version)), version_(version) {} + + BenchmarkSmallRecordWithOptionalsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::BenchmarkSmallRecordWithOptionalsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteSmallRecordImpl(test_model::SimpleEncodingCounters const& value) override; + void WriteSmallRecordImpl(std::vector const& values) override; + void EndSmallRecordImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the BenchmarkSmallRecordWithOptionals protocol. class BenchmarkSmallRecordWithOptionalsReader : public test_model::BenchmarkSmallRecordWithOptionalsReaderBase, yardl::binary::BinaryReader { public: @@ -222,6 +422,31 @@ class BenchmarkSmallRecordWithOptionalsReader : public test_model::BenchmarkSmal size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the BenchmarkSmallRecordWithOptionals protocol. +class BenchmarkSmallRecordWithOptionalsIndexedReader : public test_model::BenchmarkSmallRecordWithOptionalsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + BenchmarkSmallRecordWithOptionalsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::BenchmarkSmallRecordWithOptionalsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + BenchmarkSmallRecordWithOptionalsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::BenchmarkSmallRecordWithOptionalsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadSmallRecordImpl(test_model::SimpleEncodingCounters& value) override; + bool ReadSmallRecordImpl(std::vector& values) override; + bool ReadSmallRecordImpl(test_model::SimpleEncodingCounters& value, size_t idx) override; + bool ReadSmallRecordImpl(std::vector& values, size_t idx) override; + size_t CountSmallRecordImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the BenchmarkSimpleMrd protocol. class BenchmarkSimpleMrdWriter : public test_model::BenchmarkSimpleMrdWriterBase, yardl::binary::BinaryWriter { public: @@ -242,6 +467,26 @@ class BenchmarkSimpleMrdWriter : public test_model::BenchmarkSimpleMrdWriterBase Version version_; }; +// Binary indexed writer for the BenchmarkSimpleMrd protocol. +class BenchmarkSimpleMrdIndexedWriter : public test_model::BenchmarkSimpleMrdWriterBase, yardl::binary::BinaryIndexedWriter { + public: + BenchmarkSimpleMrdIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::BenchmarkSimpleMrdWriterBase::SchemaFromVersion(version)), version_(version) {} + + BenchmarkSimpleMrdIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::BenchmarkSimpleMrdWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteDataImpl(std::variant> const& value) override; + void WriteDataImpl(std::vector>> const& values) override; + void EndDataImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the BenchmarkSimpleMrd protocol. class BenchmarkSimpleMrdReader : public test_model::BenchmarkSimpleMrdReaderBase, yardl::binary::BinaryReader { public: @@ -264,6 +509,31 @@ class BenchmarkSimpleMrdReader : public test_model::BenchmarkSimpleMrdReaderBase size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the BenchmarkSimpleMrd protocol. +class BenchmarkSimpleMrdIndexedReader : public test_model::BenchmarkSimpleMrdIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + BenchmarkSimpleMrdIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::BenchmarkSimpleMrdIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + BenchmarkSimpleMrdIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::BenchmarkSimpleMrdIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadDataImpl(std::variant>& value) override; + bool ReadDataImpl(std::vector>>& values) override; + bool ReadDataImpl(std::variant>& value, size_t idx) override; + bool ReadDataImpl(std::vector>>& values, size_t idx) override; + size_t CountDataImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the Scalars protocol. class ScalarsWriter : public test_model::ScalarsWriterBase, yardl::binary::BinaryWriter { public: @@ -283,6 +553,25 @@ class ScalarsWriter : public test_model::ScalarsWriterBase, yardl::binary::Binar Version version_; }; +// Binary indexed writer for the Scalars protocol. +class ScalarsIndexedWriter : public test_model::ScalarsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ScalarsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::ScalarsWriterBase::SchemaFromVersion(version)), version_(version) {} + + ScalarsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::ScalarsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteInt32Impl(int32_t const& value) override; + void WriteRecordImpl(test_model::RecordWithPrimitives const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Scalars protocol. class ScalarsReader : public test_model::ScalarsReaderBase, yardl::binary::BinaryReader { public: @@ -302,6 +591,25 @@ class ScalarsReader : public test_model::ScalarsReaderBase, yardl::binary::Binar Version version_; }; +// Binary indexed reader for the Scalars protocol. +class ScalarsIndexedReader : public test_model::ScalarsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ScalarsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::ScalarsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ScalarsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::ScalarsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadInt32Impl(int32_t& value) override; + void ReadRecordImpl(test_model::RecordWithPrimitives& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the ScalarOptionals protocol. class ScalarOptionalsWriter : public test_model::ScalarOptionalsWriterBase, yardl::binary::BinaryWriter { public: @@ -323,6 +631,27 @@ class ScalarOptionalsWriter : public test_model::ScalarOptionalsWriterBase, yard Version version_; }; +// Binary indexed writer for the ScalarOptionals protocol. +class ScalarOptionalsIndexedWriter : public test_model::ScalarOptionalsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ScalarOptionalsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::ScalarOptionalsWriterBase::SchemaFromVersion(version)), version_(version) {} + + ScalarOptionalsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::ScalarOptionalsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteOptionalIntImpl(std::optional const& value) override; + void WriteOptionalRecordImpl(std::optional const& value) override; + void WriteRecordWithOptionalFieldsImpl(test_model::RecordWithOptionalFields const& value) override; + void WriteOptionalRecordWithOptionalFieldsImpl(std::optional const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the ScalarOptionals protocol. class ScalarOptionalsReader : public test_model::ScalarOptionalsReaderBase, yardl::binary::BinaryReader { public: @@ -344,6 +673,27 @@ class ScalarOptionalsReader : public test_model::ScalarOptionalsReaderBase, yard Version version_; }; +// Binary indexed reader for the ScalarOptionals protocol. +class ScalarOptionalsIndexedReader : public test_model::ScalarOptionalsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ScalarOptionalsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::ScalarOptionalsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ScalarOptionalsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::ScalarOptionalsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadOptionalIntImpl(std::optional& value) override; + void ReadOptionalRecordImpl(std::optional& value) override; + void ReadRecordWithOptionalFieldsImpl(test_model::RecordWithOptionalFields& value) override; + void ReadOptionalRecordWithOptionalFieldsImpl(std::optional& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the NestedRecords protocol. class NestedRecordsWriter : public test_model::NestedRecordsWriterBase, yardl::binary::BinaryWriter { public: @@ -362,6 +712,24 @@ class NestedRecordsWriter : public test_model::NestedRecordsWriterBase, yardl::b Version version_; }; +// Binary indexed writer for the NestedRecords protocol. +class NestedRecordsIndexedWriter : public test_model::NestedRecordsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + NestedRecordsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::NestedRecordsWriterBase::SchemaFromVersion(version)), version_(version) {} + + NestedRecordsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::NestedRecordsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteTupleWithRecordsImpl(test_model::TupleWithRecords const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the NestedRecords protocol. class NestedRecordsReader : public test_model::NestedRecordsReaderBase, yardl::binary::BinaryReader { public: @@ -380,16 +748,55 @@ class NestedRecordsReader : public test_model::NestedRecordsReaderBase, yardl::b Version version_; }; -// Binary writer for the Vlens protocol. -class VlensWriter : public test_model::VlensWriterBase, yardl::binary::BinaryWriter { +// Binary indexed reader for the NestedRecords protocol. +class NestedRecordsIndexedReader : public test_model::NestedRecordsIndexedReaderBase, yardl::binary::BinaryIndexedReader { public: - VlensWriter(std::ostream& stream, Version version = Version::Current) - : yardl::binary::BinaryWriter(stream, test_model::VlensWriterBase::SchemaFromVersion(version)), version_(version) {} + NestedRecordsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::NestedRecordsIndexedReaderBase::VersionFromSchema(schema_read_)) {} - VlensWriter(std::string file_name, Version version = Version::Current) - : yardl::binary::BinaryWriter(file_name, test_model::VlensWriterBase::SchemaFromVersion(version)), version_(version) {} + NestedRecordsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::NestedRecordsIndexedReaderBase::VersionFromSchema(schema_read_)) {} - void Flush() override; + Version GetVersion() { return version_; } + + protected: + void ReadTupleWithRecordsImpl(test_model::TupleWithRecords& value) override; + void CloseImpl() override; + + Version version_; +}; + +// Binary writer for the Vlens protocol. +class VlensWriter : public test_model::VlensWriterBase, yardl::binary::BinaryWriter { + public: + VlensWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryWriter(stream, test_model::VlensWriterBase::SchemaFromVersion(version)), version_(version) {} + + VlensWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryWriter(file_name, test_model::VlensWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntVectorImpl(std::vector const& value) override; + void WriteComplexVectorImpl(std::vector> const& value) override; + void WriteRecordWithVlensImpl(test_model::RecordWithVlens const& value) override; + void WriteVlenOfRecordWithVlensImpl(std::vector const& value) override; + void CloseImpl() override; + + Version version_; +}; + +// Binary indexed writer for the Vlens protocol. +class VlensIndexedWriter : public test_model::VlensWriterBase, yardl::binary::BinaryIndexedWriter { + public: + VlensIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::VlensWriterBase::SchemaFromVersion(version)), version_(version) {} + + VlensIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::VlensWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; protected: void WriteIntVectorImpl(std::vector const& value) override; @@ -422,6 +829,27 @@ class VlensReader : public test_model::VlensReaderBase, yardl::binary::BinaryRea Version version_; }; +// Binary indexed reader for the Vlens protocol. +class VlensIndexedReader : public test_model::VlensIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + VlensIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::VlensIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + VlensIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::VlensIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadIntVectorImpl(std::vector& value) override; + void ReadComplexVectorImpl(std::vector>& value) override; + void ReadRecordWithVlensImpl(test_model::RecordWithVlens& value) override; + void ReadVlenOfRecordWithVlensImpl(std::vector& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the Strings protocol. class StringsWriter : public test_model::StringsWriterBase, yardl::binary::BinaryWriter { public: @@ -441,6 +869,25 @@ class StringsWriter : public test_model::StringsWriterBase, yardl::binary::Binar Version version_; }; +// Binary indexed writer for the Strings protocol. +class StringsIndexedWriter : public test_model::StringsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + StringsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::StringsWriterBase::SchemaFromVersion(version)), version_(version) {} + + StringsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::StringsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteSingleStringImpl(std::string const& value) override; + void WriteRecWithStringImpl(test_model::RecordWithStrings const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Strings protocol. class StringsReader : public test_model::StringsReaderBase, yardl::binary::BinaryReader { public: @@ -460,6 +907,25 @@ class StringsReader : public test_model::StringsReaderBase, yardl::binary::Binar Version version_; }; +// Binary indexed reader for the Strings protocol. +class StringsIndexedReader : public test_model::StringsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + StringsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::StringsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + StringsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::StringsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadSingleStringImpl(std::string& value) override; + void ReadRecWithStringImpl(test_model::RecordWithStrings& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the OptionalVectors protocol. class OptionalVectorsWriter : public test_model::OptionalVectorsWriterBase, yardl::binary::BinaryWriter { public: @@ -478,6 +944,24 @@ class OptionalVectorsWriter : public test_model::OptionalVectorsWriterBase, yard Version version_; }; +// Binary indexed writer for the OptionalVectors protocol. +class OptionalVectorsIndexedWriter : public test_model::OptionalVectorsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + OptionalVectorsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::OptionalVectorsWriterBase::SchemaFromVersion(version)), version_(version) {} + + OptionalVectorsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::OptionalVectorsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteRecordWithOptionalVectorImpl(test_model::RecordWithOptionalVector const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the OptionalVectors protocol. class OptionalVectorsReader : public test_model::OptionalVectorsReaderBase, yardl::binary::BinaryReader { public: @@ -496,6 +980,24 @@ class OptionalVectorsReader : public test_model::OptionalVectorsReaderBase, yard Version version_; }; +// Binary indexed reader for the OptionalVectors protocol. +class OptionalVectorsIndexedReader : public test_model::OptionalVectorsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + OptionalVectorsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::OptionalVectorsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + OptionalVectorsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::OptionalVectorsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadRecordWithOptionalVectorImpl(test_model::RecordWithOptionalVector& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the FixedVectors protocol. class FixedVectorsWriter : public test_model::FixedVectorsWriterBase, yardl::binary::BinaryWriter { public: @@ -517,6 +1019,27 @@ class FixedVectorsWriter : public test_model::FixedVectorsWriterBase, yardl::bin Version version_; }; +// Binary indexed writer for the FixedVectors protocol. +class FixedVectorsIndexedWriter : public test_model::FixedVectorsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + FixedVectorsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::FixedVectorsWriterBase::SchemaFromVersion(version)), version_(version) {} + + FixedVectorsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::FixedVectorsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteFixedIntVectorImpl(std::array const& value) override; + void WriteFixedSimpleRecordVectorImpl(std::array const& value) override; + void WriteFixedRecordWithVlensVectorImpl(std::array const& value) override; + void WriteRecordWithFixedVectorsImpl(test_model::RecordWithFixedVectors const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the FixedVectors protocol. class FixedVectorsReader : public test_model::FixedVectorsReaderBase, yardl::binary::BinaryReader { public: @@ -538,6 +1061,27 @@ class FixedVectorsReader : public test_model::FixedVectorsReaderBase, yardl::bin Version version_; }; +// Binary indexed reader for the FixedVectors protocol. +class FixedVectorsIndexedReader : public test_model::FixedVectorsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + FixedVectorsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::FixedVectorsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + FixedVectorsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::FixedVectorsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadFixedIntVectorImpl(std::array& value) override; + void ReadFixedSimpleRecordVectorImpl(std::array& value) override; + void ReadFixedRecordWithVlensVectorImpl(std::array& value) override; + void ReadRecordWithFixedVectorsImpl(test_model::RecordWithFixedVectors& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the Streams protocol. class StreamsWriter : public test_model::StreamsWriterBase, yardl::binary::BinaryWriter { public: @@ -567,6 +1111,35 @@ class StreamsWriter : public test_model::StreamsWriterBase, yardl::binary::Binar Version version_; }; +// Binary indexed writer for the Streams protocol. +class StreamsIndexedWriter : public test_model::StreamsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + StreamsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::StreamsWriterBase::SchemaFromVersion(version)), version_(version) {} + + StreamsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::StreamsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntDataImpl(int32_t const& value) override; + void WriteIntDataImpl(std::vector const& values) override; + void EndIntDataImpl() override; + void WriteOptionalIntDataImpl(std::optional const& value) override; + void WriteOptionalIntDataImpl(std::vector> const& values) override; + void EndOptionalIntDataImpl() override; + void WriteRecordWithOptionalVectorDataImpl(test_model::RecordWithOptionalVector const& value) override; + void WriteRecordWithOptionalVectorDataImpl(std::vector const& values) override; + void EndRecordWithOptionalVectorDataImpl() override; + void WriteFixedVectorImpl(std::array const& value) override; + void WriteFixedVectorImpl(std::vector> const& values) override; + void EndFixedVectorImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Streams protocol. class StreamsReader : public test_model::StreamsReaderBase, yardl::binary::BinaryReader { public: @@ -595,6 +1168,46 @@ class StreamsReader : public test_model::StreamsReaderBase, yardl::binary::Binar size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the Streams protocol. +class StreamsIndexedReader : public test_model::StreamsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + StreamsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::StreamsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + StreamsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::StreamsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadIntDataImpl(int32_t& value) override; + bool ReadIntDataImpl(std::vector& values) override; + bool ReadIntDataImpl(int32_t& value, size_t idx) override; + bool ReadIntDataImpl(std::vector& values, size_t idx) override; + size_t CountIntDataImpl() override; + bool ReadOptionalIntDataImpl(std::optional& value) override; + bool ReadOptionalIntDataImpl(std::vector>& values) override; + bool ReadOptionalIntDataImpl(std::optional& value, size_t idx) override; + bool ReadOptionalIntDataImpl(std::vector>& values, size_t idx) override; + size_t CountOptionalIntDataImpl() override; + bool ReadRecordWithOptionalVectorDataImpl(test_model::RecordWithOptionalVector& value) override; + bool ReadRecordWithOptionalVectorDataImpl(std::vector& values) override; + bool ReadRecordWithOptionalVectorDataImpl(test_model::RecordWithOptionalVector& value, size_t idx) override; + bool ReadRecordWithOptionalVectorDataImpl(std::vector& values, size_t idx) override; + size_t CountRecordWithOptionalVectorDataImpl() override; + bool ReadFixedVectorImpl(std::array& value) override; + bool ReadFixedVectorImpl(std::vector>& values) override; + bool ReadFixedVectorImpl(std::array& value, size_t idx) override; + bool ReadFixedVectorImpl(std::vector>& values, size_t idx) override; + size_t CountFixedVectorImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the FixedArrays protocol. class FixedArraysWriter : public test_model::FixedArraysWriterBase, yardl::binary::BinaryWriter { public: @@ -617,6 +1230,28 @@ class FixedArraysWriter : public test_model::FixedArraysWriterBase, yardl::binar Version version_; }; +// Binary indexed writer for the FixedArrays protocol. +class FixedArraysIndexedWriter : public test_model::FixedArraysWriterBase, yardl::binary::BinaryIndexedWriter { + public: + FixedArraysIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::FixedArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + FixedArraysIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::FixedArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntsImpl(yardl::FixedNDArray const& value) override; + void WriteFixedSimpleRecordArrayImpl(yardl::FixedNDArray const& value) override; + void WriteFixedRecordWithVlensArrayImpl(yardl::FixedNDArray const& value) override; + void WriteRecordWithFixedArraysImpl(test_model::RecordWithFixedArrays const& value) override; + void WriteNamedArrayImpl(test_model::NamedFixedNDArray const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the FixedArrays protocol. class FixedArraysReader : public test_model::FixedArraysReaderBase, yardl::binary::BinaryReader { public: @@ -639,6 +1274,28 @@ class FixedArraysReader : public test_model::FixedArraysReaderBase, yardl::binar Version version_; }; +// Binary indexed reader for the FixedArrays protocol. +class FixedArraysIndexedReader : public test_model::FixedArraysIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + FixedArraysIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::FixedArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + FixedArraysIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::FixedArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadIntsImpl(yardl::FixedNDArray& value) override; + void ReadFixedSimpleRecordArrayImpl(yardl::FixedNDArray& value) override; + void ReadFixedRecordWithVlensArrayImpl(yardl::FixedNDArray& value) override; + void ReadRecordWithFixedArraysImpl(test_model::RecordWithFixedArrays& value) override; + void ReadNamedArrayImpl(test_model::NamedFixedNDArray& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the Subarrays protocol. class SubarraysWriter : public test_model::SubarraysWriterBase, yardl::binary::BinaryWriter { public: @@ -665,6 +1322,32 @@ class SubarraysWriter : public test_model::SubarraysWriterBase, yardl::binary::B Version version_; }; +// Binary indexed writer for the Subarrays protocol. +class SubarraysIndexedWriter : public test_model::SubarraysWriterBase, yardl::binary::BinaryIndexedWriter { + public: + SubarraysIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::SubarraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + SubarraysIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::SubarraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteDynamicWithFixedIntSubarrayImpl(yardl::DynamicNDArray> const& value) override; + void WriteDynamicWithFixedFloatSubarrayImpl(yardl::DynamicNDArray> const& value) override; + void WriteKnownDimCountWithFixedIntSubarrayImpl(yardl::NDArray, 1> const& value) override; + void WriteKnownDimCountWithFixedFloatSubarrayImpl(yardl::NDArray, 1> const& value) override; + void WriteFixedWithFixedIntSubarrayImpl(yardl::FixedNDArray, 2> const& value) override; + void WriteFixedWithFixedFloatSubarrayImpl(yardl::FixedNDArray, 2> const& value) override; + void WriteNestedSubarrayImpl(yardl::DynamicNDArray, 2>> const& value) override; + void WriteDynamicWithFixedVectorSubarrayImpl(yardl::DynamicNDArray> const& value) override; + void WriteGenericSubarrayImpl(test_model::Image> const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Subarrays protocol. class SubarraysReader : public test_model::SubarraysReaderBase, yardl::binary::BinaryReader { public: @@ -691,6 +1374,32 @@ class SubarraysReader : public test_model::SubarraysReaderBase, yardl::binary::B Version version_; }; +// Binary indexed reader for the Subarrays protocol. +class SubarraysIndexedReader : public test_model::SubarraysIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + SubarraysIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::SubarraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + SubarraysIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::SubarraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadDynamicWithFixedIntSubarrayImpl(yardl::DynamicNDArray>& value) override; + void ReadDynamicWithFixedFloatSubarrayImpl(yardl::DynamicNDArray>& value) override; + void ReadKnownDimCountWithFixedIntSubarrayImpl(yardl::NDArray, 1>& value) override; + void ReadKnownDimCountWithFixedFloatSubarrayImpl(yardl::NDArray, 1>& value) override; + void ReadFixedWithFixedIntSubarrayImpl(yardl::FixedNDArray, 2>& value) override; + void ReadFixedWithFixedFloatSubarrayImpl(yardl::FixedNDArray, 2>& value) override; + void ReadNestedSubarrayImpl(yardl::DynamicNDArray, 2>>& value) override; + void ReadDynamicWithFixedVectorSubarrayImpl(yardl::DynamicNDArray>& value) override; + void ReadGenericSubarrayImpl(test_model::Image>& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the SubarraysInRecords protocol. class SubarraysInRecordsWriter : public test_model::SubarraysInRecordsWriterBase, yardl::binary::BinaryWriter { public: @@ -710,6 +1419,25 @@ class SubarraysInRecordsWriter : public test_model::SubarraysInRecordsWriterBase Version version_; }; +// Binary indexed writer for the SubarraysInRecords protocol. +class SubarraysInRecordsIndexedWriter : public test_model::SubarraysInRecordsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + SubarraysInRecordsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::SubarraysInRecordsWriterBase::SchemaFromVersion(version)), version_(version) {} + + SubarraysInRecordsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::SubarraysInRecordsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteWithFixedSubarraysImpl(yardl::DynamicNDArray const& value) override; + void WriteWithVlenSubarraysImpl(yardl::DynamicNDArray const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the SubarraysInRecords protocol. class SubarraysInRecordsReader : public test_model::SubarraysInRecordsReaderBase, yardl::binary::BinaryReader { public: @@ -729,6 +1457,25 @@ class SubarraysInRecordsReader : public test_model::SubarraysInRecordsReaderBase Version version_; }; +// Binary indexed reader for the SubarraysInRecords protocol. +class SubarraysInRecordsIndexedReader : public test_model::SubarraysInRecordsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + SubarraysInRecordsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::SubarraysInRecordsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + SubarraysInRecordsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::SubarraysInRecordsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadWithFixedSubarraysImpl(yardl::DynamicNDArray& value) override; + void ReadWithVlenSubarraysImpl(yardl::DynamicNDArray& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the NDArrays protocol. class NDArraysWriter : public test_model::NDArraysWriterBase, yardl::binary::BinaryWriter { public: @@ -751,6 +1498,28 @@ class NDArraysWriter : public test_model::NDArraysWriterBase, yardl::binary::Bin Version version_; }; +// Binary indexed writer for the NDArrays protocol. +class NDArraysIndexedWriter : public test_model::NDArraysWriterBase, yardl::binary::BinaryIndexedWriter { + public: + NDArraysIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::NDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + NDArraysIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::NDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntsImpl(yardl::NDArray const& value) override; + void WriteSimpleRecordArrayImpl(yardl::NDArray const& value) override; + void WriteRecordWithVlensArrayImpl(yardl::NDArray const& value) override; + void WriteRecordWithNDArraysImpl(test_model::RecordWithNDArrays const& value) override; + void WriteNamedArrayImpl(test_model::NamedNDArray const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the NDArrays protocol. class NDArraysReader : public test_model::NDArraysReaderBase, yardl::binary::BinaryReader { public: @@ -773,6 +1542,28 @@ class NDArraysReader : public test_model::NDArraysReaderBase, yardl::binary::Bin Version version_; }; +// Binary indexed reader for the NDArrays protocol. +class NDArraysIndexedReader : public test_model::NDArraysIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + NDArraysIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::NDArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + NDArraysIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::NDArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadIntsImpl(yardl::NDArray& value) override; + void ReadSimpleRecordArrayImpl(yardl::NDArray& value) override; + void ReadRecordWithVlensArrayImpl(yardl::NDArray& value) override; + void ReadRecordWithNDArraysImpl(test_model::RecordWithNDArrays& value) override; + void ReadNamedArrayImpl(test_model::NamedNDArray& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the NDArraysSingleDimension protocol. class NDArraysSingleDimensionWriter : public test_model::NDArraysSingleDimensionWriterBase, yardl::binary::BinaryWriter { public: @@ -794,6 +1585,27 @@ class NDArraysSingleDimensionWriter : public test_model::NDArraysSingleDimension Version version_; }; +// Binary indexed writer for the NDArraysSingleDimension protocol. +class NDArraysSingleDimensionIndexedWriter : public test_model::NDArraysSingleDimensionWriterBase, yardl::binary::BinaryIndexedWriter { + public: + NDArraysSingleDimensionIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::NDArraysSingleDimensionWriterBase::SchemaFromVersion(version)), version_(version) {} + + NDArraysSingleDimensionIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::NDArraysSingleDimensionWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntsImpl(yardl::NDArray const& value) override; + void WriteSimpleRecordArrayImpl(yardl::NDArray const& value) override; + void WriteRecordWithVlensArrayImpl(yardl::NDArray const& value) override; + void WriteRecordWithNDArraysImpl(test_model::RecordWithNDArraysSingleDimension const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the NDArraysSingleDimension protocol. class NDArraysSingleDimensionReader : public test_model::NDArraysSingleDimensionReaderBase, yardl::binary::BinaryReader { public: @@ -815,6 +1627,27 @@ class NDArraysSingleDimensionReader : public test_model::NDArraysSingleDimension Version version_; }; +// Binary indexed reader for the NDArraysSingleDimension protocol. +class NDArraysSingleDimensionIndexedReader : public test_model::NDArraysSingleDimensionIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + NDArraysSingleDimensionIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::NDArraysSingleDimensionIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + NDArraysSingleDimensionIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::NDArraysSingleDimensionIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadIntsImpl(yardl::NDArray& value) override; + void ReadSimpleRecordArrayImpl(yardl::NDArray& value) override; + void ReadRecordWithVlensArrayImpl(yardl::NDArray& value) override; + void ReadRecordWithNDArraysImpl(test_model::RecordWithNDArraysSingleDimension& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the DynamicNDArrays protocol. class DynamicNDArraysWriter : public test_model::DynamicNDArraysWriterBase, yardl::binary::BinaryWriter { public: @@ -836,6 +1669,27 @@ class DynamicNDArraysWriter : public test_model::DynamicNDArraysWriterBase, yard Version version_; }; +// Binary indexed writer for the DynamicNDArrays protocol. +class DynamicNDArraysIndexedWriter : public test_model::DynamicNDArraysWriterBase, yardl::binary::BinaryIndexedWriter { + public: + DynamicNDArraysIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::DynamicNDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + DynamicNDArraysIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::DynamicNDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntsImpl(yardl::DynamicNDArray const& value) override; + void WriteSimpleRecordArrayImpl(yardl::DynamicNDArray const& value) override; + void WriteRecordWithVlensArrayImpl(yardl::DynamicNDArray const& value) override; + void WriteRecordWithDynamicNDArraysImpl(test_model::RecordWithDynamicNDArrays const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the DynamicNDArrays protocol. class DynamicNDArraysReader : public test_model::DynamicNDArraysReaderBase, yardl::binary::BinaryReader { public: @@ -857,14 +1711,58 @@ class DynamicNDArraysReader : public test_model::DynamicNDArraysReaderBase, yard Version version_; }; -// Binary writer for the MultiDArrays protocol. -class MultiDArraysWriter : public test_model::MultiDArraysWriterBase, yardl::binary::BinaryWriter { +// Binary indexed reader for the DynamicNDArrays protocol. +class DynamicNDArraysIndexedReader : public test_model::DynamicNDArraysIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + DynamicNDArraysIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::DynamicNDArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + DynamicNDArraysIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::DynamicNDArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadIntsImpl(yardl::DynamicNDArray& value) override; + void ReadSimpleRecordArrayImpl(yardl::DynamicNDArray& value) override; + void ReadRecordWithVlensArrayImpl(yardl::DynamicNDArray& value) override; + void ReadRecordWithDynamicNDArraysImpl(test_model::RecordWithDynamicNDArrays& value) override; + void CloseImpl() override; + + Version version_; +}; + +// Binary writer for the MultiDArrays protocol. +class MultiDArraysWriter : public test_model::MultiDArraysWriterBase, yardl::binary::BinaryWriter { + public: + MultiDArraysWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryWriter(stream, test_model::MultiDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + MultiDArraysWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryWriter(file_name, test_model::MultiDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteImagesImpl(yardl::NDArray const& value) override; + void WriteImagesImpl(std::vector> const& values) override; + void EndImagesImpl() override; + void WriteFramesImpl(yardl::FixedNDArray const& value) override; + void WriteFramesImpl(std::vector> const& values) override; + void EndFramesImpl() override; + void CloseImpl() override; + + Version version_; +}; + +// Binary indexed writer for the MultiDArrays protocol. +class MultiDArraysIndexedWriter : public test_model::MultiDArraysWriterBase, yardl::binary::BinaryIndexedWriter { public: - MultiDArraysWriter(std::ostream& stream, Version version = Version::Current) - : yardl::binary::BinaryWriter(stream, test_model::MultiDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + MultiDArraysIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::MultiDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} - MultiDArraysWriter(std::string file_name, Version version = Version::Current) - : yardl::binary::BinaryWriter(file_name, test_model::MultiDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + MultiDArraysIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::MultiDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} void Flush() override; @@ -904,6 +1802,36 @@ class MultiDArraysReader : public test_model::MultiDArraysReaderBase, yardl::bin size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the MultiDArrays protocol. +class MultiDArraysIndexedReader : public test_model::MultiDArraysIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + MultiDArraysIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::MultiDArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + MultiDArraysIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::MultiDArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadImagesImpl(yardl::NDArray& value) override; + bool ReadImagesImpl(std::vector>& values) override; + bool ReadImagesImpl(yardl::NDArray& value, size_t idx) override; + bool ReadImagesImpl(std::vector>& values, size_t idx) override; + size_t CountImagesImpl() override; + bool ReadFramesImpl(yardl::FixedNDArray& value) override; + bool ReadFramesImpl(std::vector>& values) override; + bool ReadFramesImpl(yardl::FixedNDArray& value, size_t idx) override; + bool ReadFramesImpl(std::vector>& values, size_t idx) override; + size_t CountFramesImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the ComplexArrays protocol. class ComplexArraysWriter : public test_model::ComplexArraysWriterBase, yardl::binary::BinaryWriter { public: @@ -923,6 +1851,25 @@ class ComplexArraysWriter : public test_model::ComplexArraysWriterBase, yardl::b Version version_; }; +// Binary indexed writer for the ComplexArrays protocol. +class ComplexArraysIndexedWriter : public test_model::ComplexArraysWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ComplexArraysIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::ComplexArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + ComplexArraysIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::ComplexArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteFloatsImpl(yardl::DynamicNDArray> const& value) override; + void WriteDoublesImpl(yardl::NDArray, 2> const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the ComplexArrays protocol. class ComplexArraysReader : public test_model::ComplexArraysReaderBase, yardl::binary::BinaryReader { public: @@ -942,6 +1889,25 @@ class ComplexArraysReader : public test_model::ComplexArraysReaderBase, yardl::b Version version_; }; +// Binary indexed reader for the ComplexArrays protocol. +class ComplexArraysIndexedReader : public test_model::ComplexArraysIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ComplexArraysIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::ComplexArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ComplexArraysIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::ComplexArraysIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadFloatsImpl(yardl::DynamicNDArray>& value) override; + void ReadDoublesImpl(yardl::NDArray, 2>& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the Maps protocol. class MapsWriter : public test_model::MapsWriterBase, yardl::binary::BinaryWriter { public: @@ -964,6 +1930,28 @@ class MapsWriter : public test_model::MapsWriterBase, yardl::binary::BinaryWrite Version version_; }; +// Binary indexed writer for the Maps protocol. +class MapsIndexedWriter : public test_model::MapsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + MapsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::MapsWriterBase::SchemaFromVersion(version)), version_(version) {} + + MapsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::MapsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteStringToIntImpl(std::unordered_map const& value) override; + void WriteIntToStringImpl(std::unordered_map const& value) override; + void WriteStringToUnionImpl(std::unordered_map> const& value) override; + void WriteAliasedGenericImpl(basic_types::AliasedMap const& value) override; + void WriteRecordsImpl(std::vector const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Maps protocol. class MapsReader : public test_model::MapsReaderBase, yardl::binary::BinaryReader { public: @@ -986,6 +1974,28 @@ class MapsReader : public test_model::MapsReaderBase, yardl::binary::BinaryReade Version version_; }; +// Binary indexed reader for the Maps protocol. +class MapsIndexedReader : public test_model::MapsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + MapsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::MapsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + MapsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::MapsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadStringToIntImpl(std::unordered_map& value) override; + void ReadIntToStringImpl(std::unordered_map& value) override; + void ReadStringToUnionImpl(std::unordered_map>& value) override; + void ReadAliasedGenericImpl(basic_types::AliasedMap& value) override; + void ReadRecordsImpl(std::vector& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the Unions protocol. class UnionsWriter : public test_model::UnionsWriterBase, yardl::binary::BinaryWriter { public: @@ -1007,6 +2017,27 @@ class UnionsWriter : public test_model::UnionsWriterBase, yardl::binary::BinaryW Version version_; }; +// Binary indexed writer for the Unions protocol. +class UnionsIndexedWriter : public test_model::UnionsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + UnionsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::UnionsWriterBase::SchemaFromVersion(version)), version_(version) {} + + UnionsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::UnionsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntOrSimpleRecordImpl(std::variant const& value) override; + void WriteIntOrRecordWithVlensImpl(std::variant const& value) override; + void WriteMonosotateOrIntOrSimpleRecordImpl(std::variant const& value) override; + void WriteRecordWithUnionsImpl(basic_types::RecordWithUnions const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Unions protocol. class UnionsReader : public test_model::UnionsReaderBase, yardl::binary::BinaryReader { public: @@ -1028,6 +2059,27 @@ class UnionsReader : public test_model::UnionsReaderBase, yardl::binary::BinaryR Version version_; }; +// Binary indexed reader for the Unions protocol. +class UnionsIndexedReader : public test_model::UnionsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + UnionsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::UnionsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + UnionsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::UnionsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadIntOrSimpleRecordImpl(std::variant& value) override; + void ReadIntOrRecordWithVlensImpl(std::variant& value) override; + void ReadMonosotateOrIntOrSimpleRecordImpl(std::variant& value) override; + void ReadRecordWithUnionsImpl(basic_types::RecordWithUnions& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the StreamsOfUnions protocol. class StreamsOfUnionsWriter : public test_model::StreamsOfUnionsWriterBase, yardl::binary::BinaryWriter { public: @@ -1054,6 +2106,32 @@ class StreamsOfUnionsWriter : public test_model::StreamsOfUnionsWriterBase, yard Version version_; }; +// Binary indexed writer for the StreamsOfUnions protocol. +class StreamsOfUnionsIndexedWriter : public test_model::StreamsOfUnionsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + StreamsOfUnionsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::StreamsOfUnionsWriterBase::SchemaFromVersion(version)), version_(version) {} + + StreamsOfUnionsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::StreamsOfUnionsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntOrSimpleRecordImpl(std::variant const& value) override; + void WriteIntOrSimpleRecordImpl(std::vector> const& values) override; + void EndIntOrSimpleRecordImpl() override; + void WriteNullableIntOrSimpleRecordImpl(std::variant const& value) override; + void WriteNullableIntOrSimpleRecordImpl(std::vector> const& values) override; + void EndNullableIntOrSimpleRecordImpl() override; + void WriteManyCasesImpl(std::variant const& value) override; + void WriteManyCasesImpl(std::vector> const& values) override; + void EndManyCasesImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the StreamsOfUnions protocol. class StreamsOfUnionsReader : public test_model::StreamsOfUnionsReaderBase, yardl::binary::BinaryReader { public: @@ -1080,6 +2158,41 @@ class StreamsOfUnionsReader : public test_model::StreamsOfUnionsReaderBase, yard size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the StreamsOfUnions protocol. +class StreamsOfUnionsIndexedReader : public test_model::StreamsOfUnionsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + StreamsOfUnionsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::StreamsOfUnionsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + StreamsOfUnionsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::StreamsOfUnionsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadIntOrSimpleRecordImpl(std::variant& value) override; + bool ReadIntOrSimpleRecordImpl(std::vector>& values) override; + bool ReadIntOrSimpleRecordImpl(std::variant& value, size_t idx) override; + bool ReadIntOrSimpleRecordImpl(std::vector>& values, size_t idx) override; + size_t CountIntOrSimpleRecordImpl() override; + bool ReadNullableIntOrSimpleRecordImpl(std::variant& value) override; + bool ReadNullableIntOrSimpleRecordImpl(std::vector>& values) override; + bool ReadNullableIntOrSimpleRecordImpl(std::variant& value, size_t idx) override; + bool ReadNullableIntOrSimpleRecordImpl(std::vector>& values, size_t idx) override; + size_t CountNullableIntOrSimpleRecordImpl() override; + bool ReadManyCasesImpl(std::variant& value) override; + bool ReadManyCasesImpl(std::vector>& values) override; + bool ReadManyCasesImpl(std::variant& value, size_t idx) override; + bool ReadManyCasesImpl(std::vector>& values, size_t idx) override; + size_t CountManyCasesImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the Enums protocol. class EnumsWriter : public test_model::EnumsWriterBase, yardl::binary::BinaryWriter { public: @@ -1101,6 +2214,27 @@ class EnumsWriter : public test_model::EnumsWriterBase, yardl::binary::BinaryWri Version version_; }; +// Binary indexed writer for the Enums protocol. +class EnumsIndexedWriter : public test_model::EnumsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + EnumsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::EnumsWriterBase::SchemaFromVersion(version)), version_(version) {} + + EnumsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::EnumsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteSingleImpl(test_model::Fruits const& value) override; + void WriteVecImpl(std::vector const& value) override; + void WriteSizeImpl(test_model::SizeBasedEnum const& value) override; + void WriteRecImpl(test_model::RecordWithEnums const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Enums protocol. class EnumsReader : public test_model::EnumsReaderBase, yardl::binary::BinaryReader { public: @@ -1122,6 +2256,27 @@ class EnumsReader : public test_model::EnumsReaderBase, yardl::binary::BinaryRea Version version_; }; +// Binary indexed reader for the Enums protocol. +class EnumsIndexedReader : public test_model::EnumsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + EnumsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::EnumsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + EnumsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::EnumsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadSingleImpl(test_model::Fruits& value) override; + void ReadVecImpl(std::vector& value) override; + void ReadSizeImpl(test_model::SizeBasedEnum& value) override; + void ReadRecImpl(test_model::RecordWithEnums& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the Flags protocol. class FlagsWriter : public test_model::FlagsWriterBase, yardl::binary::BinaryWriter { public: @@ -1145,6 +2300,29 @@ class FlagsWriter : public test_model::FlagsWriterBase, yardl::binary::BinaryWri Version version_; }; +// Binary indexed writer for the Flags protocol. +class FlagsIndexedWriter : public test_model::FlagsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + FlagsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::FlagsWriterBase::SchemaFromVersion(version)), version_(version) {} + + FlagsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::FlagsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteDaysImpl(test_model::DaysOfWeek const& value) override; + void WriteDaysImpl(std::vector const& values) override; + void EndDaysImpl() override; + void WriteFormatsImpl(test_model::TextFormat const& value) override; + void WriteFormatsImpl(std::vector const& values) override; + void EndFormatsImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Flags protocol. class FlagsReader : public test_model::FlagsReaderBase, yardl::binary::BinaryReader { public: @@ -1169,6 +2347,36 @@ class FlagsReader : public test_model::FlagsReaderBase, yardl::binary::BinaryRea size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the Flags protocol. +class FlagsIndexedReader : public test_model::FlagsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + FlagsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::FlagsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + FlagsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::FlagsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadDaysImpl(test_model::DaysOfWeek& value) override; + bool ReadDaysImpl(std::vector& values) override; + bool ReadDaysImpl(test_model::DaysOfWeek& value, size_t idx) override; + bool ReadDaysImpl(std::vector& values, size_t idx) override; + size_t CountDaysImpl() override; + bool ReadFormatsImpl(test_model::TextFormat& value) override; + bool ReadFormatsImpl(std::vector& values) override; + bool ReadFormatsImpl(test_model::TextFormat& value, size_t idx) override; + bool ReadFormatsImpl(std::vector& values, size_t idx) override; + size_t CountFormatsImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the StateTest protocol. class StateTestWriter : public test_model::StateTestWriterBase, yardl::binary::BinaryWriter { public: @@ -1191,14 +2399,60 @@ class StateTestWriter : public test_model::StateTestWriterBase, yardl::binary::B Version version_; }; -// Binary reader for the StateTest protocol. -class StateTestReader : public test_model::StateTestReaderBase, yardl::binary::BinaryReader { +// Binary indexed writer for the StateTest protocol. +class StateTestIndexedWriter : public test_model::StateTestWriterBase, yardl::binary::BinaryIndexedWriter { + public: + StateTestIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::StateTestWriterBase::SchemaFromVersion(version)), version_(version) {} + + StateTestIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::StateTestWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteAnIntImpl(int32_t const& value) override; + void WriteAStreamImpl(int32_t const& value) override; + void WriteAStreamImpl(std::vector const& values) override; + void EndAStreamImpl() override; + void WriteAnotherIntImpl(int32_t const& value) override; + void CloseImpl() override; + + Version version_; +}; + +// Binary reader for the StateTest protocol. +class StateTestReader : public test_model::StateTestReaderBase, yardl::binary::BinaryReader { + public: + StateTestReader(std::istream& stream) + : yardl::binary::BinaryReader(stream), version_(test_model::StateTestReaderBase::VersionFromSchema(schema_read_)) {} + + StateTestReader(std::string file_name) + : yardl::binary::BinaryReader(file_name), version_(test_model::StateTestReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadAnIntImpl(int32_t& value) override; + bool ReadAStreamImpl(int32_t& value) override; + bool ReadAStreamImpl(std::vector& values) override; + void ReadAnotherIntImpl(int32_t& value) override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + +// Binary indexed reader for the StateTest protocol. +class StateTestIndexedReader : public test_model::StateTestIndexedReaderBase, yardl::binary::BinaryIndexedReader { public: - StateTestReader(std::istream& stream) - : yardl::binary::BinaryReader(stream), version_(test_model::StateTestReaderBase::VersionFromSchema(schema_read_)) {} + StateTestIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::StateTestIndexedReaderBase::VersionFromSchema(schema_read_)) {} - StateTestReader(std::string file_name) - : yardl::binary::BinaryReader(file_name), version_(test_model::StateTestReaderBase::VersionFromSchema(schema_read_)) {} + StateTestIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::StateTestIndexedReaderBase::VersionFromSchema(schema_read_)) {} Version GetVersion() { return version_; } @@ -1206,6 +2460,9 @@ class StateTestReader : public test_model::StateTestReaderBase, yardl::binary::B void ReadAnIntImpl(int32_t& value) override; bool ReadAStreamImpl(int32_t& value) override; bool ReadAStreamImpl(std::vector& values) override; + bool ReadAStreamImpl(int32_t& value, size_t idx) override; + bool ReadAStreamImpl(std::vector& values, size_t idx) override; + size_t CountAStreamImpl() override; void ReadAnotherIntImpl(int32_t& value) override; void CloseImpl() override; @@ -1243,6 +2500,34 @@ class SimpleGenericsWriter : public test_model::SimpleGenericsWriterBase, yardl: Version version_; }; +// Binary indexed writer for the SimpleGenerics protocol. +class SimpleGenericsIndexedWriter : public test_model::SimpleGenericsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + SimpleGenericsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::SimpleGenericsWriterBase::SchemaFromVersion(version)), version_(version) {} + + SimpleGenericsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::SimpleGenericsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteFloatImageImpl(image::FloatImage const& value) override; + void WriteIntImageImpl(image::IntImage const& value) override; + void WriteIntImageAlternateSyntaxImpl(test_model::Image const& value) override; + void WriteStringImageImpl(test_model::Image const& value) override; + void WriteIntFloatTupleImpl(tuples::Tuple const& value) override; + void WriteFloatFloatTupleImpl(tuples::Tuple const& value) override; + void WriteIntFloatTupleAlternateSyntaxImpl(tuples::Tuple const& value) override; + void WriteIntStringTupleImpl(tuples::Tuple const& value) override; + void WriteStreamOfTypeVariantsImpl(std::variant> const& value) override; + void WriteStreamOfTypeVariantsImpl(std::vector>> const& values) override; + void EndStreamOfTypeVariantsImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the SimpleGenerics protocol. class SimpleGenericsReader : public test_model::SimpleGenericsReaderBase, yardl::binary::BinaryReader { public: @@ -1273,6 +2558,39 @@ class SimpleGenericsReader : public test_model::SimpleGenericsReaderBase, yardl: size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the SimpleGenerics protocol. +class SimpleGenericsIndexedReader : public test_model::SimpleGenericsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + SimpleGenericsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::SimpleGenericsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + SimpleGenericsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::SimpleGenericsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadFloatImageImpl(image::FloatImage& value) override; + void ReadIntImageImpl(image::IntImage& value) override; + void ReadIntImageAlternateSyntaxImpl(test_model::Image& value) override; + void ReadStringImageImpl(test_model::Image& value) override; + void ReadIntFloatTupleImpl(tuples::Tuple& value) override; + void ReadFloatFloatTupleImpl(tuples::Tuple& value) override; + void ReadIntFloatTupleAlternateSyntaxImpl(tuples::Tuple& value) override; + void ReadIntStringTupleImpl(tuples::Tuple& value) override; + bool ReadStreamOfTypeVariantsImpl(std::variant>& value) override; + bool ReadStreamOfTypeVariantsImpl(std::vector>>& values) override; + bool ReadStreamOfTypeVariantsImpl(std::variant>& value, size_t idx) override; + bool ReadStreamOfTypeVariantsImpl(std::vector>>& values, size_t idx) override; + size_t CountStreamOfTypeVariantsImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the AdvancedGenerics protocol. class AdvancedGenericsWriter : public test_model::AdvancedGenericsWriterBase, yardl::binary::BinaryWriter { public: @@ -1295,6 +2613,28 @@ class AdvancedGenericsWriter : public test_model::AdvancedGenericsWriterBase, ya Version version_; }; +// Binary indexed writer for the AdvancedGenerics protocol. +class AdvancedGenericsIndexedWriter : public test_model::AdvancedGenericsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + AdvancedGenericsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::AdvancedGenericsWriterBase::SchemaFromVersion(version)), version_(version) {} + + AdvancedGenericsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::AdvancedGenericsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteFloatImageImageImpl(test_model::Image> const& value) override; + void WriteGenericRecord1Impl(test_model::GenericRecord const& value) override; + void WriteTupleOfOptionalsImpl(test_model::MyTuple, std::optional> const& value) override; + void WriteTupleOfOptionalsAlternateSyntaxImpl(test_model::MyTuple, std::optional> const& value) override; + void WriteTupleOfVectorsImpl(test_model::MyTuple, std::vector> const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the AdvancedGenerics protocol. class AdvancedGenericsReader : public test_model::AdvancedGenericsReaderBase, yardl::binary::BinaryReader { public: @@ -1317,6 +2657,28 @@ class AdvancedGenericsReader : public test_model::AdvancedGenericsReaderBase, ya Version version_; }; +// Binary indexed reader for the AdvancedGenerics protocol. +class AdvancedGenericsIndexedReader : public test_model::AdvancedGenericsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + AdvancedGenericsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::AdvancedGenericsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + AdvancedGenericsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::AdvancedGenericsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadFloatImageImageImpl(test_model::Image>& value) override; + void ReadGenericRecord1Impl(test_model::GenericRecord& value) override; + void ReadTupleOfOptionalsImpl(test_model::MyTuple, std::optional>& value) override; + void ReadTupleOfOptionalsAlternateSyntaxImpl(test_model::MyTuple, std::optional>& value) override; + void ReadTupleOfVectorsImpl(test_model::MyTuple, std::vector>& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the Aliases protocol. class AliasesWriter : public test_model::AliasesWriterBase, yardl::binary::BinaryWriter { public: @@ -1346,6 +2708,35 @@ class AliasesWriter : public test_model::AliasesWriterBase, yardl::binary::Binar Version version_; }; +// Binary indexed writer for the Aliases protocol. +class AliasesIndexedWriter : public test_model::AliasesWriterBase, yardl::binary::BinaryIndexedWriter { + public: + AliasesIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::AliasesWriterBase::SchemaFromVersion(version)), version_(version) {} + + AliasesIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::AliasesWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteAliasedStringImpl(test_model::AliasedString const& value) override; + void WriteAliasedEnumImpl(test_model::AliasedEnum const& value) override; + void WriteAliasedOpenGenericImpl(test_model::AliasedOpenGeneric const& value) override; + void WriteAliasedClosedGenericImpl(test_model::AliasedClosedGeneric const& value) override; + void WriteAliasedOptionalImpl(test_model::AliasedOptional const& value) override; + void WriteAliasedGenericOptionalImpl(test_model::AliasedGenericOptional const& value) override; + void WriteAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2 const& value) override; + void WriteAliasedGenericVectorImpl(test_model::AliasedGenericVector const& value) override; + void WriteAliasedGenericFixedVectorImpl(test_model::AliasedGenericFixedVector const& value) override; + void WriteStreamOfAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2 const& value) override; + void WriteStreamOfAliasedGenericUnion2Impl(std::vector> const& values) override; + void EndStreamOfAliasedGenericUnion2Impl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the Aliases protocol. class AliasesReader : public test_model::AliasesReaderBase, yardl::binary::BinaryReader { public: @@ -1377,6 +2768,40 @@ class AliasesReader : public test_model::AliasesReaderBase, yardl::binary::Binar size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the Aliases protocol. +class AliasesIndexedReader : public test_model::AliasesIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + AliasesIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::AliasesIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + AliasesIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::AliasesIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadAliasedStringImpl(test_model::AliasedString& value) override; + void ReadAliasedEnumImpl(test_model::AliasedEnum& value) override; + void ReadAliasedOpenGenericImpl(test_model::AliasedOpenGeneric& value) override; + void ReadAliasedClosedGenericImpl(test_model::AliasedClosedGeneric& value) override; + void ReadAliasedOptionalImpl(test_model::AliasedOptional& value) override; + void ReadAliasedGenericOptionalImpl(test_model::AliasedGenericOptional& value) override; + void ReadAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2& value) override; + void ReadAliasedGenericVectorImpl(test_model::AliasedGenericVector& value) override; + void ReadAliasedGenericFixedVectorImpl(test_model::AliasedGenericFixedVector& value) override; + bool ReadStreamOfAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2& value) override; + bool ReadStreamOfAliasedGenericUnion2Impl(std::vector>& values) override; + bool ReadStreamOfAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2& value, size_t idx) override; + bool ReadStreamOfAliasedGenericUnion2Impl(std::vector>& values, size_t idx) override; + size_t CountStreamOfAliasedGenericUnion2Impl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the StreamsOfAliasedUnions protocol. class StreamsOfAliasedUnionsWriter : public test_model::StreamsOfAliasedUnionsWriterBase, yardl::binary::BinaryWriter { public: @@ -1400,6 +2825,29 @@ class StreamsOfAliasedUnionsWriter : public test_model::StreamsOfAliasedUnionsWr Version version_; }; +// Binary indexed writer for the StreamsOfAliasedUnions protocol. +class StreamsOfAliasedUnionsIndexedWriter : public test_model::StreamsOfAliasedUnionsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + StreamsOfAliasedUnionsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::StreamsOfAliasedUnionsWriterBase::SchemaFromVersion(version)), version_(version) {} + + StreamsOfAliasedUnionsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::StreamsOfAliasedUnionsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntOrSimpleRecordImpl(test_model::AliasedIntOrSimpleRecord const& value) override; + void WriteIntOrSimpleRecordImpl(std::vector const& values) override; + void EndIntOrSimpleRecordImpl() override; + void WriteNullableIntOrSimpleRecordImpl(test_model::AliasedNullableIntSimpleRecord const& value) override; + void WriteNullableIntOrSimpleRecordImpl(std::vector const& values) override; + void EndNullableIntOrSimpleRecordImpl() override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the StreamsOfAliasedUnions protocol. class StreamsOfAliasedUnionsReader : public test_model::StreamsOfAliasedUnionsReaderBase, yardl::binary::BinaryReader { public: @@ -1424,6 +2872,36 @@ class StreamsOfAliasedUnionsReader : public test_model::StreamsOfAliasedUnionsRe size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the StreamsOfAliasedUnions protocol. +class StreamsOfAliasedUnionsIndexedReader : public test_model::StreamsOfAliasedUnionsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + StreamsOfAliasedUnionsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::StreamsOfAliasedUnionsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + StreamsOfAliasedUnionsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::StreamsOfAliasedUnionsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadIntOrSimpleRecordImpl(test_model::AliasedIntOrSimpleRecord& value) override; + bool ReadIntOrSimpleRecordImpl(std::vector& values) override; + bool ReadIntOrSimpleRecordImpl(test_model::AliasedIntOrSimpleRecord& value, size_t idx) override; + bool ReadIntOrSimpleRecordImpl(std::vector& values, size_t idx) override; + size_t CountIntOrSimpleRecordImpl() override; + bool ReadNullableIntOrSimpleRecordImpl(test_model::AliasedNullableIntSimpleRecord& value) override; + bool ReadNullableIntOrSimpleRecordImpl(std::vector& values) override; + bool ReadNullableIntOrSimpleRecordImpl(test_model::AliasedNullableIntSimpleRecord& value, size_t idx) override; + bool ReadNullableIntOrSimpleRecordImpl(std::vector& values, size_t idx) override; + size_t CountNullableIntOrSimpleRecordImpl() override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the ProtocolWithComputedFields protocol. class ProtocolWithComputedFieldsWriter : public test_model::ProtocolWithComputedFieldsWriterBase, yardl::binary::BinaryWriter { public: @@ -1442,6 +2920,24 @@ class ProtocolWithComputedFieldsWriter : public test_model::ProtocolWithComputed Version version_; }; +// Binary indexed writer for the ProtocolWithComputedFields protocol. +class ProtocolWithComputedFieldsIndexedWriter : public test_model::ProtocolWithComputedFieldsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ProtocolWithComputedFieldsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::ProtocolWithComputedFieldsWriterBase::SchemaFromVersion(version)), version_(version) {} + + ProtocolWithComputedFieldsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::ProtocolWithComputedFieldsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteRecordWithComputedFieldsImpl(test_model::RecordWithComputedFields const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the ProtocolWithComputedFields protocol. class ProtocolWithComputedFieldsReader : public test_model::ProtocolWithComputedFieldsReaderBase, yardl::binary::BinaryReader { public: @@ -1460,6 +2956,24 @@ class ProtocolWithComputedFieldsReader : public test_model::ProtocolWithComputed Version version_; }; +// Binary indexed reader for the ProtocolWithComputedFields protocol. +class ProtocolWithComputedFieldsIndexedReader : public test_model::ProtocolWithComputedFieldsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ProtocolWithComputedFieldsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::ProtocolWithComputedFieldsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ProtocolWithComputedFieldsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::ProtocolWithComputedFieldsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadRecordWithComputedFieldsImpl(test_model::RecordWithComputedFields& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary writer for the ProtocolWithKeywordSteps protocol. class ProtocolWithKeywordStepsWriter : public test_model::ProtocolWithKeywordStepsWriterBase, yardl::binary::BinaryWriter { public: @@ -1481,6 +2995,27 @@ class ProtocolWithKeywordStepsWriter : public test_model::ProtocolWithKeywordSte Version version_; }; +// Binary indexed writer for the ProtocolWithKeywordSteps protocol. +class ProtocolWithKeywordStepsIndexedWriter : public test_model::ProtocolWithKeywordStepsWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ProtocolWithKeywordStepsIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::ProtocolWithKeywordStepsWriterBase::SchemaFromVersion(version)), version_(version) {} + + ProtocolWithKeywordStepsIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::ProtocolWithKeywordStepsWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteIntImpl(test_model::RecordWithKeywordFields const& value) override; + void WriteIntImpl(std::vector const& values) override; + void EndIntImpl() override; + void WriteFloatImpl(test_model::EnumWithKeywordSymbols const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the ProtocolWithKeywordSteps protocol. class ProtocolWithKeywordStepsReader : public test_model::ProtocolWithKeywordStepsReaderBase, yardl::binary::BinaryReader { public: @@ -1504,6 +3039,32 @@ class ProtocolWithKeywordStepsReader : public test_model::ProtocolWithKeywordSte size_t current_block_remaining_ = 0; }; +// Binary indexed reader for the ProtocolWithKeywordSteps protocol. +class ProtocolWithKeywordStepsIndexedReader : public test_model::ProtocolWithKeywordStepsIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ProtocolWithKeywordStepsIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::ProtocolWithKeywordStepsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ProtocolWithKeywordStepsIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::ProtocolWithKeywordStepsIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadIntImpl(test_model::RecordWithKeywordFields& value) override; + bool ReadIntImpl(std::vector& values) override; + bool ReadIntImpl(test_model::RecordWithKeywordFields& value, size_t idx) override; + bool ReadIntImpl(std::vector& values, size_t idx) override; + size_t CountIntImpl() override; + void ReadFloatImpl(test_model::EnumWithKeywordSymbols& value) override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the ProtocolWithOptionalDate protocol. class ProtocolWithOptionalDateWriter : public test_model::ProtocolWithOptionalDateWriterBase, yardl::binary::BinaryWriter { public: @@ -1522,6 +3083,24 @@ class ProtocolWithOptionalDateWriter : public test_model::ProtocolWithOptionalDa Version version_; }; +// Binary indexed writer for the ProtocolWithOptionalDate protocol. +class ProtocolWithOptionalDateIndexedWriter : public test_model::ProtocolWithOptionalDateWriterBase, yardl::binary::BinaryIndexedWriter { + public: + ProtocolWithOptionalDateIndexedWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(stream, test_model::ProtocolWithOptionalDateWriterBase::SchemaFromVersion(version)), version_(version) {} + + ProtocolWithOptionalDateIndexedWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryIndexedWriter(file_name, test_model::ProtocolWithOptionalDateWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteRecordImpl(std::optional const& value) override; + void CloseImpl() override; + + Version version_; +}; + // Binary reader for the ProtocolWithOptionalDate protocol. class ProtocolWithOptionalDateReader : public test_model::ProtocolWithOptionalDateReaderBase, yardl::binary::BinaryReader { public: @@ -1540,4 +3119,22 @@ class ProtocolWithOptionalDateReader : public test_model::ProtocolWithOptionalDa Version version_; }; +// Binary indexed reader for the ProtocolWithOptionalDate protocol. +class ProtocolWithOptionalDateIndexedReader : public test_model::ProtocolWithOptionalDateIndexedReaderBase, yardl::binary::BinaryIndexedReader { + public: + ProtocolWithOptionalDateIndexedReader(std::istream& stream) + : yardl::binary::BinaryIndexedReader(stream), version_(test_model::ProtocolWithOptionalDateIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + ProtocolWithOptionalDateIndexedReader(std::string file_name) + : yardl::binary::BinaryIndexedReader(file_name), version_(test_model::ProtocolWithOptionalDateIndexedReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + void ReadRecordImpl(std::optional& value) override; + void CloseImpl() override; + + Version version_; +}; + } // namespace test_model::binary diff --git a/cpp/test/generated/protocols.cc b/cpp/test/generated/protocols.cc index 7c2d730..ac6b807 100644 --- a/cpp/test/generated/protocols.cc +++ b/cpp/test/generated/protocols.cc @@ -9,33 +9,6 @@ #endif namespace test_model { -namespace { -void BenchmarkFloat256x256WriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteFloat256x256() or EndFloat256x256()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndFloat256x256()" : "WriteFloat256x256()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void BenchmarkFloat256x256ReaderBaseInvalidState(uint8_t attempted, uint8_t current) { - auto f = [](uint8_t i) -> std::string { - switch (i/2) { - case 0: return "ReadFloat256x256()"; - case 1: return "Close()"; - default: return ""; - } - }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); -} - -} // namespace - std::string BenchmarkFloat256x256WriterBase::schema_ = R"({"protocol":{"name":"BenchmarkFloat256x256","sequence":[{"name":"float256x256","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"length":256},{"length":256}]}}}}}]},"types":null})"; std::vector BenchmarkFloat256x256WriterBase::previous_schemas_ = { @@ -48,9 +21,10 @@ std::string BenchmarkFloat256x256WriterBase::SchemaFromVersion(Version version) } } + void BenchmarkFloat256x256WriterBase::WriteFloat256x256(yardl::FixedNDArray const& value) { if (unlikely(state_ != 0)) { - BenchmarkFloat256x256WriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteFloat256x256Impl(value); @@ -58,7 +32,7 @@ void BenchmarkFloat256x256WriterBase::WriteFloat256x256(yardl::FixedNDArray> const& values) { if (unlikely(state_ != 0)) { - BenchmarkFloat256x256WriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteFloat256x256Impl(values); @@ -66,7 +40,7 @@ void BenchmarkFloat256x256WriterBase::WriteFloat256x256(std::vector BenchmarkFloat256x256ReaderBase::previous_schemas_ = BenchmarkFloat256x256WriterBase::previous_schemas_; @@ -98,13 +85,14 @@ Version BenchmarkFloat256x256ReaderBase::VersionFromSchema(std::string const& sc } throw std::runtime_error("The schema does not match any version supported by protocol BenchmarkFloat256x256."); } + bool BenchmarkFloat256x256ReaderBase::ReadFloat256x256(yardl::FixedNDArray& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - BenchmarkFloat256x256ReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadFloat256x256Impl(value); @@ -124,7 +112,7 @@ bool BenchmarkFloat256x256ReaderBase::ReadFloat256x256(std::vector 1) { std::vector> values; @@ -180,32 +169,40 @@ void BenchmarkFloat256x256ReaderBase::CopyTo(BenchmarkFloat256x256WriterBase& wr } } -namespace { -void BenchmarkInt256x256WriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInt256x256() or EndInt256x256()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndInt256x256()" : "WriteInt256x256()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void BenchmarkInt256x256ReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void BenchmarkFloat256x256ReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadInt256x256()"; + case 0: return "ReadFloat256x256()"; case 1: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool BenchmarkFloat256x256IndexedReaderBase::ReadFloat256x256(yardl::FixedNDArray& value, size_t idx) { + return ReadFloat256x256Impl(value, idx); +} + +bool BenchmarkFloat256x256IndexedReaderBase::ReadFloat256x256(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadFloat256x256Impl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t BenchmarkFloat256x256IndexedReaderBase::CountFloat256x256() { + return CountFloat256x256Impl(); +} + +void BenchmarkFloat256x256IndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string BenchmarkInt256x256WriterBase::schema_ = R"({"protocol":{"name":"BenchmarkInt256x256","sequence":[{"name":"int256x256","type":{"stream":{"items":{"array":{"items":"int32","dimensions":[{"length":256},{"length":256}]}}}}}]},"types":null})"; @@ -219,9 +216,10 @@ std::string BenchmarkInt256x256WriterBase::SchemaFromVersion(Version version) { } } + void BenchmarkInt256x256WriterBase::WriteInt256x256(yardl::FixedNDArray const& value) { if (unlikely(state_ != 0)) { - BenchmarkInt256x256WriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteInt256x256Impl(value); @@ -229,7 +227,7 @@ void BenchmarkInt256x256WriterBase::WriteInt256x256(yardl::FixedNDArray> const& values) { if (unlikely(state_ != 0)) { - BenchmarkInt256x256WriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteInt256x256Impl(values); @@ -237,7 +235,7 @@ void BenchmarkInt256x256WriterBase::WriteInt256x256(std::vector BenchmarkInt256x256ReaderBase::previous_schemas_ = BenchmarkInt256x256WriterBase::previous_schemas_; @@ -269,13 +280,14 @@ Version BenchmarkInt256x256ReaderBase::VersionFromSchema(std::string const& sche } throw std::runtime_error("The schema does not match any version supported by protocol BenchmarkInt256x256."); } + bool BenchmarkInt256x256ReaderBase::ReadInt256x256(yardl::FixedNDArray& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - BenchmarkInt256x256ReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadInt256x256Impl(value); @@ -295,7 +307,7 @@ bool BenchmarkInt256x256ReaderBase::ReadInt256x256(std::vector 1) { std::vector> values; @@ -351,32 +364,40 @@ void BenchmarkInt256x256ReaderBase::CopyTo(BenchmarkInt256x256WriterBase& writer } } -namespace { -void BenchmarkFloatVlenWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteFloatArray() or EndFloatArray()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndFloatArray()" : "WriteFloatArray()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void BenchmarkFloatVlenReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void BenchmarkInt256x256ReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadFloatArray()"; + case 0: return "ReadInt256x256()"; case 1: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool BenchmarkInt256x256IndexedReaderBase::ReadInt256x256(yardl::FixedNDArray& value, size_t idx) { + return ReadInt256x256Impl(value, idx); +} + +bool BenchmarkInt256x256IndexedReaderBase::ReadInt256x256(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadInt256x256Impl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t BenchmarkInt256x256IndexedReaderBase::CountInt256x256() { + return CountInt256x256Impl(); +} + +void BenchmarkInt256x256IndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string BenchmarkFloatVlenWriterBase::schema_ = R"({"protocol":{"name":"BenchmarkFloatVlen","sequence":[{"name":"floatArray","type":{"stream":{"items":{"array":{"items":"float32","dimensions":2}}}}}]},"types":null})"; @@ -390,9 +411,10 @@ std::string BenchmarkFloatVlenWriterBase::SchemaFromVersion(Version version) { } } + void BenchmarkFloatVlenWriterBase::WriteFloatArray(yardl::NDArray const& value) { if (unlikely(state_ != 0)) { - BenchmarkFloatVlenWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteFloatArrayImpl(value); @@ -400,7 +422,7 @@ void BenchmarkFloatVlenWriterBase::WriteFloatArray(yardl::NDArray cons void BenchmarkFloatVlenWriterBase::WriteFloatArray(std::vector> const& values) { if (unlikely(state_ != 0)) { - BenchmarkFloatVlenWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteFloatArrayImpl(values); @@ -408,7 +430,7 @@ void BenchmarkFloatVlenWriterBase::WriteFloatArray(std::vector BenchmarkFloatVlenReaderBase::previous_schemas_ = BenchmarkFloatVlenWriterBase::previous_schemas_; @@ -440,13 +475,14 @@ Version BenchmarkFloatVlenReaderBase::VersionFromSchema(std::string const& schem } throw std::runtime_error("The schema does not match any version supported by protocol BenchmarkFloatVlen."); } + bool BenchmarkFloatVlenReaderBase::ReadFloatArray(yardl::NDArray& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - BenchmarkFloatVlenReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadFloatArrayImpl(value); @@ -466,7 +502,7 @@ bool BenchmarkFloatVlenReaderBase::ReadFloatArray(std::vector 1) { std::vector> values; @@ -522,32 +559,40 @@ void BenchmarkFloatVlenReaderBase::CopyTo(BenchmarkFloatVlenWriterBase& writer, } } -namespace { -void BenchmarkSmallRecordWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteSmallRecord() or EndSmallRecord()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndSmallRecord()" : "WriteSmallRecord()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void BenchmarkSmallRecordReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void BenchmarkFloatVlenReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadSmallRecord()"; + case 0: return "ReadFloatArray()"; case 1: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool BenchmarkFloatVlenIndexedReaderBase::ReadFloatArray(yardl::NDArray& value, size_t idx) { + return ReadFloatArrayImpl(value, idx); +} + +bool BenchmarkFloatVlenIndexedReaderBase::ReadFloatArray(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadFloatArrayImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t BenchmarkFloatVlenIndexedReaderBase::CountFloatArray() { + return CountFloatArrayImpl(); +} + +void BenchmarkFloatVlenIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string BenchmarkSmallRecordWriterBase::schema_ = R"({"protocol":{"name":"BenchmarkSmallRecord","sequence":[{"name":"smallRecord","type":{"stream":{"items":"TestModel.SmallBenchmarkRecord"}}}]},"types":[{"name":"SmallBenchmarkRecord","fields":[{"name":"a","type":"float64"},{"name":"b","type":"float32"},{"name":"c","type":"float32"}]}]})"; @@ -561,9 +606,10 @@ std::string BenchmarkSmallRecordWriterBase::SchemaFromVersion(Version version) { } } + void BenchmarkSmallRecordWriterBase::WriteSmallRecord(test_model::SmallBenchmarkRecord const& value) { if (unlikely(state_ != 0)) { - BenchmarkSmallRecordWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteSmallRecordImpl(value); @@ -571,7 +617,7 @@ void BenchmarkSmallRecordWriterBase::WriteSmallRecord(test_model::SmallBenchmark void BenchmarkSmallRecordWriterBase::WriteSmallRecord(std::vector const& values) { if (unlikely(state_ != 0)) { - BenchmarkSmallRecordWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteSmallRecordImpl(values); @@ -579,7 +625,7 @@ void BenchmarkSmallRecordWriterBase::WriteSmallRecord(std::vector BenchmarkSmallRecordReaderBase::previous_schemas_ = BenchmarkSmallRecordWriterBase::previous_schemas_; @@ -611,13 +670,14 @@ Version BenchmarkSmallRecordReaderBase::VersionFromSchema(std::string const& sch } throw std::runtime_error("The schema does not match any version supported by protocol BenchmarkSmallRecord."); } + bool BenchmarkSmallRecordReaderBase::ReadSmallRecord(test_model::SmallBenchmarkRecord& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - BenchmarkSmallRecordReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadSmallRecordImpl(value); @@ -637,7 +697,7 @@ bool BenchmarkSmallRecordReaderBase::ReadSmallRecord(std::vector 1) { std::vector values; @@ -693,21 +754,7 @@ void BenchmarkSmallRecordReaderBase::CopyTo(BenchmarkSmallRecordWriterBase& writ } } -namespace { -void BenchmarkSmallRecordWithOptionalsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteSmallRecord() or EndSmallRecord()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndSmallRecord()" : "WriteSmallRecord()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void BenchmarkSmallRecordWithOptionalsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void BenchmarkSmallRecordReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { case 0: return "ReadSmallRecord()"; @@ -715,10 +762,32 @@ void BenchmarkSmallRecordWithOptionalsReaderBaseInvalidState(uint8_t attempted, default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool BenchmarkSmallRecordIndexedReaderBase::ReadSmallRecord(test_model::SmallBenchmarkRecord& value, size_t idx) { + return ReadSmallRecordImpl(value, idx); +} + +bool BenchmarkSmallRecordIndexedReaderBase::ReadSmallRecord(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadSmallRecordImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t BenchmarkSmallRecordIndexedReaderBase::CountSmallRecord() { + return CountSmallRecordImpl(); +} + +void BenchmarkSmallRecordIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string BenchmarkSmallRecordWithOptionalsWriterBase::schema_ = R"({"protocol":{"name":"BenchmarkSmallRecordWithOptionals","sequence":[{"name":"smallRecord","type":{"stream":{"items":"TestModel.SimpleEncodingCounters"}}}]},"types":[{"name":"SimpleEncodingCounters","fields":[{"name":"e1","type":[null,"uint32"]},{"name":"e2","type":[null,"uint32"]},{"name":"slice","type":[null,"uint32"]},{"name":"repetition","type":[null,"uint32"]}]}]})"; @@ -732,9 +801,10 @@ std::string BenchmarkSmallRecordWithOptionalsWriterBase::SchemaFromVersion(Versi } } + void BenchmarkSmallRecordWithOptionalsWriterBase::WriteSmallRecord(test_model::SimpleEncodingCounters const& value) { if (unlikely(state_ != 0)) { - BenchmarkSmallRecordWithOptionalsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteSmallRecordImpl(value); @@ -742,7 +812,7 @@ void BenchmarkSmallRecordWithOptionalsWriterBase::WriteSmallRecord(test_model::S void BenchmarkSmallRecordWithOptionalsWriterBase::WriteSmallRecord(std::vector const& values) { if (unlikely(state_ != 0)) { - BenchmarkSmallRecordWithOptionalsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteSmallRecordImpl(values); @@ -750,7 +820,7 @@ void BenchmarkSmallRecordWithOptionalsWriterBase::WriteSmallRecord(std::vector BenchmarkSmallRecordWithOptionalsReaderBase::previous_schemas_ = BenchmarkSmallRecordWithOptionalsWriterBase::previous_schemas_; @@ -782,13 +865,14 @@ Version BenchmarkSmallRecordWithOptionalsReaderBase::VersionFromSchema(std::stri } throw std::runtime_error("The schema does not match any version supported by protocol BenchmarkSmallRecordWithOptionals."); } + bool BenchmarkSmallRecordWithOptionalsReaderBase::ReadSmallRecord(test_model::SimpleEncodingCounters& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - BenchmarkSmallRecordWithOptionalsReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadSmallRecordImpl(value); @@ -808,7 +892,7 @@ bool BenchmarkSmallRecordWithOptionalsReaderBase::ReadSmallRecord(std::vector 1) { std::vector values; @@ -864,32 +949,40 @@ void BenchmarkSmallRecordWithOptionalsReaderBase::CopyTo(BenchmarkSmallRecordWit } } -namespace { -void BenchmarkSimpleMrdWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteData() or EndData()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndData()" : "WriteData()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void BenchmarkSimpleMrdReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void BenchmarkSmallRecordWithOptionalsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadData()"; + case 0: return "ReadSmallRecord()"; case 1: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool BenchmarkSmallRecordWithOptionalsIndexedReaderBase::ReadSmallRecord(test_model::SimpleEncodingCounters& value, size_t idx) { + return ReadSmallRecordImpl(value, idx); +} + +bool BenchmarkSmallRecordWithOptionalsIndexedReaderBase::ReadSmallRecord(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadSmallRecordImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t BenchmarkSmallRecordWithOptionalsIndexedReaderBase::CountSmallRecord() { + return CountSmallRecordImpl(); +} + +void BenchmarkSmallRecordWithOptionalsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string BenchmarkSimpleMrdWriterBase::schema_ = R"({"protocol":{"name":"BenchmarkSimpleMrd","sequence":[{"name":"data","type":{"stream":{"items":[{"tag":"acquisition","explicitTag":true,"type":"TestModel.SimpleAcquisition"},{"tag":"image","explicitTag":true,"type":{"name":"Image.Image","typeArguments":["float32"]}}]}}}]},"types":[{"name":"Image","typeParameters":["T"],"type":{"array":{"items":"T","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"SimpleAcquisition","fields":[{"name":"flags","type":"uint64"},{"name":"idx","type":"TestModel.SimpleEncodingCounters"},{"name":"data","type":{"array":{"items":"complexfloat32","dimensions":2}}},{"name":"trajectory","type":{"array":{"items":"float32","dimensions":2}}}]},{"name":"SimpleEncodingCounters","fields":[{"name":"e1","type":[null,"uint32"]},{"name":"e2","type":[null,"uint32"]},{"name":"slice","type":[null,"uint32"]},{"name":"repetition","type":[null,"uint32"]}]}]})"; @@ -903,9 +996,10 @@ std::string BenchmarkSimpleMrdWriterBase::SchemaFromVersion(Version version) { } } + void BenchmarkSimpleMrdWriterBase::WriteData(std::variant> const& value) { if (unlikely(state_ != 0)) { - BenchmarkSimpleMrdWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteDataImpl(value); @@ -913,7 +1007,7 @@ void BenchmarkSimpleMrdWriterBase::WriteData(std::variant>> const& values) { if (unlikely(state_ != 0)) { - BenchmarkSimpleMrdWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteDataImpl(values); @@ -921,7 +1015,7 @@ void BenchmarkSimpleMrdWriterBase::WriteData(std::vector BenchmarkSimpleMrdReaderBase::previous_schemas_ = BenchmarkSimpleMrdWriterBase::previous_schemas_; @@ -953,13 +1060,14 @@ Version BenchmarkSimpleMrdReaderBase::VersionFromSchema(std::string const& schem } throw std::runtime_error("The schema does not match any version supported by protocol BenchmarkSimpleMrd."); } + bool BenchmarkSimpleMrdReaderBase::ReadData(std::variant>& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - BenchmarkSimpleMrdReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadDataImpl(value); @@ -979,7 +1087,7 @@ bool BenchmarkSimpleMrdReaderBase::ReadData(std::vector 1) { std::vector>> values; @@ -1035,35 +1144,40 @@ void BenchmarkSimpleMrdReaderBase::CopyTo(BenchmarkSimpleMrdWriterBase& writer, } } -namespace { -void ScalarsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInt32()"; break; - case 1: expected_method = "WriteRecord()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteInt32()"; break; - case 1: attempted_method = "WriteRecord()"; break; - case 2: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ScalarsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void BenchmarkSimpleMrdReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadInt32()"; - case 1: return "ReadRecord()"; - case 2: return "Close()"; + case 0: return "ReadData()"; + case 1: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool BenchmarkSimpleMrdIndexedReaderBase::ReadData(std::variant>& value, size_t idx) { + return ReadDataImpl(value, idx); +} + +bool BenchmarkSimpleMrdIndexedReaderBase::ReadData(std::vector>>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadDataImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t BenchmarkSimpleMrdIndexedReaderBase::CountData() { + return CountDataImpl(); +} + +void BenchmarkSimpleMrdIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string ScalarsWriterBase::schema_ = R"({"protocol":{"name":"Scalars","sequence":[{"name":"int32","type":"int32"},{"name":"record","type":"TestModel.RecordWithPrimitives"}]},"types":[{"name":"RecordWithPrimitives","fields":[{"name":"boolField","type":"bool"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"int32Field","type":"int32"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"dateField","type":"date"},{"name":"timeField","type":"time"},{"name":"datetimeField","type":"datetime"}]}]})"; @@ -1077,9 +1191,10 @@ std::string ScalarsWriterBase::SchemaFromVersion(Version version) { } } + void ScalarsWriterBase::WriteInt32(int32_t const& value) { if (unlikely(state_ != 0)) { - ScalarsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteInt32Impl(value); @@ -1088,7 +1203,7 @@ void ScalarsWriterBase::WriteInt32(int32_t const& value) { void ScalarsWriterBase::WriteRecord(test_model::RecordWithPrimitives const& value) { if (unlikely(state_ != 1)) { - ScalarsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteRecordImpl(value); @@ -1097,12 +1212,27 @@ void ScalarsWriterBase::WriteRecord(test_model::RecordWithPrimitives const& valu void ScalarsWriterBase::Close() { if (unlikely(state_ != 2)) { - ScalarsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } CloseImpl(); } +void ScalarsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteInt32()"; break; + case 1: expected_method = "WriteRecord()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteInt32()"; break; + case 1: attempted_method = "WriteRecord()"; break; + case 2: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string ScalarsReaderBase::schema_ = ScalarsWriterBase::schema_; std::vector ScalarsReaderBase::previous_schemas_ = ScalarsWriterBase::previous_schemas_; @@ -1113,9 +1243,10 @@ Version ScalarsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Scalars."); } + void ScalarsReaderBase::ReadInt32(int32_t& value) { if (unlikely(state_ != 0)) { - ScalarsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadInt32Impl(value); @@ -1124,7 +1255,7 @@ void ScalarsReaderBase::ReadInt32(int32_t& value) { void ScalarsReaderBase::ReadRecord(test_model::RecordWithPrimitives& value) { if (unlikely(state_ != 2)) { - ScalarsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadRecordImpl(value); @@ -1133,11 +1264,12 @@ void ScalarsReaderBase::ReadRecord(test_model::RecordWithPrimitives& value) { void ScalarsReaderBase::Close() { if (unlikely(state_ != 4)) { - ScalarsReaderBaseInvalidState(4, state_); + InvalidState(4); } CloseImpl(); } + void ScalarsReaderBase::CopyTo(ScalarsWriterBase& writer) { { int32_t value; @@ -1151,41 +1283,23 @@ void ScalarsReaderBase::CopyTo(ScalarsWriterBase& writer) { } } -namespace { -void ScalarOptionalsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteOptionalInt()"; break; - case 1: expected_method = "WriteOptionalRecord()"; break; - case 2: expected_method = "WriteRecordWithOptionalFields()"; break; - case 3: expected_method = "WriteOptionalRecordWithOptionalFields()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteOptionalInt()"; break; - case 1: attempted_method = "WriteOptionalRecord()"; break; - case 2: attempted_method = "WriteRecordWithOptionalFields()"; break; - case 3: attempted_method = "WriteOptionalRecordWithOptionalFields()"; break; - case 4: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ScalarOptionalsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void ScalarsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadOptionalInt()"; - case 1: return "ReadOptionalRecord()"; - case 2: return "ReadRecordWithOptionalFields()"; - case 3: return "ReadOptionalRecordWithOptionalFields()"; - case 4: return "Close()"; + case 0: return "ReadInt32()"; + case 1: return "ReadRecord()"; + case 2: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void ScalarsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string ScalarOptionalsWriterBase::schema_ = R"({"protocol":{"name":"ScalarOptionals","sequence":[{"name":"optionalInt","type":[null,"int32"]},{"name":"optionalRecord","type":[null,"TestModel.SimpleRecord"]},{"name":"recordWithOptionalFields","type":"TestModel.RecordWithOptionalFields"},{"name":"optionalRecordWithOptionalFields","type":[null,"TestModel.RecordWithOptionalFields"]}]},"types":[{"name":"RecordWithOptionalFields","fields":[{"name":"optionalInt","type":[null,"int32"]},{"name":"optionalIntAlternateSyntax","type":[null,"int32"]},{"name":"optionalTime","type":[null,"time"]}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -1199,9 +1313,10 @@ std::string ScalarOptionalsWriterBase::SchemaFromVersion(Version version) { } } + void ScalarOptionalsWriterBase::WriteOptionalInt(std::optional const& value) { if (unlikely(state_ != 0)) { - ScalarOptionalsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteOptionalIntImpl(value); @@ -1210,7 +1325,7 @@ void ScalarOptionalsWriterBase::WriteOptionalInt(std::optional const& v void ScalarOptionalsWriterBase::WriteOptionalRecord(std::optional const& value) { if (unlikely(state_ != 1)) { - ScalarOptionalsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteOptionalRecordImpl(value); @@ -1219,7 +1334,7 @@ void ScalarOptionalsWriterBase::WriteOptionalRecord(std::optional const& value) { if (unlikely(state_ != 3)) { - ScalarOptionalsWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteOptionalRecordWithOptionalFieldsImpl(value); @@ -1237,12 +1352,31 @@ void ScalarOptionalsWriterBase::WriteOptionalRecordWithOptionalFields(std::optio void ScalarOptionalsWriterBase::Close() { if (unlikely(state_ != 4)) { - ScalarOptionalsWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } CloseImpl(); } +void ScalarOptionalsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteOptionalInt()"; break; + case 1: expected_method = "WriteOptionalRecord()"; break; + case 2: expected_method = "WriteRecordWithOptionalFields()"; break; + case 3: expected_method = "WriteOptionalRecordWithOptionalFields()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteOptionalInt()"; break; + case 1: attempted_method = "WriteOptionalRecord()"; break; + case 2: attempted_method = "WriteRecordWithOptionalFields()"; break; + case 3: attempted_method = "WriteOptionalRecordWithOptionalFields()"; break; + case 4: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string ScalarOptionalsReaderBase::schema_ = ScalarOptionalsWriterBase::schema_; std::vector ScalarOptionalsReaderBase::previous_schemas_ = ScalarOptionalsWriterBase::previous_schemas_; @@ -1253,9 +1387,10 @@ Version ScalarOptionalsReaderBase::VersionFromSchema(std::string const& schema) } throw std::runtime_error("The schema does not match any version supported by protocol ScalarOptionals."); } + void ScalarOptionalsReaderBase::ReadOptionalInt(std::optional& value) { if (unlikely(state_ != 0)) { - ScalarOptionalsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadOptionalIntImpl(value); @@ -1264,7 +1399,7 @@ void ScalarOptionalsReaderBase::ReadOptionalInt(std::optional& value) { void ScalarOptionalsReaderBase::ReadOptionalRecord(std::optional& value) { if (unlikely(state_ != 2)) { - ScalarOptionalsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadOptionalRecordImpl(value); @@ -1273,7 +1408,7 @@ void ScalarOptionalsReaderBase::ReadOptionalRecord(std::optional& value) { if (unlikely(state_ != 6)) { - ScalarOptionalsReaderBaseInvalidState(6, state_); + InvalidState(6); } ReadOptionalRecordWithOptionalFieldsImpl(value); @@ -1291,11 +1426,12 @@ void ScalarOptionalsReaderBase::ReadOptionalRecordWithOptionalFields(std::option void ScalarOptionalsReaderBase::Close() { if (unlikely(state_ != 8)) { - ScalarOptionalsReaderBaseInvalidState(8, state_); + InvalidState(8); } CloseImpl(); } + void ScalarOptionalsReaderBase::CopyTo(ScalarOptionalsWriterBase& writer) { { std::optional value; @@ -1319,32 +1455,25 @@ void ScalarOptionalsReaderBase::CopyTo(ScalarOptionalsWriterBase& writer) { } } -namespace { -void NestedRecordsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteTupleWithRecords()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteTupleWithRecords()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void NestedRecordsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void ScalarOptionalsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadTupleWithRecords()"; - case 1: return "Close()"; + case 0: return "ReadOptionalInt()"; + case 1: return "ReadOptionalRecord()"; + case 2: return "ReadRecordWithOptionalFields()"; + case 3: return "ReadOptionalRecordWithOptionalFields()"; + case 4: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void ScalarOptionalsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string NestedRecordsWriterBase::schema_ = R"({"protocol":{"name":"NestedRecords","sequence":[{"name":"tupleWithRecords","type":"TestModel.TupleWithRecords"}]},"types":[{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]},{"name":"TupleWithRecords","fields":[{"name":"a","type":"TestModel.SimpleRecord"},{"name":"b","type":"TestModel.SimpleRecord"}]}]})"; @@ -1358,9 +1487,10 @@ std::string NestedRecordsWriterBase::SchemaFromVersion(Version version) { } } + void NestedRecordsWriterBase::WriteTupleWithRecords(test_model::TupleWithRecords const& value) { if (unlikely(state_ != 0)) { - NestedRecordsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteTupleWithRecordsImpl(value); @@ -1369,12 +1499,25 @@ void NestedRecordsWriterBase::WriteTupleWithRecords(test_model::TupleWithRecords void NestedRecordsWriterBase::Close() { if (unlikely(state_ != 1)) { - NestedRecordsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } CloseImpl(); } +void NestedRecordsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteTupleWithRecords()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteTupleWithRecords()"; break; + case 1: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string NestedRecordsReaderBase::schema_ = NestedRecordsWriterBase::schema_; std::vector NestedRecordsReaderBase::previous_schemas_ = NestedRecordsWriterBase::previous_schemas_; @@ -1385,9 +1528,10 @@ Version NestedRecordsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol NestedRecords."); } + void NestedRecordsReaderBase::ReadTupleWithRecords(test_model::TupleWithRecords& value) { if (unlikely(state_ != 0)) { - NestedRecordsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadTupleWithRecordsImpl(value); @@ -1396,11 +1540,12 @@ void NestedRecordsReaderBase::ReadTupleWithRecords(test_model::TupleWithRecords& void NestedRecordsReaderBase::Close() { if (unlikely(state_ != 2)) { - NestedRecordsReaderBaseInvalidState(2, state_); + InvalidState(2); } CloseImpl(); } + void NestedRecordsReaderBase::CopyTo(NestedRecordsWriterBase& writer) { { test_model::TupleWithRecords value; @@ -1409,41 +1554,22 @@ void NestedRecordsReaderBase::CopyTo(NestedRecordsWriterBase& writer) { } } -namespace { -void VlensWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteIntVector()"; break; - case 1: expected_method = "WriteComplexVector()"; break; - case 2: expected_method = "WriteRecordWithVlens()"; break; - case 3: expected_method = "WriteVlenOfRecordWithVlens()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteIntVector()"; break; - case 1: attempted_method = "WriteComplexVector()"; break; - case 2: attempted_method = "WriteRecordWithVlens()"; break; - case 3: attempted_method = "WriteVlenOfRecordWithVlens()"; break; - case 4: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void VlensReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void NestedRecordsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadIntVector()"; - case 1: return "ReadComplexVector()"; - case 2: return "ReadRecordWithVlens()"; - case 3: return "ReadVlenOfRecordWithVlens()"; - case 4: return "Close()"; + case 0: return "ReadTupleWithRecords()"; + case 1: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void NestedRecordsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string VlensWriterBase::schema_ = R"({"protocol":{"name":"Vlens","sequence":[{"name":"intVector","type":{"vector":{"items":"int32"}}},{"name":"complexVector","type":{"vector":{"items":"complexfloat32"}}},{"name":"recordWithVlens","type":"TestModel.RecordWithVlens"},{"name":"vlenOfRecordWithVlens","type":{"vector":{"items":"TestModel.RecordWithVlens"}}}]},"types":[{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -1457,9 +1583,10 @@ std::string VlensWriterBase::SchemaFromVersion(Version version) { } } + void VlensWriterBase::WriteIntVector(std::vector const& value) { if (unlikely(state_ != 0)) { - VlensWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntVectorImpl(value); @@ -1468,7 +1595,7 @@ void VlensWriterBase::WriteIntVector(std::vector const& value) { void VlensWriterBase::WriteComplexVector(std::vector> const& value) { if (unlikely(state_ != 1)) { - VlensWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteComplexVectorImpl(value); @@ -1477,7 +1604,7 @@ void VlensWriterBase::WriteComplexVector(std::vector> const& void VlensWriterBase::WriteRecordWithVlens(test_model::RecordWithVlens const& value) { if (unlikely(state_ != 2)) { - VlensWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteRecordWithVlensImpl(value); @@ -1486,7 +1613,7 @@ void VlensWriterBase::WriteRecordWithVlens(test_model::RecordWithVlens const& va void VlensWriterBase::WriteVlenOfRecordWithVlens(std::vector const& value) { if (unlikely(state_ != 3)) { - VlensWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteVlenOfRecordWithVlensImpl(value); @@ -1495,12 +1622,31 @@ void VlensWriterBase::WriteVlenOfRecordWithVlens(std::vector VlensReaderBase::previous_schemas_ = VlensWriterBase::previous_schemas_; @@ -1511,9 +1657,10 @@ Version VlensReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Vlens."); } + void VlensReaderBase::ReadIntVector(std::vector& value) { if (unlikely(state_ != 0)) { - VlensReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadIntVectorImpl(value); @@ -1522,7 +1669,7 @@ void VlensReaderBase::ReadIntVector(std::vector& value) { void VlensReaderBase::ReadComplexVector(std::vector>& value) { if (unlikely(state_ != 2)) { - VlensReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadComplexVectorImpl(value); @@ -1531,7 +1678,7 @@ void VlensReaderBase::ReadComplexVector(std::vector>& value) void VlensReaderBase::ReadRecordWithVlens(test_model::RecordWithVlens& value) { if (unlikely(state_ != 4)) { - VlensReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadRecordWithVlensImpl(value); @@ -1540,7 +1687,7 @@ void VlensReaderBase::ReadRecordWithVlens(test_model::RecordWithVlens& value) { void VlensReaderBase::ReadVlenOfRecordWithVlens(std::vector& value) { if (unlikely(state_ != 6)) { - VlensReaderBaseInvalidState(6, state_); + InvalidState(6); } ReadVlenOfRecordWithVlensImpl(value); @@ -1549,11 +1696,12 @@ void VlensReaderBase::ReadVlenOfRecordWithVlens(std::vector value; @@ -1577,35 +1725,25 @@ void VlensReaderBase::CopyTo(VlensWriterBase& writer) { } } -namespace { -void StringsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteSingleString()"; break; - case 1: expected_method = "WriteRecWithString()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteSingleString()"; break; - case 1: attempted_method = "WriteRecWithString()"; break; - case 2: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void StringsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void VlensReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadSingleString()"; - case 1: return "ReadRecWithString()"; - case 2: return "Close()"; + case 0: return "ReadIntVector()"; + case 1: return "ReadComplexVector()"; + case 2: return "ReadRecordWithVlens()"; + case 3: return "ReadVlenOfRecordWithVlens()"; + case 4: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void VlensIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string StringsWriterBase::schema_ = R"({"protocol":{"name":"Strings","sequence":[{"name":"singleString","type":"string"},{"name":"recWithString","type":"TestModel.RecordWithStrings"}]},"types":[{"name":"RecordWithStrings","fields":[{"name":"a","type":"string"},{"name":"b","type":"string"}]}]})"; @@ -1619,9 +1757,10 @@ std::string StringsWriterBase::SchemaFromVersion(Version version) { } } + void StringsWriterBase::WriteSingleString(std::string const& value) { if (unlikely(state_ != 0)) { - StringsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteSingleStringImpl(value); @@ -1630,7 +1769,7 @@ void StringsWriterBase::WriteSingleString(std::string const& value) { void StringsWriterBase::WriteRecWithString(test_model::RecordWithStrings const& value) { if (unlikely(state_ != 1)) { - StringsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteRecWithStringImpl(value); @@ -1639,12 +1778,27 @@ void StringsWriterBase::WriteRecWithString(test_model::RecordWithStrings const& void StringsWriterBase::Close() { if (unlikely(state_ != 2)) { - StringsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } CloseImpl(); } +void StringsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteSingleString()"; break; + case 1: expected_method = "WriteRecWithString()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteSingleString()"; break; + case 1: attempted_method = "WriteRecWithString()"; break; + case 2: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string StringsReaderBase::schema_ = StringsWriterBase::schema_; std::vector StringsReaderBase::previous_schemas_ = StringsWriterBase::previous_schemas_; @@ -1655,9 +1809,10 @@ Version StringsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Strings."); } + void StringsReaderBase::ReadSingleString(std::string& value) { if (unlikely(state_ != 0)) { - StringsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadSingleStringImpl(value); @@ -1666,7 +1821,7 @@ void StringsReaderBase::ReadSingleString(std::string& value) { void StringsReaderBase::ReadRecWithString(test_model::RecordWithStrings& value) { if (unlikely(state_ != 2)) { - StringsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadRecWithStringImpl(value); @@ -1675,11 +1830,12 @@ void StringsReaderBase::ReadRecWithString(test_model::RecordWithStrings& value) void StringsReaderBase::Close() { if (unlikely(state_ != 4)) { - StringsReaderBaseInvalidState(4, state_); + InvalidState(4); } CloseImpl(); } + void StringsReaderBase::CopyTo(StringsWriterBase& writer) { { std::string value; @@ -1693,32 +1849,23 @@ void StringsReaderBase::CopyTo(StringsWriterBase& writer) { } } -namespace { -void OptionalVectorsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteRecordWithOptionalVector()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteRecordWithOptionalVector()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void OptionalVectorsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void StringsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadRecordWithOptionalVector()"; - case 1: return "Close()"; + case 0: return "ReadSingleString()"; + case 1: return "ReadRecWithString()"; + case 2: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void StringsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string OptionalVectorsWriterBase::schema_ = R"({"protocol":{"name":"OptionalVectors","sequence":[{"name":"recordWithOptionalVector","type":"TestModel.RecordWithOptionalVector"}]},"types":[{"name":"RecordWithOptionalVector","fields":[{"name":"optionalVector","type":[null,{"vector":{"items":"int32"}}]}]}]})"; @@ -1732,9 +1879,10 @@ std::string OptionalVectorsWriterBase::SchemaFromVersion(Version version) { } } + void OptionalVectorsWriterBase::WriteRecordWithOptionalVector(test_model::RecordWithOptionalVector const& value) { if (unlikely(state_ != 0)) { - OptionalVectorsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteRecordWithOptionalVectorImpl(value); @@ -1743,12 +1891,25 @@ void OptionalVectorsWriterBase::WriteRecordWithOptionalVector(test_model::Record void OptionalVectorsWriterBase::Close() { if (unlikely(state_ != 1)) { - OptionalVectorsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } CloseImpl(); } +void OptionalVectorsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteRecordWithOptionalVector()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteRecordWithOptionalVector()"; break; + case 1: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string OptionalVectorsReaderBase::schema_ = OptionalVectorsWriterBase::schema_; std::vector OptionalVectorsReaderBase::previous_schemas_ = OptionalVectorsWriterBase::previous_schemas_; @@ -1759,9 +1920,10 @@ Version OptionalVectorsReaderBase::VersionFromSchema(std::string const& schema) } throw std::runtime_error("The schema does not match any version supported by protocol OptionalVectors."); } + void OptionalVectorsReaderBase::ReadRecordWithOptionalVector(test_model::RecordWithOptionalVector& value) { if (unlikely(state_ != 0)) { - OptionalVectorsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadRecordWithOptionalVectorImpl(value); @@ -1770,11 +1932,12 @@ void OptionalVectorsReaderBase::ReadRecordWithOptionalVector(test_model::RecordW void OptionalVectorsReaderBase::Close() { if (unlikely(state_ != 2)) { - OptionalVectorsReaderBaseInvalidState(2, state_); + InvalidState(2); } CloseImpl(); } + void OptionalVectorsReaderBase::CopyTo(OptionalVectorsWriterBase& writer) { { test_model::RecordWithOptionalVector value; @@ -1783,41 +1946,22 @@ void OptionalVectorsReaderBase::CopyTo(OptionalVectorsWriterBase& writer) { } } -namespace { -void FixedVectorsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteFixedIntVector()"; break; - case 1: expected_method = "WriteFixedSimpleRecordVector()"; break; - case 2: expected_method = "WriteFixedRecordWithVlensVector()"; break; - case 3: expected_method = "WriteRecordWithFixedVectors()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteFixedIntVector()"; break; - case 1: attempted_method = "WriteFixedSimpleRecordVector()"; break; - case 2: attempted_method = "WriteFixedRecordWithVlensVector()"; break; - case 3: attempted_method = "WriteRecordWithFixedVectors()"; break; - case 4: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void FixedVectorsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void OptionalVectorsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadFixedIntVector()"; - case 1: return "ReadFixedSimpleRecordVector()"; - case 2: return "ReadFixedRecordWithVlensVector()"; - case 3: return "ReadRecordWithFixedVectors()"; - case 4: return "Close()"; + case 0: return "ReadRecordWithOptionalVector()"; + case 1: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void OptionalVectorsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string FixedVectorsWriterBase::schema_ = R"({"protocol":{"name":"FixedVectors","sequence":[{"name":"fixedIntVector","type":{"vector":{"items":"int32","length":5}}},{"name":"fixedSimpleRecordVector","type":{"vector":{"items":"TestModel.SimpleRecord","length":3}}},{"name":"fixedRecordWithVlensVector","type":{"vector":{"items":"TestModel.RecordWithVlens","length":2}}},{"name":"recordWithFixedVectors","type":"TestModel.RecordWithFixedVectors"}]},"types":[{"name":"RecordWithFixedVectors","fields":[{"name":"fixedIntVector","type":{"vector":{"items":"int32","length":5}}},{"name":"fixedSimpleRecordVector","type":{"vector":{"items":"TestModel.SimpleRecord","length":3}}},{"name":"fixedRecordWithVlensVector","type":{"vector":{"items":"TestModel.RecordWithVlens","length":2}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -1831,9 +1975,10 @@ std::string FixedVectorsWriterBase::SchemaFromVersion(Version version) { } } + void FixedVectorsWriterBase::WriteFixedIntVector(std::array const& value) { if (unlikely(state_ != 0)) { - FixedVectorsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteFixedIntVectorImpl(value); @@ -1842,7 +1987,7 @@ void FixedVectorsWriterBase::WriteFixedIntVector(std::array const& v void FixedVectorsWriterBase::WriteFixedSimpleRecordVector(std::array const& value) { if (unlikely(state_ != 1)) { - FixedVectorsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteFixedSimpleRecordVectorImpl(value); @@ -1851,7 +1996,7 @@ void FixedVectorsWriterBase::WriteFixedSimpleRecordVector(std::array const& value) { if (unlikely(state_ != 2)) { - FixedVectorsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteFixedRecordWithVlensVectorImpl(value); @@ -1860,7 +2005,7 @@ void FixedVectorsWriterBase::WriteFixedRecordWithVlensVector(std::array FixedVectorsReaderBase::previous_schemas_ = FixedVectorsWriterBase::previous_schemas_; @@ -1885,9 +2049,10 @@ Version FixedVectorsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol FixedVectors."); } + void FixedVectorsReaderBase::ReadFixedIntVector(std::array& value) { if (unlikely(state_ != 0)) { - FixedVectorsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadFixedIntVectorImpl(value); @@ -1896,7 +2061,7 @@ void FixedVectorsReaderBase::ReadFixedIntVector(std::array& value) { void FixedVectorsReaderBase::ReadFixedSimpleRecordVector(std::array& value) { if (unlikely(state_ != 2)) { - FixedVectorsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadFixedSimpleRecordVectorImpl(value); @@ -1905,7 +2070,7 @@ void FixedVectorsReaderBase::ReadFixedSimpleRecordVector(std::array& value) { if (unlikely(state_ != 4)) { - FixedVectorsReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadFixedRecordWithVlensVectorImpl(value); @@ -1914,7 +2079,7 @@ void FixedVectorsReaderBase::ReadFixedRecordWithVlensVector(std::array value; @@ -1951,41 +2117,25 @@ void FixedVectorsReaderBase::CopyTo(FixedVectorsWriterBase& writer) { } } -namespace { -void StreamsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteIntData() or EndIntData()"; break; - case 1: expected_method = "WriteOptionalIntData() or EndOptionalIntData()"; break; - case 2: expected_method = "WriteRecordWithOptionalVectorData() or EndRecordWithOptionalVectorData()"; break; - case 3: expected_method = "WriteFixedVector() or EndFixedVector()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndIntData()" : "WriteIntData()"; break; - case 1: attempted_method = end ? "EndOptionalIntData()" : "WriteOptionalIntData()"; break; - case 2: attempted_method = end ? "EndRecordWithOptionalVectorData()" : "WriteRecordWithOptionalVectorData()"; break; - case 3: attempted_method = end ? "EndFixedVector()" : "WriteFixedVector()"; break; - case 4: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void StreamsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void FixedVectorsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadIntData()"; - case 1: return "ReadOptionalIntData()"; - case 2: return "ReadRecordWithOptionalVectorData()"; - case 3: return "ReadFixedVector()"; + case 0: return "ReadFixedIntVector()"; + case 1: return "ReadFixedSimpleRecordVector()"; + case 2: return "ReadFixedRecordWithVlensVector()"; + case 3: return "ReadRecordWithFixedVectors()"; case 4: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void FixedVectorsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string StreamsWriterBase::schema_ = R"({"protocol":{"name":"Streams","sequence":[{"name":"intData","type":{"stream":{"items":"int32"}}},{"name":"optionalIntData","type":{"stream":{"items":[null,"int32"]}}},{"name":"recordWithOptionalVectorData","type":{"stream":{"items":"TestModel.RecordWithOptionalVector"}}},{"name":"fixedVector","type":{"stream":{"items":{"vector":{"items":"int32","length":3}}}}}]},"types":[{"name":"RecordWithOptionalVector","fields":[{"name":"optionalVector","type":[null,{"vector":{"items":"int32"}}]}]}]})"; @@ -1999,9 +2149,10 @@ std::string StreamsWriterBase::SchemaFromVersion(Version version) { } } + void StreamsWriterBase::WriteIntData(int32_t const& value) { if (unlikely(state_ != 0)) { - StreamsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntDataImpl(value); @@ -2009,7 +2160,7 @@ void StreamsWriterBase::WriteIntData(int32_t const& value) { void StreamsWriterBase::WriteIntData(std::vector const& values) { if (unlikely(state_ != 0)) { - StreamsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntDataImpl(values); @@ -2017,7 +2168,7 @@ void StreamsWriterBase::WriteIntData(std::vector const& values) { void StreamsWriterBase::EndIntData() { if (unlikely(state_ != 0)) { - StreamsWriterBaseInvalidState(0, true, state_); + InvalidState(0, true); } EndIntDataImpl(); @@ -2033,7 +2184,7 @@ void StreamsWriterBase::WriteIntDataImpl(std::vector const& values) { void StreamsWriterBase::WriteOptionalIntData(std::optional const& value) { if (unlikely(state_ != 1)) { - StreamsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteOptionalIntDataImpl(value); @@ -2041,7 +2192,7 @@ void StreamsWriterBase::WriteOptionalIntData(std::optional const& value void StreamsWriterBase::WriteOptionalIntData(std::vector> const& values) { if (unlikely(state_ != 1)) { - StreamsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteOptionalIntDataImpl(values); @@ -2049,7 +2200,7 @@ void StreamsWriterBase::WriteOptionalIntData(std::vector> void StreamsWriterBase::EndOptionalIntData() { if (unlikely(state_ != 1)) { - StreamsWriterBaseInvalidState(1, true, state_); + InvalidState(1, true); } EndOptionalIntDataImpl(); @@ -2065,7 +2216,7 @@ void StreamsWriterBase::WriteOptionalIntDataImpl(std::vector const& values) { if (unlikely(state_ != 2)) { - StreamsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteRecordWithOptionalVectorDataImpl(values); @@ -2081,7 +2232,7 @@ void StreamsWriterBase::WriteRecordWithOptionalVectorData(std::vector const& value) { if (unlikely(state_ != 3)) { - StreamsWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteFixedVectorImpl(value); @@ -2105,7 +2256,7 @@ void StreamsWriterBase::WriteFixedVector(std::array const& value) { void StreamsWriterBase::WriteFixedVector(std::vector> const& values) { if (unlikely(state_ != 3)) { - StreamsWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteFixedVectorImpl(values); @@ -2113,7 +2264,7 @@ void StreamsWriterBase::WriteFixedVector(std::vector> con void StreamsWriterBase::EndFixedVector() { if (unlikely(state_ != 3)) { - StreamsWriterBaseInvalidState(3, true, state_); + InvalidState(3, true); } EndFixedVectorImpl(); @@ -2125,14 +2276,33 @@ void StreamsWriterBase::WriteFixedVectorImpl(std::vector> for (auto const& v : values) { WriteFixedVectorImpl(v); } -} - -void StreamsWriterBase::Close() { - if (unlikely(state_ != 4)) { - StreamsWriterBaseInvalidState(4, false, state_); +} + +void StreamsWriterBase::Close() { + if (unlikely(state_ != 4)) { + InvalidState(4, false); + } + + CloseImpl(); +} + +void StreamsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteIntData() or EndIntData()"; break; + case 1: expected_method = "WriteOptionalIntData() or EndOptionalIntData()"; break; + case 2: expected_method = "WriteRecordWithOptionalVectorData() or EndRecordWithOptionalVectorData()"; break; + case 3: expected_method = "WriteFixedVector() or EndFixedVector()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = end ? "EndIntData()" : "WriteIntData()"; break; + case 1: attempted_method = end ? "EndOptionalIntData()" : "WriteOptionalIntData()"; break; + case 2: attempted_method = end ? "EndRecordWithOptionalVectorData()" : "WriteRecordWithOptionalVectorData()"; break; + case 3: attempted_method = end ? "EndFixedVector()" : "WriteFixedVector()"; break; + case 4: attempted_method = "Close()"; break; } - - CloseImpl(); + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); } std::string StreamsReaderBase::schema_ = StreamsWriterBase::schema_; @@ -2145,13 +2315,14 @@ Version StreamsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Streams."); } + bool StreamsReaderBase::ReadIntData(int32_t& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - StreamsReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadIntDataImpl(value); @@ -2171,7 +2342,7 @@ bool StreamsReaderBase::ReadIntData(std::vector& values) { values.clear(); return false; } - StreamsReaderBaseInvalidState(0, state_); + InvalidState(0); } if (!ReadIntDataImpl(values)) { @@ -2208,7 +2379,7 @@ bool StreamsReaderBase::ReadOptionalIntData(std::optional& value) { if (state_ == 1) { state_ = 2; } else { - StreamsReaderBaseInvalidState(2, state_); + InvalidState(2); } } @@ -2232,7 +2403,7 @@ bool StreamsReaderBase::ReadOptionalIntData(std::vector>& if (state_ == 1) { state_ = 2; } else { - StreamsReaderBaseInvalidState(2, state_); + InvalidState(2); } } @@ -2270,7 +2441,7 @@ bool StreamsReaderBase::ReadRecordWithOptionalVectorData(test_model::RecordWithO if (state_ == 3) { state_ = 4; } else { - StreamsReaderBaseInvalidState(4, state_); + InvalidState(4); } } @@ -2294,7 +2465,7 @@ bool StreamsReaderBase::ReadRecordWithOptionalVectorData(std::vector& value) { if (state_ == 5) { state_ = 6; } else { - StreamsReaderBaseInvalidState(6, state_); + InvalidState(6); } } @@ -2356,7 +2527,7 @@ bool StreamsReaderBase::ReadFixedVector(std::vector>& val if (state_ == 5) { state_ = 6; } else { - StreamsReaderBaseInvalidState(6, state_); + InvalidState(6); } } @@ -2390,12 +2561,13 @@ void StreamsReaderBase::Close() { if (state_ == 7) { state_ = 8; } else { - StreamsReaderBaseInvalidState(8, state_); + InvalidState(8); } } CloseImpl(); } + void StreamsReaderBase::CopyTo(StreamsWriterBase& writer, size_t int_data_buffer_size, size_t optional_int_data_buffer_size, size_t record_with_optional_vector_data_buffer_size, size_t fixed_vector_buffer_size) { if (int_data_buffer_size > 1) { std::vector values; @@ -2455,44 +2627,97 @@ void StreamsReaderBase::CopyTo(StreamsWriterBase& writer, size_t int_data_buffer } } -namespace { -void FixedArraysWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInts()"; break; - case 1: expected_method = "WriteFixedSimpleRecordArray()"; break; - case 2: expected_method = "WriteFixedRecordWithVlensArray()"; break; - case 3: expected_method = "WriteRecordWithFixedArrays()"; break; - case 4: expected_method = "WriteNamedArray()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteInts()"; break; - case 1: attempted_method = "WriteFixedSimpleRecordArray()"; break; - case 2: attempted_method = "WriteFixedRecordWithVlensArray()"; break; - case 3: attempted_method = "WriteRecordWithFixedArrays()"; break; - case 4: attempted_method = "WriteNamedArray()"; break; - case 5: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void FixedArraysReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void StreamsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadInts()"; - case 1: return "ReadFixedSimpleRecordArray()"; - case 2: return "ReadFixedRecordWithVlensArray()"; - case 3: return "ReadRecordWithFixedArrays()"; - case 4: return "ReadNamedArray()"; - case 5: return "Close()"; + case 0: return "ReadIntData()"; + case 1: return "ReadOptionalIntData()"; + case 2: return "ReadRecordWithOptionalVectorData()"; + case 3: return "ReadFixedVector()"; + case 4: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool StreamsIndexedReaderBase::ReadIntData(int32_t& value, size_t idx) { + return ReadIntDataImpl(value, idx); +} + +bool StreamsIndexedReaderBase::ReadIntData(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadIntDataImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsIndexedReaderBase::CountIntData() { + return CountIntDataImpl(); +} + +bool StreamsIndexedReaderBase::ReadOptionalIntData(std::optional& value, size_t idx) { + return ReadOptionalIntDataImpl(value, idx); +} + +bool StreamsIndexedReaderBase::ReadOptionalIntData(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadOptionalIntDataImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsIndexedReaderBase::CountOptionalIntData() { + return CountOptionalIntDataImpl(); +} + +bool StreamsIndexedReaderBase::ReadRecordWithOptionalVectorData(test_model::RecordWithOptionalVector& value, size_t idx) { + return ReadRecordWithOptionalVectorDataImpl(value, idx); +} + +bool StreamsIndexedReaderBase::ReadRecordWithOptionalVectorData(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadRecordWithOptionalVectorDataImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsIndexedReaderBase::CountRecordWithOptionalVectorData() { + return CountRecordWithOptionalVectorDataImpl(); +} + +bool StreamsIndexedReaderBase::ReadFixedVector(std::array& value, size_t idx) { + return ReadFixedVectorImpl(value, idx); +} + +bool StreamsIndexedReaderBase::ReadFixedVector(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadFixedVectorImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsIndexedReaderBase::CountFixedVector() { + return CountFixedVectorImpl(); +} + +void StreamsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string FixedArraysWriterBase::schema_ = R"({"protocol":{"name":"FixedArrays","sequence":[{"name":"ints","type":{"array":{"items":"int32","dimensions":[{"length":2},{"length":3}]}}},{"name":"fixedSimpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":[{"length":3},{"length":2}]}}},{"name":"fixedRecordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":[{"length":2},{"length":2}]}}},{"name":"recordWithFixedArrays","type":"TestModel.RecordWithFixedArrays"},{"name":"namedArray","type":"TestModel.NamedFixedNDArray"}]},"types":[{"name":"NamedFixedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA","length":2},{"name":"dimB","length":4}]}}},{"name":"RecordWithFixedArrays","fields":[{"name":"ints","type":{"array":{"items":"int32","dimensions":[{"length":2},{"length":3}]}}},{"name":"fixedSimpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":[{"length":3},{"length":2}]}}},{"name":"fixedRecordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":[{"length":2},{"length":2}]}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -2506,9 +2731,10 @@ std::string FixedArraysWriterBase::SchemaFromVersion(Version version) { } } + void FixedArraysWriterBase::WriteInts(yardl::FixedNDArray const& value) { if (unlikely(state_ != 0)) { - FixedArraysWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntsImpl(value); @@ -2517,7 +2743,7 @@ void FixedArraysWriterBase::WriteInts(yardl::FixedNDArray const& void FixedArraysWriterBase::WriteFixedSimpleRecordArray(yardl::FixedNDArray const& value) { if (unlikely(state_ != 1)) { - FixedArraysWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteFixedSimpleRecordArrayImpl(value); @@ -2526,7 +2752,7 @@ void FixedArraysWriterBase::WriteFixedSimpleRecordArray(yardl::FixedNDArray const& value) { if (unlikely(state_ != 2)) { - FixedArraysWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteFixedRecordWithVlensArrayImpl(value); @@ -2535,7 +2761,7 @@ void FixedArraysWriterBase::WriteFixedRecordWithVlensArray(yardl::FixedNDArray FixedArraysReaderBase::previous_schemas_ = FixedArraysWriterBase::previous_schemas_; @@ -2569,9 +2816,10 @@ Version FixedArraysReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol FixedArrays."); } + void FixedArraysReaderBase::ReadInts(yardl::FixedNDArray& value) { if (unlikely(state_ != 0)) { - FixedArraysReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadIntsImpl(value); @@ -2580,7 +2828,7 @@ void FixedArraysReaderBase::ReadInts(yardl::FixedNDArray& value) void FixedArraysReaderBase::ReadFixedSimpleRecordArray(yardl::FixedNDArray& value) { if (unlikely(state_ != 2)) { - FixedArraysReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadFixedSimpleRecordArrayImpl(value); @@ -2589,7 +2837,7 @@ void FixedArraysReaderBase::ReadFixedSimpleRecordArray(yardl::FixedNDArray& value) { if (unlikely(state_ != 4)) { - FixedArraysReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadFixedRecordWithVlensArrayImpl(value); @@ -2598,7 +2846,7 @@ void FixedArraysReaderBase::ReadFixedRecordWithVlensArray(yardl::FixedNDArray value; @@ -2649,56 +2898,26 @@ void FixedArraysReaderBase::CopyTo(FixedArraysWriterBase& writer) { } } -namespace { -void SubarraysWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteDynamicWithFixedIntSubarray()"; break; - case 1: expected_method = "WriteDynamicWithFixedFloatSubarray()"; break; - case 2: expected_method = "WriteKnownDimCountWithFixedIntSubarray()"; break; - case 3: expected_method = "WriteKnownDimCountWithFixedFloatSubarray()"; break; - case 4: expected_method = "WriteFixedWithFixedIntSubarray()"; break; - case 5: expected_method = "WriteFixedWithFixedFloatSubarray()"; break; - case 6: expected_method = "WriteNestedSubarray()"; break; - case 7: expected_method = "WriteDynamicWithFixedVectorSubarray()"; break; - case 8: expected_method = "WriteGenericSubarray()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteDynamicWithFixedIntSubarray()"; break; - case 1: attempted_method = "WriteDynamicWithFixedFloatSubarray()"; break; - case 2: attempted_method = "WriteKnownDimCountWithFixedIntSubarray()"; break; - case 3: attempted_method = "WriteKnownDimCountWithFixedFloatSubarray()"; break; - case 4: attempted_method = "WriteFixedWithFixedIntSubarray()"; break; - case 5: attempted_method = "WriteFixedWithFixedFloatSubarray()"; break; - case 6: attempted_method = "WriteNestedSubarray()"; break; - case 7: attempted_method = "WriteDynamicWithFixedVectorSubarray()"; break; - case 8: attempted_method = "WriteGenericSubarray()"; break; - case 9: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void SubarraysReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void FixedArraysReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadDynamicWithFixedIntSubarray()"; - case 1: return "ReadDynamicWithFixedFloatSubarray()"; - case 2: return "ReadKnownDimCountWithFixedIntSubarray()"; - case 3: return "ReadKnownDimCountWithFixedFloatSubarray()"; - case 4: return "ReadFixedWithFixedIntSubarray()"; - case 5: return "ReadFixedWithFixedFloatSubarray()"; - case 6: return "ReadNestedSubarray()"; - case 7: return "ReadDynamicWithFixedVectorSubarray()"; - case 8: return "ReadGenericSubarray()"; - case 9: return "Close()"; + case 0: return "ReadInts()"; + case 1: return "ReadFixedSimpleRecordArray()"; + case 2: return "ReadFixedRecordWithVlensArray()"; + case 3: return "ReadRecordWithFixedArrays()"; + case 4: return "ReadNamedArray()"; + case 5: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void FixedArraysIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string SubarraysWriterBase::schema_ = R"({"protocol":{"name":"Subarrays","sequence":[{"name":"dynamicWithFixedIntSubarray","type":{"array":{"items":{"array":{"items":"int32","dimensions":[{"length":3}]}}}}},{"name":"dynamicWithFixedFloatSubarray","type":{"array":{"items":{"array":{"items":"float32","dimensions":[{"length":3}]}}}}},{"name":"knownDimCountWithFixedIntSubarray","type":{"array":{"items":{"array":{"items":"int32","dimensions":[{"length":3}]}},"dimensions":1}}},{"name":"knownDimCountWithFixedFloatSubarray","type":{"array":{"items":{"array":{"items":"float32","dimensions":[{"length":3}]}},"dimensions":1}}},{"name":"fixedWithFixedIntSubarray","type":{"array":{"items":{"array":{"items":"int32","dimensions":[{"length":3}]}},"dimensions":[{"length":2}]}}},{"name":"fixedWithFixedFloatSubarray","type":{"array":{"items":{"array":{"items":"float32","dimensions":[{"length":3}]}},"dimensions":[{"length":2}]}}},{"name":"nestedSubarray","type":{"array":{"items":{"array":{"items":{"array":{"items":"int32","dimensions":[{"length":3}]}},"dimensions":[{"length":2}]}}}}},{"name":"dynamicWithFixedVectorSubarray","type":{"array":{"items":{"vector":{"items":"int32","length":3}}}}},{"name":"genericSubarray","type":{"name":"TestModel.Image","typeArguments":[{"array":{"items":"int32","dimensions":[{"length":3}]}}]}}]},"types":[{"name":"Image","typeParameters":["T"],"type":{"array":{"items":"T","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"Image","typeParameters":["T"],"type":{"name":"Image.Image","typeArguments":["T"]}}]})"; @@ -2712,9 +2931,10 @@ std::string SubarraysWriterBase::SchemaFromVersion(Version version) { } } + void SubarraysWriterBase::WriteDynamicWithFixedIntSubarray(yardl::DynamicNDArray> const& value) { if (unlikely(state_ != 0)) { - SubarraysWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteDynamicWithFixedIntSubarrayImpl(value); @@ -2723,7 +2943,7 @@ void SubarraysWriterBase::WriteDynamicWithFixedIntSubarray(yardl::DynamicNDArray void SubarraysWriterBase::WriteDynamicWithFixedFloatSubarray(yardl::DynamicNDArray> const& value) { if (unlikely(state_ != 1)) { - SubarraysWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteDynamicWithFixedFloatSubarrayImpl(value); @@ -2732,7 +2952,7 @@ void SubarraysWriterBase::WriteDynamicWithFixedFloatSubarray(yardl::DynamicNDArr void SubarraysWriterBase::WriteKnownDimCountWithFixedIntSubarray(yardl::NDArray, 1> const& value) { if (unlikely(state_ != 2)) { - SubarraysWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteKnownDimCountWithFixedIntSubarrayImpl(value); @@ -2741,7 +2961,7 @@ void SubarraysWriterBase::WriteKnownDimCountWithFixedIntSubarray(yardl::NDArray< void SubarraysWriterBase::WriteKnownDimCountWithFixedFloatSubarray(yardl::NDArray, 1> const& value) { if (unlikely(state_ != 3)) { - SubarraysWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteKnownDimCountWithFixedFloatSubarrayImpl(value); @@ -2750,7 +2970,7 @@ void SubarraysWriterBase::WriteKnownDimCountWithFixedFloatSubarray(yardl::NDArra void SubarraysWriterBase::WriteFixedWithFixedIntSubarray(yardl::FixedNDArray, 2> const& value) { if (unlikely(state_ != 4)) { - SubarraysWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } WriteFixedWithFixedIntSubarrayImpl(value); @@ -2759,7 +2979,7 @@ void SubarraysWriterBase::WriteFixedWithFixedIntSubarray(yardl::FixedNDArray, 2> const& value) { if (unlikely(state_ != 5)) { - SubarraysWriterBaseInvalidState(5, false, state_); + InvalidState(5, false); } WriteFixedWithFixedFloatSubarrayImpl(value); @@ -2768,7 +2988,7 @@ void SubarraysWriterBase::WriteFixedWithFixedFloatSubarray(yardl::FixedNDArray, 2>> const& value) { if (unlikely(state_ != 6)) { - SubarraysWriterBaseInvalidState(6, false, state_); + InvalidState(6, false); } WriteNestedSubarrayImpl(value); @@ -2777,7 +2997,7 @@ void SubarraysWriterBase::WriteNestedSubarray(yardl::DynamicNDArray> const& value) { if (unlikely(state_ != 7)) { - SubarraysWriterBaseInvalidState(7, false, state_); + InvalidState(7, false); } WriteDynamicWithFixedVectorSubarrayImpl(value); @@ -2786,7 +3006,7 @@ void SubarraysWriterBase::WriteDynamicWithFixedVectorSubarray(yardl::DynamicNDAr void SubarraysWriterBase::WriteGenericSubarray(test_model::Image> const& value) { if (unlikely(state_ != 8)) { - SubarraysWriterBaseInvalidState(8, false, state_); + InvalidState(8, false); } WriteGenericSubarrayImpl(value); @@ -2795,12 +3015,41 @@ void SubarraysWriterBase::WriteGenericSubarray(test_model::Image SubarraysReaderBase::previous_schemas_ = SubarraysWriterBase::previous_schemas_; @@ -2811,9 +3060,10 @@ Version SubarraysReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Subarrays."); } + void SubarraysReaderBase::ReadDynamicWithFixedIntSubarray(yardl::DynamicNDArray>& value) { if (unlikely(state_ != 0)) { - SubarraysReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadDynamicWithFixedIntSubarrayImpl(value); @@ -2822,7 +3072,7 @@ void SubarraysReaderBase::ReadDynamicWithFixedIntSubarray(yardl::DynamicNDArray< void SubarraysReaderBase::ReadDynamicWithFixedFloatSubarray(yardl::DynamicNDArray>& value) { if (unlikely(state_ != 2)) { - SubarraysReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadDynamicWithFixedFloatSubarrayImpl(value); @@ -2831,7 +3081,7 @@ void SubarraysReaderBase::ReadDynamicWithFixedFloatSubarray(yardl::DynamicNDArra void SubarraysReaderBase::ReadKnownDimCountWithFixedIntSubarray(yardl::NDArray, 1>& value) { if (unlikely(state_ != 4)) { - SubarraysReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadKnownDimCountWithFixedIntSubarrayImpl(value); @@ -2840,7 +3090,7 @@ void SubarraysReaderBase::ReadKnownDimCountWithFixedIntSubarray(yardl::NDArray, 1>& value) { if (unlikely(state_ != 6)) { - SubarraysReaderBaseInvalidState(6, state_); + InvalidState(6); } ReadKnownDimCountWithFixedFloatSubarrayImpl(value); @@ -2849,7 +3099,7 @@ void SubarraysReaderBase::ReadKnownDimCountWithFixedFloatSubarray(yardl::NDArray void SubarraysReaderBase::ReadFixedWithFixedIntSubarray(yardl::FixedNDArray, 2>& value) { if (unlikely(state_ != 8)) { - SubarraysReaderBaseInvalidState(8, state_); + InvalidState(8); } ReadFixedWithFixedIntSubarrayImpl(value); @@ -2858,7 +3108,7 @@ void SubarraysReaderBase::ReadFixedWithFixedIntSubarray(yardl::FixedNDArray, 2>& value) { if (unlikely(state_ != 10)) { - SubarraysReaderBaseInvalidState(10, state_); + InvalidState(10); } ReadFixedWithFixedFloatSubarrayImpl(value); @@ -2867,7 +3117,7 @@ void SubarraysReaderBase::ReadFixedWithFixedFloatSubarray(yardl::FixedNDArray, 2>>& value) { if (unlikely(state_ != 12)) { - SubarraysReaderBaseInvalidState(12, state_); + InvalidState(12); } ReadNestedSubarrayImpl(value); @@ -2876,7 +3126,7 @@ void SubarraysReaderBase::ReadNestedSubarray(yardl::DynamicNDArray>& value) { if (unlikely(state_ != 14)) { - SubarraysReaderBaseInvalidState(14, state_); + InvalidState(14); } ReadDynamicWithFixedVectorSubarrayImpl(value); @@ -2885,7 +3135,7 @@ void SubarraysReaderBase::ReadDynamicWithFixedVectorSubarray(yardl::DynamicNDArr void SubarraysReaderBase::ReadGenericSubarray(test_model::Image>& value) { if (unlikely(state_ != 16)) { - SubarraysReaderBaseInvalidState(16, state_); + InvalidState(16); } ReadGenericSubarrayImpl(value); @@ -2894,11 +3144,12 @@ void SubarraysReaderBase::ReadGenericSubarray(test_model::Image> value; @@ -2947,35 +3198,30 @@ void SubarraysReaderBase::CopyTo(SubarraysWriterBase& writer) { } } -namespace { -void SubarraysInRecordsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteWithFixedSubarrays()"; break; - case 1: expected_method = "WriteWithVlenSubarrays()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteWithFixedSubarrays()"; break; - case 1: attempted_method = "WriteWithVlenSubarrays()"; break; - case 2: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void SubarraysInRecordsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void SubarraysReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadWithFixedSubarrays()"; - case 1: return "ReadWithVlenSubarrays()"; - case 2: return "Close()"; + case 0: return "ReadDynamicWithFixedIntSubarray()"; + case 1: return "ReadDynamicWithFixedFloatSubarray()"; + case 2: return "ReadKnownDimCountWithFixedIntSubarray()"; + case 3: return "ReadKnownDimCountWithFixedFloatSubarray()"; + case 4: return "ReadFixedWithFixedIntSubarray()"; + case 5: return "ReadFixedWithFixedFloatSubarray()"; + case 6: return "ReadNestedSubarray()"; + case 7: return "ReadDynamicWithFixedVectorSubarray()"; + case 8: return "ReadGenericSubarray()"; + case 9: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void SubarraysIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string SubarraysInRecordsWriterBase::schema_ = R"({"protocol":{"name":"SubarraysInRecords","sequence":[{"name":"withFixedSubarrays","type":{"array":{"items":"TestModel.RecordWithFixedCollections"}}},{"name":"withVlenSubarrays","type":{"array":{"items":"TestModel.RecordWithVlenCollections"}}}]},"types":[{"name":"RecordWithFixedCollections","fields":[{"name":"fixedVector","type":{"vector":{"items":"int32","length":3}}},{"name":"fixedArray","type":{"array":{"items":"int32","dimensions":[{"length":2},{"length":3}]}}}]},{"name":"RecordWithVlenCollections","fields":[{"name":"vector","type":{"vector":{"items":"int32"}}},{"name":"array","type":{"array":{"items":"int32","dimensions":2}}}]}]})"; @@ -2989,9 +3235,10 @@ std::string SubarraysInRecordsWriterBase::SchemaFromVersion(Version version) { } } + void SubarraysInRecordsWriterBase::WriteWithFixedSubarrays(yardl::DynamicNDArray const& value) { if (unlikely(state_ != 0)) { - SubarraysInRecordsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteWithFixedSubarraysImpl(value); @@ -3000,7 +3247,7 @@ void SubarraysInRecordsWriterBase::WriteWithFixedSubarrays(yardl::DynamicNDArray void SubarraysInRecordsWriterBase::WriteWithVlenSubarrays(yardl::DynamicNDArray const& value) { if (unlikely(state_ != 1)) { - SubarraysInRecordsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteWithVlenSubarraysImpl(value); @@ -3009,12 +3256,27 @@ void SubarraysInRecordsWriterBase::WriteWithVlenSubarrays(yardl::DynamicNDArray< void SubarraysInRecordsWriterBase::Close() { if (unlikely(state_ != 2)) { - SubarraysInRecordsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } CloseImpl(); } +void SubarraysInRecordsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteWithFixedSubarrays()"; break; + case 1: expected_method = "WriteWithVlenSubarrays()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteWithFixedSubarrays()"; break; + case 1: attempted_method = "WriteWithVlenSubarrays()"; break; + case 2: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string SubarraysInRecordsReaderBase::schema_ = SubarraysInRecordsWriterBase::schema_; std::vector SubarraysInRecordsReaderBase::previous_schemas_ = SubarraysInRecordsWriterBase::previous_schemas_; @@ -3025,9 +3287,10 @@ Version SubarraysInRecordsReaderBase::VersionFromSchema(std::string const& schem } throw std::runtime_error("The schema does not match any version supported by protocol SubarraysInRecords."); } + void SubarraysInRecordsReaderBase::ReadWithFixedSubarrays(yardl::DynamicNDArray& value) { if (unlikely(state_ != 0)) { - SubarraysInRecordsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadWithFixedSubarraysImpl(value); @@ -3036,7 +3299,7 @@ void SubarraysInRecordsReaderBase::ReadWithFixedSubarrays(yardl::DynamicNDArray< void SubarraysInRecordsReaderBase::ReadWithVlenSubarrays(yardl::DynamicNDArray& value) { if (unlikely(state_ != 2)) { - SubarraysInRecordsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadWithVlenSubarraysImpl(value); @@ -3045,62 +3308,42 @@ void SubarraysInRecordsReaderBase::ReadWithVlenSubarrays(yardl::DynamicNDArray value; - ReadWithFixedSubarrays(value); - writer.WriteWithFixedSubarrays(value); - } - { - yardl::DynamicNDArray value; - ReadWithVlenSubarrays(value); - writer.WriteWithVlenSubarrays(value); - } -} - -namespace { -void NDArraysWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInts()"; break; - case 1: expected_method = "WriteSimpleRecordArray()"; break; - case 2: expected_method = "WriteRecordWithVlensArray()"; break; - case 3: expected_method = "WriteRecordWithNDArrays()"; break; - case 4: expected_method = "WriteNamedArray()"; break; + yardl::DynamicNDArray value; + ReadWithFixedSubarrays(value); + writer.WriteWithFixedSubarrays(value); } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteInts()"; break; - case 1: attempted_method = "WriteSimpleRecordArray()"; break; - case 2: attempted_method = "WriteRecordWithVlensArray()"; break; - case 3: attempted_method = "WriteRecordWithNDArrays()"; break; - case 4: attempted_method = "WriteNamedArray()"; break; - case 5: attempted_method = "Close()"; break; + { + yardl::DynamicNDArray value; + ReadWithVlenSubarrays(value); + writer.WriteWithVlenSubarrays(value); } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); } -void NDArraysReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void SubarraysInRecordsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadInts()"; - case 1: return "ReadSimpleRecordArray()"; - case 2: return "ReadRecordWithVlensArray()"; - case 3: return "ReadRecordWithNDArrays()"; - case 4: return "ReadNamedArray()"; - case 5: return "Close()"; + case 0: return "ReadWithFixedSubarrays()"; + case 1: return "ReadWithVlenSubarrays()"; + case 2: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void SubarraysInRecordsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string NDArraysWriterBase::schema_ = R"({"protocol":{"name":"NDArrays","sequence":[{"name":"ints","type":{"array":{"items":"int32","dimensions":2}}},{"name":"simpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":2}}},{"name":"recordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":2}}},{"name":"recordWithNDArrays","type":"TestModel.RecordWithNDArrays"},{"name":"namedArray","type":"TestModel.NamedNDArray"}]},"types":[{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithNDArrays","fields":[{"name":"ints","type":{"array":{"items":"int32","dimensions":2}}},{"name":"fixedSimpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":2}}},{"name":"fixedRecordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":2}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -3114,9 +3357,10 @@ std::string NDArraysWriterBase::SchemaFromVersion(Version version) { } } + void NDArraysWriterBase::WriteInts(yardl::NDArray const& value) { if (unlikely(state_ != 0)) { - NDArraysWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntsImpl(value); @@ -3125,7 +3369,7 @@ void NDArraysWriterBase::WriteInts(yardl::NDArray const& value) { void NDArraysWriterBase::WriteSimpleRecordArray(yardl::NDArray const& value) { if (unlikely(state_ != 1)) { - NDArraysWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteSimpleRecordArrayImpl(value); @@ -3134,7 +3378,7 @@ void NDArraysWriterBase::WriteSimpleRecordArray(yardl::NDArray const& value) { if (unlikely(state_ != 2)) { - NDArraysWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteRecordWithVlensArrayImpl(value); @@ -3143,7 +3387,7 @@ void NDArraysWriterBase::WriteRecordWithVlensArray(yardl::NDArray NDArraysReaderBase::previous_schemas_ = NDArraysWriterBase::previous_schemas_; @@ -3177,9 +3442,10 @@ Version NDArraysReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol NDArrays."); } + void NDArraysReaderBase::ReadInts(yardl::NDArray& value) { if (unlikely(state_ != 0)) { - NDArraysReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadIntsImpl(value); @@ -3188,7 +3454,7 @@ void NDArraysReaderBase::ReadInts(yardl::NDArray& value) { void NDArraysReaderBase::ReadSimpleRecordArray(yardl::NDArray& value) { if (unlikely(state_ != 2)) { - NDArraysReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadSimpleRecordArrayImpl(value); @@ -3197,7 +3463,7 @@ void NDArraysReaderBase::ReadSimpleRecordArray(yardl::NDArray& value) { if (unlikely(state_ != 4)) { - NDArraysReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadRecordWithVlensArrayImpl(value); @@ -3206,7 +3472,7 @@ void NDArraysReaderBase::ReadRecordWithVlensArray(yardl::NDArray value; @@ -3257,41 +3524,26 @@ void NDArraysReaderBase::CopyTo(NDArraysWriterBase& writer) { } } -namespace { -void NDArraysSingleDimensionWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInts()"; break; - case 1: expected_method = "WriteSimpleRecordArray()"; break; - case 2: expected_method = "WriteRecordWithVlensArray()"; break; - case 3: expected_method = "WriteRecordWithNDArrays()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteInts()"; break; - case 1: attempted_method = "WriteSimpleRecordArray()"; break; - case 2: attempted_method = "WriteRecordWithVlensArray()"; break; - case 3: attempted_method = "WriteRecordWithNDArrays()"; break; - case 4: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void NDArraysSingleDimensionReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void NDArraysReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { case 0: return "ReadInts()"; case 1: return "ReadSimpleRecordArray()"; case 2: return "ReadRecordWithVlensArray()"; case 3: return "ReadRecordWithNDArrays()"; - case 4: return "Close()"; + case 4: return "ReadNamedArray()"; + case 5: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void NDArraysIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string NDArraysSingleDimensionWriterBase::schema_ = R"({"protocol":{"name":"NDArraysSingleDimension","sequence":[{"name":"ints","type":{"array":{"items":"int32","dimensions":1}}},{"name":"simpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":1}}},{"name":"recordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":1}}},{"name":"recordWithNDArrays","type":"TestModel.RecordWithNDArraysSingleDimension"}]},"types":[{"name":"RecordWithNDArraysSingleDimension","fields":[{"name":"ints","type":{"array":{"items":"int32","dimensions":1}}},{"name":"fixedSimpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":1}}},{"name":"fixedRecordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":1}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -3305,9 +3557,10 @@ std::string NDArraysSingleDimensionWriterBase::SchemaFromVersion(Version version } } + void NDArraysSingleDimensionWriterBase::WriteInts(yardl::NDArray const& value) { if (unlikely(state_ != 0)) { - NDArraysSingleDimensionWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntsImpl(value); @@ -3316,7 +3569,7 @@ void NDArraysSingleDimensionWriterBase::WriteInts(yardl::NDArray con void NDArraysSingleDimensionWriterBase::WriteSimpleRecordArray(yardl::NDArray const& value) { if (unlikely(state_ != 1)) { - NDArraysSingleDimensionWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteSimpleRecordArrayImpl(value); @@ -3325,7 +3578,7 @@ void NDArraysSingleDimensionWriterBase::WriteSimpleRecordArray(yardl::NDArray const& value) { if (unlikely(state_ != 2)) { - NDArraysSingleDimensionWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteRecordWithVlensArrayImpl(value); @@ -3334,7 +3587,7 @@ void NDArraysSingleDimensionWriterBase::WriteRecordWithVlensArray(yardl::NDArray void NDArraysSingleDimensionWriterBase::WriteRecordWithNDArrays(test_model::RecordWithNDArraysSingleDimension const& value) { if (unlikely(state_ != 3)) { - NDArraysSingleDimensionWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteRecordWithNDArraysImpl(value); @@ -3343,12 +3596,31 @@ void NDArraysSingleDimensionWriterBase::WriteRecordWithNDArrays(test_model::Reco void NDArraysSingleDimensionWriterBase::Close() { if (unlikely(state_ != 4)) { - NDArraysSingleDimensionWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } CloseImpl(); } +void NDArraysSingleDimensionWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteInts()"; break; + case 1: expected_method = "WriteSimpleRecordArray()"; break; + case 2: expected_method = "WriteRecordWithVlensArray()"; break; + case 3: expected_method = "WriteRecordWithNDArrays()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteInts()"; break; + case 1: attempted_method = "WriteSimpleRecordArray()"; break; + case 2: attempted_method = "WriteRecordWithVlensArray()"; break; + case 3: attempted_method = "WriteRecordWithNDArrays()"; break; + case 4: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string NDArraysSingleDimensionReaderBase::schema_ = NDArraysSingleDimensionWriterBase::schema_; std::vector NDArraysSingleDimensionReaderBase::previous_schemas_ = NDArraysSingleDimensionWriterBase::previous_schemas_; @@ -3359,9 +3631,10 @@ Version NDArraysSingleDimensionReaderBase::VersionFromSchema(std::string const& } throw std::runtime_error("The schema does not match any version supported by protocol NDArraysSingleDimension."); } + void NDArraysSingleDimensionReaderBase::ReadInts(yardl::NDArray& value) { if (unlikely(state_ != 0)) { - NDArraysSingleDimensionReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadIntsImpl(value); @@ -3370,7 +3643,7 @@ void NDArraysSingleDimensionReaderBase::ReadInts(yardl::NDArray& val void NDArraysSingleDimensionReaderBase::ReadSimpleRecordArray(yardl::NDArray& value) { if (unlikely(state_ != 2)) { - NDArraysSingleDimensionReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadSimpleRecordArrayImpl(value); @@ -3379,7 +3652,7 @@ void NDArraysSingleDimensionReaderBase::ReadSimpleRecordArray(yardl::NDArray& value) { if (unlikely(state_ != 4)) { - NDArraysSingleDimensionReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadRecordWithVlensArrayImpl(value); @@ -3388,7 +3661,7 @@ void NDArraysSingleDimensionReaderBase::ReadRecordWithVlensArray(yardl::NDArray< void NDArraysSingleDimensionReaderBase::ReadRecordWithNDArrays(test_model::RecordWithNDArraysSingleDimension& value) { if (unlikely(state_ != 6)) { - NDArraysSingleDimensionReaderBaseInvalidState(6, state_); + InvalidState(6); } ReadRecordWithNDArraysImpl(value); @@ -3397,11 +3670,12 @@ void NDArraysSingleDimensionReaderBase::ReadRecordWithNDArrays(test_model::Recor void NDArraysSingleDimensionReaderBase::Close() { if (unlikely(state_ != 8)) { - NDArraysSingleDimensionReaderBaseInvalidState(8, state_); + InvalidState(8); } CloseImpl(); } + void NDArraysSingleDimensionReaderBase::CopyTo(NDArraysSingleDimensionWriterBase& writer) { { yardl::NDArray value; @@ -3425,41 +3699,25 @@ void NDArraysSingleDimensionReaderBase::CopyTo(NDArraysSingleDimensionWriterBase } } -namespace { -void DynamicNDArraysWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInts()"; break; - case 1: expected_method = "WriteSimpleRecordArray()"; break; - case 2: expected_method = "WriteRecordWithVlensArray()"; break; - case 3: expected_method = "WriteRecordWithDynamicNDArrays()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteInts()"; break; - case 1: attempted_method = "WriteSimpleRecordArray()"; break; - case 2: attempted_method = "WriteRecordWithVlensArray()"; break; - case 3: attempted_method = "WriteRecordWithDynamicNDArrays()"; break; - case 4: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void DynamicNDArraysReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void NDArraysSingleDimensionReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { case 0: return "ReadInts()"; case 1: return "ReadSimpleRecordArray()"; case 2: return "ReadRecordWithVlensArray()"; - case 3: return "ReadRecordWithDynamicNDArrays()"; + case 3: return "ReadRecordWithNDArrays()"; case 4: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void NDArraysSingleDimensionIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string DynamicNDArraysWriterBase::schema_ = R"({"protocol":{"name":"DynamicNDArrays","sequence":[{"name":"ints","type":{"array":{"items":"int32"}}},{"name":"simpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord"}}},{"name":"recordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens"}}},{"name":"recordWithDynamicNDArrays","type":"TestModel.RecordWithDynamicNDArrays"}]},"types":[{"name":"IntArray","type":{"array":{"items":"int32"}}},{"name":"RecordWithDynamicNDArrays","fields":[{"name":"ints","type":"TestModel.IntArray"},{"name":"simpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord"}}},{"name":"recordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens"}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -3473,9 +3731,10 @@ std::string DynamicNDArraysWriterBase::SchemaFromVersion(Version version) { } } + void DynamicNDArraysWriterBase::WriteInts(yardl::DynamicNDArray const& value) { if (unlikely(state_ != 0)) { - DynamicNDArraysWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntsImpl(value); @@ -3484,7 +3743,7 @@ void DynamicNDArraysWriterBase::WriteInts(yardl::DynamicNDArray const& void DynamicNDArraysWriterBase::WriteSimpleRecordArray(yardl::DynamicNDArray const& value) { if (unlikely(state_ != 1)) { - DynamicNDArraysWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteSimpleRecordArrayImpl(value); @@ -3493,7 +3752,7 @@ void DynamicNDArraysWriterBase::WriteSimpleRecordArray(yardl::DynamicNDArray const& value) { if (unlikely(state_ != 2)) { - DynamicNDArraysWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteRecordWithVlensArrayImpl(value); @@ -3502,7 +3761,7 @@ void DynamicNDArraysWriterBase::WriteRecordWithVlensArray(yardl::DynamicNDArray< void DynamicNDArraysWriterBase::WriteRecordWithDynamicNDArrays(test_model::RecordWithDynamicNDArrays const& value) { if (unlikely(state_ != 3)) { - DynamicNDArraysWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteRecordWithDynamicNDArraysImpl(value); @@ -3511,12 +3770,31 @@ void DynamicNDArraysWriterBase::WriteRecordWithDynamicNDArrays(test_model::Recor void DynamicNDArraysWriterBase::Close() { if (unlikely(state_ != 4)) { - DynamicNDArraysWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } CloseImpl(); } +void DynamicNDArraysWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteInts()"; break; + case 1: expected_method = "WriteSimpleRecordArray()"; break; + case 2: expected_method = "WriteRecordWithVlensArray()"; break; + case 3: expected_method = "WriteRecordWithDynamicNDArrays()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteInts()"; break; + case 1: attempted_method = "WriteSimpleRecordArray()"; break; + case 2: attempted_method = "WriteRecordWithVlensArray()"; break; + case 3: attempted_method = "WriteRecordWithDynamicNDArrays()"; break; + case 4: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string DynamicNDArraysReaderBase::schema_ = DynamicNDArraysWriterBase::schema_; std::vector DynamicNDArraysReaderBase::previous_schemas_ = DynamicNDArraysWriterBase::previous_schemas_; @@ -3527,9 +3805,10 @@ Version DynamicNDArraysReaderBase::VersionFromSchema(std::string const& schema) } throw std::runtime_error("The schema does not match any version supported by protocol DynamicNDArrays."); } + void DynamicNDArraysReaderBase::ReadInts(yardl::DynamicNDArray& value) { if (unlikely(state_ != 0)) { - DynamicNDArraysReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadIntsImpl(value); @@ -3538,7 +3817,7 @@ void DynamicNDArraysReaderBase::ReadInts(yardl::DynamicNDArray& value) void DynamicNDArraysReaderBase::ReadSimpleRecordArray(yardl::DynamicNDArray& value) { if (unlikely(state_ != 2)) { - DynamicNDArraysReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadSimpleRecordArrayImpl(value); @@ -3547,7 +3826,7 @@ void DynamicNDArraysReaderBase::ReadSimpleRecordArray(yardl::DynamicNDArray& value) { if (unlikely(state_ != 4)) { - DynamicNDArraysReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadRecordWithVlensArrayImpl(value); @@ -3556,7 +3835,7 @@ void DynamicNDArraysReaderBase::ReadRecordWithVlensArray(yardl::DynamicNDArray value; @@ -3593,35 +3873,25 @@ void DynamicNDArraysReaderBase::CopyTo(DynamicNDArraysWriterBase& writer) { } } -namespace { -void MultiDArraysWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteImages() or EndImages()"; break; - case 1: expected_method = "WriteFrames() or EndFrames()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndImages()" : "WriteImages()"; break; - case 1: attempted_method = end ? "EndFrames()" : "WriteFrames()"; break; - case 2: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void MultiDArraysReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void DynamicNDArraysReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadImages()"; - case 1: return "ReadFrames()"; - case 2: return "Close()"; + case 0: return "ReadInts()"; + case 1: return "ReadSimpleRecordArray()"; + case 2: return "ReadRecordWithVlensArray()"; + case 3: return "ReadRecordWithDynamicNDArrays()"; + case 4: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void DynamicNDArraysIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string MultiDArraysWriterBase::schema_ = R"({"protocol":{"name":"MultiDArrays","sequence":[{"name":"images","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"name":"ch"},{"name":"z"},{"name":"y"},{"name":"x"}]}}}}},{"name":"frames","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"name":"ch","length":1},{"name":"z","length":1},{"name":"y","length":64},{"name":"x","length":32}]}}}}}]},"types":null})"; @@ -3635,9 +3905,10 @@ std::string MultiDArraysWriterBase::SchemaFromVersion(Version version) { } } + void MultiDArraysWriterBase::WriteImages(yardl::NDArray const& value) { if (unlikely(state_ != 0)) { - MultiDArraysWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteImagesImpl(value); @@ -3645,7 +3916,7 @@ void MultiDArraysWriterBase::WriteImages(yardl::NDArray const& value) void MultiDArraysWriterBase::WriteImages(std::vector> const& values) { if (unlikely(state_ != 0)) { - MultiDArraysWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteImagesImpl(values); @@ -3653,7 +3924,7 @@ void MultiDArraysWriterBase::WriteImages(std::vector> c void MultiDArraysWriterBase::EndImages() { if (unlikely(state_ != 0)) { - MultiDArraysWriterBaseInvalidState(0, true, state_); + InvalidState(0, true); } EndImagesImpl(); @@ -3669,7 +3940,7 @@ void MultiDArraysWriterBase::WriteImagesImpl(std::vector const& value) { if (unlikely(state_ != 1)) { - MultiDArraysWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteFramesImpl(value); @@ -3677,7 +3948,7 @@ void MultiDArraysWriterBase::WriteFrames(yardl::FixedNDArray> const& values) { if (unlikely(state_ != 1)) { - MultiDArraysWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteFramesImpl(values); @@ -3685,7 +3956,7 @@ void MultiDArraysWriterBase::WriteFrames(std::vector MultiDArraysReaderBase::previous_schemas_ = MultiDArraysWriterBase::previous_schemas_; @@ -3717,13 +4003,14 @@ Version MultiDArraysReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol MultiDArrays."); } + bool MultiDArraysReaderBase::ReadImages(yardl::NDArray& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - MultiDArraysReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadImagesImpl(value); @@ -3743,7 +4030,7 @@ bool MultiDArraysReaderBase::ReadImages(std::vector>& v values.clear(); return false; } - MultiDArraysReaderBaseInvalidState(0, state_); + InvalidState(0); } if (!ReadImagesImpl(values)) { @@ -3780,7 +4067,7 @@ bool MultiDArraysReaderBase::ReadFrames(yardl::FixedNDArray if (state_ == 1) { state_ = 2; } else { - MultiDArraysReaderBaseInvalidState(2, state_); + InvalidState(2); } } @@ -3804,7 +4091,7 @@ bool MultiDArraysReaderBase::ReadFrames(std::vector 1) { std::vector> values; @@ -3875,35 +4163,59 @@ void MultiDArraysReaderBase::CopyTo(MultiDArraysWriterBase& writer, size_t image } } -namespace { -void ComplexArraysWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteFloats()"; break; - case 1: expected_method = "WriteDoubles()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteFloats()"; break; - case 1: attempted_method = "WriteDoubles()"; break; - case 2: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ComplexArraysReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void MultiDArraysReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadFloats()"; - case 1: return "ReadDoubles()"; + case 0: return "ReadImages()"; + case 1: return "ReadFrames()"; case 2: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool MultiDArraysIndexedReaderBase::ReadImages(yardl::NDArray& value, size_t idx) { + return ReadImagesImpl(value, idx); +} + +bool MultiDArraysIndexedReaderBase::ReadImages(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadImagesImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t MultiDArraysIndexedReaderBase::CountImages() { + return CountImagesImpl(); +} + +bool MultiDArraysIndexedReaderBase::ReadFrames(yardl::FixedNDArray& value, size_t idx) { + return ReadFramesImpl(value, idx); +} + +bool MultiDArraysIndexedReaderBase::ReadFrames(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadFramesImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t MultiDArraysIndexedReaderBase::CountFrames() { + return CountFramesImpl(); +} + +void MultiDArraysIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string ComplexArraysWriterBase::schema_ = R"({"protocol":{"name":"ComplexArrays","sequence":[{"name":"floats","type":{"array":{"items":"complexfloat32"}}},{"name":"doubles","type":{"array":{"items":"complexfloat64","dimensions":2}}}]},"types":null})"; @@ -3917,9 +4229,10 @@ std::string ComplexArraysWriterBase::SchemaFromVersion(Version version) { } } + void ComplexArraysWriterBase::WriteFloats(yardl::DynamicNDArray> const& value) { if (unlikely(state_ != 0)) { - ComplexArraysWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteFloatsImpl(value); @@ -3928,7 +4241,7 @@ void ComplexArraysWriterBase::WriteFloats(yardl::DynamicNDArray, 2> const& value) { if (unlikely(state_ != 1)) { - ComplexArraysWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteDoublesImpl(value); @@ -3937,12 +4250,27 @@ void ComplexArraysWriterBase::WriteDoubles(yardl::NDArray, void ComplexArraysWriterBase::Close() { if (unlikely(state_ != 2)) { - ComplexArraysWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } CloseImpl(); } +void ComplexArraysWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteFloats()"; break; + case 1: expected_method = "WriteDoubles()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteFloats()"; break; + case 1: attempted_method = "WriteDoubles()"; break; + case 2: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string ComplexArraysReaderBase::schema_ = ComplexArraysWriterBase::schema_; std::vector ComplexArraysReaderBase::previous_schemas_ = ComplexArraysWriterBase::previous_schemas_; @@ -3953,9 +4281,10 @@ Version ComplexArraysReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol ComplexArrays."); } + void ComplexArraysReaderBase::ReadFloats(yardl::DynamicNDArray>& value) { if (unlikely(state_ != 0)) { - ComplexArraysReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadFloatsImpl(value); @@ -3964,7 +4293,7 @@ void ComplexArraysReaderBase::ReadFloats(yardl::DynamicNDArray, 2>& value) { if (unlikely(state_ != 2)) { - ComplexArraysReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadDoublesImpl(value); @@ -3973,62 +4302,42 @@ void ComplexArraysReaderBase::ReadDoubles(yardl::NDArray, 2 void ComplexArraysReaderBase::Close() { if (unlikely(state_ != 4)) { - ComplexArraysReaderBaseInvalidState(4, state_); + InvalidState(4); } CloseImpl(); } + void ComplexArraysReaderBase::CopyTo(ComplexArraysWriterBase& writer) { { - yardl::DynamicNDArray> value; - ReadFloats(value); - writer.WriteFloats(value); - } - { - yardl::NDArray, 2> value; - ReadDoubles(value); - writer.WriteDoubles(value); - } -} - -namespace { -void MapsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteStringToInt()"; break; - case 1: expected_method = "WriteIntToString()"; break; - case 2: expected_method = "WriteStringToUnion()"; break; - case 3: expected_method = "WriteAliasedGeneric()"; break; - case 4: expected_method = "WriteRecords()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteStringToInt()"; break; - case 1: attempted_method = "WriteIntToString()"; break; - case 2: attempted_method = "WriteStringToUnion()"; break; - case 3: attempted_method = "WriteAliasedGeneric()"; break; - case 4: attempted_method = "WriteRecords()"; break; - case 5: attempted_method = "Close()"; break; + yardl::DynamicNDArray> value; + ReadFloats(value); + writer.WriteFloats(value); + } + { + yardl::NDArray, 2> value; + ReadDoubles(value); + writer.WriteDoubles(value); } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); } -void MapsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void ComplexArraysReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadStringToInt()"; - case 1: return "ReadIntToString()"; - case 2: return "ReadStringToUnion()"; - case 3: return "ReadAliasedGeneric()"; - case 4: return "ReadRecords()"; - case 5: return "Close()"; + case 0: return "ReadFloats()"; + case 1: return "ReadDoubles()"; + case 2: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void ComplexArraysIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string MapsWriterBase::schema_ = R"({"protocol":{"name":"Maps","sequence":[{"name":"stringToInt","type":{"map":{"keys":"string","values":"int32"}}},{"name":"intToString","type":{"map":{"keys":"int32","values":"string"}}},{"name":"stringToUnion","type":{"map":{"keys":"string","values":[{"tag":"string","type":"string"},{"tag":"int32","type":"int32"}]}}},{"name":"aliasedGeneric","type":{"name":"BasicTypes.AliasedMap","typeArguments":["string","int32"]}},{"name":"records","type":{"vector":{"items":"TestModel.RecordWithMaps"}}}]},"types":[{"name":"AliasedMap","typeParameters":["K","V"],"type":{"map":{"keys":"K","values":"V"}}},{"name":"RecordWithMaps","fields":[{"name":"set1","type":{"map":{"keys":"uint32","values":"uint32"}}},{"name":"set2","type":{"map":{"keys":"int32","values":"bool"}}}]}]})"; @@ -4042,9 +4351,10 @@ std::string MapsWriterBase::SchemaFromVersion(Version version) { } } + void MapsWriterBase::WriteStringToInt(std::unordered_map const& value) { if (unlikely(state_ != 0)) { - MapsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteStringToIntImpl(value); @@ -4053,7 +4363,7 @@ void MapsWriterBase::WriteStringToInt(std::unordered_map c void MapsWriterBase::WriteIntToString(std::unordered_map const& value) { if (unlikely(state_ != 1)) { - MapsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteIntToStringImpl(value); @@ -4062,7 +4372,7 @@ void MapsWriterBase::WriteIntToString(std::unordered_map c void MapsWriterBase::WriteStringToUnion(std::unordered_map> const& value) { if (unlikely(state_ != 2)) { - MapsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteStringToUnionImpl(value); @@ -4071,7 +4381,7 @@ void MapsWriterBase::WriteStringToUnion(std::unordered_map const& value) { if (unlikely(state_ != 3)) { - MapsWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteAliasedGenericImpl(value); @@ -4080,7 +4390,7 @@ void MapsWriterBase::WriteAliasedGeneric(basic_types::AliasedMap const& value) { if (unlikely(state_ != 4)) { - MapsWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } WriteRecordsImpl(value); @@ -4089,12 +4399,33 @@ void MapsWriterBase::WriteRecords(std::vector const& void MapsWriterBase::Close() { if (unlikely(state_ != 5)) { - MapsWriterBaseInvalidState(5, false, state_); + InvalidState(5, false); } CloseImpl(); } +void MapsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteStringToInt()"; break; + case 1: expected_method = "WriteIntToString()"; break; + case 2: expected_method = "WriteStringToUnion()"; break; + case 3: expected_method = "WriteAliasedGeneric()"; break; + case 4: expected_method = "WriteRecords()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteStringToInt()"; break; + case 1: attempted_method = "WriteIntToString()"; break; + case 2: attempted_method = "WriteStringToUnion()"; break; + case 3: attempted_method = "WriteAliasedGeneric()"; break; + case 4: attempted_method = "WriteRecords()"; break; + case 5: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string MapsReaderBase::schema_ = MapsWriterBase::schema_; std::vector MapsReaderBase::previous_schemas_ = MapsWriterBase::previous_schemas_; @@ -4105,9 +4436,10 @@ Version MapsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Maps."); } + void MapsReaderBase::ReadStringToInt(std::unordered_map& value) { if (unlikely(state_ != 0)) { - MapsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadStringToIntImpl(value); @@ -4116,7 +4448,7 @@ void MapsReaderBase::ReadStringToInt(std::unordered_map& v void MapsReaderBase::ReadIntToString(std::unordered_map& value) { if (unlikely(state_ != 2)) { - MapsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadIntToStringImpl(value); @@ -4125,7 +4457,7 @@ void MapsReaderBase::ReadIntToString(std::unordered_map& v void MapsReaderBase::ReadStringToUnion(std::unordered_map>& value) { if (unlikely(state_ != 4)) { - MapsReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadStringToUnionImpl(value); @@ -4134,7 +4466,7 @@ void MapsReaderBase::ReadStringToUnion(std::unordered_map& value) { if (unlikely(state_ != 6)) { - MapsReaderBaseInvalidState(6, state_); + InvalidState(6); } ReadAliasedGenericImpl(value); @@ -4143,7 +4475,7 @@ void MapsReaderBase::ReadAliasedGeneric(basic_types::AliasedMap& value) { if (unlikely(state_ != 8)) { - MapsReaderBaseInvalidState(8, state_); + InvalidState(8); } ReadRecordsImpl(value); @@ -4152,11 +4484,12 @@ void MapsReaderBase::ReadRecords(std::vector& value) void MapsReaderBase::Close() { if (unlikely(state_ != 10)) { - MapsReaderBaseInvalidState(10, state_); + InvalidState(10); } CloseImpl(); } + void MapsReaderBase::CopyTo(MapsWriterBase& writer) { { std::unordered_map value; @@ -4185,41 +4518,26 @@ void MapsReaderBase::CopyTo(MapsWriterBase& writer) { } } -namespace { -void UnionsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteIntOrSimpleRecord()"; break; - case 1: expected_method = "WriteIntOrRecordWithVlens()"; break; - case 2: expected_method = "WriteMonosotateOrIntOrSimpleRecord()"; break; - case 3: expected_method = "WriteRecordWithUnions()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteIntOrSimpleRecord()"; break; - case 1: attempted_method = "WriteIntOrRecordWithVlens()"; break; - case 2: attempted_method = "WriteMonosotateOrIntOrSimpleRecord()"; break; - case 3: attempted_method = "WriteRecordWithUnions()"; break; - case 4: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void UnionsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void MapsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadIntOrSimpleRecord()"; - case 1: return "ReadIntOrRecordWithVlens()"; - case 2: return "ReadMonosotateOrIntOrSimpleRecord()"; - case 3: return "ReadRecordWithUnions()"; - case 4: return "Close()"; + case 0: return "ReadStringToInt()"; + case 1: return "ReadIntToString()"; + case 2: return "ReadStringToUnion()"; + case 3: return "ReadAliasedGeneric()"; + case 4: return "ReadRecords()"; + case 5: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void MapsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string UnionsWriterBase::schema_ = R"({"protocol":{"name":"Unions","sequence":[{"name":"intOrSimpleRecord","type":[{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]},{"name":"intOrRecordWithVlens","type":[{"tag":"int32","type":"int32"},{"tag":"RecordWithVlens","type":"TestModel.RecordWithVlens"}]},{"name":"monosotateOrIntOrSimpleRecord","type":[null,{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]},{"name":"recordWithUnions","type":"BasicTypes.RecordWithUnions"}]},"types":[{"name":"DaysOfWeek","values":[{"symbol":"monday","value":1},{"symbol":"tuesday","value":2},{"symbol":"wednesday","value":4},{"symbol":"thursday","value":8},{"symbol":"friday","value":16},{"symbol":"saturday","value":32},{"symbol":"sunday","value":64}]},{"name":"Fruits","values":[{"symbol":"apple","value":1},{"symbol":"banana","value":2},{"symbol":"pear","value":3}]},{"name":"GenericNullableUnion2","typeParameters":["T1","T2"],"type":[null,{"tag":"T1","type":"T1"},{"tag":"T2","type":"T2"}]},{"name":"RecordWithString","fields":[{"name":"i","type":"string"}]},{"name":"RecordWithUnions","fields":[{"name":"nullOrIntOrString","type":[null,{"tag":"int32","type":"int32"},{"tag":"string","type":"string"}]},{"name":"dateOrDatetime","type":[{"tag":"time","type":"time"},{"tag":"datetime","type":"datetime"}]},{"name":"nullOrFruitsOrDaysOfWeek","type":{"name":"BasicTypes.GenericNullableUnion2","typeArguments":["BasicTypes.Fruits","BasicTypes.DaysOfWeek"]}},{"name":"recordOrInt","type":[{"tag":"RecordWithString","type":"BasicTypes.RecordWithString"},{"tag":"int32","type":"int32"}]}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -4233,9 +4551,10 @@ std::string UnionsWriterBase::SchemaFromVersion(Version version) { } } + void UnionsWriterBase::WriteIntOrSimpleRecord(std::variant const& value) { if (unlikely(state_ != 0)) { - UnionsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntOrSimpleRecordImpl(value); @@ -4244,7 +4563,7 @@ void UnionsWriterBase::WriteIntOrSimpleRecord(std::variant const& value) { if (unlikely(state_ != 1)) { - UnionsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteIntOrRecordWithVlensImpl(value); @@ -4253,7 +4572,7 @@ void UnionsWriterBase::WriteIntOrRecordWithVlens(std::variant const& value) { if (unlikely(state_ != 2)) { - UnionsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteMonosotateOrIntOrSimpleRecordImpl(value); @@ -4262,7 +4581,7 @@ void UnionsWriterBase::WriteMonosotateOrIntOrSimpleRecord(std::variant UnionsReaderBase::previous_schemas_ = UnionsWriterBase::previous_schemas_; @@ -4287,9 +4625,10 @@ Version UnionsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Unions."); } + void UnionsReaderBase::ReadIntOrSimpleRecord(std::variant& value) { if (unlikely(state_ != 0)) { - UnionsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadIntOrSimpleRecordImpl(value); @@ -4298,7 +4637,7 @@ void UnionsReaderBase::ReadIntOrSimpleRecord(std::variant& value) { if (unlikely(state_ != 2)) { - UnionsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadIntOrRecordWithVlensImpl(value); @@ -4307,7 +4646,7 @@ void UnionsReaderBase::ReadIntOrRecordWithVlens(std::variant& value) { if (unlikely(state_ != 4)) { - UnionsReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadMonosotateOrIntOrSimpleRecordImpl(value); @@ -4316,7 +4655,7 @@ void UnionsReaderBase::ReadMonosotateOrIntOrSimpleRecord(std::variant value; @@ -4353,38 +4693,25 @@ void UnionsReaderBase::CopyTo(UnionsWriterBase& writer) { } } -namespace { -void StreamsOfUnionsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteIntOrSimpleRecord() or EndIntOrSimpleRecord()"; break; - case 1: expected_method = "WriteNullableIntOrSimpleRecord() or EndNullableIntOrSimpleRecord()"; break; - case 2: expected_method = "WriteManyCases() or EndManyCases()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndIntOrSimpleRecord()" : "WriteIntOrSimpleRecord()"; break; - case 1: attempted_method = end ? "EndNullableIntOrSimpleRecord()" : "WriteNullableIntOrSimpleRecord()"; break; - case 2: attempted_method = end ? "EndManyCases()" : "WriteManyCases()"; break; - case 3: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void StreamsOfUnionsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void UnionsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { case 0: return "ReadIntOrSimpleRecord()"; - case 1: return "ReadNullableIntOrSimpleRecord()"; - case 2: return "ReadManyCases()"; - case 3: return "Close()"; + case 1: return "ReadIntOrRecordWithVlens()"; + case 2: return "ReadMonosotateOrIntOrSimpleRecord()"; + case 3: return "ReadRecordWithUnions()"; + case 4: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void UnionsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string StreamsOfUnionsWriterBase::schema_ = R"({"protocol":{"name":"StreamsOfUnions","sequence":[{"name":"intOrSimpleRecord","type":{"stream":{"items":[{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]}}},{"name":"nullableIntOrSimpleRecord","type":{"stream":{"items":[null,{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]}}},{"name":"manyCases","type":{"stream":{"items":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"},{"tag":"string","type":"string"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"},{"tag":"NamedFixedNDArray","type":"TestModel.NamedFixedNDArray"}]}}}]},"types":[{"name":"NamedFixedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA","length":2},{"name":"dimB","length":4}]}}},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -4398,9 +4725,10 @@ std::string StreamsOfUnionsWriterBase::SchemaFromVersion(Version version) { } } + void StreamsOfUnionsWriterBase::WriteIntOrSimpleRecord(std::variant const& value) { if (unlikely(state_ != 0)) { - StreamsOfUnionsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntOrSimpleRecordImpl(value); @@ -4408,7 +4736,7 @@ void StreamsOfUnionsWriterBase::WriteIntOrSimpleRecord(std::variant> const& values) { if (unlikely(state_ != 0)) { - StreamsOfUnionsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntOrSimpleRecordImpl(values); @@ -4416,7 +4744,7 @@ void StreamsOfUnionsWriterBase::WriteIntOrSimpleRecord(std::vector const& value) { if (unlikely(state_ != 1)) { - StreamsOfUnionsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteNullableIntOrSimpleRecordImpl(value); @@ -4440,7 +4768,7 @@ void StreamsOfUnionsWriterBase::WriteNullableIntOrSimpleRecord(std::variant> const& values) { if (unlikely(state_ != 1)) { - StreamsOfUnionsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteNullableIntOrSimpleRecordImpl(values); @@ -4448,7 +4776,7 @@ void StreamsOfUnionsWriterBase::WriteNullableIntOrSimpleRecord(std::vector const& value) { if (unlikely(state_ != 2)) { - StreamsOfUnionsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteManyCasesImpl(value); @@ -4472,7 +4800,7 @@ void StreamsOfUnionsWriterBase::WriteManyCases(std::variant> const& values) { if (unlikely(state_ != 2)) { - StreamsOfUnionsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteManyCasesImpl(values); @@ -4480,7 +4808,7 @@ void StreamsOfUnionsWriterBase::WriteManyCases(std::vector StreamsOfUnionsReaderBase::previous_schemas_ = StreamsOfUnionsWriterBase::previous_schemas_; @@ -4512,13 +4857,14 @@ Version StreamsOfUnionsReaderBase::VersionFromSchema(std::string const& schema) } throw std::runtime_error("The schema does not match any version supported by protocol StreamsOfUnions."); } + bool StreamsOfUnionsReaderBase::ReadIntOrSimpleRecord(std::variant& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - StreamsOfUnionsReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadIntOrSimpleRecordImpl(value); @@ -4538,7 +4884,7 @@ bool StreamsOfUnionsReaderBase::ReadIntOrSimpleRecord(std::vector 1) { std::vector> values; @@ -4746,41 +5093,78 @@ void StreamsOfUnionsReaderBase::CopyTo(StreamsOfUnionsWriterBase& writer, size_t } } -namespace { -void EnumsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteSingle()"; break; - case 1: expected_method = "WriteVec()"; break; - case 2: expected_method = "WriteSize()"; break; - case 3: expected_method = "WriteRec()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteSingle()"; break; - case 1: attempted_method = "WriteVec()"; break; - case 2: attempted_method = "WriteSize()"; break; - case 3: attempted_method = "WriteRec()"; break; - case 4: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void EnumsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void StreamsOfUnionsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadSingle()"; - case 1: return "ReadVec()"; - case 2: return "ReadSize()"; - case 3: return "ReadRec()"; - case 4: return "Close()"; + case 0: return "ReadIntOrSimpleRecord()"; + case 1: return "ReadNullableIntOrSimpleRecord()"; + case 2: return "ReadManyCases()"; + case 3: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool StreamsOfUnionsIndexedReaderBase::ReadIntOrSimpleRecord(std::variant& value, size_t idx) { + return ReadIntOrSimpleRecordImpl(value, idx); +} + +bool StreamsOfUnionsIndexedReaderBase::ReadIntOrSimpleRecord(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadIntOrSimpleRecordImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsOfUnionsIndexedReaderBase::CountIntOrSimpleRecord() { + return CountIntOrSimpleRecordImpl(); +} + +bool StreamsOfUnionsIndexedReaderBase::ReadNullableIntOrSimpleRecord(std::variant& value, size_t idx) { + return ReadNullableIntOrSimpleRecordImpl(value, idx); +} + +bool StreamsOfUnionsIndexedReaderBase::ReadNullableIntOrSimpleRecord(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadNullableIntOrSimpleRecordImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsOfUnionsIndexedReaderBase::CountNullableIntOrSimpleRecord() { + return CountNullableIntOrSimpleRecordImpl(); +} + +bool StreamsOfUnionsIndexedReaderBase::ReadManyCases(std::variant& value, size_t idx) { + return ReadManyCasesImpl(value, idx); +} + +bool StreamsOfUnionsIndexedReaderBase::ReadManyCases(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadManyCasesImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsOfUnionsIndexedReaderBase::CountManyCases() { + return CountManyCasesImpl(); +} + +void StreamsOfUnionsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string EnumsWriterBase::schema_ = R"({"protocol":{"name":"Enums","sequence":[{"name":"single","type":"TestModel.Fruits"},{"name":"vec","type":{"vector":{"items":"TestModel.Fruits"}}},{"name":"size","type":"TestModel.SizeBasedEnum"},{"name":"rec","type":"TestModel.RecordWithEnums"}]},"types":[{"name":"DaysOfWeek","values":[{"symbol":"monday","value":1},{"symbol":"tuesday","value":2},{"symbol":"wednesday","value":4},{"symbol":"thursday","value":8},{"symbol":"friday","value":16},{"symbol":"saturday","value":32},{"symbol":"sunday","value":64}]},{"name":"Fruits","values":[{"symbol":"apple","value":1},{"symbol":"banana","value":2},{"symbol":"pear","value":3}]},{"name":"TextFormat","base":"uint64","values":[{"symbol":"regular","value":0},{"symbol":"bold","value":1},{"symbol":"italic","value":2},{"symbol":"underline","value":4},{"symbol":"strikethrough","value":8}]},{"name":"DaysOfWeek","type":"BasicTypes.DaysOfWeek"},{"name":"Fruits","type":"BasicTypes.Fruits"},{"name":"RecordWithEnums","fields":[{"name":"enum","type":"TestModel.Fruits"},{"name":"flags","type":"TestModel.DaysOfWeek"},{"name":"flags2","type":"TestModel.TextFormat"},{"name":"rec","type":"TestModel.RecordWithNoDefaultEnum"}]},{"name":"RecordWithNoDefaultEnum","fields":[{"name":"enum","type":"TestModel.Fruits"}]},{"name":"SizeBasedEnum","base":"size","values":[{"symbol":"a","value":0},{"symbol":"b","value":1},{"symbol":"c","value":2}]},{"name":"TextFormat","type":"BasicTypes.TextFormat"}]})"; @@ -4794,9 +5178,10 @@ std::string EnumsWriterBase::SchemaFromVersion(Version version) { } } + void EnumsWriterBase::WriteSingle(test_model::Fruits const& value) { if (unlikely(state_ != 0)) { - EnumsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteSingleImpl(value); @@ -4805,7 +5190,7 @@ void EnumsWriterBase::WriteSingle(test_model::Fruits const& value) { void EnumsWriterBase::WriteVec(std::vector const& value) { if (unlikely(state_ != 1)) { - EnumsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteVecImpl(value); @@ -4814,7 +5199,7 @@ void EnumsWriterBase::WriteVec(std::vector const& value) { void EnumsWriterBase::WriteSize(test_model::SizeBasedEnum const& value) { if (unlikely(state_ != 2)) { - EnumsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteSizeImpl(value); @@ -4823,7 +5208,7 @@ void EnumsWriterBase::WriteSize(test_model::SizeBasedEnum const& value) { void EnumsWriterBase::WriteRec(test_model::RecordWithEnums const& value) { if (unlikely(state_ != 3)) { - EnumsWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteRecImpl(value); @@ -4832,12 +5217,31 @@ void EnumsWriterBase::WriteRec(test_model::RecordWithEnums const& value) { void EnumsWriterBase::Close() { if (unlikely(state_ != 4)) { - EnumsWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } CloseImpl(); } +void EnumsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteSingle()"; break; + case 1: expected_method = "WriteVec()"; break; + case 2: expected_method = "WriteSize()"; break; + case 3: expected_method = "WriteRec()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteSingle()"; break; + case 1: attempted_method = "WriteVec()"; break; + case 2: attempted_method = "WriteSize()"; break; + case 3: attempted_method = "WriteRec()"; break; + case 4: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string EnumsReaderBase::schema_ = EnumsWriterBase::schema_; std::vector EnumsReaderBase::previous_schemas_ = EnumsWriterBase::previous_schemas_; @@ -4848,9 +5252,10 @@ Version EnumsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Enums."); } + void EnumsReaderBase::ReadSingle(test_model::Fruits& value) { if (unlikely(state_ != 0)) { - EnumsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadSingleImpl(value); @@ -4859,7 +5264,7 @@ void EnumsReaderBase::ReadSingle(test_model::Fruits& value) { void EnumsReaderBase::ReadVec(std::vector& value) { if (unlikely(state_ != 2)) { - EnumsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadVecImpl(value); @@ -4868,7 +5273,7 @@ void EnumsReaderBase::ReadVec(std::vector& value) { void EnumsReaderBase::ReadSize(test_model::SizeBasedEnum& value) { if (unlikely(state_ != 4)) { - EnumsReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadSizeImpl(value); @@ -4877,7 +5282,7 @@ void EnumsReaderBase::ReadSize(test_model::SizeBasedEnum& value) { void EnumsReaderBase::ReadRec(test_model::RecordWithEnums& value) { if (unlikely(state_ != 6)) { - EnumsReaderBaseInvalidState(6, state_); + InvalidState(6); } ReadRecImpl(value); @@ -4886,11 +5291,12 @@ void EnumsReaderBase::ReadRec(test_model::RecordWithEnums& value) { void EnumsReaderBase::Close() { if (unlikely(state_ != 8)) { - EnumsReaderBaseInvalidState(8, state_); + InvalidState(8); } CloseImpl(); } + void EnumsReaderBase::CopyTo(EnumsWriterBase& writer) { { test_model::Fruits value; @@ -4914,35 +5320,25 @@ void EnumsReaderBase::CopyTo(EnumsWriterBase& writer) { } } -namespace { -void FlagsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteDays() or EndDays()"; break; - case 1: expected_method = "WriteFormats() or EndFormats()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndDays()" : "WriteDays()"; break; - case 1: attempted_method = end ? "EndFormats()" : "WriteFormats()"; break; - case 2: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void FlagsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void EnumsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadDays()"; - case 1: return "ReadFormats()"; - case 2: return "Close()"; + case 0: return "ReadSingle()"; + case 1: return "ReadVec()"; + case 2: return "ReadSize()"; + case 3: return "ReadRec()"; + case 4: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void EnumsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string FlagsWriterBase::schema_ = R"({"protocol":{"name":"Flags","sequence":[{"name":"days","type":{"stream":{"items":"TestModel.DaysOfWeek"}}},{"name":"formats","type":{"stream":{"items":"TestModel.TextFormat"}}}]},"types":[{"name":"DaysOfWeek","values":[{"symbol":"monday","value":1},{"symbol":"tuesday","value":2},{"symbol":"wednesday","value":4},{"symbol":"thursday","value":8},{"symbol":"friday","value":16},{"symbol":"saturday","value":32},{"symbol":"sunday","value":64}]},{"name":"TextFormat","base":"uint64","values":[{"symbol":"regular","value":0},{"symbol":"bold","value":1},{"symbol":"italic","value":2},{"symbol":"underline","value":4},{"symbol":"strikethrough","value":8}]},{"name":"DaysOfWeek","type":"BasicTypes.DaysOfWeek"},{"name":"TextFormat","type":"BasicTypes.TextFormat"}]})"; @@ -4956,9 +5352,10 @@ std::string FlagsWriterBase::SchemaFromVersion(Version version) { } } + void FlagsWriterBase::WriteDays(test_model::DaysOfWeek const& value) { if (unlikely(state_ != 0)) { - FlagsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteDaysImpl(value); @@ -4966,7 +5363,7 @@ void FlagsWriterBase::WriteDays(test_model::DaysOfWeek const& value) { void FlagsWriterBase::WriteDays(std::vector const& values) { if (unlikely(state_ != 0)) { - FlagsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteDaysImpl(values); @@ -4974,7 +5371,7 @@ void FlagsWriterBase::WriteDays(std::vector const& value void FlagsWriterBase::EndDays() { if (unlikely(state_ != 0)) { - FlagsWriterBaseInvalidState(0, true, state_); + InvalidState(0, true); } EndDaysImpl(); @@ -4990,7 +5387,7 @@ void FlagsWriterBase::WriteDaysImpl(std::vector const& v void FlagsWriterBase::WriteFormats(test_model::TextFormat const& value) { if (unlikely(state_ != 1)) { - FlagsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteFormatsImpl(value); @@ -4998,7 +5395,7 @@ void FlagsWriterBase::WriteFormats(test_model::TextFormat const& value) { void FlagsWriterBase::WriteFormats(std::vector const& values) { if (unlikely(state_ != 1)) { - FlagsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteFormatsImpl(values); @@ -5006,7 +5403,7 @@ void FlagsWriterBase::WriteFormats(std::vector const& va void FlagsWriterBase::EndFormats() { if (unlikely(state_ != 1)) { - FlagsWriterBaseInvalidState(1, true, state_); + InvalidState(1, true); } EndFormatsImpl(); @@ -5022,10 +5419,25 @@ void FlagsWriterBase::WriteFormatsImpl(std::vector const void FlagsWriterBase::Close() { if (unlikely(state_ != 2)) { - FlagsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); + } + + CloseImpl(); +} + +void FlagsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteDays() or EndDays()"; break; + case 1: expected_method = "WriteFormats() or EndFormats()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = end ? "EndDays()" : "WriteDays()"; break; + case 1: attempted_method = end ? "EndFormats()" : "WriteFormats()"; break; + case 2: attempted_method = "Close()"; break; } - - CloseImpl(); + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); } std::string FlagsReaderBase::schema_ = FlagsWriterBase::schema_; @@ -5038,13 +5450,14 @@ Version FlagsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Flags."); } + bool FlagsReaderBase::ReadDays(test_model::DaysOfWeek& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - FlagsReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadDaysImpl(value); @@ -5064,7 +5477,7 @@ bool FlagsReaderBase::ReadDays(std::vector& values) { values.clear(); return false; } - FlagsReaderBaseInvalidState(0, state_); + InvalidState(0); } if (!ReadDaysImpl(values)) { @@ -5101,7 +5514,7 @@ bool FlagsReaderBase::ReadFormats(test_model::TextFormat& value) { if (state_ == 1) { state_ = 2; } else { - FlagsReaderBaseInvalidState(2, state_); + InvalidState(2); } } @@ -5125,7 +5538,7 @@ bool FlagsReaderBase::ReadFormats(std::vector& values) { if (state_ == 1) { state_ = 2; } else { - FlagsReaderBaseInvalidState(2, state_); + InvalidState(2); } } @@ -5159,12 +5572,13 @@ void FlagsReaderBase::Close() { if (state_ == 3) { state_ = 4; } else { - FlagsReaderBaseInvalidState(4, state_); + InvalidState(4); } } CloseImpl(); } + void FlagsReaderBase::CopyTo(FlagsWriterBase& writer, size_t days_buffer_size, size_t formats_buffer_size) { if (days_buffer_size > 1) { std::vector values; @@ -5196,38 +5610,59 @@ void FlagsReaderBase::CopyTo(FlagsWriterBase& writer, size_t days_buffer_size, s } } -namespace { -void StateTestWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteAnInt()"; break; - case 1: expected_method = "WriteAStream() or EndAStream()"; break; - case 2: expected_method = "WriteAnotherInt()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteAnInt()"; break; - case 1: attempted_method = end ? "EndAStream()" : "WriteAStream()"; break; - case 2: attempted_method = "WriteAnotherInt()"; break; - case 3: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void StateTestReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void FlagsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadAnInt()"; - case 1: return "ReadAStream()"; - case 2: return "ReadAnotherInt()"; - case 3: return "Close()"; + case 0: return "ReadDays()"; + case 1: return "ReadFormats()"; + case 2: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool FlagsIndexedReaderBase::ReadDays(test_model::DaysOfWeek& value, size_t idx) { + return ReadDaysImpl(value, idx); +} + +bool FlagsIndexedReaderBase::ReadDays(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadDaysImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t FlagsIndexedReaderBase::CountDays() { + return CountDaysImpl(); +} + +bool FlagsIndexedReaderBase::ReadFormats(test_model::TextFormat& value, size_t idx) { + return ReadFormatsImpl(value, idx); +} + +bool FlagsIndexedReaderBase::ReadFormats(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadFormatsImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t FlagsIndexedReaderBase::CountFormats() { + return CountFormatsImpl(); +} + +void FlagsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string StateTestWriterBase::schema_ = R"({"protocol":{"name":"StateTest","sequence":[{"name":"anInt","type":"int32"},{"name":"aStream","type":{"stream":{"items":"int32"}}},{"name":"anotherInt","type":"int32"}]},"types":null})"; @@ -5241,9 +5676,10 @@ std::string StateTestWriterBase::SchemaFromVersion(Version version) { } } + void StateTestWriterBase::WriteAnInt(int32_t const& value) { if (unlikely(state_ != 0)) { - StateTestWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteAnIntImpl(value); @@ -5252,7 +5688,7 @@ void StateTestWriterBase::WriteAnInt(int32_t const& value) { void StateTestWriterBase::WriteAStream(int32_t const& value) { if (unlikely(state_ != 1)) { - StateTestWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteAStreamImpl(value); @@ -5260,7 +5696,7 @@ void StateTestWriterBase::WriteAStream(int32_t const& value) { void StateTestWriterBase::WriteAStream(std::vector const& values) { if (unlikely(state_ != 1)) { - StateTestWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteAStreamImpl(values); @@ -5268,7 +5704,7 @@ void StateTestWriterBase::WriteAStream(std::vector const& values) { void StateTestWriterBase::EndAStream() { if (unlikely(state_ != 1)) { - StateTestWriterBaseInvalidState(1, true, state_); + InvalidState(1, true); } EndAStreamImpl(); @@ -5284,7 +5720,7 @@ void StateTestWriterBase::WriteAStreamImpl(std::vector const& values) { void StateTestWriterBase::WriteAnotherInt(int32_t const& value) { if (unlikely(state_ != 2)) { - StateTestWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteAnotherIntImpl(value); @@ -5293,12 +5729,29 @@ void StateTestWriterBase::WriteAnotherInt(int32_t const& value) { void StateTestWriterBase::Close() { if (unlikely(state_ != 3)) { - StateTestWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } CloseImpl(); } +void StateTestWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteAnInt()"; break; + case 1: expected_method = "WriteAStream() or EndAStream()"; break; + case 2: expected_method = "WriteAnotherInt()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteAnInt()"; break; + case 1: attempted_method = end ? "EndAStream()" : "WriteAStream()"; break; + case 2: attempted_method = "WriteAnotherInt()"; break; + case 3: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string StateTestReaderBase::schema_ = StateTestWriterBase::schema_; std::vector StateTestReaderBase::previous_schemas_ = StateTestWriterBase::previous_schemas_; @@ -5309,9 +5762,10 @@ Version StateTestReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol StateTest."); } + void StateTestReaderBase::ReadAnInt(int32_t& value) { if (unlikely(state_ != 0)) { - StateTestReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadAnIntImpl(value); @@ -5324,7 +5778,7 @@ bool StateTestReaderBase::ReadAStream(int32_t& value) { state_ = 4; return false; } - StateTestReaderBaseInvalidState(2, state_); + InvalidState(2); } bool result = ReadAStreamImpl(value); @@ -5344,7 +5798,7 @@ bool StateTestReaderBase::ReadAStream(std::vector& values) { values.clear(); return false; } - StateTestReaderBaseInvalidState(2, state_); + InvalidState(2); } if (!ReadAStreamImpl(values)) { @@ -5377,7 +5831,7 @@ void StateTestReaderBase::ReadAnotherInt(int32_t& value) { if (state_ == 3) { state_ = 4; } else { - StateTestReaderBaseInvalidState(4, state_); + InvalidState(4); } } @@ -5387,11 +5841,12 @@ void StateTestReaderBase::ReadAnotherInt(int32_t& value) { void StateTestReaderBase::Close() { if (unlikely(state_ != 6)) { - StateTestReaderBaseInvalidState(6, state_); + InvalidState(6); } CloseImpl(); } + void StateTestReaderBase::CopyTo(StateTestWriterBase& writer, size_t a_stream_buffer_size) { { int32_t value; @@ -5419,56 +5874,42 @@ void StateTestReaderBase::CopyTo(StateTestWriterBase& writer, size_t a_stream_bu } } -namespace { -void SimpleGenericsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteFloatImage()"; break; - case 1: expected_method = "WriteIntImage()"; break; - case 2: expected_method = "WriteIntImageAlternateSyntax()"; break; - case 3: expected_method = "WriteStringImage()"; break; - case 4: expected_method = "WriteIntFloatTuple()"; break; - case 5: expected_method = "WriteFloatFloatTuple()"; break; - case 6: expected_method = "WriteIntFloatTupleAlternateSyntax()"; break; - case 7: expected_method = "WriteIntStringTuple()"; break; - case 8: expected_method = "WriteStreamOfTypeVariants() or EndStreamOfTypeVariants()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteFloatImage()"; break; - case 1: attempted_method = "WriteIntImage()"; break; - case 2: attempted_method = "WriteIntImageAlternateSyntax()"; break; - case 3: attempted_method = "WriteStringImage()"; break; - case 4: attempted_method = "WriteIntFloatTuple()"; break; - case 5: attempted_method = "WriteFloatFloatTuple()"; break; - case 6: attempted_method = "WriteIntFloatTupleAlternateSyntax()"; break; - case 7: attempted_method = "WriteIntStringTuple()"; break; - case 8: attempted_method = end ? "EndStreamOfTypeVariants()" : "WriteStreamOfTypeVariants()"; break; - case 9: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void SimpleGenericsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void StateTestReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadFloatImage()"; - case 1: return "ReadIntImage()"; - case 2: return "ReadIntImageAlternateSyntax()"; - case 3: return "ReadStringImage()"; - case 4: return "ReadIntFloatTuple()"; - case 5: return "ReadFloatFloatTuple()"; - case 6: return "ReadIntFloatTupleAlternateSyntax()"; - case 7: return "ReadIntStringTuple()"; - case 8: return "ReadStreamOfTypeVariants()"; - case 9: return "Close()"; + case 0: return "ReadAnInt()"; + case 1: return "ReadAStream()"; + case 2: return "ReadAnotherInt()"; + case 3: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool StateTestIndexedReaderBase::ReadAStream(int32_t& value, size_t idx) { + return ReadAStreamImpl(value, idx); +} + +bool StateTestIndexedReaderBase::ReadAStream(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadAStreamImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StateTestIndexedReaderBase::CountAStream() { + return CountAStreamImpl(); +} + +void StateTestIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string SimpleGenericsWriterBase::schema_ = R"({"protocol":{"name":"SimpleGenerics","sequence":[{"name":"floatImage","type":"Image.FloatImage"},{"name":"intImage","type":"Image.IntImage"},{"name":"intImageAlternateSyntax","type":{"name":"TestModel.Image","typeArguments":["int32"]}},{"name":"stringImage","type":{"name":"TestModel.Image","typeArguments":["string"]}},{"name":"intFloatTuple","type":{"name":"Tuples.Tuple","typeArguments":["int32","float32"]}},{"name":"floatFloatTuple","type":{"name":"Tuples.Tuple","typeArguments":["float32","float32"]}},{"name":"intFloatTupleAlternateSyntax","type":{"name":"Tuples.Tuple","typeArguments":["int32","float32"]}},{"name":"intStringTuple","type":{"name":"Tuples.Tuple","typeArguments":["int32","string"]}},{"name":"streamOfTypeVariants","type":{"stream":{"items":[{"tag":"imageFloat","explicitTag":true,"type":"Image.FloatImage"},{"tag":"imageDouble","explicitTag":true,"type":{"name":"TestModel.Image","typeArguments":["float64"]}}]}}}]},"types":[{"name":"FloatImage","type":{"name":"Image.Image","typeArguments":["float32"]}},{"name":"Image","typeParameters":["T"],"type":{"array":{"items":"T","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"IntImage","type":{"name":"Image.Image","typeArguments":["int32"]}},{"name":"Image","typeParameters":["T"],"type":{"name":"Image.Image","typeArguments":["T"]}},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]})"; @@ -5482,9 +5923,10 @@ std::string SimpleGenericsWriterBase::SchemaFromVersion(Version version) { } } + void SimpleGenericsWriterBase::WriteFloatImage(image::FloatImage const& value) { if (unlikely(state_ != 0)) { - SimpleGenericsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteFloatImageImpl(value); @@ -5493,7 +5935,7 @@ void SimpleGenericsWriterBase::WriteFloatImage(image::FloatImage const& value) { void SimpleGenericsWriterBase::WriteIntImage(image::IntImage const& value) { if (unlikely(state_ != 1)) { - SimpleGenericsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteIntImageImpl(value); @@ -5502,7 +5944,7 @@ void SimpleGenericsWriterBase::WriteIntImage(image::IntImage const& value) { void SimpleGenericsWriterBase::WriteIntImageAlternateSyntax(test_model::Image const& value) { if (unlikely(state_ != 2)) { - SimpleGenericsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteIntImageAlternateSyntaxImpl(value); @@ -5511,7 +5953,7 @@ void SimpleGenericsWriterBase::WriteIntImageAlternateSyntax(test_model::Image const& value) { if (unlikely(state_ != 3)) { - SimpleGenericsWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteStringImageImpl(value); @@ -5520,7 +5962,7 @@ void SimpleGenericsWriterBase::WriteStringImage(test_model::Image c void SimpleGenericsWriterBase::WriteIntFloatTuple(tuples::Tuple const& value) { if (unlikely(state_ != 4)) { - SimpleGenericsWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } WriteIntFloatTupleImpl(value); @@ -5529,7 +5971,7 @@ void SimpleGenericsWriterBase::WriteIntFloatTuple(tuples::Tuple void SimpleGenericsWriterBase::WriteFloatFloatTuple(tuples::Tuple const& value) { if (unlikely(state_ != 5)) { - SimpleGenericsWriterBaseInvalidState(5, false, state_); + InvalidState(5, false); } WriteFloatFloatTupleImpl(value); @@ -5538,7 +5980,7 @@ void SimpleGenericsWriterBase::WriteFloatFloatTuple(tuples::Tuple void SimpleGenericsWriterBase::WriteIntFloatTupleAlternateSyntax(tuples::Tuple const& value) { if (unlikely(state_ != 6)) { - SimpleGenericsWriterBaseInvalidState(6, false, state_); + InvalidState(6, false); } WriteIntFloatTupleAlternateSyntaxImpl(value); @@ -5547,7 +5989,7 @@ void SimpleGenericsWriterBase::WriteIntFloatTupleAlternateSyntax(tuples::Tuple const& value) { if (unlikely(state_ != 7)) { - SimpleGenericsWriterBaseInvalidState(7, false, state_); + InvalidState(7, false); } WriteIntStringTupleImpl(value); @@ -5556,7 +5998,7 @@ void SimpleGenericsWriterBase::WriteIntStringTuple(tuples::Tuple> const& value) { if (unlikely(state_ != 8)) { - SimpleGenericsWriterBaseInvalidState(8, false, state_); + InvalidState(8, false); } WriteStreamOfTypeVariantsImpl(value); @@ -5564,7 +6006,7 @@ void SimpleGenericsWriterBase::WriteStreamOfTypeVariants(std::variant>> const& values) { if (unlikely(state_ != 8)) { - SimpleGenericsWriterBaseInvalidState(8, false, state_); + InvalidState(8, false); } WriteStreamOfTypeVariantsImpl(values); @@ -5572,7 +6014,7 @@ void SimpleGenericsWriterBase::WriteStreamOfTypeVariants(std::vector SimpleGenericsReaderBase::previous_schemas_ = SimpleGenericsWriterBase::previous_schemas_; @@ -5604,9 +6075,10 @@ Version SimpleGenericsReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol SimpleGenerics."); } + void SimpleGenericsReaderBase::ReadFloatImage(image::FloatImage& value) { if (unlikely(state_ != 0)) { - SimpleGenericsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadFloatImageImpl(value); @@ -5615,7 +6087,7 @@ void SimpleGenericsReaderBase::ReadFloatImage(image::FloatImage& value) { void SimpleGenericsReaderBase::ReadIntImage(image::IntImage& value) { if (unlikely(state_ != 2)) { - SimpleGenericsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadIntImageImpl(value); @@ -5624,7 +6096,7 @@ void SimpleGenericsReaderBase::ReadIntImage(image::IntImage& value) { void SimpleGenericsReaderBase::ReadIntImageAlternateSyntax(test_model::Image& value) { if (unlikely(state_ != 4)) { - SimpleGenericsReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadIntImageAlternateSyntaxImpl(value); @@ -5633,7 +6105,7 @@ void SimpleGenericsReaderBase::ReadIntImageAlternateSyntax(test_model::Image& value) { if (unlikely(state_ != 6)) { - SimpleGenericsReaderBaseInvalidState(6, state_); + InvalidState(6); } ReadStringImageImpl(value); @@ -5642,7 +6114,7 @@ void SimpleGenericsReaderBase::ReadStringImage(test_model::Image& v void SimpleGenericsReaderBase::ReadIntFloatTuple(tuples::Tuple& value) { if (unlikely(state_ != 8)) { - SimpleGenericsReaderBaseInvalidState(8, state_); + InvalidState(8); } ReadIntFloatTupleImpl(value); @@ -5651,7 +6123,7 @@ void SimpleGenericsReaderBase::ReadIntFloatTuple(tuples::Tuple& void SimpleGenericsReaderBase::ReadFloatFloatTuple(tuples::Tuple& value) { if (unlikely(state_ != 10)) { - SimpleGenericsReaderBaseInvalidState(10, state_); + InvalidState(10); } ReadFloatFloatTupleImpl(value); @@ -5660,7 +6132,7 @@ void SimpleGenericsReaderBase::ReadFloatFloatTuple(tuples::Tuple& void SimpleGenericsReaderBase::ReadIntFloatTupleAlternateSyntax(tuples::Tuple& value) { if (unlikely(state_ != 12)) { - SimpleGenericsReaderBaseInvalidState(12, state_); + InvalidState(12); } ReadIntFloatTupleAlternateSyntaxImpl(value); @@ -5669,7 +6141,7 @@ void SimpleGenericsReaderBase::ReadIntFloatTupleAlternateSyntax(tuples::Tuple& value) { if (unlikely(state_ != 14)) { - SimpleGenericsReaderBaseInvalidState(14, state_); + InvalidState(14); } ReadIntStringTupleImpl(value); @@ -5682,7 +6154,7 @@ bool SimpleGenericsReaderBase::ReadStreamOfTypeVariants(std::variant std::string { switch (i/2) { - case 0: return "ReadFloatImageImage()"; - case 1: return "ReadGenericRecord1()"; - case 2: return "ReadTupleOfOptionals()"; - case 3: return "ReadTupleOfOptionalsAlternateSyntax()"; - case 4: return "ReadTupleOfVectors()"; - case 5: return "Close()"; + case 0: return "ReadFloatImage()"; + case 1: return "ReadIntImage()"; + case 2: return "ReadIntImageAlternateSyntax()"; + case 3: return "ReadStringImage()"; + case 4: return "ReadIntFloatTuple()"; + case 5: return "ReadFloatFloatTuple()"; + case 6: return "ReadIntFloatTupleAlternateSyntax()"; + case 7: return "ReadIntStringTuple()"; + case 8: return "ReadStreamOfTypeVariants()"; + case 9: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool SimpleGenericsIndexedReaderBase::ReadStreamOfTypeVariants(std::variant>& value, size_t idx) { + return ReadStreamOfTypeVariantsImpl(value, idx); +} + +bool SimpleGenericsIndexedReaderBase::ReadStreamOfTypeVariants(std::vector>>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamOfTypeVariantsImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t SimpleGenericsIndexedReaderBase::CountStreamOfTypeVariants() { + return CountStreamOfTypeVariantsImpl(); +} + +void SimpleGenericsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string AdvancedGenericsWriterBase::schema_ = R"({"protocol":{"name":"AdvancedGenerics","sequence":[{"name":"floatImageImage","type":{"name":"TestModel.Image","typeArguments":[{"name":"TestModel.Image","typeArguments":["float32"]}]}},{"name":"genericRecord1","type":{"name":"TestModel.GenericRecord","typeArguments":["int32","string"]}},{"name":"tupleOfOptionals","type":{"name":"TestModel.MyTuple","typeArguments":[[null,"int32"],[null,"string"]]}},{"name":"tupleOfOptionalsAlternateSyntax","type":{"name":"TestModel.MyTuple","typeArguments":[[null,"int32"],[null,"string"]]}},{"name":"tupleOfVectors","type":{"name":"TestModel.MyTuple","typeArguments":[{"vector":{"items":"int32"}},{"vector":{"items":"float32"}}]}}]},"types":[{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"Image","typeParameters":["T"],"type":{"array":{"items":"T","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"GenericRecord","typeParameters":["T1","T2"],"fields":[{"name":"scalar1","type":"T1"},{"name":"scalar2","type":"T2"},{"name":"vector1","type":{"vector":{"items":"T1"}}},{"name":"image2","type":{"name":"TestModel.Image","typeArguments":["T2"]}}]},{"name":"Image","typeParameters":["T"],"type":{"name":"Image.Image","typeArguments":["T"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]})"; @@ -5849,9 +6326,10 @@ std::string AdvancedGenericsWriterBase::SchemaFromVersion(Version version) { } } + void AdvancedGenericsWriterBase::WriteFloatImageImage(test_model::Image> const& value) { if (unlikely(state_ != 0)) { - AdvancedGenericsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteFloatImageImageImpl(value); @@ -5860,7 +6338,7 @@ void AdvancedGenericsWriterBase::WriteFloatImageImage(test_model::Image const& value) { if (unlikely(state_ != 1)) { - AdvancedGenericsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteGenericRecord1Impl(value); @@ -5869,7 +6347,7 @@ void AdvancedGenericsWriterBase::WriteGenericRecord1(test_model::GenericRecord, std::optional> const& value) { if (unlikely(state_ != 2)) { - AdvancedGenericsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteTupleOfOptionalsImpl(value); @@ -5878,7 +6356,7 @@ void AdvancedGenericsWriterBase::WriteTupleOfOptionals(test_model::MyTuple, std::optional> const& value) { if (unlikely(state_ != 3)) { - AdvancedGenericsWriterBaseInvalidState(3, false, state_); + InvalidState(3, false); } WriteTupleOfOptionalsAlternateSyntaxImpl(value); @@ -5887,7 +6365,7 @@ void AdvancedGenericsWriterBase::WriteTupleOfOptionalsAlternateSyntax(test_model void AdvancedGenericsWriterBase::WriteTupleOfVectors(test_model::MyTuple, std::vector> const& value) { if (unlikely(state_ != 4)) { - AdvancedGenericsWriterBaseInvalidState(4, false, state_); + InvalidState(4, false); } WriteTupleOfVectorsImpl(value); @@ -5896,12 +6374,33 @@ void AdvancedGenericsWriterBase::WriteTupleOfVectors(test_model::MyTuple AdvancedGenericsReaderBase::previous_schemas_ = AdvancedGenericsWriterBase::previous_schemas_; @@ -5912,9 +6411,10 @@ Version AdvancedGenericsReaderBase::VersionFromSchema(std::string const& schema) } throw std::runtime_error("The schema does not match any version supported by protocol AdvancedGenerics."); } + void AdvancedGenericsReaderBase::ReadFloatImageImage(test_model::Image>& value) { if (unlikely(state_ != 0)) { - AdvancedGenericsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadFloatImageImageImpl(value); @@ -5923,7 +6423,7 @@ void AdvancedGenericsReaderBase::ReadFloatImageImage(test_model::Image& value) { if (unlikely(state_ != 2)) { - AdvancedGenericsReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadGenericRecord1Impl(value); @@ -5932,7 +6432,7 @@ void AdvancedGenericsReaderBase::ReadGenericRecord1(test_model::GenericRecord, std::optional>& value) { if (unlikely(state_ != 4)) { - AdvancedGenericsReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadTupleOfOptionalsImpl(value); @@ -5941,7 +6441,7 @@ void AdvancedGenericsReaderBase::ReadTupleOfOptionals(test_model::MyTuple, std::optional>& value) { if (unlikely(state_ != 6)) { - AdvancedGenericsReaderBaseInvalidState(6, state_); + InvalidState(6); } ReadTupleOfOptionalsAlternateSyntaxImpl(value); @@ -5950,7 +6450,7 @@ void AdvancedGenericsReaderBase::ReadTupleOfOptionalsAlternateSyntax(test_model: void AdvancedGenericsReaderBase::ReadTupleOfVectors(test_model::MyTuple, std::vector>& value) { if (unlikely(state_ != 8)) { - AdvancedGenericsReaderBaseInvalidState(8, state_); + InvalidState(8); } ReadTupleOfVectorsImpl(value); @@ -5959,11 +6459,12 @@ void AdvancedGenericsReaderBase::ReadTupleOfVectors(test_model::MyTuple> value; @@ -5992,59 +6493,26 @@ void AdvancedGenericsReaderBase::CopyTo(AdvancedGenericsWriterBase& writer) { } } -namespace { -void AliasesWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteAliasedString()"; break; - case 1: expected_method = "WriteAliasedEnum()"; break; - case 2: expected_method = "WriteAliasedOpenGeneric()"; break; - case 3: expected_method = "WriteAliasedClosedGeneric()"; break; - case 4: expected_method = "WriteAliasedOptional()"; break; - case 5: expected_method = "WriteAliasedGenericOptional()"; break; - case 6: expected_method = "WriteAliasedGenericUnion2()"; break; - case 7: expected_method = "WriteAliasedGenericVector()"; break; - case 8: expected_method = "WriteAliasedGenericFixedVector()"; break; - case 9: expected_method = "WriteStreamOfAliasedGenericUnion2() or EndStreamOfAliasedGenericUnion2()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteAliasedString()"; break; - case 1: attempted_method = "WriteAliasedEnum()"; break; - case 2: attempted_method = "WriteAliasedOpenGeneric()"; break; - case 3: attempted_method = "WriteAliasedClosedGeneric()"; break; - case 4: attempted_method = "WriteAliasedOptional()"; break; - case 5: attempted_method = "WriteAliasedGenericOptional()"; break; - case 6: attempted_method = "WriteAliasedGenericUnion2()"; break; - case 7: attempted_method = "WriteAliasedGenericVector()"; break; - case 8: attempted_method = "WriteAliasedGenericFixedVector()"; break; - case 9: attempted_method = end ? "EndStreamOfAliasedGenericUnion2()" : "WriteStreamOfAliasedGenericUnion2()"; break; - case 10: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void AliasesReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void AdvancedGenericsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadAliasedString()"; - case 1: return "ReadAliasedEnum()"; - case 2: return "ReadAliasedOpenGeneric()"; - case 3: return "ReadAliasedClosedGeneric()"; - case 4: return "ReadAliasedOptional()"; - case 5: return "ReadAliasedGenericOptional()"; - case 6: return "ReadAliasedGenericUnion2()"; - case 7: return "ReadAliasedGenericVector()"; - case 8: return "ReadAliasedGenericFixedVector()"; - case 9: return "ReadStreamOfAliasedGenericUnion2()"; - case 10: return "Close()"; + case 0: return "ReadFloatImageImage()"; + case 1: return "ReadGenericRecord1()"; + case 2: return "ReadTupleOfOptionals()"; + case 3: return "ReadTupleOfOptionalsAlternateSyntax()"; + case 4: return "ReadTupleOfVectors()"; + case 5: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void AdvancedGenericsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string AliasesWriterBase::schema_ = R"({"protocol":{"name":"Aliases","sequence":[{"name":"aliasedString","type":"TestModel.AliasedString"},{"name":"aliasedEnum","type":"TestModel.AliasedEnum"},{"name":"aliasedOpenGeneric","type":{"name":"TestModel.AliasedOpenGeneric","typeArguments":["TestModel.AliasedString","TestModel.AliasedEnum"]}},{"name":"aliasedClosedGeneric","type":"TestModel.AliasedClosedGeneric"},{"name":"aliasedOptional","type":"TestModel.AliasedOptional"},{"name":"aliasedGenericOptional","type":{"name":"TestModel.AliasedGenericOptional","typeArguments":["float32"]}},{"name":"aliasedGenericUnion2","type":{"name":"TestModel.AliasedGenericUnion2","typeArguments":["TestModel.AliasedString","TestModel.AliasedEnum"]}},{"name":"aliasedGenericVector","type":{"name":"TestModel.AliasedGenericVector","typeArguments":["float32"]}},{"name":"aliasedGenericFixedVector","type":{"name":"TestModel.AliasedGenericFixedVector","typeArguments":["float32"]}},{"name":"streamOfAliasedGenericUnion2","type":{"stream":{"items":{"name":"TestModel.AliasedGenericUnion2","typeArguments":["TestModel.AliasedString","TestModel.AliasedEnum"]}}}}]},"types":[{"name":"Fruits","values":[{"symbol":"apple","value":1},{"symbol":"banana","value":2},{"symbol":"pear","value":3}]},{"name":"GenericUnion2","typeParameters":["T1","T2"],"type":[{"tag":"T1","type":"T1"},{"tag":"T2","type":"T2"}]},{"name":"GenericVector","typeParameters":["T"],"type":{"vector":{"items":"T"}}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"AliasedClosedGeneric","type":{"name":"TestModel.AliasedTuple","typeArguments":["TestModel.AliasedString","TestModel.AliasedEnum"]}},{"name":"AliasedEnum","type":"TestModel.Fruits"},{"name":"AliasedGenericFixedVector","typeParameters":["T"],"type":{"vector":{"items":"T","length":3}}},{"name":"AliasedGenericOptional","typeParameters":["T"],"type":[null,"T"]},{"name":"AliasedGenericUnion2","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.GenericUnion2","typeArguments":["T1","T2"]}},{"name":"AliasedGenericVector","typeParameters":["T"],"type":{"name":"BasicTypes.GenericVector","typeArguments":["T"]}},{"name":"AliasedOpenGeneric","typeParameters":["T1","T2"],"type":{"name":"TestModel.AliasedTuple","typeArguments":["T1","T2"]}},{"name":"AliasedOptional","type":[null,"int32"]},{"name":"AliasedString","type":"string"},{"name":"AliasedTuple","typeParameters":["T1","T2"],"type":{"name":"TestModel.MyTuple","typeArguments":["T1","T2"]}},{"name":"Fruits","type":"BasicTypes.Fruits"},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]})"; @@ -6058,9 +6526,10 @@ std::string AliasesWriterBase::SchemaFromVersion(Version version) { } } + void AliasesWriterBase::WriteAliasedString(test_model::AliasedString const& value) { if (unlikely(state_ != 0)) { - AliasesWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteAliasedStringImpl(value); @@ -6069,7 +6538,7 @@ void AliasesWriterBase::WriteAliasedString(test_model::AliasedString const& valu void AliasesWriterBase::WriteAliasedEnum(test_model::AliasedEnum const& value) { if (unlikely(state_ != 1)) { - AliasesWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteAliasedEnumImpl(value); @@ -6078,7 +6547,7 @@ void AliasesWriterBase::WriteAliasedEnum(test_model::AliasedEnum const& value) { void AliasesWriterBase::WriteAliasedOpenGeneric(test_model::AliasedOpenGeneric const& value) { if (unlikely(state_ != 2)) { - AliasesWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } WriteAliasedOpenGenericImpl(value); @@ -6087,7 +6556,7 @@ void AliasesWriterBase::WriteAliasedOpenGeneric(test_model::AliasedOpenGeneric const& value) { if (unlikely(state_ != 5)) { - AliasesWriterBaseInvalidState(5, false, state_); + InvalidState(5, false); } WriteAliasedGenericOptionalImpl(value); @@ -6114,7 +6583,7 @@ void AliasesWriterBase::WriteAliasedGenericOptional(test_model::AliasedGenericOp void AliasesWriterBase::WriteAliasedGenericUnion2(test_model::AliasedGenericUnion2 const& value) { if (unlikely(state_ != 6)) { - AliasesWriterBaseInvalidState(6, false, state_); + InvalidState(6, false); } WriteAliasedGenericUnion2Impl(value); @@ -6123,7 +6592,7 @@ void AliasesWriterBase::WriteAliasedGenericUnion2(test_model::AliasedGenericUnio void AliasesWriterBase::WriteAliasedGenericVector(test_model::AliasedGenericVector const& value) { if (unlikely(state_ != 7)) { - AliasesWriterBaseInvalidState(7, false, state_); + InvalidState(7, false); } WriteAliasedGenericVectorImpl(value); @@ -6132,7 +6601,7 @@ void AliasesWriterBase::WriteAliasedGenericVector(test_model::AliasedGenericVect void AliasesWriterBase::WriteAliasedGenericFixedVector(test_model::AliasedGenericFixedVector const& value) { if (unlikely(state_ != 8)) { - AliasesWriterBaseInvalidState(8, false, state_); + InvalidState(8, false); } WriteAliasedGenericFixedVectorImpl(value); @@ -6141,7 +6610,7 @@ void AliasesWriterBase::WriteAliasedGenericFixedVector(test_model::AliasedGeneri void AliasesWriterBase::WriteStreamOfAliasedGenericUnion2(test_model::AliasedGenericUnion2 const& value) { if (unlikely(state_ != 9)) { - AliasesWriterBaseInvalidState(9, false, state_); + InvalidState(9, false); } WriteStreamOfAliasedGenericUnion2Impl(value); @@ -6149,7 +6618,7 @@ void AliasesWriterBase::WriteStreamOfAliasedGenericUnion2(test_model::AliasedGen void AliasesWriterBase::WriteStreamOfAliasedGenericUnion2(std::vector> const& values) { if (unlikely(state_ != 9)) { - AliasesWriterBaseInvalidState(9, false, state_); + InvalidState(9, false); } WriteStreamOfAliasedGenericUnion2Impl(values); @@ -6157,7 +6626,7 @@ void AliasesWriterBase::WriteStreamOfAliasedGenericUnion2(std::vector AliasesReaderBase::previous_schemas_ = AliasesWriterBase::previous_schemas_; @@ -6189,9 +6689,10 @@ Version AliasesReaderBase::VersionFromSchema(std::string const& schema) { } throw std::runtime_error("The schema does not match any version supported by protocol Aliases."); } + void AliasesReaderBase::ReadAliasedString(test_model::AliasedString& value) { if (unlikely(state_ != 0)) { - AliasesReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadAliasedStringImpl(value); @@ -6200,7 +6701,7 @@ void AliasesReaderBase::ReadAliasedString(test_model::AliasedString& value) { void AliasesReaderBase::ReadAliasedEnum(test_model::AliasedEnum& value) { if (unlikely(state_ != 2)) { - AliasesReaderBaseInvalidState(2, state_); + InvalidState(2); } ReadAliasedEnumImpl(value); @@ -6209,7 +6710,7 @@ void AliasesReaderBase::ReadAliasedEnum(test_model::AliasedEnum& value) { void AliasesReaderBase::ReadAliasedOpenGeneric(test_model::AliasedOpenGeneric& value) { if (unlikely(state_ != 4)) { - AliasesReaderBaseInvalidState(4, state_); + InvalidState(4); } ReadAliasedOpenGenericImpl(value); @@ -6218,7 +6719,7 @@ void AliasesReaderBase::ReadAliasedOpenGeneric(test_model::AliasedOpenGeneric& value) { if (unlikely(state_ != 10)) { - AliasesReaderBaseInvalidState(10, state_); + InvalidState(10); } ReadAliasedGenericOptionalImpl(value); @@ -6245,7 +6746,7 @@ void AliasesReaderBase::ReadAliasedGenericOptional(test_model::AliasedGenericOpt void AliasesReaderBase::ReadAliasedGenericUnion2(test_model::AliasedGenericUnion2& value) { if (unlikely(state_ != 12)) { - AliasesReaderBaseInvalidState(12, state_); + InvalidState(12); } ReadAliasedGenericUnion2Impl(value); @@ -6254,7 +6755,7 @@ void AliasesReaderBase::ReadAliasedGenericUnion2(test_model::AliasedGenericUnion void AliasesReaderBase::ReadAliasedGenericVector(test_model::AliasedGenericVector& value) { if (unlikely(state_ != 14)) { - AliasesReaderBaseInvalidState(14, state_); + InvalidState(14); } ReadAliasedGenericVectorImpl(value); @@ -6263,7 +6764,7 @@ void AliasesReaderBase::ReadAliasedGenericVector(test_model::AliasedGenericVecto void AliasesReaderBase::ReadAliasedGenericFixedVector(test_model::AliasedGenericFixedVector& value) { if (unlikely(state_ != 16)) { - AliasesReaderBaseInvalidState(16, state_); + InvalidState(16); } ReadAliasedGenericFixedVectorImpl(value); @@ -6276,7 +6777,7 @@ bool AliasesReaderBase::ReadStreamOfAliasedGenericUnion2(test_model::AliasedGene state_ = 20; return false; } - AliasesReaderBaseInvalidState(18, state_); + InvalidState(18); } bool result = ReadStreamOfAliasedGenericUnion2Impl(value); @@ -6296,7 +6797,7 @@ bool AliasesReaderBase::ReadStreamOfAliasedGenericUnion2(std::vector std::string { switch (i/2) { - case 0: return "ReadIntOrSimpleRecord()"; - case 1: return "ReadNullableIntOrSimpleRecord()"; - case 2: return "Close()"; + case 0: return "ReadAliasedString()"; + case 1: return "ReadAliasedEnum()"; + case 2: return "ReadAliasedOpenGeneric()"; + case 3: return "ReadAliasedClosedGeneric()"; + case 4: return "ReadAliasedOptional()"; + case 5: return "ReadAliasedGenericOptional()"; + case 6: return "ReadAliasedGenericUnion2()"; + case 7: return "ReadAliasedGenericVector()"; + case 8: return "ReadAliasedGenericFixedVector()"; + case 9: return "ReadStreamOfAliasedGenericUnion2()"; + case 10: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool AliasesIndexedReaderBase::ReadStreamOfAliasedGenericUnion2(test_model::AliasedGenericUnion2& value, size_t idx) { + return ReadStreamOfAliasedGenericUnion2Impl(value, idx); +} + +bool AliasesIndexedReaderBase::ReadStreamOfAliasedGenericUnion2(std::vector>& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadStreamOfAliasedGenericUnion2Impl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t AliasesIndexedReaderBase::CountStreamOfAliasedGenericUnion2() { + return CountStreamOfAliasedGenericUnion2Impl(); +} + +void AliasesIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string StreamsOfAliasedUnionsWriterBase::schema_ = R"({"protocol":{"name":"StreamsOfAliasedUnions","sequence":[{"name":"intOrSimpleRecord","type":{"stream":{"items":"TestModel.AliasedIntOrSimpleRecord"}}},{"name":"nullableIntOrSimpleRecord","type":{"stream":{"items":"TestModel.AliasedNullableIntSimpleRecord"}}}]},"types":[{"name":"AliasedIntOrSimpleRecord","type":[{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]},{"name":"AliasedNullableIntSimpleRecord","type":[null,{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]})"; @@ -6439,9 +6955,10 @@ std::string StreamsOfAliasedUnionsWriterBase::SchemaFromVersion(Version version) } } + void StreamsOfAliasedUnionsWriterBase::WriteIntOrSimpleRecord(test_model::AliasedIntOrSimpleRecord const& value) { if (unlikely(state_ != 0)) { - StreamsOfAliasedUnionsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntOrSimpleRecordImpl(value); @@ -6449,7 +6966,7 @@ void StreamsOfAliasedUnionsWriterBase::WriteIntOrSimpleRecord(test_model::Aliase void StreamsOfAliasedUnionsWriterBase::WriteIntOrSimpleRecord(std::vector const& values) { if (unlikely(state_ != 0)) { - StreamsOfAliasedUnionsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntOrSimpleRecordImpl(values); @@ -6457,7 +6974,7 @@ void StreamsOfAliasedUnionsWriterBase::WriteIntOrSimpleRecord(std::vector const& values) { if (unlikely(state_ != 1)) { - StreamsOfAliasedUnionsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } WriteNullableIntOrSimpleRecordImpl(values); @@ -6489,7 +7006,7 @@ void StreamsOfAliasedUnionsWriterBase::WriteNullableIntOrSimpleRecord(std::vecto void StreamsOfAliasedUnionsWriterBase::EndNullableIntOrSimpleRecord() { if (unlikely(state_ != 1)) { - StreamsOfAliasedUnionsWriterBaseInvalidState(1, true, state_); + InvalidState(1, true); } EndNullableIntOrSimpleRecordImpl(); @@ -6505,12 +7022,27 @@ void StreamsOfAliasedUnionsWriterBase::WriteNullableIntOrSimpleRecordImpl(std::v void StreamsOfAliasedUnionsWriterBase::Close() { if (unlikely(state_ != 2)) { - StreamsOfAliasedUnionsWriterBaseInvalidState(2, false, state_); + InvalidState(2, false); } CloseImpl(); } +void StreamsOfAliasedUnionsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteIntOrSimpleRecord() or EndIntOrSimpleRecord()"; break; + case 1: expected_method = "WriteNullableIntOrSimpleRecord() or EndNullableIntOrSimpleRecord()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = end ? "EndIntOrSimpleRecord()" : "WriteIntOrSimpleRecord()"; break; + case 1: attempted_method = end ? "EndNullableIntOrSimpleRecord()" : "WriteNullableIntOrSimpleRecord()"; break; + case 2: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string StreamsOfAliasedUnionsReaderBase::schema_ = StreamsOfAliasedUnionsWriterBase::schema_; std::vector StreamsOfAliasedUnionsReaderBase::previous_schemas_ = StreamsOfAliasedUnionsWriterBase::previous_schemas_; @@ -6521,13 +7053,14 @@ Version StreamsOfAliasedUnionsReaderBase::VersionFromSchema(std::string const& s } throw std::runtime_error("The schema does not match any version supported by protocol StreamsOfAliasedUnions."); } + bool StreamsOfAliasedUnionsReaderBase::ReadIntOrSimpleRecord(test_model::AliasedIntOrSimpleRecord& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - StreamsOfAliasedUnionsReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadIntOrSimpleRecordImpl(value); @@ -6547,7 +7080,7 @@ bool StreamsOfAliasedUnionsReaderBase::ReadIntOrSimpleRecord(std::vector 1) { std::vector values; @@ -6679,32 +7213,59 @@ void StreamsOfAliasedUnionsReaderBase::CopyTo(StreamsOfAliasedUnionsWriterBase& } } -namespace { -void ProtocolWithComputedFieldsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteRecordWithComputedFields()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteRecordWithComputedFields()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ProtocolWithComputedFieldsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void StreamsOfAliasedUnionsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadRecordWithComputedFields()"; - case 1: return "Close()"; + case 0: return "ReadIntOrSimpleRecord()"; + case 1: return "ReadNullableIntOrSimpleRecord()"; + case 2: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool StreamsOfAliasedUnionsIndexedReaderBase::ReadIntOrSimpleRecord(test_model::AliasedIntOrSimpleRecord& value, size_t idx) { + return ReadIntOrSimpleRecordImpl(value, idx); +} + +bool StreamsOfAliasedUnionsIndexedReaderBase::ReadIntOrSimpleRecord(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadIntOrSimpleRecordImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsOfAliasedUnionsIndexedReaderBase::CountIntOrSimpleRecord() { + return CountIntOrSimpleRecordImpl(); +} + +bool StreamsOfAliasedUnionsIndexedReaderBase::ReadNullableIntOrSimpleRecord(test_model::AliasedNullableIntSimpleRecord& value, size_t idx) { + return ReadNullableIntOrSimpleRecordImpl(value, idx); +} + +bool StreamsOfAliasedUnionsIndexedReaderBase::ReadNullableIntOrSimpleRecord(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadNullableIntOrSimpleRecordImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t StreamsOfAliasedUnionsIndexedReaderBase::CountNullableIntOrSimpleRecord() { + return CountNullableIntOrSimpleRecordImpl(); +} + +void StreamsOfAliasedUnionsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string ProtocolWithComputedFieldsWriterBase::schema_ = R"({"protocol":{"name":"ProtocolWithComputedFields","sequence":[{"name":"recordWithComputedFields","type":"TestModel.RecordWithComputedFields"}]},"types":[{"name":"GenericRecordWithComputedFields","typeParameters":["T0","T1"],"fields":[{"name":"f1","type":[{"tag":"T0","type":"T0"},{"tag":"T1","type":"T1"}]}]},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithComputedFields","fields":[{"name":"arrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"arrayFieldMapDimensions","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"dynamicArrayField","type":{"array":{"items":"int32"}}},{"name":"fixedArrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x","length":3},{"name":"y","length":4}]}}},{"name":"intField","type":"int32"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"stringField","type":"string"},{"name":"tupleField","type":{"name":"TestModel.MyTuple","typeArguments":["int32","int32"]}},{"name":"vectorField","type":{"vector":{"items":"int32"}}},{"name":"vectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32"}}}}},{"name":"fixedVectorField","type":{"vector":{"items":"int32","length":3}}},{"name":"fixedVectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32","length":3}},"length":2}}},{"name":"optionalNamedArray","type":[null,"TestModel.NamedNDArray"]},{"name":"intFloatUnion","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"nullableIntFloatUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"unionWithNestedGenericUnion","type":[{"tag":"int","explicitTag":true,"type":"int32"},{"tag":"genericRecordWithComputedFields","explicitTag":true,"type":{"name":"BasicTypes.GenericRecordWithComputedFields","typeArguments":["string","float32"]}}]},{"name":"mapField","type":{"map":{"keys":"string","values":"string"}}}]},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]})"; @@ -6718,9 +7279,10 @@ std::string ProtocolWithComputedFieldsWriterBase::SchemaFromVersion(Version vers } } + void ProtocolWithComputedFieldsWriterBase::WriteRecordWithComputedFields(test_model::RecordWithComputedFields const& value) { if (unlikely(state_ != 0)) { - ProtocolWithComputedFieldsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteRecordWithComputedFieldsImpl(value); @@ -6729,12 +7291,25 @@ void ProtocolWithComputedFieldsWriterBase::WriteRecordWithComputedFields(test_mo void ProtocolWithComputedFieldsWriterBase::Close() { if (unlikely(state_ != 1)) { - ProtocolWithComputedFieldsWriterBaseInvalidState(1, false, state_); + InvalidState(1, false); } CloseImpl(); } +void ProtocolWithComputedFieldsWriterBase::InvalidState(uint8_t attempted, [[maybe_unused]] bool end) { + std::string expected_method; + switch (state_) { + case 0: expected_method = "WriteRecordWithComputedFields()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = "WriteRecordWithComputedFields()"; break; + case 1: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + std::string ProtocolWithComputedFieldsReaderBase::schema_ = ProtocolWithComputedFieldsWriterBase::schema_; std::vector ProtocolWithComputedFieldsReaderBase::previous_schemas_ = ProtocolWithComputedFieldsWriterBase::previous_schemas_; @@ -6745,9 +7320,10 @@ Version ProtocolWithComputedFieldsReaderBase::VersionFromSchema(std::string cons } throw std::runtime_error("The schema does not match any version supported by protocol ProtocolWithComputedFields."); } + void ProtocolWithComputedFieldsReaderBase::ReadRecordWithComputedFields(test_model::RecordWithComputedFields& value) { if (unlikely(state_ != 0)) { - ProtocolWithComputedFieldsReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadRecordWithComputedFieldsImpl(value); @@ -6756,11 +7332,12 @@ void ProtocolWithComputedFieldsReaderBase::ReadRecordWithComputedFields(test_mod void ProtocolWithComputedFieldsReaderBase::Close() { if (unlikely(state_ != 2)) { - ProtocolWithComputedFieldsReaderBaseInvalidState(2, state_); + InvalidState(2); } CloseImpl(); } + void ProtocolWithComputedFieldsReaderBase::CopyTo(ProtocolWithComputedFieldsWriterBase& writer) { { test_model::RecordWithComputedFields value; @@ -6769,35 +7346,22 @@ void ProtocolWithComputedFieldsReaderBase::CopyTo(ProtocolWithComputedFieldsWrit } } -namespace { -void ProtocolWithKeywordStepsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteInt() or EndInt()"; break; - case 1: expected_method = "WriteFloat()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = end ? "EndInt()" : "WriteInt()"; break; - case 1: attempted_method = "WriteFloat()"; break; - case 2: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ProtocolWithKeywordStepsReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void ProtocolWithComputedFieldsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadInt()"; - case 1: return "ReadFloat()"; - case 2: return "Close()"; + case 0: return "ReadRecordWithComputedFields()"; + case 1: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void ProtocolWithComputedFieldsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string ProtocolWithKeywordStepsWriterBase::schema_ = R"({"protocol":{"name":"ProtocolWithKeywordSteps","sequence":[{"name":"int","type":{"stream":{"items":"TestModel.RecordWithKeywordFields"}}},{"name":"float","type":"TestModel.EnumWithKeywordSymbols"}]},"types":[{"name":"ArrayWithKeywordDimensionNames","type":{"array":{"items":"int32","dimensions":[{"name":"while"},{"name":"do"}]}}},{"name":"EnumWithKeywordSymbols","values":[{"symbol":"try","value":2},{"symbol":"catch","value":1}]},{"name":"RecordWithKeywordFields","fields":[{"name":"int","type":"string"},{"name":"sizeof","type":"TestModel.ArrayWithKeywordDimensionNames"},{"name":"if","type":"TestModel.EnumWithKeywordSymbols"}]}]})"; @@ -6811,9 +7375,10 @@ std::string ProtocolWithKeywordStepsWriterBase::SchemaFromVersion(Version versio } } + void ProtocolWithKeywordStepsWriterBase::WriteInt(test_model::RecordWithKeywordFields const& value) { if (unlikely(state_ != 0)) { - ProtocolWithKeywordStepsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntImpl(value); @@ -6821,7 +7386,7 @@ void ProtocolWithKeywordStepsWriterBase::WriteInt(test_model::RecordWithKeywordF void ProtocolWithKeywordStepsWriterBase::WriteInt(std::vector const& values) { if (unlikely(state_ != 0)) { - ProtocolWithKeywordStepsWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteIntImpl(values); @@ -6829,7 +7394,7 @@ void ProtocolWithKeywordStepsWriterBase::WriteInt(std::vector ProtocolWithKeywordStepsReaderBase::previous_schemas_ = ProtocolWithKeywordStepsWriterBase::previous_schemas_; @@ -6870,13 +7450,14 @@ Version ProtocolWithKeywordStepsReaderBase::VersionFromSchema(std::string const& } throw std::runtime_error("The schema does not match any version supported by protocol ProtocolWithKeywordSteps."); } + bool ProtocolWithKeywordStepsReaderBase::ReadInt(test_model::RecordWithKeywordFields& value) { if (unlikely(state_ != 0)) { if (state_ == 1) { state_ = 2; return false; } - ProtocolWithKeywordStepsReaderBaseInvalidState(0, state_); + InvalidState(0); } bool result = ReadIntImpl(value); @@ -6896,7 +7477,7 @@ bool ProtocolWithKeywordStepsReaderBase::ReadInt(std::vector 1) { std::vector values; @@ -6966,32 +7548,41 @@ void ProtocolWithKeywordStepsReaderBase::CopyTo(ProtocolWithKeywordStepsWriterBa } } -namespace { -void ProtocolWithOptionalDateWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { - std::string expected_method; - switch (current) { - case 0: expected_method = "WriteRecord()"; break; - } - std::string attempted_method; - switch (attempted) { - case 0: attempted_method = "WriteRecord()"; break; - case 1: attempted_method = "Close()"; break; - } - throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); -} - -void ProtocolWithOptionalDateReaderBaseInvalidState(uint8_t attempted, uint8_t current) { +void ProtocolWithKeywordStepsReaderBase::InvalidState(uint8_t attempted) { auto f = [](uint8_t i) -> std::string { switch (i/2) { - case 0: return "ReadRecord()"; - case 1: return "Close()"; + case 0: return "ReadInt()"; + case 1: return "ReadFloat()"; + case 2: return "Close()"; default: return ""; } }; - throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +bool ProtocolWithKeywordStepsIndexedReaderBase::ReadInt(test_model::RecordWithKeywordFields& value, size_t idx) { + return ReadIntImpl(value, idx); +} + +bool ProtocolWithKeywordStepsIndexedReaderBase::ReadInt(std::vector& values, size_t idx) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (!ReadIntImpl(values, idx)) { + return values.size() > 0; + } + return true; +} + +size_t ProtocolWithKeywordStepsIndexedReaderBase::CountInt() { + return CountIntImpl(); +} + +void ProtocolWithKeywordStepsIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; } -} // namespace std::string ProtocolWithOptionalDateWriterBase::schema_ = R"({"protocol":{"name":"ProtocolWithOptionalDate","sequence":[{"name":"record","type":[null,"TestModel.RecordWithOptionalDate"]}]},"types":[{"name":"RecordWithOptionalDate","fields":[{"name":"dateField","type":[null,"date"]}]}]})"; @@ -7005,9 +7596,10 @@ std::string ProtocolWithOptionalDateWriterBase::SchemaFromVersion(Version versio } } + void ProtocolWithOptionalDateWriterBase::WriteRecord(std::optional const& value) { if (unlikely(state_ != 0)) { - ProtocolWithOptionalDateWriterBaseInvalidState(0, false, state_); + InvalidState(0, false); } WriteRecordImpl(value); @@ -7016,12 +7608,25 @@ void ProtocolWithOptionalDateWriterBase::WriteRecord(std::optional ProtocolWithOptionalDateReaderBase::previous_schemas_ = ProtocolWithOptionalDateWriterBase::previous_schemas_; @@ -7032,9 +7637,10 @@ Version ProtocolWithOptionalDateReaderBase::VersionFromSchema(std::string const& } throw std::runtime_error("The schema does not match any version supported by protocol ProtocolWithOptionalDate."); } + void ProtocolWithOptionalDateReaderBase::ReadRecord(std::optional& value) { if (unlikely(state_ != 0)) { - ProtocolWithOptionalDateReaderBaseInvalidState(0, state_); + InvalidState(0); } ReadRecordImpl(value); @@ -7043,11 +7649,12 @@ void ProtocolWithOptionalDateReaderBase::ReadRecord(std::optional value; @@ -7055,4 +7662,21 @@ void ProtocolWithOptionalDateReaderBase::CopyTo(ProtocolWithOptionalDateWriterBa writer.WriteRecord(value); } } + +void ProtocolWithOptionalDateReaderBase::InvalidState(uint8_t attempted) { + auto f = [](uint8_t i) -> std::string { + switch (i/2) { + case 0: return "ReadRecord()"; + case 1: return "Close()"; + default: return ""; + } + }; + throw std::runtime_error("Expected call to " + f(state_) + " but received call to " + f(attempted) + " instead."); +} + +void ProtocolWithOptionalDateIndexedReaderBase::InvalidState(uint8_t attempted) { + (void)(attempted); + return; +} + } // namespace test_model diff --git a/cpp/test/generated/protocols.h b/cpp/test/generated/protocols.h index 5d92ff7..44c100a 100644 --- a/cpp/test/generated/protocols.h +++ b/cpp/test/generated/protocols.h @@ -42,9 +42,11 @@ class BenchmarkFloat256x256WriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class BenchmarkFloat256x256ReaderBase; + friend class BenchmarkFloat256x256IndexedReaderBase; }; // Abstract reader for the BenchmarkFloat256x256 protocol. @@ -74,9 +76,29 @@ class BenchmarkFloat256x256ReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the BenchmarkFloat256x256 protocol. +class BenchmarkFloat256x256IndexedReaderBase : public BenchmarkFloat256x256ReaderBase { + public: + using BenchmarkFloat256x256ReaderBase::ReadFloat256x256; + [[nodiscard]] bool ReadFloat256x256(yardl::FixedNDArray& value, size_t idx); + [[nodiscard]] bool ReadFloat256x256(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountFloat256x256(); + + virtual ~BenchmarkFloat256x256IndexedReaderBase() = default; + + protected: + virtual bool ReadFloat256x256Impl(yardl::FixedNDArray& value, size_t idx) = 0; + virtual bool ReadFloat256x256Impl(std::vector>& values, size_t idx) = 0; + virtual size_t CountFloat256x256Impl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the BenchmarkInt256x256 protocol. class BenchmarkInt256x256WriterBase { public: @@ -112,9 +134,11 @@ class BenchmarkInt256x256WriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class BenchmarkInt256x256ReaderBase; + friend class BenchmarkInt256x256IndexedReaderBase; }; // Abstract reader for the BenchmarkInt256x256 protocol. @@ -144,9 +168,29 @@ class BenchmarkInt256x256ReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the BenchmarkInt256x256 protocol. +class BenchmarkInt256x256IndexedReaderBase : public BenchmarkInt256x256ReaderBase { + public: + using BenchmarkInt256x256ReaderBase::ReadInt256x256; + [[nodiscard]] bool ReadInt256x256(yardl::FixedNDArray& value, size_t idx); + [[nodiscard]] bool ReadInt256x256(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountInt256x256(); + + virtual ~BenchmarkInt256x256IndexedReaderBase() = default; + + protected: + virtual bool ReadInt256x256Impl(yardl::FixedNDArray& value, size_t idx) = 0; + virtual bool ReadInt256x256Impl(std::vector>& values, size_t idx) = 0; + virtual size_t CountInt256x256Impl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the BenchmarkFloatVlen protocol. class BenchmarkFloatVlenWriterBase { public: @@ -182,9 +226,11 @@ class BenchmarkFloatVlenWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class BenchmarkFloatVlenReaderBase; + friend class BenchmarkFloatVlenIndexedReaderBase; }; // Abstract reader for the BenchmarkFloatVlen protocol. @@ -214,9 +260,29 @@ class BenchmarkFloatVlenReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the BenchmarkFloatVlen protocol. +class BenchmarkFloatVlenIndexedReaderBase : public BenchmarkFloatVlenReaderBase { + public: + using BenchmarkFloatVlenReaderBase::ReadFloatArray; + [[nodiscard]] bool ReadFloatArray(yardl::NDArray& value, size_t idx); + [[nodiscard]] bool ReadFloatArray(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountFloatArray(); + + virtual ~BenchmarkFloatVlenIndexedReaderBase() = default; + + protected: + virtual bool ReadFloatArrayImpl(yardl::NDArray& value, size_t idx) = 0; + virtual bool ReadFloatArrayImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountFloatArrayImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the BenchmarkSmallRecord protocol. class BenchmarkSmallRecordWriterBase { public: @@ -252,9 +318,11 @@ class BenchmarkSmallRecordWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class BenchmarkSmallRecordReaderBase; + friend class BenchmarkSmallRecordIndexedReaderBase; }; // Abstract reader for the BenchmarkSmallRecord protocol. @@ -284,9 +352,29 @@ class BenchmarkSmallRecordReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the BenchmarkSmallRecord protocol. +class BenchmarkSmallRecordIndexedReaderBase : public BenchmarkSmallRecordReaderBase { + public: + using BenchmarkSmallRecordReaderBase::ReadSmallRecord; + [[nodiscard]] bool ReadSmallRecord(test_model::SmallBenchmarkRecord& value, size_t idx); + [[nodiscard]] bool ReadSmallRecord(std::vector& values, size_t idx); + [[nodiscard]] size_t CountSmallRecord(); + + virtual ~BenchmarkSmallRecordIndexedReaderBase() = default; + + protected: + virtual bool ReadSmallRecordImpl(test_model::SmallBenchmarkRecord& value, size_t idx) = 0; + virtual bool ReadSmallRecordImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountSmallRecordImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the BenchmarkSmallRecordWithOptionals protocol. class BenchmarkSmallRecordWithOptionalsWriterBase { public: @@ -322,9 +410,11 @@ class BenchmarkSmallRecordWithOptionalsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class BenchmarkSmallRecordWithOptionalsReaderBase; + friend class BenchmarkSmallRecordWithOptionalsIndexedReaderBase; }; // Abstract reader for the BenchmarkSmallRecordWithOptionals protocol. @@ -354,9 +444,29 @@ class BenchmarkSmallRecordWithOptionalsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the BenchmarkSmallRecordWithOptionals protocol. +class BenchmarkSmallRecordWithOptionalsIndexedReaderBase : public BenchmarkSmallRecordWithOptionalsReaderBase { + public: + using BenchmarkSmallRecordWithOptionalsReaderBase::ReadSmallRecord; + [[nodiscard]] bool ReadSmallRecord(test_model::SimpleEncodingCounters& value, size_t idx); + [[nodiscard]] bool ReadSmallRecord(std::vector& values, size_t idx); + [[nodiscard]] size_t CountSmallRecord(); + + virtual ~BenchmarkSmallRecordWithOptionalsIndexedReaderBase() = default; + + protected: + virtual bool ReadSmallRecordImpl(test_model::SimpleEncodingCounters& value, size_t idx) = 0; + virtual bool ReadSmallRecordImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountSmallRecordImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the BenchmarkSimpleMrd protocol. class BenchmarkSimpleMrdWriterBase { public: @@ -392,9 +502,11 @@ class BenchmarkSimpleMrdWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class BenchmarkSimpleMrdReaderBase; + friend class BenchmarkSimpleMrdIndexedReaderBase; }; // Abstract reader for the BenchmarkSimpleMrd protocol. @@ -424,9 +536,29 @@ class BenchmarkSimpleMrdReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the BenchmarkSimpleMrd protocol. +class BenchmarkSimpleMrdIndexedReaderBase : public BenchmarkSimpleMrdReaderBase { + public: + using BenchmarkSimpleMrdReaderBase::ReadData; + [[nodiscard]] bool ReadData(std::variant>& value, size_t idx); + [[nodiscard]] bool ReadData(std::vector>>& values, size_t idx); + [[nodiscard]] size_t CountData(); + + virtual ~BenchmarkSimpleMrdIndexedReaderBase() = default; + + protected: + virtual bool ReadDataImpl(std::variant>& value, size_t idx) = 0; + virtual bool ReadDataImpl(std::vector>>& values, size_t idx) = 0; + virtual size_t CountDataImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Scalars protocol. class ScalarsWriterBase { public: @@ -456,9 +588,11 @@ class ScalarsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ScalarsReaderBase; + friend class ScalarsIndexedReaderBase; }; // Abstract reader for the Scalars protocol. @@ -488,9 +622,21 @@ class ScalarsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Scalars protocol. +class ScalarsIndexedReaderBase : public ScalarsReaderBase { + public: + virtual ~ScalarsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the ScalarOptionals protocol. class ScalarOptionalsWriterBase { public: @@ -528,9 +674,11 @@ class ScalarOptionalsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ScalarOptionalsReaderBase; + friend class ScalarOptionalsIndexedReaderBase; }; // Abstract reader for the ScalarOptionals protocol. @@ -568,9 +716,21 @@ class ScalarOptionalsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the ScalarOptionals protocol. +class ScalarOptionalsIndexedReaderBase : public ScalarOptionalsReaderBase { + public: + virtual ~ScalarOptionalsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the NestedRecords protocol. class NestedRecordsWriterBase { public: @@ -596,9 +756,11 @@ class NestedRecordsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class NestedRecordsReaderBase; + friend class NestedRecordsIndexedReaderBase; }; // Abstract reader for the NestedRecords protocol. @@ -624,9 +786,21 @@ class NestedRecordsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the NestedRecords protocol. +class NestedRecordsIndexedReaderBase : public NestedRecordsReaderBase { + public: + virtual ~NestedRecordsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Vlens protocol. class VlensWriterBase { public: @@ -664,9 +838,11 @@ class VlensWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class VlensReaderBase; + friend class VlensIndexedReaderBase; }; // Abstract reader for the Vlens protocol. @@ -704,9 +880,21 @@ class VlensReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Vlens protocol. +class VlensIndexedReaderBase : public VlensReaderBase { + public: + virtual ~VlensIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Strings protocol. class StringsWriterBase { public: @@ -736,9 +924,11 @@ class StringsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class StringsReaderBase; + friend class StringsIndexedReaderBase; }; // Abstract reader for the Strings protocol. @@ -768,9 +958,21 @@ class StringsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Strings protocol. +class StringsIndexedReaderBase : public StringsReaderBase { + public: + virtual ~StringsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the OptionalVectors protocol. class OptionalVectorsWriterBase { public: @@ -796,9 +998,11 @@ class OptionalVectorsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class OptionalVectorsReaderBase; + friend class OptionalVectorsIndexedReaderBase; }; // Abstract reader for the OptionalVectors protocol. @@ -824,9 +1028,21 @@ class OptionalVectorsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the OptionalVectors protocol. +class OptionalVectorsIndexedReaderBase : public OptionalVectorsReaderBase { + public: + virtual ~OptionalVectorsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the FixedVectors protocol. class FixedVectorsWriterBase { public: @@ -864,9 +1080,11 @@ class FixedVectorsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class FixedVectorsReaderBase; + friend class FixedVectorsIndexedReaderBase; }; // Abstract reader for the FixedVectors protocol. @@ -904,9 +1122,21 @@ class FixedVectorsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the FixedVectors protocol. +class FixedVectorsIndexedReaderBase : public FixedVectorsReaderBase { + public: + virtual ~FixedVectorsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Streams protocol. class StreamsWriterBase { public: @@ -984,9 +1214,11 @@ class StreamsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class StreamsReaderBase; + friend class StreamsIndexedReaderBase; }; // Abstract reader for the Streams protocol. @@ -1040,9 +1272,53 @@ class StreamsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Streams protocol. +class StreamsIndexedReaderBase : public StreamsReaderBase { + public: + using StreamsReaderBase::ReadIntData; + [[nodiscard]] bool ReadIntData(int32_t& value, size_t idx); + [[nodiscard]] bool ReadIntData(std::vector& values, size_t idx); + [[nodiscard]] size_t CountIntData(); + + using StreamsReaderBase::ReadOptionalIntData; + [[nodiscard]] bool ReadOptionalIntData(std::optional& value, size_t idx); + [[nodiscard]] bool ReadOptionalIntData(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountOptionalIntData(); + + using StreamsReaderBase::ReadRecordWithOptionalVectorData; + [[nodiscard]] bool ReadRecordWithOptionalVectorData(test_model::RecordWithOptionalVector& value, size_t idx); + [[nodiscard]] bool ReadRecordWithOptionalVectorData(std::vector& values, size_t idx); + [[nodiscard]] size_t CountRecordWithOptionalVectorData(); + + using StreamsReaderBase::ReadFixedVector; + [[nodiscard]] bool ReadFixedVector(std::array& value, size_t idx); + [[nodiscard]] bool ReadFixedVector(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountFixedVector(); + + virtual ~StreamsIndexedReaderBase() = default; + + protected: + virtual bool ReadIntDataImpl(int32_t& value, size_t idx) = 0; + virtual bool ReadIntDataImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountIntDataImpl() = 0; + virtual bool ReadOptionalIntDataImpl(std::optional& value, size_t idx) = 0; + virtual bool ReadOptionalIntDataImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountOptionalIntDataImpl() = 0; + virtual bool ReadRecordWithOptionalVectorDataImpl(test_model::RecordWithOptionalVector& value, size_t idx) = 0; + virtual bool ReadRecordWithOptionalVectorDataImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountRecordWithOptionalVectorDataImpl() = 0; + virtual bool ReadFixedVectorImpl(std::array& value, size_t idx) = 0; + virtual bool ReadFixedVectorImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountFixedVectorImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the FixedArrays protocol. class FixedArraysWriterBase { public: @@ -1084,9 +1360,11 @@ class FixedArraysWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class FixedArraysReaderBase; + friend class FixedArraysIndexedReaderBase; }; // Abstract reader for the FixedArrays protocol. @@ -1128,9 +1406,21 @@ class FixedArraysReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the FixedArrays protocol. +class FixedArraysIndexedReaderBase : public FixedArraysReaderBase { + public: + virtual ~FixedArraysIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Subarrays protocol. class SubarraysWriterBase { public: @@ -1188,9 +1478,11 @@ class SubarraysWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class SubarraysReaderBase; + friend class SubarraysIndexedReaderBase; }; // Abstract reader for the Subarrays protocol. @@ -1248,9 +1540,21 @@ class SubarraysReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Subarrays protocol. +class SubarraysIndexedReaderBase : public SubarraysReaderBase { + public: + virtual ~SubarraysIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the SubarraysInRecords protocol. class SubarraysInRecordsWriterBase { public: @@ -1280,9 +1584,11 @@ class SubarraysInRecordsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class SubarraysInRecordsReaderBase; + friend class SubarraysInRecordsIndexedReaderBase; }; // Abstract reader for the SubarraysInRecords protocol. @@ -1312,9 +1618,21 @@ class SubarraysInRecordsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the SubarraysInRecords protocol. +class SubarraysInRecordsIndexedReaderBase : public SubarraysInRecordsReaderBase { + public: + virtual ~SubarraysInRecordsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the NDArrays protocol. class NDArraysWriterBase { public: @@ -1356,9 +1674,11 @@ class NDArraysWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class NDArraysReaderBase; + friend class NDArraysIndexedReaderBase; }; // Abstract reader for the NDArrays protocol. @@ -1400,9 +1720,21 @@ class NDArraysReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the NDArrays protocol. +class NDArraysIndexedReaderBase : public NDArraysReaderBase { + public: + virtual ~NDArraysIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the NDArraysSingleDimension protocol. class NDArraysSingleDimensionWriterBase { public: @@ -1440,9 +1772,11 @@ class NDArraysSingleDimensionWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class NDArraysSingleDimensionReaderBase; + friend class NDArraysSingleDimensionIndexedReaderBase; }; // Abstract reader for the NDArraysSingleDimension protocol. @@ -1480,9 +1814,21 @@ class NDArraysSingleDimensionReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the NDArraysSingleDimension protocol. +class NDArraysSingleDimensionIndexedReaderBase : public NDArraysSingleDimensionReaderBase { + public: + virtual ~NDArraysSingleDimensionIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the DynamicNDArrays protocol. class DynamicNDArraysWriterBase { public: @@ -1520,9 +1866,11 @@ class DynamicNDArraysWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class DynamicNDArraysReaderBase; + friend class DynamicNDArraysIndexedReaderBase; }; // Abstract reader for the DynamicNDArrays protocol. @@ -1560,9 +1908,21 @@ class DynamicNDArraysReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the DynamicNDArrays protocol. +class DynamicNDArraysIndexedReaderBase : public DynamicNDArraysReaderBase { + public: + virtual ~DynamicNDArraysIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the MultiDArrays protocol. class MultiDArraysWriterBase { public: @@ -1612,9 +1972,11 @@ class MultiDArraysWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class MultiDArraysReaderBase; + friend class MultiDArraysIndexedReaderBase; }; // Abstract reader for the MultiDArrays protocol. @@ -1652,9 +2014,37 @@ class MultiDArraysReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the MultiDArrays protocol. +class MultiDArraysIndexedReaderBase : public MultiDArraysReaderBase { + public: + using MultiDArraysReaderBase::ReadImages; + [[nodiscard]] bool ReadImages(yardl::NDArray& value, size_t idx); + [[nodiscard]] bool ReadImages(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountImages(); + + using MultiDArraysReaderBase::ReadFrames; + [[nodiscard]] bool ReadFrames(yardl::FixedNDArray& value, size_t idx); + [[nodiscard]] bool ReadFrames(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountFrames(); + + virtual ~MultiDArraysIndexedReaderBase() = default; + + protected: + virtual bool ReadImagesImpl(yardl::NDArray& value, size_t idx) = 0; + virtual bool ReadImagesImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountImagesImpl() = 0; + virtual bool ReadFramesImpl(yardl::FixedNDArray& value, size_t idx) = 0; + virtual bool ReadFramesImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountFramesImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the ComplexArrays protocol. class ComplexArraysWriterBase { public: @@ -1684,9 +2074,11 @@ class ComplexArraysWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ComplexArraysReaderBase; + friend class ComplexArraysIndexedReaderBase; }; // Abstract reader for the ComplexArrays protocol. @@ -1716,9 +2108,21 @@ class ComplexArraysReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the ComplexArrays protocol. +class ComplexArraysIndexedReaderBase : public ComplexArraysReaderBase { + public: + virtual ~ComplexArraysIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Maps protocol. class MapsWriterBase { public: @@ -1760,9 +2164,11 @@ class MapsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class MapsReaderBase; + friend class MapsIndexedReaderBase; }; // Abstract reader for the Maps protocol. @@ -1804,9 +2210,21 @@ class MapsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Maps protocol. +class MapsIndexedReaderBase : public MapsReaderBase { + public: + virtual ~MapsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Unions protocol. class UnionsWriterBase { public: @@ -1844,9 +2262,11 @@ class UnionsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class UnionsReaderBase; + friend class UnionsIndexedReaderBase; }; // Abstract reader for the Unions protocol. @@ -1884,9 +2304,21 @@ class UnionsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Unions protocol. +class UnionsIndexedReaderBase : public UnionsReaderBase { + public: + virtual ~UnionsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the StreamsOfUnions protocol. class StreamsOfUnionsWriterBase { public: @@ -1950,9 +2382,11 @@ class StreamsOfUnionsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class StreamsOfUnionsReaderBase; + friend class StreamsOfUnionsIndexedReaderBase; }; // Abstract reader for the StreamsOfUnions protocol. @@ -1998,9 +2432,45 @@ class StreamsOfUnionsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the StreamsOfUnions protocol. +class StreamsOfUnionsIndexedReaderBase : public StreamsOfUnionsReaderBase { + public: + using StreamsOfUnionsReaderBase::ReadIntOrSimpleRecord; + [[nodiscard]] bool ReadIntOrSimpleRecord(std::variant& value, size_t idx); + [[nodiscard]] bool ReadIntOrSimpleRecord(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountIntOrSimpleRecord(); + + using StreamsOfUnionsReaderBase::ReadNullableIntOrSimpleRecord; + [[nodiscard]] bool ReadNullableIntOrSimpleRecord(std::variant& value, size_t idx); + [[nodiscard]] bool ReadNullableIntOrSimpleRecord(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountNullableIntOrSimpleRecord(); + + using StreamsOfUnionsReaderBase::ReadManyCases; + [[nodiscard]] bool ReadManyCases(std::variant& value, size_t idx); + [[nodiscard]] bool ReadManyCases(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountManyCases(); + + virtual ~StreamsOfUnionsIndexedReaderBase() = default; + + protected: + virtual bool ReadIntOrSimpleRecordImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadIntOrSimpleRecordImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountIntOrSimpleRecordImpl() = 0; + virtual bool ReadNullableIntOrSimpleRecordImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadNullableIntOrSimpleRecordImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountNullableIntOrSimpleRecordImpl() = 0; + virtual bool ReadManyCasesImpl(std::variant& value, size_t idx) = 0; + virtual bool ReadManyCasesImpl(std::vector>& values, size_t idx) = 0; + virtual size_t CountManyCasesImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Enums protocol. class EnumsWriterBase { public: @@ -2038,9 +2508,11 @@ class EnumsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class EnumsReaderBase; + friend class EnumsIndexedReaderBase; }; // Abstract reader for the Enums protocol. @@ -2078,9 +2550,21 @@ class EnumsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Enums protocol. +class EnumsIndexedReaderBase : public EnumsReaderBase { + public: + virtual ~EnumsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Flags protocol. class FlagsWriterBase { public: @@ -2130,9 +2614,11 @@ class FlagsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class FlagsReaderBase; + friend class FlagsIndexedReaderBase; }; // Abstract reader for the Flags protocol. @@ -2170,9 +2656,37 @@ class FlagsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Flags protocol. +class FlagsIndexedReaderBase : public FlagsReaderBase { + public: + using FlagsReaderBase::ReadDays; + [[nodiscard]] bool ReadDays(test_model::DaysOfWeek& value, size_t idx); + [[nodiscard]] bool ReadDays(std::vector& values, size_t idx); + [[nodiscard]] size_t CountDays(); + + using FlagsReaderBase::ReadFormats; + [[nodiscard]] bool ReadFormats(test_model::TextFormat& value, size_t idx); + [[nodiscard]] bool ReadFormats(std::vector& values, size_t idx); + [[nodiscard]] size_t CountFormats(); + + virtual ~FlagsIndexedReaderBase() = default; + + protected: + virtual bool ReadDaysImpl(test_model::DaysOfWeek& value, size_t idx) = 0; + virtual bool ReadDaysImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountDaysImpl() = 0; + virtual bool ReadFormatsImpl(test_model::TextFormat& value, size_t idx) = 0; + virtual bool ReadFormatsImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountFormatsImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the StateTest protocol. class StateTestWriterBase { public: @@ -2216,9 +2730,11 @@ class StateTestWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class StateTestReaderBase; + friend class StateTestIndexedReaderBase; }; // Abstract reader for the StateTest protocol. @@ -2256,9 +2772,29 @@ class StateTestReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the StateTest protocol. +class StateTestIndexedReaderBase : public StateTestReaderBase { + public: + using StateTestReaderBase::ReadAStream; + [[nodiscard]] bool ReadAStream(int32_t& value, size_t idx); + [[nodiscard]] bool ReadAStream(std::vector& values, size_t idx); + [[nodiscard]] size_t CountAStream(); + + virtual ~StateTestIndexedReaderBase() = default; + + protected: + virtual bool ReadAStreamImpl(int32_t& value, size_t idx) = 0; + virtual bool ReadAStreamImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountAStreamImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the SimpleGenerics protocol. class SimpleGenericsWriterBase { public: @@ -2326,9 +2862,11 @@ class SimpleGenericsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class SimpleGenericsReaderBase; + friend class SimpleGenericsIndexedReaderBase; }; // Abstract reader for the SimpleGenerics protocol. @@ -2390,9 +2928,29 @@ class SimpleGenericsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the SimpleGenerics protocol. +class SimpleGenericsIndexedReaderBase : public SimpleGenericsReaderBase { + public: + using SimpleGenericsReaderBase::ReadStreamOfTypeVariants; + [[nodiscard]] bool ReadStreamOfTypeVariants(std::variant>& value, size_t idx); + [[nodiscard]] bool ReadStreamOfTypeVariants(std::vector>>& values, size_t idx); + [[nodiscard]] size_t CountStreamOfTypeVariants(); + + virtual ~SimpleGenericsIndexedReaderBase() = default; + + protected: + virtual bool ReadStreamOfTypeVariantsImpl(std::variant>& value, size_t idx) = 0; + virtual bool ReadStreamOfTypeVariantsImpl(std::vector>>& values, size_t idx) = 0; + virtual size_t CountStreamOfTypeVariantsImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the AdvancedGenerics protocol. class AdvancedGenericsWriterBase { public: @@ -2434,9 +2992,11 @@ class AdvancedGenericsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class AdvancedGenericsReaderBase; + friend class AdvancedGenericsIndexedReaderBase; }; // Abstract reader for the AdvancedGenerics protocol. @@ -2478,9 +3038,21 @@ class AdvancedGenericsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the AdvancedGenerics protocol. +class AdvancedGenericsIndexedReaderBase : public AdvancedGenericsReaderBase { + public: + virtual ~AdvancedGenericsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the Aliases protocol. class AliasesWriterBase { public: @@ -2552,9 +3124,11 @@ class AliasesWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class AliasesReaderBase; + friend class AliasesIndexedReaderBase; }; // Abstract reader for the Aliases protocol. @@ -2620,9 +3194,29 @@ class AliasesReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the Aliases protocol. +class AliasesIndexedReaderBase : public AliasesReaderBase { + public: + using AliasesReaderBase::ReadStreamOfAliasedGenericUnion2; + [[nodiscard]] bool ReadStreamOfAliasedGenericUnion2(test_model::AliasedGenericUnion2& value, size_t idx); + [[nodiscard]] bool ReadStreamOfAliasedGenericUnion2(std::vector>& values, size_t idx); + [[nodiscard]] size_t CountStreamOfAliasedGenericUnion2(); + + virtual ~AliasesIndexedReaderBase() = default; + + protected: + virtual bool ReadStreamOfAliasedGenericUnion2Impl(test_model::AliasedGenericUnion2& value, size_t idx) = 0; + virtual bool ReadStreamOfAliasedGenericUnion2Impl(std::vector>& values, size_t idx) = 0; + virtual size_t CountStreamOfAliasedGenericUnion2Impl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the StreamsOfAliasedUnions protocol. class StreamsOfAliasedUnionsWriterBase { public: @@ -2672,9 +3266,11 @@ class StreamsOfAliasedUnionsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class StreamsOfAliasedUnionsReaderBase; + friend class StreamsOfAliasedUnionsIndexedReaderBase; }; // Abstract reader for the StreamsOfAliasedUnions protocol. @@ -2712,9 +3308,37 @@ class StreamsOfAliasedUnionsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the StreamsOfAliasedUnions protocol. +class StreamsOfAliasedUnionsIndexedReaderBase : public StreamsOfAliasedUnionsReaderBase { + public: + using StreamsOfAliasedUnionsReaderBase::ReadIntOrSimpleRecord; + [[nodiscard]] bool ReadIntOrSimpleRecord(test_model::AliasedIntOrSimpleRecord& value, size_t idx); + [[nodiscard]] bool ReadIntOrSimpleRecord(std::vector& values, size_t idx); + [[nodiscard]] size_t CountIntOrSimpleRecord(); + + using StreamsOfAliasedUnionsReaderBase::ReadNullableIntOrSimpleRecord; + [[nodiscard]] bool ReadNullableIntOrSimpleRecord(test_model::AliasedNullableIntSimpleRecord& value, size_t idx); + [[nodiscard]] bool ReadNullableIntOrSimpleRecord(std::vector& values, size_t idx); + [[nodiscard]] size_t CountNullableIntOrSimpleRecord(); + + virtual ~StreamsOfAliasedUnionsIndexedReaderBase() = default; + + protected: + virtual bool ReadIntOrSimpleRecordImpl(test_model::AliasedIntOrSimpleRecord& value, size_t idx) = 0; + virtual bool ReadIntOrSimpleRecordImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountIntOrSimpleRecordImpl() = 0; + virtual bool ReadNullableIntOrSimpleRecordImpl(test_model::AliasedNullableIntSimpleRecord& value, size_t idx) = 0; + virtual bool ReadNullableIntOrSimpleRecordImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountNullableIntOrSimpleRecordImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the ProtocolWithComputedFields protocol. class ProtocolWithComputedFieldsWriterBase { public: @@ -2740,9 +3364,11 @@ class ProtocolWithComputedFieldsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ProtocolWithComputedFieldsReaderBase; + friend class ProtocolWithComputedFieldsIndexedReaderBase; }; // Abstract reader for the ProtocolWithComputedFields protocol. @@ -2768,9 +3394,21 @@ class ProtocolWithComputedFieldsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the ProtocolWithComputedFields protocol. +class ProtocolWithComputedFieldsIndexedReaderBase : public ProtocolWithComputedFieldsReaderBase { + public: + virtual ~ProtocolWithComputedFieldsIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the ProtocolWithKeywordSteps protocol. class ProtocolWithKeywordStepsWriterBase { public: @@ -2810,9 +3448,11 @@ class ProtocolWithKeywordStepsWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ProtocolWithKeywordStepsReaderBase; + friend class ProtocolWithKeywordStepsIndexedReaderBase; }; // Abstract reader for the ProtocolWithKeywordSteps protocol. @@ -2846,9 +3486,29 @@ class ProtocolWithKeywordStepsReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; +// Abstract Indexed reader for the ProtocolWithKeywordSteps protocol. +class ProtocolWithKeywordStepsIndexedReaderBase : public ProtocolWithKeywordStepsReaderBase { + public: + using ProtocolWithKeywordStepsReaderBase::ReadInt; + [[nodiscard]] bool ReadInt(test_model::RecordWithKeywordFields& value, size_t idx); + [[nodiscard]] bool ReadInt(std::vector& values, size_t idx); + [[nodiscard]] size_t CountInt(); + + virtual ~ProtocolWithKeywordStepsIndexedReaderBase() = default; + + protected: + virtual bool ReadIntImpl(test_model::RecordWithKeywordFields& value, size_t idx) = 0; + virtual bool ReadIntImpl(std::vector& values, size_t idx) = 0; + virtual size_t CountIntImpl() = 0; + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; + // Abstract writer for the ProtocolWithOptionalDate protocol. class ProtocolWithOptionalDateWriterBase { public: @@ -2874,9 +3534,11 @@ class ProtocolWithOptionalDateWriterBase { static std::string SchemaFromVersion(Version version); private: + virtual void InvalidState(uint8_t attempted, [[maybe_unused]] bool end); uint8_t state_ = 0; friend class ProtocolWithOptionalDateReaderBase; + friend class ProtocolWithOptionalDateIndexedReaderBase; }; // Abstract reader for the ProtocolWithOptionalDate protocol. @@ -2902,6 +3564,18 @@ class ProtocolWithOptionalDateReaderBase { static Version VersionFromSchema(const std::string& schema); private: + virtual void InvalidState(uint8_t attempted); uint8_t state_ = 0; }; + +// Abstract Indexed reader for the ProtocolWithOptionalDate protocol. +class ProtocolWithOptionalDateIndexedReaderBase : public ProtocolWithOptionalDateReaderBase { + public: + virtual ~ProtocolWithOptionalDateIndexedReaderBase() = default; + + protected: + virtual void CloseImpl() {} + private: + virtual void InvalidState(uint8_t attempted) override; +}; } // namespace test_model diff --git a/demo/indexing/cpp/generated/yardl/detail/binary/index.h b/demo/indexing/cpp/generated/yardl/detail/binary/index.h index 069af4d..689e1a5 100644 --- a/demo/indexing/cpp/generated/yardl/detail/binary/index.h +++ b/demo/indexing/cpp/generated/yardl/detail/binary/index.h @@ -130,11 +130,11 @@ inline Index ReadIndex(CodedInputStream& stream) { auto pos = stream.Pos(); size_t index_offset = 0; - stream.Seek(-sizeof(index_offset)); + stream.Seek(-static_cast(sizeof(index_offset))); stream.ReadFixedInteger(index_offset); try { stream.Seek(index_offset); - } catch (std::exception const& e) { + } catch (std::exception const&) { throw std::runtime_error("Binary Index not found in stream."); } diff --git a/demo/indexing/python/sketch/_binary.py b/demo/indexing/python/sketch/_binary.py index e3edf8c..6d8cfd4 100644 --- a/demo/indexing/python/sketch/_binary.py +++ b/demo/indexing/python/sketch/_binary.py @@ -16,6 +16,7 @@ Optional, Tuple, cast, + Callable, ) from abc import ABC, abstractmethod import struct @@ -1532,11 +1533,13 @@ def read_numpy(self, stream: CodedInputStream) -> np.void: return cast(np.void, self._read(stream)) -class RecursiveSerializer(Generic[T, T_NP], TypeSerializer[T, np.void]): - def __init__(self, element_serializer_type: TypeSerializer[T, T_NP]) -> None: +class RecursiveSerializer(Generic[T, T_NP], TypeSerializer[Optional[T], np.void]): + def __init__( + self, element_serializer_type: Callable[[], TypeSerializer[Optional[T], T_NP]] + ) -> None: super().__init__(np.dtype([("has_value", np.bool_), ("value", np.object_)])) self._element_serializer_type = element_serializer_type - self._element_serializer = None + self._element_serializer: Union[TypeSerializer[Optional[T], T_NP], None] = None self._none = cast(np.void, np.zeros((), dtype=self.overall_dtype())[()]) def write(self, stream: CodedOutputStream, value: Optional[T]) -> None: diff --git a/demo/recursive/cpp/generated/types.h b/demo/recursive/cpp/generated/types.h index 2cb1b6b..805c5f0 100644 --- a/demo/recursive/cpp/generated/types.h +++ b/demo/recursive/cpp/generated/types.h @@ -11,13 +11,13 @@ #include "yardl/yardl.h" namespace sketch { +struct BinaryTree; + template struct LinkedList; struct Directory; -struct BinaryTree; - struct BinaryTree { int32_t value{}; std::unique_ptr left{}; diff --git a/demo/recursive/cpp/generated/yardl/detail/binary/index.h b/demo/recursive/cpp/generated/yardl/detail/binary/index.h index 069af4d..689e1a5 100644 --- a/demo/recursive/cpp/generated/yardl/detail/binary/index.h +++ b/demo/recursive/cpp/generated/yardl/detail/binary/index.h @@ -130,11 +130,11 @@ inline Index ReadIndex(CodedInputStream& stream) { auto pos = stream.Pos(); size_t index_offset = 0; - stream.Seek(-sizeof(index_offset)); + stream.Seek(-static_cast(sizeof(index_offset))); stream.ReadFixedInteger(index_offset); try { stream.Seek(index_offset); - } catch (std::exception const& e) { + } catch (std::exception const&) { throw std::runtime_error("Binary Index not found in stream."); } diff --git a/demo/recursive/python/sketch/_binary.py b/demo/recursive/python/sketch/_binary.py index 9e16ad9..6d8cfd4 100644 --- a/demo/recursive/python/sketch/_binary.py +++ b/demo/recursive/python/sketch/_binary.py @@ -16,6 +16,7 @@ Optional, Tuple, cast, + Callable, ) from abc import ABC, abstractmethod import struct @@ -99,7 +100,7 @@ def _close(self) -> None: class BinaryProtocolIndexedWriter(BinaryProtocolWriter): def __init__(self, stream: Union[BinaryIO, str], schema: str) -> None: super().__init__(stream, schema) - self._index = Index() + self._index: Index = Index() def _close(self) -> None: self._index.write(self._stream) @@ -114,7 +115,7 @@ def __init__( ) -> None: super().__init__(stream, expected_schema) # Load the index from the end of the stream - self._index = Index.read(self._stream) + self._index: Index = Index.read(self._stream) class CodedOutputStream: @@ -365,16 +366,16 @@ def _fill_buffer(self, min_count: int = 0) -> None: class Index: def __init__(self) -> None: - self.step_offsets = {} - self.stream_offsets = {} - self.stream_blocks = {} + self.step_offsets: dict[str, int] = {} + self.stream_offsets: dict[str, list[int]] = {} + self.stream_blocks: dict[str, list[int]] = {} def set_step_offset(self, step: str, offset: int) -> None: if step not in self.step_offsets: self.step_offsets[step] = offset def add_stream_offsets( - self, step: str, offsets: Iterable[int], num_blocks: int + self, step: str, offsets: list[int], num_blocks: int ) -> None: if step not in self.stream_blocks: self.stream_blocks[step] = [] @@ -434,7 +435,7 @@ def write(self, stream: CodedOutputStream) -> None: write_fixed_size_t(stream, pos) @staticmethod - def read(stream: CodedInputStream) -> None: + def read(stream: CodedInputStream) -> "Index": pos = stream.pos() stream.seek(-size_t_struct.size) @@ -446,7 +447,9 @@ def read(stream: CodedInputStream) -> None: raise RuntimeError("Binary Index not found in stream.") magic_bytes = stream.read_view(len(INDEX_MAGIC_BYTES)) - if magic_bytes != INDEX_MAGIC_BYTES: + if ( + magic_bytes != INDEX_MAGIC_BYTES + ): # pyright: ignore [reportUnnecessaryComparison] raise RuntimeError( "Binary Index in the stream is not in the expected format." ) @@ -1147,10 +1150,10 @@ def write(self, stream: CodedOutputStream, value: Iterable[T]) -> None: def write_and_save_offsets( self, stream: CodedOutputStream, value: Iterable[T] - ) -> Iterable[int]: + ) -> Tuple[list[int], int]: # Note that the final 0 is missing and will be added before the next protocol step # or the protocol is closed. - offsets = [] + offsets: list[int] = [] num_blocks = 0 if isinstance(value, list) and len(value) > 0: stream.write_unsigned_varint(len(value)) @@ -1530,11 +1533,13 @@ def read_numpy(self, stream: CodedInputStream) -> np.void: return cast(np.void, self._read(stream)) -class RecursiveSerializer(Generic[T, T_NP], TypeSerializer[T, np.void]): - def __init__(self, element_serializer_type: TypeSerializer[T, T_NP]) -> None: +class RecursiveSerializer(Generic[T, T_NP], TypeSerializer[Optional[T], np.void]): + def __init__( + self, element_serializer_type: Callable[[], TypeSerializer[Optional[T], T_NP]] + ) -> None: super().__init__(np.dtype([("has_value", np.bool_), ("value", np.object_)])) self._element_serializer_type = element_serializer_type - self._element_serializer = None + self._element_serializer: Union[TypeSerializer[Optional[T], T_NP], None] = None self._none = cast(np.void, np.zeros((), dtype=self.overall_dtype())[()]) def write(self, stream: CodedOutputStream, value: Optional[T]) -> None: diff --git a/demo/recursive/python/sketch/binary.py b/demo/recursive/python/sketch/binary.py index 9789dc9..969d058 100644 --- a/demo/recursive/python/sketch/binary.py +++ b/demo/recursive/python/sketch/binary.py @@ -110,7 +110,7 @@ def _read_list(self) -> typing.Optional[LinkedList[str]]: self._stream.seek(pos) return _binary.OptionalSerializer(LinkedListSerializer(_binary.string_serializer)).read(self._stream) - def _read_cwd(self, idx: int) -> collections.abc.Iterable[DirectoryEntry]: + def _read_cwd(self, idx: int) -> collections.abc.Iterable[DirectoryEntry]: # pyright: ignore [reportIncompatibleMethodOverride] offset, remaining = self._index.find_stream_item("Cwd", idx) self._stream.seek(offset) return _binary.StreamSerializer(_binary.UnionSerializer(DirectoryEntry, [(DirectoryEntry.File, FileSerializer()), (DirectoryEntry.Directory, _binary.RecursiveSerializer(lambda *args, **kwargs : DirectorySerializer()))])).read_mid_stream(self._stream, remaining) diff --git a/demo/recursive/python/sketch/protocols.py b/demo/recursive/python/sketch/protocols.py index 1157143..7e94738 100644 --- a/demo/recursive/python/sketch/protocols.py +++ b/demo/recursive/python/sketch/protocols.py @@ -268,5 +268,9 @@ def count_cwd(self) -> int: def _read_cwd(self, idx: int = 0) -> collections.abc.Iterable[DirectoryEntry]: raise NotImplementedError() + @abc.abstractmethod + def _count_cwd(self) -> int: + raise NotImplementedError() + def _raise_unexpected_state(self, actual: int) -> None: pass diff --git a/demo/recursive/python/sketch/types.py b/demo/recursive/python/sketch/types.py index efab215..e84e1be 100644 --- a/demo/recursive/python/sketch/types.py +++ b/demo/recursive/python/sketch/types.py @@ -21,9 +21,9 @@ T_NP = typing.TypeVar("T_NP", bound=np.generic) +Directory__: typing.TypeAlias = "Directory" BinaryTree__: typing.TypeAlias = "BinaryTree" LinkedList__: typing.TypeAlias = "LinkedList[T]" -Directory__: typing.TypeAlias = "Directory" class BinaryTree: value: yardl.Int32 diff --git a/python/test_model/__init__.py b/python/test_model/__init__.py index 31101df..a8fadeb 100644 --- a/python/test_model/__init__.py +++ b/python/test_model/__init__.py @@ -126,146 +126,251 @@ def _parse_version(version: str) -> _Tuple[int, ...]: get_dtype, ) from .protocols import ( + AdvancedGenericsIndexedReaderBase, AdvancedGenericsReaderBase, AdvancedGenericsWriterBase, + AliasesIndexedReaderBase, AliasesReaderBase, AliasesWriterBase, + BenchmarkFloat256x256IndexedReaderBase, BenchmarkFloat256x256ReaderBase, BenchmarkFloat256x256WriterBase, + BenchmarkFloatVlenIndexedReaderBase, BenchmarkFloatVlenReaderBase, BenchmarkFloatVlenWriterBase, + BenchmarkInt256x256IndexedReaderBase, BenchmarkInt256x256ReaderBase, BenchmarkInt256x256WriterBase, + BenchmarkSimpleMrdIndexedReaderBase, BenchmarkSimpleMrdReaderBase, BenchmarkSimpleMrdWriterBase, + BenchmarkSmallRecordIndexedReaderBase, BenchmarkSmallRecordReaderBase, + BenchmarkSmallRecordWithOptionalsIndexedReaderBase, BenchmarkSmallRecordWithOptionalsReaderBase, BenchmarkSmallRecordWithOptionalsWriterBase, BenchmarkSmallRecordWriterBase, + ComplexArraysIndexedReaderBase, ComplexArraysReaderBase, ComplexArraysWriterBase, + DynamicNDArraysIndexedReaderBase, DynamicNDArraysReaderBase, DynamicNDArraysWriterBase, + EnumsIndexedReaderBase, EnumsReaderBase, EnumsWriterBase, + FixedArraysIndexedReaderBase, FixedArraysReaderBase, FixedArraysWriterBase, + FixedVectorsIndexedReaderBase, FixedVectorsReaderBase, FixedVectorsWriterBase, + FlagsIndexedReaderBase, FlagsReaderBase, FlagsWriterBase, + MapsIndexedReaderBase, MapsReaderBase, MapsWriterBase, + MultiDArraysIndexedReaderBase, MultiDArraysReaderBase, MultiDArraysWriterBase, + NDArraysIndexedReaderBase, NDArraysReaderBase, + NDArraysSingleDimensionIndexedReaderBase, NDArraysSingleDimensionReaderBase, NDArraysSingleDimensionWriterBase, NDArraysWriterBase, + NestedRecordsIndexedReaderBase, NestedRecordsReaderBase, NestedRecordsWriterBase, + OptionalVectorsIndexedReaderBase, OptionalVectorsReaderBase, OptionalVectorsWriterBase, + ProtocolWithComputedFieldsIndexedReaderBase, ProtocolWithComputedFieldsReaderBase, ProtocolWithComputedFieldsWriterBase, + ProtocolWithKeywordStepsIndexedReaderBase, ProtocolWithKeywordStepsReaderBase, ProtocolWithKeywordStepsWriterBase, + ProtocolWithOptionalDateIndexedReaderBase, ProtocolWithOptionalDateReaderBase, ProtocolWithOptionalDateWriterBase, + ScalarOptionalsIndexedReaderBase, ScalarOptionalsReaderBase, ScalarOptionalsWriterBase, + ScalarsIndexedReaderBase, ScalarsReaderBase, ScalarsWriterBase, + SimpleGenericsIndexedReaderBase, SimpleGenericsReaderBase, SimpleGenericsWriterBase, + StateTestIndexedReaderBase, StateTestReaderBase, StateTestWriterBase, + StreamsIndexedReaderBase, + StreamsOfAliasedUnionsIndexedReaderBase, StreamsOfAliasedUnionsReaderBase, StreamsOfAliasedUnionsWriterBase, + StreamsOfUnionsIndexedReaderBase, StreamsOfUnionsReaderBase, StreamsOfUnionsWriterBase, StreamsReaderBase, StreamsWriterBase, + StringsIndexedReaderBase, StringsReaderBase, StringsWriterBase, + SubarraysInRecordsIndexedReaderBase, SubarraysInRecordsReaderBase, SubarraysInRecordsWriterBase, + SubarraysIndexedReaderBase, SubarraysReaderBase, SubarraysWriterBase, + UnionsIndexedReaderBase, UnionsReaderBase, UnionsWriterBase, + VlensIndexedReaderBase, VlensReaderBase, VlensWriterBase, ) from .binary import ( + BinaryAdvancedGenericsIndexedReader, + BinaryAdvancedGenericsIndexedWriter, BinaryAdvancedGenericsReader, BinaryAdvancedGenericsWriter, + BinaryAliasesIndexedReader, + BinaryAliasesIndexedWriter, BinaryAliasesReader, BinaryAliasesWriter, + BinaryBenchmarkFloat256x256IndexedReader, + BinaryBenchmarkFloat256x256IndexedWriter, BinaryBenchmarkFloat256x256Reader, BinaryBenchmarkFloat256x256Writer, + BinaryBenchmarkFloatVlenIndexedReader, + BinaryBenchmarkFloatVlenIndexedWriter, BinaryBenchmarkFloatVlenReader, BinaryBenchmarkFloatVlenWriter, + BinaryBenchmarkInt256x256IndexedReader, + BinaryBenchmarkInt256x256IndexedWriter, BinaryBenchmarkInt256x256Reader, BinaryBenchmarkInt256x256Writer, + BinaryBenchmarkSimpleMrdIndexedReader, + BinaryBenchmarkSimpleMrdIndexedWriter, BinaryBenchmarkSimpleMrdReader, BinaryBenchmarkSimpleMrdWriter, + BinaryBenchmarkSmallRecordIndexedReader, + BinaryBenchmarkSmallRecordIndexedWriter, BinaryBenchmarkSmallRecordReader, + BinaryBenchmarkSmallRecordWithOptionalsIndexedReader, + BinaryBenchmarkSmallRecordWithOptionalsIndexedWriter, BinaryBenchmarkSmallRecordWithOptionalsReader, BinaryBenchmarkSmallRecordWithOptionalsWriter, BinaryBenchmarkSmallRecordWriter, + BinaryComplexArraysIndexedReader, + BinaryComplexArraysIndexedWriter, BinaryComplexArraysReader, BinaryComplexArraysWriter, + BinaryDynamicNDArraysIndexedReader, + BinaryDynamicNDArraysIndexedWriter, BinaryDynamicNDArraysReader, BinaryDynamicNDArraysWriter, + BinaryEnumsIndexedReader, + BinaryEnumsIndexedWriter, BinaryEnumsReader, BinaryEnumsWriter, + BinaryFixedArraysIndexedReader, + BinaryFixedArraysIndexedWriter, BinaryFixedArraysReader, BinaryFixedArraysWriter, + BinaryFixedVectorsIndexedReader, + BinaryFixedVectorsIndexedWriter, BinaryFixedVectorsReader, BinaryFixedVectorsWriter, + BinaryFlagsIndexedReader, + BinaryFlagsIndexedWriter, BinaryFlagsReader, BinaryFlagsWriter, + BinaryMapsIndexedReader, + BinaryMapsIndexedWriter, BinaryMapsReader, BinaryMapsWriter, + BinaryMultiDArraysIndexedReader, + BinaryMultiDArraysIndexedWriter, BinaryMultiDArraysReader, BinaryMultiDArraysWriter, + BinaryNDArraysIndexedReader, + BinaryNDArraysIndexedWriter, BinaryNDArraysReader, + BinaryNDArraysSingleDimensionIndexedReader, + BinaryNDArraysSingleDimensionIndexedWriter, BinaryNDArraysSingleDimensionReader, BinaryNDArraysSingleDimensionWriter, BinaryNDArraysWriter, + BinaryNestedRecordsIndexedReader, + BinaryNestedRecordsIndexedWriter, BinaryNestedRecordsReader, BinaryNestedRecordsWriter, + BinaryOptionalVectorsIndexedReader, + BinaryOptionalVectorsIndexedWriter, BinaryOptionalVectorsReader, BinaryOptionalVectorsWriter, + BinaryProtocolWithComputedFieldsIndexedReader, + BinaryProtocolWithComputedFieldsIndexedWriter, BinaryProtocolWithComputedFieldsReader, BinaryProtocolWithComputedFieldsWriter, + BinaryProtocolWithKeywordStepsIndexedReader, + BinaryProtocolWithKeywordStepsIndexedWriter, BinaryProtocolWithKeywordStepsReader, BinaryProtocolWithKeywordStepsWriter, + BinaryProtocolWithOptionalDateIndexedReader, + BinaryProtocolWithOptionalDateIndexedWriter, BinaryProtocolWithOptionalDateReader, BinaryProtocolWithOptionalDateWriter, + BinaryScalarOptionalsIndexedReader, + BinaryScalarOptionalsIndexedWriter, BinaryScalarOptionalsReader, BinaryScalarOptionalsWriter, + BinaryScalarsIndexedReader, + BinaryScalarsIndexedWriter, BinaryScalarsReader, BinaryScalarsWriter, + BinarySimpleGenericsIndexedReader, + BinarySimpleGenericsIndexedWriter, BinarySimpleGenericsReader, BinarySimpleGenericsWriter, + BinaryStateTestIndexedReader, + BinaryStateTestIndexedWriter, BinaryStateTestReader, BinaryStateTestWriter, + BinaryStreamsIndexedReader, + BinaryStreamsIndexedWriter, + BinaryStreamsOfAliasedUnionsIndexedReader, + BinaryStreamsOfAliasedUnionsIndexedWriter, BinaryStreamsOfAliasedUnionsReader, BinaryStreamsOfAliasedUnionsWriter, + BinaryStreamsOfUnionsIndexedReader, + BinaryStreamsOfUnionsIndexedWriter, BinaryStreamsOfUnionsReader, BinaryStreamsOfUnionsWriter, BinaryStreamsReader, BinaryStreamsWriter, + BinaryStringsIndexedReader, + BinaryStringsIndexedWriter, BinaryStringsReader, BinaryStringsWriter, + BinarySubarraysInRecordsIndexedReader, + BinarySubarraysInRecordsIndexedWriter, BinarySubarraysInRecordsReader, BinarySubarraysInRecordsWriter, + BinarySubarraysIndexedReader, + BinarySubarraysIndexedWriter, BinarySubarraysReader, BinarySubarraysWriter, + BinaryUnionsIndexedReader, + BinaryUnionsIndexedWriter, BinaryUnionsReader, BinaryUnionsWriter, + BinaryVlensIndexedReader, + BinaryVlensIndexedWriter, BinaryVlensReader, BinaryVlensWriter, ) diff --git a/python/test_model/binary.py b/python/test_model/binary.py index dbacc36..1bab29f 100644 --- a/python/test_model/binary.py +++ b/python/test_model/binary.py @@ -22,7 +22,6 @@ class BinaryBenchmarkFloat256x256Writer(_binary.BinaryProtocolWriter, BenchmarkFloat256x256WriterBase): """Binary writer for the BenchmarkFloat256x256 protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: BenchmarkFloat256x256WriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, BenchmarkFloat256x256WriterBase.schema) @@ -34,7 +33,6 @@ def _write_float256x256(self, value: collections.abc.Iterable[npt.NDArray[np.flo class BinaryBenchmarkFloat256x256Reader(_binary.BinaryProtocolReader, BenchmarkFloat256x256ReaderBase): """Binary writer for the BenchmarkFloat256x256 protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: BenchmarkFloat256x256ReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, BenchmarkFloat256x256ReaderBase.schema) @@ -42,10 +40,39 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_float256x256(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: return _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (256, 256,))).read(self._stream) + +class BinaryBenchmarkFloat256x256IndexedWriter(_binary.BinaryProtocolIndexedWriter, BenchmarkFloat256x256WriterBase): + """Binary indexed writer for the BenchmarkFloat256x256 protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + BenchmarkFloat256x256WriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, BenchmarkFloat256x256WriterBase.schema) + + def _write_float256x256(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Float256x256", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (256, 256,))).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("Float256x256", offsets, num_blocks) + + +class BinaryBenchmarkFloat256x256IndexedReader(_binary.BinaryProtocolIndexedReader, BenchmarkFloat256x256IndexedReaderBase): + """Binary indexed writer for the BenchmarkFloat256x256 protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + BenchmarkFloat256x256IndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, BenchmarkFloat256x256IndexedReaderBase.schema) + + def _read_float256x256(self, idx: int) -> collections.abc.Iterable[npt.NDArray[np.float32]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("Float256x256", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (256, 256,))).read_mid_stream(self._stream, remaining) + + def _count_float256x256(self) -> int: + return self._index.get_stream_size("Float256x256") + class BinaryBenchmarkInt256x256Writer(_binary.BinaryProtocolWriter, BenchmarkInt256x256WriterBase): """Binary writer for the BenchmarkInt256x256 protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: BenchmarkInt256x256WriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, BenchmarkInt256x256WriterBase.schema) @@ -57,7 +84,6 @@ def _write_int256x256(self, value: collections.abc.Iterable[npt.NDArray[np.int32 class BinaryBenchmarkInt256x256Reader(_binary.BinaryProtocolReader, BenchmarkInt256x256ReaderBase): """Binary writer for the BenchmarkInt256x256 protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: BenchmarkInt256x256ReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, BenchmarkInt256x256ReaderBase.schema) @@ -65,10 +91,39 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_int256x256(self) -> collections.abc.Iterable[npt.NDArray[np.int32]]: return _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (256, 256,))).read(self._stream) + +class BinaryBenchmarkInt256x256IndexedWriter(_binary.BinaryProtocolIndexedWriter, BenchmarkInt256x256WriterBase): + """Binary indexed writer for the BenchmarkInt256x256 protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + BenchmarkInt256x256WriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, BenchmarkInt256x256WriterBase.schema) + + def _write_int256x256(self, value: collections.abc.Iterable[npt.NDArray[np.int32]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Int256x256", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (256, 256,))).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("Int256x256", offsets, num_blocks) + + +class BinaryBenchmarkInt256x256IndexedReader(_binary.BinaryProtocolIndexedReader, BenchmarkInt256x256IndexedReaderBase): + """Binary indexed writer for the BenchmarkInt256x256 protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + BenchmarkInt256x256IndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, BenchmarkInt256x256IndexedReaderBase.schema) + + def _read_int256x256(self, idx: int) -> collections.abc.Iterable[npt.NDArray[np.int32]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("Int256x256", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (256, 256,))).read_mid_stream(self._stream, remaining) + + def _count_int256x256(self) -> int: + return self._index.get_stream_size("Int256x256") + class BinaryBenchmarkFloatVlenWriter(_binary.BinaryProtocolWriter, BenchmarkFloatVlenWriterBase): """Binary writer for the BenchmarkFloatVlen protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: BenchmarkFloatVlenWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, BenchmarkFloatVlenWriterBase.schema) @@ -80,7 +135,6 @@ def _write_float_array(self, value: collections.abc.Iterable[npt.NDArray[np.floa class BinaryBenchmarkFloatVlenReader(_binary.BinaryProtocolReader, BenchmarkFloatVlenReaderBase): """Binary writer for the BenchmarkFloatVlen protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: BenchmarkFloatVlenReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, BenchmarkFloatVlenReaderBase.schema) @@ -88,10 +142,39 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_float_array(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: return _binary.StreamSerializer(_binary.NDArraySerializer(_binary.float32_serializer, 2)).read(self._stream) + +class BinaryBenchmarkFloatVlenIndexedWriter(_binary.BinaryProtocolIndexedWriter, BenchmarkFloatVlenWriterBase): + """Binary indexed writer for the BenchmarkFloatVlen protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + BenchmarkFloatVlenWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, BenchmarkFloatVlenWriterBase.schema) + + def _write_float_array(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FloatArray", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.NDArraySerializer(_binary.float32_serializer, 2)).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("FloatArray", offsets, num_blocks) + + +class BinaryBenchmarkFloatVlenIndexedReader(_binary.BinaryProtocolIndexedReader, BenchmarkFloatVlenIndexedReaderBase): + """Binary indexed writer for the BenchmarkFloatVlen protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + BenchmarkFloatVlenIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, BenchmarkFloatVlenIndexedReaderBase.schema) + + def _read_float_array(self, idx: int) -> collections.abc.Iterable[npt.NDArray[np.float32]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("FloatArray", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.NDArraySerializer(_binary.float32_serializer, 2)).read_mid_stream(self._stream, remaining) + + def _count_float_array(self) -> int: + return self._index.get_stream_size("FloatArray") + class BinaryBenchmarkSmallRecordWriter(_binary.BinaryProtocolWriter, BenchmarkSmallRecordWriterBase): """Binary writer for the BenchmarkSmallRecord protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: BenchmarkSmallRecordWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, BenchmarkSmallRecordWriterBase.schema) @@ -103,7 +186,6 @@ def _write_small_record(self, value: collections.abc.Iterable[SmallBenchmarkReco class BinaryBenchmarkSmallRecordReader(_binary.BinaryProtocolReader, BenchmarkSmallRecordReaderBase): """Binary writer for the BenchmarkSmallRecord protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: BenchmarkSmallRecordReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, BenchmarkSmallRecordReaderBase.schema) @@ -111,10 +193,39 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_small_record(self) -> collections.abc.Iterable[SmallBenchmarkRecord]: return _binary.StreamSerializer(SmallBenchmarkRecordSerializer()).read(self._stream) + +class BinaryBenchmarkSmallRecordIndexedWriter(_binary.BinaryProtocolIndexedWriter, BenchmarkSmallRecordWriterBase): + """Binary indexed writer for the BenchmarkSmallRecord protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + BenchmarkSmallRecordWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, BenchmarkSmallRecordWriterBase.schema) + + def _write_small_record(self, value: collections.abc.Iterable[SmallBenchmarkRecord]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("SmallRecord", pos) + offsets, num_blocks = _binary.StreamSerializer(SmallBenchmarkRecordSerializer()).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("SmallRecord", offsets, num_blocks) + + +class BinaryBenchmarkSmallRecordIndexedReader(_binary.BinaryProtocolIndexedReader, BenchmarkSmallRecordIndexedReaderBase): + """Binary indexed writer for the BenchmarkSmallRecord protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + BenchmarkSmallRecordIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, BenchmarkSmallRecordIndexedReaderBase.schema) + + def _read_small_record(self, idx: int) -> collections.abc.Iterable[SmallBenchmarkRecord]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("SmallRecord", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(SmallBenchmarkRecordSerializer()).read_mid_stream(self._stream, remaining) + + def _count_small_record(self) -> int: + return self._index.get_stream_size("SmallRecord") + class BinaryBenchmarkSmallRecordWithOptionalsWriter(_binary.BinaryProtocolWriter, BenchmarkSmallRecordWithOptionalsWriterBase): """Binary writer for the BenchmarkSmallRecordWithOptionals protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: BenchmarkSmallRecordWithOptionalsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, BenchmarkSmallRecordWithOptionalsWriterBase.schema) @@ -126,7 +237,6 @@ def _write_small_record(self, value: collections.abc.Iterable[SimpleEncodingCoun class BinaryBenchmarkSmallRecordWithOptionalsReader(_binary.BinaryProtocolReader, BenchmarkSmallRecordWithOptionalsReaderBase): """Binary writer for the BenchmarkSmallRecordWithOptionals protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: BenchmarkSmallRecordWithOptionalsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, BenchmarkSmallRecordWithOptionalsReaderBase.schema) @@ -134,10 +244,39 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_small_record(self) -> collections.abc.Iterable[SimpleEncodingCounters]: return _binary.StreamSerializer(SimpleEncodingCountersSerializer()).read(self._stream) + +class BinaryBenchmarkSmallRecordWithOptionalsIndexedWriter(_binary.BinaryProtocolIndexedWriter, BenchmarkSmallRecordWithOptionalsWriterBase): + """Binary indexed writer for the BenchmarkSmallRecordWithOptionals protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + BenchmarkSmallRecordWithOptionalsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, BenchmarkSmallRecordWithOptionalsWriterBase.schema) + + def _write_small_record(self, value: collections.abc.Iterable[SimpleEncodingCounters]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("SmallRecord", pos) + offsets, num_blocks = _binary.StreamSerializer(SimpleEncodingCountersSerializer()).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("SmallRecord", offsets, num_blocks) + + +class BinaryBenchmarkSmallRecordWithOptionalsIndexedReader(_binary.BinaryProtocolIndexedReader, BenchmarkSmallRecordWithOptionalsIndexedReaderBase): + """Binary indexed writer for the BenchmarkSmallRecordWithOptionals protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + BenchmarkSmallRecordWithOptionalsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, BenchmarkSmallRecordWithOptionalsIndexedReaderBase.schema) + + def _read_small_record(self, idx: int) -> collections.abc.Iterable[SimpleEncodingCounters]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("SmallRecord", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(SimpleEncodingCountersSerializer()).read_mid_stream(self._stream, remaining) + + def _count_small_record(self) -> int: + return self._index.get_stream_size("SmallRecord") + class BinaryBenchmarkSimpleMrdWriter(_binary.BinaryProtocolWriter, BenchmarkSimpleMrdWriterBase): """Binary writer for the BenchmarkSimpleMrd protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: BenchmarkSimpleMrdWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, BenchmarkSimpleMrdWriterBase.schema) @@ -149,7 +288,6 @@ def _write_data(self, value: collections.abc.Iterable[AcquisitionOrImage]) -> No class BinaryBenchmarkSimpleMrdReader(_binary.BinaryProtocolReader, BenchmarkSimpleMrdReaderBase): """Binary writer for the BenchmarkSimpleMrd protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: BenchmarkSimpleMrdReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, BenchmarkSimpleMrdReaderBase.schema) @@ -157,10 +295,39 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_data(self) -> collections.abc.Iterable[AcquisitionOrImage]: return _binary.StreamSerializer(_binary.UnionSerializer(AcquisitionOrImage, [(AcquisitionOrImage.Acquisition, SimpleAcquisitionSerializer()), (AcquisitionOrImage.Image, _binary.NDArraySerializer(_binary.float32_serializer, 2))])).read(self._stream) + +class BinaryBenchmarkSimpleMrdIndexedWriter(_binary.BinaryProtocolIndexedWriter, BenchmarkSimpleMrdWriterBase): + """Binary indexed writer for the BenchmarkSimpleMrd protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + BenchmarkSimpleMrdWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, BenchmarkSimpleMrdWriterBase.schema) + + def _write_data(self, value: collections.abc.Iterable[AcquisitionOrImage]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Data", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.UnionSerializer(AcquisitionOrImage, [(AcquisitionOrImage.Acquisition, SimpleAcquisitionSerializer()), (AcquisitionOrImage.Image, _binary.NDArraySerializer(_binary.float32_serializer, 2))])).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("Data", offsets, num_blocks) + + +class BinaryBenchmarkSimpleMrdIndexedReader(_binary.BinaryProtocolIndexedReader, BenchmarkSimpleMrdIndexedReaderBase): + """Binary indexed writer for the BenchmarkSimpleMrd protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + BenchmarkSimpleMrdIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, BenchmarkSimpleMrdIndexedReaderBase.schema) + + def _read_data(self, idx: int) -> collections.abc.Iterable[AcquisitionOrImage]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("Data", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.UnionSerializer(AcquisitionOrImage, [(AcquisitionOrImage.Acquisition, SimpleAcquisitionSerializer()), (AcquisitionOrImage.Image, _binary.NDArraySerializer(_binary.float32_serializer, 2))])).read_mid_stream(self._stream, remaining) + + def _count_data(self) -> int: + return self._index.get_stream_size("Data") + class BinaryScalarsWriter(_binary.BinaryProtocolWriter, ScalarsWriterBase): """Binary writer for the Scalars protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: ScalarsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, ScalarsWriterBase.schema) @@ -175,7 +342,6 @@ def _write_record(self, value: RecordWithPrimitives) -> None: class BinaryScalarsReader(_binary.BinaryProtocolReader, ScalarsReaderBase): """Binary writer for the Scalars protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: ScalarsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, ScalarsReaderBase.schema) @@ -186,10 +352,45 @@ def _read_int32(self) -> yardl.Int32: def _read_record(self) -> RecordWithPrimitives: return RecordWithPrimitivesSerializer().read(self._stream) + +class BinaryScalarsIndexedWriter(_binary.BinaryProtocolIndexedWriter, ScalarsWriterBase): + """Binary indexed writer for the Scalars protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + ScalarsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, ScalarsWriterBase.schema) + + def _write_int32(self, value: yardl.Int32) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Int32", pos) + _binary.int32_serializer.write(self._stream, value) + + def _write_record(self, value: RecordWithPrimitives) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Record", pos) + RecordWithPrimitivesSerializer().write(self._stream, value) + + +class BinaryScalarsIndexedReader(_binary.BinaryProtocolIndexedReader, ScalarsIndexedReaderBase): + """Binary indexed writer for the Scalars protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + ScalarsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, ScalarsIndexedReaderBase.schema) + + def _read_int32(self) -> yardl.Int32: + pos = self._index.get_step_offset("Int32") + self._stream.seek(pos) + return _binary.int32_serializer.read(self._stream) + + def _read_record(self) -> RecordWithPrimitives: + pos = self._index.get_step_offset("Record") + self._stream.seek(pos) + return RecordWithPrimitivesSerializer().read(self._stream) + class BinaryScalarOptionalsWriter(_binary.BinaryProtocolWriter, ScalarOptionalsWriterBase): """Binary writer for the ScalarOptionals protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: ScalarOptionalsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, ScalarOptionalsWriterBase.schema) @@ -210,7 +411,6 @@ def _write_optional_record_with_optional_fields(self, value: typing.Optional[Rec class BinaryScalarOptionalsReader(_binary.BinaryProtocolReader, ScalarOptionalsReaderBase): """Binary writer for the ScalarOptionals protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: ScalarOptionalsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, ScalarOptionalsReaderBase.schema) @@ -227,10 +427,65 @@ def _read_record_with_optional_fields(self) -> RecordWithOptionalFields: def _read_optional_record_with_optional_fields(self) -> typing.Optional[RecordWithOptionalFields]: return _binary.OptionalSerializer(RecordWithOptionalFieldsSerializer()).read(self._stream) + +class BinaryScalarOptionalsIndexedWriter(_binary.BinaryProtocolIndexedWriter, ScalarOptionalsWriterBase): + """Binary indexed writer for the ScalarOptionals protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + ScalarOptionalsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, ScalarOptionalsWriterBase.schema) + + def _write_optional_int(self, value: typing.Optional[yardl.Int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("OptionalInt", pos) + _binary.OptionalSerializer(_binary.int32_serializer).write(self._stream, value) + + def _write_optional_record(self, value: typing.Optional[SimpleRecord]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("OptionalRecord", pos) + _binary.OptionalSerializer(SimpleRecordSerializer()).write(self._stream, value) + + def _write_record_with_optional_fields(self, value: RecordWithOptionalFields) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithOptionalFields", pos) + RecordWithOptionalFieldsSerializer().write(self._stream, value) + + def _write_optional_record_with_optional_fields(self, value: typing.Optional[RecordWithOptionalFields]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("OptionalRecordWithOptionalFields", pos) + _binary.OptionalSerializer(RecordWithOptionalFieldsSerializer()).write(self._stream, value) + + +class BinaryScalarOptionalsIndexedReader(_binary.BinaryProtocolIndexedReader, ScalarOptionalsIndexedReaderBase): + """Binary indexed writer for the ScalarOptionals protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + ScalarOptionalsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, ScalarOptionalsIndexedReaderBase.schema) + + def _read_optional_int(self) -> typing.Optional[yardl.Int32]: + pos = self._index.get_step_offset("OptionalInt") + self._stream.seek(pos) + return _binary.OptionalSerializer(_binary.int32_serializer).read(self._stream) + + def _read_optional_record(self) -> typing.Optional[SimpleRecord]: + pos = self._index.get_step_offset("OptionalRecord") + self._stream.seek(pos) + return _binary.OptionalSerializer(SimpleRecordSerializer()).read(self._stream) + + def _read_record_with_optional_fields(self) -> RecordWithOptionalFields: + pos = self._index.get_step_offset("RecordWithOptionalFields") + self._stream.seek(pos) + return RecordWithOptionalFieldsSerializer().read(self._stream) + + def _read_optional_record_with_optional_fields(self) -> typing.Optional[RecordWithOptionalFields]: + pos = self._index.get_step_offset("OptionalRecordWithOptionalFields") + self._stream.seek(pos) + return _binary.OptionalSerializer(RecordWithOptionalFieldsSerializer()).read(self._stream) + class BinaryNestedRecordsWriter(_binary.BinaryProtocolWriter, NestedRecordsWriterBase): """Binary writer for the NestedRecords protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: NestedRecordsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, NestedRecordsWriterBase.schema) @@ -242,7 +497,6 @@ def _write_tuple_with_records(self, value: TupleWithRecords) -> None: class BinaryNestedRecordsReader(_binary.BinaryProtocolReader, NestedRecordsReaderBase): """Binary writer for the NestedRecords protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: NestedRecordsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, NestedRecordsReaderBase.schema) @@ -250,10 +504,35 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_tuple_with_records(self) -> TupleWithRecords: return TupleWithRecordsSerializer().read(self._stream) + +class BinaryNestedRecordsIndexedWriter(_binary.BinaryProtocolIndexedWriter, NestedRecordsWriterBase): + """Binary indexed writer for the NestedRecords protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + NestedRecordsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, NestedRecordsWriterBase.schema) + + def _write_tuple_with_records(self, value: TupleWithRecords) -> None: + pos = self._stream.pos() + self._index.set_step_offset("TupleWithRecords", pos) + TupleWithRecordsSerializer().write(self._stream, value) + + +class BinaryNestedRecordsIndexedReader(_binary.BinaryProtocolIndexedReader, NestedRecordsIndexedReaderBase): + """Binary indexed writer for the NestedRecords protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + NestedRecordsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, NestedRecordsIndexedReaderBase.schema) + + def _read_tuple_with_records(self) -> TupleWithRecords: + pos = self._index.get_step_offset("TupleWithRecords") + self._stream.seek(pos) + return TupleWithRecordsSerializer().read(self._stream) + class BinaryVlensWriter(_binary.BinaryProtocolWriter, VlensWriterBase): """Binary writer for the Vlens protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: VlensWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, VlensWriterBase.schema) @@ -274,7 +553,6 @@ def _write_vlen_of_record_with_vlens(self, value: list[RecordWithVlens]) -> None class BinaryVlensReader(_binary.BinaryProtocolReader, VlensReaderBase): """Binary writer for the Vlens protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: VlensReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, VlensReaderBase.schema) @@ -291,10 +569,65 @@ def _read_record_with_vlens(self) -> RecordWithVlens: def _read_vlen_of_record_with_vlens(self) -> list[RecordWithVlens]: return _binary.VectorSerializer(RecordWithVlensSerializer()).read(self._stream) + +class BinaryVlensIndexedWriter(_binary.BinaryProtocolIndexedWriter, VlensWriterBase): + """Binary indexed writer for the Vlens protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + VlensWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, VlensWriterBase.schema) + + def _write_int_vector(self, value: list[yardl.Int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntVector", pos) + _binary.VectorSerializer(_binary.int32_serializer).write(self._stream, value) + + def _write_complex_vector(self, value: list[yardl.ComplexFloat]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("ComplexVector", pos) + _binary.VectorSerializer(_binary.complexfloat32_serializer).write(self._stream, value) + + def _write_record_with_vlens(self, value: RecordWithVlens) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithVlens", pos) + RecordWithVlensSerializer().write(self._stream, value) + + def _write_vlen_of_record_with_vlens(self, value: list[RecordWithVlens]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("VlenOfRecordWithVlens", pos) + _binary.VectorSerializer(RecordWithVlensSerializer()).write(self._stream, value) + + +class BinaryVlensIndexedReader(_binary.BinaryProtocolIndexedReader, VlensIndexedReaderBase): + """Binary indexed writer for the Vlens protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + VlensIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, VlensIndexedReaderBase.schema) + + def _read_int_vector(self) -> list[yardl.Int32]: + pos = self._index.get_step_offset("IntVector") + self._stream.seek(pos) + return _binary.VectorSerializer(_binary.int32_serializer).read(self._stream) + + def _read_complex_vector(self) -> list[yardl.ComplexFloat]: + pos = self._index.get_step_offset("ComplexVector") + self._stream.seek(pos) + return _binary.VectorSerializer(_binary.complexfloat32_serializer).read(self._stream) + + def _read_record_with_vlens(self) -> RecordWithVlens: + pos = self._index.get_step_offset("RecordWithVlens") + self._stream.seek(pos) + return RecordWithVlensSerializer().read(self._stream) + + def _read_vlen_of_record_with_vlens(self) -> list[RecordWithVlens]: + pos = self._index.get_step_offset("VlenOfRecordWithVlens") + self._stream.seek(pos) + return _binary.VectorSerializer(RecordWithVlensSerializer()).read(self._stream) + class BinaryStringsWriter(_binary.BinaryProtocolWriter, StringsWriterBase): """Binary writer for the Strings protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: StringsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, StringsWriterBase.schema) @@ -309,7 +642,6 @@ def _write_rec_with_string(self, value: RecordWithStrings) -> None: class BinaryStringsReader(_binary.BinaryProtocolReader, StringsReaderBase): """Binary writer for the Strings protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: StringsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, StringsReaderBase.schema) @@ -320,10 +652,45 @@ def _read_single_string(self) -> str: def _read_rec_with_string(self) -> RecordWithStrings: return RecordWithStringsSerializer().read(self._stream) + +class BinaryStringsIndexedWriter(_binary.BinaryProtocolIndexedWriter, StringsWriterBase): + """Binary indexed writer for the Strings protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + StringsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, StringsWriterBase.schema) + + def _write_single_string(self, value: str) -> None: + pos = self._stream.pos() + self._index.set_step_offset("SingleString", pos) + _binary.string_serializer.write(self._stream, value) + + def _write_rec_with_string(self, value: RecordWithStrings) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecWithString", pos) + RecordWithStringsSerializer().write(self._stream, value) + + +class BinaryStringsIndexedReader(_binary.BinaryProtocolIndexedReader, StringsIndexedReaderBase): + """Binary indexed writer for the Strings protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + StringsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, StringsIndexedReaderBase.schema) + + def _read_single_string(self) -> str: + pos = self._index.get_step_offset("SingleString") + self._stream.seek(pos) + return _binary.string_serializer.read(self._stream) + + def _read_rec_with_string(self) -> RecordWithStrings: + pos = self._index.get_step_offset("RecWithString") + self._stream.seek(pos) + return RecordWithStringsSerializer().read(self._stream) + class BinaryOptionalVectorsWriter(_binary.BinaryProtocolWriter, OptionalVectorsWriterBase): """Binary writer for the OptionalVectors protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: OptionalVectorsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, OptionalVectorsWriterBase.schema) @@ -335,7 +702,6 @@ def _write_record_with_optional_vector(self, value: RecordWithOptionalVector) -> class BinaryOptionalVectorsReader(_binary.BinaryProtocolReader, OptionalVectorsReaderBase): """Binary writer for the OptionalVectors protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: OptionalVectorsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, OptionalVectorsReaderBase.schema) @@ -343,10 +709,35 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_record_with_optional_vector(self) -> RecordWithOptionalVector: return RecordWithOptionalVectorSerializer().read(self._stream) + +class BinaryOptionalVectorsIndexedWriter(_binary.BinaryProtocolIndexedWriter, OptionalVectorsWriterBase): + """Binary indexed writer for the OptionalVectors protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + OptionalVectorsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, OptionalVectorsWriterBase.schema) + + def _write_record_with_optional_vector(self, value: RecordWithOptionalVector) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithOptionalVector", pos) + RecordWithOptionalVectorSerializer().write(self._stream, value) + + +class BinaryOptionalVectorsIndexedReader(_binary.BinaryProtocolIndexedReader, OptionalVectorsIndexedReaderBase): + """Binary indexed writer for the OptionalVectors protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + OptionalVectorsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, OptionalVectorsIndexedReaderBase.schema) + + def _read_record_with_optional_vector(self) -> RecordWithOptionalVector: + pos = self._index.get_step_offset("RecordWithOptionalVector") + self._stream.seek(pos) + return RecordWithOptionalVectorSerializer().read(self._stream) + class BinaryFixedVectorsWriter(_binary.BinaryProtocolWriter, FixedVectorsWriterBase): """Binary writer for the FixedVectors protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: FixedVectorsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, FixedVectorsWriterBase.schema) @@ -367,7 +758,6 @@ def _write_record_with_fixed_vectors(self, value: RecordWithFixedVectors) -> Non class BinaryFixedVectorsReader(_binary.BinaryProtocolReader, FixedVectorsReaderBase): """Binary writer for the FixedVectors protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: FixedVectorsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, FixedVectorsReaderBase.schema) @@ -384,21 +774,76 @@ def _read_fixed_record_with_vlens_vector(self) -> list[RecordWithVlens]: def _read_record_with_fixed_vectors(self) -> RecordWithFixedVectors: return RecordWithFixedVectorsSerializer().read(self._stream) -class BinaryStreamsWriter(_binary.BinaryProtocolWriter, StreamsWriterBase): - """Binary writer for the Streams protocol.""" +class BinaryFixedVectorsIndexedWriter(_binary.BinaryProtocolIndexedWriter, FixedVectorsWriterBase): + """Binary indexed writer for the FixedVectors protocol.""" def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: - StreamsWriterBase.__init__(self) - _binary.BinaryProtocolWriter.__init__(self, stream, StreamsWriterBase.schema) + FixedVectorsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, FixedVectorsWriterBase.schema) - def _write_int_data(self, value: collections.abc.Iterable[yardl.Int32]) -> None: - _binary.StreamSerializer(_binary.int32_serializer).write(self._stream, value) + def _write_fixed_int_vector(self, value: list[yardl.Int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FixedIntVector", pos) + _binary.FixedVectorSerializer(_binary.int32_serializer, 5).write(self._stream, value) - def _write_optional_int_data(self, value: collections.abc.Iterable[typing.Optional[yardl.Int32]]) -> None: - _binary.StreamSerializer(_binary.OptionalSerializer(_binary.int32_serializer)).write(self._stream, value) + def _write_fixed_simple_record_vector(self, value: list[SimpleRecord]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FixedSimpleRecordVector", pos) + _binary.FixedVectorSerializer(SimpleRecordSerializer(), 3).write(self._stream, value) - def _write_record_with_optional_vector_data(self, value: collections.abc.Iterable[RecordWithOptionalVector]) -> None: + def _write_fixed_record_with_vlens_vector(self, value: list[RecordWithVlens]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FixedRecordWithVlensVector", pos) + _binary.FixedVectorSerializer(RecordWithVlensSerializer(), 2).write(self._stream, value) + + def _write_record_with_fixed_vectors(self, value: RecordWithFixedVectors) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithFixedVectors", pos) + RecordWithFixedVectorsSerializer().write(self._stream, value) + + +class BinaryFixedVectorsIndexedReader(_binary.BinaryProtocolIndexedReader, FixedVectorsIndexedReaderBase): + """Binary indexed writer for the FixedVectors protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + FixedVectorsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, FixedVectorsIndexedReaderBase.schema) + + def _read_fixed_int_vector(self) -> list[yardl.Int32]: + pos = self._index.get_step_offset("FixedIntVector") + self._stream.seek(pos) + return _binary.FixedVectorSerializer(_binary.int32_serializer, 5).read(self._stream) + + def _read_fixed_simple_record_vector(self) -> list[SimpleRecord]: + pos = self._index.get_step_offset("FixedSimpleRecordVector") + self._stream.seek(pos) + return _binary.FixedVectorSerializer(SimpleRecordSerializer(), 3).read(self._stream) + + def _read_fixed_record_with_vlens_vector(self) -> list[RecordWithVlens]: + pos = self._index.get_step_offset("FixedRecordWithVlensVector") + self._stream.seek(pos) + return _binary.FixedVectorSerializer(RecordWithVlensSerializer(), 2).read(self._stream) + + def _read_record_with_fixed_vectors(self) -> RecordWithFixedVectors: + pos = self._index.get_step_offset("RecordWithFixedVectors") + self._stream.seek(pos) + return RecordWithFixedVectorsSerializer().read(self._stream) + +class BinaryStreamsWriter(_binary.BinaryProtocolWriter, StreamsWriterBase): + """Binary writer for the Streams protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + StreamsWriterBase.__init__(self) + _binary.BinaryProtocolWriter.__init__(self, stream, StreamsWriterBase.schema) + + def _write_int_data(self, value: collections.abc.Iterable[yardl.Int32]) -> None: + _binary.StreamSerializer(_binary.int32_serializer).write(self._stream, value) + + def _write_optional_int_data(self, value: collections.abc.Iterable[typing.Optional[yardl.Int32]]) -> None: + _binary.StreamSerializer(_binary.OptionalSerializer(_binary.int32_serializer)).write(self._stream, value) + + def _write_record_with_optional_vector_data(self, value: collections.abc.Iterable[RecordWithOptionalVector]) -> None: _binary.StreamSerializer(RecordWithOptionalVectorSerializer()).write(self._stream, value) def _write_fixed_vector(self, value: collections.abc.Iterable[list[yardl.Int32]]) -> None: @@ -408,7 +853,6 @@ def _write_fixed_vector(self, value: collections.abc.Iterable[list[yardl.Int32]] class BinaryStreamsReader(_binary.BinaryProtocolReader, StreamsReaderBase): """Binary writer for the Streams protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: StreamsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, StreamsReaderBase.schema) @@ -425,10 +869,81 @@ def _read_record_with_optional_vector_data(self) -> collections.abc.Iterable[Rec def _read_fixed_vector(self) -> collections.abc.Iterable[list[yardl.Int32]]: return _binary.StreamSerializer(_binary.FixedVectorSerializer(_binary.int32_serializer, 3)).read(self._stream) + +class BinaryStreamsIndexedWriter(_binary.BinaryProtocolIndexedWriter, StreamsWriterBase): + """Binary indexed writer for the Streams protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + StreamsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, StreamsWriterBase.schema) + + def _write_int_data(self, value: collections.abc.Iterable[yardl.Int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntData", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.int32_serializer).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("IntData", offsets, num_blocks) + + def _write_optional_int_data(self, value: collections.abc.Iterable[typing.Optional[yardl.Int32]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("OptionalIntData", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.OptionalSerializer(_binary.int32_serializer)).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("OptionalIntData", offsets, num_blocks) + + def _write_record_with_optional_vector_data(self, value: collections.abc.Iterable[RecordWithOptionalVector]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithOptionalVectorData", pos) + offsets, num_blocks = _binary.StreamSerializer(RecordWithOptionalVectorSerializer()).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("RecordWithOptionalVectorData", offsets, num_blocks) + + def _write_fixed_vector(self, value: collections.abc.Iterable[list[yardl.Int32]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FixedVector", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.FixedVectorSerializer(_binary.int32_serializer, 3)).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("FixedVector", offsets, num_blocks) + + +class BinaryStreamsIndexedReader(_binary.BinaryProtocolIndexedReader, StreamsIndexedReaderBase): + """Binary indexed writer for the Streams protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + StreamsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, StreamsIndexedReaderBase.schema) + + def _read_int_data(self, idx: int) -> collections.abc.Iterable[yardl.Int32]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("IntData", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.int32_serializer).read_mid_stream(self._stream, remaining) + + def _count_int_data(self) -> int: + return self._index.get_stream_size("IntData") + + def _read_optional_int_data(self, idx: int) -> collections.abc.Iterable[typing.Optional[yardl.Int32]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("OptionalIntData", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.OptionalSerializer(_binary.int32_serializer)).read_mid_stream(self._stream, remaining) + + def _count_optional_int_data(self) -> int: + return self._index.get_stream_size("OptionalIntData") + + def _read_record_with_optional_vector_data(self, idx: int) -> collections.abc.Iterable[RecordWithOptionalVector]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("RecordWithOptionalVectorData", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(RecordWithOptionalVectorSerializer()).read_mid_stream(self._stream, remaining) + + def _count_record_with_optional_vector_data(self) -> int: + return self._index.get_stream_size("RecordWithOptionalVectorData") + + def _read_fixed_vector(self, idx: int) -> collections.abc.Iterable[list[yardl.Int32]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("FixedVector", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.FixedVectorSerializer(_binary.int32_serializer, 3)).read_mid_stream(self._stream, remaining) + + def _count_fixed_vector(self) -> int: + return self._index.get_stream_size("FixedVector") + class BinaryFixedArraysWriter(_binary.BinaryProtocolWriter, FixedArraysWriterBase): """Binary writer for the FixedArrays protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: FixedArraysWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, FixedArraysWriterBase.schema) @@ -452,7 +967,6 @@ def _write_named_array(self, value: NamedFixedNDArray) -> None: class BinaryFixedArraysReader(_binary.BinaryProtocolReader, FixedArraysReaderBase): """Binary writer for the FixedArrays protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: FixedArraysReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, FixedArraysReaderBase.schema) @@ -472,10 +986,75 @@ def _read_record_with_fixed_arrays(self) -> RecordWithFixedArrays: def _read_named_array(self) -> NamedFixedNDArray: return _binary.FixedNDArraySerializer(_binary.int32_serializer, (2, 4,)).read(self._stream) + +class BinaryFixedArraysIndexedWriter(_binary.BinaryProtocolIndexedWriter, FixedArraysWriterBase): + """Binary indexed writer for the FixedArrays protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + FixedArraysWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, FixedArraysWriterBase.schema) + + def _write_ints(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Ints", pos) + _binary.FixedNDArraySerializer(_binary.int32_serializer, (2, 3,)).write(self._stream, value) + + def _write_fixed_simple_record_array(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FixedSimpleRecordArray", pos) + _binary.FixedNDArraySerializer(SimpleRecordSerializer(), (3, 2,)).write(self._stream, value) + + def _write_fixed_record_with_vlens_array(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FixedRecordWithVlensArray", pos) + _binary.FixedNDArraySerializer(RecordWithVlensSerializer(), (2, 2,)).write(self._stream, value) + + def _write_record_with_fixed_arrays(self, value: RecordWithFixedArrays) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithFixedArrays", pos) + RecordWithFixedArraysSerializer().write(self._stream, value) + + def _write_named_array(self, value: NamedFixedNDArray) -> None: + pos = self._stream.pos() + self._index.set_step_offset("NamedArray", pos) + _binary.FixedNDArraySerializer(_binary.int32_serializer, (2, 4,)).write(self._stream, value) + + +class BinaryFixedArraysIndexedReader(_binary.BinaryProtocolIndexedReader, FixedArraysIndexedReaderBase): + """Binary indexed writer for the FixedArrays protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + FixedArraysIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, FixedArraysIndexedReaderBase.schema) + + def _read_ints(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("Ints") + self._stream.seek(pos) + return _binary.FixedNDArraySerializer(_binary.int32_serializer, (2, 3,)).read(self._stream) + + def _read_fixed_simple_record_array(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("FixedSimpleRecordArray") + self._stream.seek(pos) + return _binary.FixedNDArraySerializer(SimpleRecordSerializer(), (3, 2,)).read(self._stream) + + def _read_fixed_record_with_vlens_array(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("FixedRecordWithVlensArray") + self._stream.seek(pos) + return _binary.FixedNDArraySerializer(RecordWithVlensSerializer(), (2, 2,)).read(self._stream) + + def _read_record_with_fixed_arrays(self) -> RecordWithFixedArrays: + pos = self._index.get_step_offset("RecordWithFixedArrays") + self._stream.seek(pos) + return RecordWithFixedArraysSerializer().read(self._stream) + + def _read_named_array(self) -> NamedFixedNDArray: + pos = self._index.get_step_offset("NamedArray") + self._stream.seek(pos) + return _binary.FixedNDArraySerializer(_binary.int32_serializer, (2, 4,)).read(self._stream) + class BinarySubarraysWriter(_binary.BinaryProtocolWriter, SubarraysWriterBase): """Binary writer for the Subarrays protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: SubarraysWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, SubarraysWriterBase.schema) @@ -511,7 +1090,6 @@ def _write_generic_subarray(self, value: Image[np.int32]) -> None: class BinarySubarraysReader(_binary.BinaryProtocolReader, SubarraysReaderBase): """Binary writer for the Subarrays protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: SubarraysReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, SubarraysReaderBase.schema) @@ -543,10 +1121,115 @@ def _read_dynamic_with_fixed_vector_subarray(self) -> npt.NDArray[np.int32]: def _read_generic_subarray(self) -> Image[np.int32]: return _binary.NDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), 2).read(self._stream) + +class BinarySubarraysIndexedWriter(_binary.BinaryProtocolIndexedWriter, SubarraysWriterBase): + """Binary indexed writer for the Subarrays protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + SubarraysWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, SubarraysWriterBase.schema) + + def _write_dynamic_with_fixed_int_subarray(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("DynamicWithFixedIntSubarray", pos) + _binary.DynamicNDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,))).write(self._stream, value) + + def _write_dynamic_with_fixed_float_subarray(self, value: npt.NDArray[np.float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("DynamicWithFixedFloatSubarray", pos) + _binary.DynamicNDArraySerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))).write(self._stream, value) + + def _write_known_dim_count_with_fixed_int_subarray(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("KnownDimCountWithFixedIntSubarray", pos) + _binary.NDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), 1).write(self._stream, value) + + def _write_known_dim_count_with_fixed_float_subarray(self, value: npt.NDArray[np.float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("KnownDimCountWithFixedFloatSubarray", pos) + _binary.NDArraySerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (3,)), 1).write(self._stream, value) + + def _write_fixed_with_fixed_int_subarray(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FixedWithFixedIntSubarray", pos) + _binary.FixedNDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), (2,)).write(self._stream, value) + + def _write_fixed_with_fixed_float_subarray(self, value: npt.NDArray[np.float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FixedWithFixedFloatSubarray", pos) + _binary.FixedNDArraySerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (3,)), (2,)).write(self._stream, value) + + def _write_nested_subarray(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("NestedSubarray", pos) + _binary.DynamicNDArraySerializer(_binary.FixedNDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), (2,))).write(self._stream, value) + + def _write_dynamic_with_fixed_vector_subarray(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("DynamicWithFixedVectorSubarray", pos) + _binary.DynamicNDArraySerializer(_binary.FixedVectorSerializer(_binary.int32_serializer, 3)).write(self._stream, value) + + def _write_generic_subarray(self, value: Image[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("GenericSubarray", pos) + _binary.NDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), 2).write(self._stream, value) + + +class BinarySubarraysIndexedReader(_binary.BinaryProtocolIndexedReader, SubarraysIndexedReaderBase): + """Binary indexed writer for the Subarrays protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + SubarraysIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, SubarraysIndexedReaderBase.schema) + + def _read_dynamic_with_fixed_int_subarray(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("DynamicWithFixedIntSubarray") + self._stream.seek(pos) + return _binary.DynamicNDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,))).read(self._stream) + + def _read_dynamic_with_fixed_float_subarray(self) -> npt.NDArray[np.float32]: + pos = self._index.get_step_offset("DynamicWithFixedFloatSubarray") + self._stream.seek(pos) + return _binary.DynamicNDArraySerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))).read(self._stream) + + def _read_known_dim_count_with_fixed_int_subarray(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("KnownDimCountWithFixedIntSubarray") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), 1).read(self._stream) + + def _read_known_dim_count_with_fixed_float_subarray(self) -> npt.NDArray[np.float32]: + pos = self._index.get_step_offset("KnownDimCountWithFixedFloatSubarray") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (3,)), 1).read(self._stream) + + def _read_fixed_with_fixed_int_subarray(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("FixedWithFixedIntSubarray") + self._stream.seek(pos) + return _binary.FixedNDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), (2,)).read(self._stream) + + def _read_fixed_with_fixed_float_subarray(self) -> npt.NDArray[np.float32]: + pos = self._index.get_step_offset("FixedWithFixedFloatSubarray") + self._stream.seek(pos) + return _binary.FixedNDArraySerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (3,)), (2,)).read(self._stream) + + def _read_nested_subarray(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("NestedSubarray") + self._stream.seek(pos) + return _binary.DynamicNDArraySerializer(_binary.FixedNDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), (2,))).read(self._stream) + + def _read_dynamic_with_fixed_vector_subarray(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("DynamicWithFixedVectorSubarray") + self._stream.seek(pos) + return _binary.DynamicNDArraySerializer(_binary.FixedVectorSerializer(_binary.int32_serializer, 3)).read(self._stream) + + def _read_generic_subarray(self) -> Image[np.int32]: + pos = self._index.get_step_offset("GenericSubarray") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.FixedNDArraySerializer(_binary.int32_serializer, (3,)), 2).read(self._stream) + class BinarySubarraysInRecordsWriter(_binary.BinaryProtocolWriter, SubarraysInRecordsWriterBase): """Binary writer for the SubarraysInRecords protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: SubarraysInRecordsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, SubarraysInRecordsWriterBase.schema) @@ -561,7 +1244,6 @@ def _write_with_vlen_subarrays(self, value: npt.NDArray[np.void]) -> None: class BinarySubarraysInRecordsReader(_binary.BinaryProtocolReader, SubarraysInRecordsReaderBase): """Binary writer for the SubarraysInRecords protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: SubarraysInRecordsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, SubarraysInRecordsReaderBase.schema) @@ -572,10 +1254,45 @@ def _read_with_fixed_subarrays(self) -> npt.NDArray[np.void]: def _read_with_vlen_subarrays(self) -> npt.NDArray[np.void]: return _binary.DynamicNDArraySerializer(RecordWithVlenCollectionsSerializer()).read(self._stream) + +class BinarySubarraysInRecordsIndexedWriter(_binary.BinaryProtocolIndexedWriter, SubarraysInRecordsWriterBase): + """Binary indexed writer for the SubarraysInRecords protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + SubarraysInRecordsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, SubarraysInRecordsWriterBase.schema) + + def _write_with_fixed_subarrays(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("WithFixedSubarrays", pos) + _binary.DynamicNDArraySerializer(RecordWithFixedCollectionsSerializer()).write(self._stream, value) + + def _write_with_vlen_subarrays(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("WithVlenSubarrays", pos) + _binary.DynamicNDArraySerializer(RecordWithVlenCollectionsSerializer()).write(self._stream, value) + + +class BinarySubarraysInRecordsIndexedReader(_binary.BinaryProtocolIndexedReader, SubarraysInRecordsIndexedReaderBase): + """Binary indexed writer for the SubarraysInRecords protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + SubarraysInRecordsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, SubarraysInRecordsIndexedReaderBase.schema) + + def _read_with_fixed_subarrays(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("WithFixedSubarrays") + self._stream.seek(pos) + return _binary.DynamicNDArraySerializer(RecordWithFixedCollectionsSerializer()).read(self._stream) + + def _read_with_vlen_subarrays(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("WithVlenSubarrays") + self._stream.seek(pos) + return _binary.DynamicNDArraySerializer(RecordWithVlenCollectionsSerializer()).read(self._stream) + class BinaryNDArraysWriter(_binary.BinaryProtocolWriter, NDArraysWriterBase): """Binary writer for the NDArrays protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: NDArraysWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, NDArraysWriterBase.schema) @@ -599,7 +1316,6 @@ def _write_named_array(self, value: NamedNDArray) -> None: class BinaryNDArraysReader(_binary.BinaryProtocolReader, NDArraysReaderBase): """Binary writer for the NDArrays protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: NDArraysReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, NDArraysReaderBase.schema) @@ -619,10 +1335,75 @@ def _read_record_with_nd_arrays(self) -> RecordWithNDArrays: def _read_named_array(self) -> NamedNDArray: return _binary.NDArraySerializer(_binary.int32_serializer, 2).read(self._stream) + +class BinaryNDArraysIndexedWriter(_binary.BinaryProtocolIndexedWriter, NDArraysWriterBase): + """Binary indexed writer for the NDArrays protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + NDArraysWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, NDArraysWriterBase.schema) + + def _write_ints(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Ints", pos) + _binary.NDArraySerializer(_binary.int32_serializer, 2).write(self._stream, value) + + def _write_simple_record_array(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("SimpleRecordArray", pos) + _binary.NDArraySerializer(SimpleRecordSerializer(), 2).write(self._stream, value) + + def _write_record_with_vlens_array(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithVlensArray", pos) + _binary.NDArraySerializer(RecordWithVlensSerializer(), 2).write(self._stream, value) + + def _write_record_with_nd_arrays(self, value: RecordWithNDArrays) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithNDArrays", pos) + RecordWithNDArraysSerializer().write(self._stream, value) + + def _write_named_array(self, value: NamedNDArray) -> None: + pos = self._stream.pos() + self._index.set_step_offset("NamedArray", pos) + _binary.NDArraySerializer(_binary.int32_serializer, 2).write(self._stream, value) + + +class BinaryNDArraysIndexedReader(_binary.BinaryProtocolIndexedReader, NDArraysIndexedReaderBase): + """Binary indexed writer for the NDArrays protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + NDArraysIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, NDArraysIndexedReaderBase.schema) + + def _read_ints(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("Ints") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.int32_serializer, 2).read(self._stream) + + def _read_simple_record_array(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("SimpleRecordArray") + self._stream.seek(pos) + return _binary.NDArraySerializer(SimpleRecordSerializer(), 2).read(self._stream) + + def _read_record_with_vlens_array(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("RecordWithVlensArray") + self._stream.seek(pos) + return _binary.NDArraySerializer(RecordWithVlensSerializer(), 2).read(self._stream) + + def _read_record_with_nd_arrays(self) -> RecordWithNDArrays: + pos = self._index.get_step_offset("RecordWithNDArrays") + self._stream.seek(pos) + return RecordWithNDArraysSerializer().read(self._stream) + + def _read_named_array(self) -> NamedNDArray: + pos = self._index.get_step_offset("NamedArray") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.int32_serializer, 2).read(self._stream) + class BinaryNDArraysSingleDimensionWriter(_binary.BinaryProtocolWriter, NDArraysSingleDimensionWriterBase): """Binary writer for the NDArraysSingleDimension protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: NDArraysSingleDimensionWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, NDArraysSingleDimensionWriterBase.schema) @@ -640,71 +1421,179 @@ def _write_record_with_nd_arrays(self, value: RecordWithNDArraysSingleDimension) RecordWithNDArraysSingleDimensionSerializer().write(self._stream, value) -class BinaryNDArraysSingleDimensionReader(_binary.BinaryProtocolReader, NDArraysSingleDimensionReaderBase): - """Binary writer for the NDArraysSingleDimension protocol.""" +class BinaryNDArraysSingleDimensionReader(_binary.BinaryProtocolReader, NDArraysSingleDimensionReaderBase): + """Binary writer for the NDArraysSingleDimension protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + NDArraysSingleDimensionReaderBase.__init__(self) + _binary.BinaryProtocolReader.__init__(self, stream, NDArraysSingleDimensionReaderBase.schema) + + def _read_ints(self) -> npt.NDArray[np.int32]: + return _binary.NDArraySerializer(_binary.int32_serializer, 1).read(self._stream) + + def _read_simple_record_array(self) -> npt.NDArray[np.void]: + return _binary.NDArraySerializer(SimpleRecordSerializer(), 1).read(self._stream) + + def _read_record_with_vlens_array(self) -> npt.NDArray[np.void]: + return _binary.NDArraySerializer(RecordWithVlensSerializer(), 1).read(self._stream) + + def _read_record_with_nd_arrays(self) -> RecordWithNDArraysSingleDimension: + return RecordWithNDArraysSingleDimensionSerializer().read(self._stream) + + +class BinaryNDArraysSingleDimensionIndexedWriter(_binary.BinaryProtocolIndexedWriter, NDArraysSingleDimensionWriterBase): + """Binary indexed writer for the NDArraysSingleDimension protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + NDArraysSingleDimensionWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, NDArraysSingleDimensionWriterBase.schema) + + def _write_ints(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Ints", pos) + _binary.NDArraySerializer(_binary.int32_serializer, 1).write(self._stream, value) + + def _write_simple_record_array(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("SimpleRecordArray", pos) + _binary.NDArraySerializer(SimpleRecordSerializer(), 1).write(self._stream, value) + + def _write_record_with_vlens_array(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithVlensArray", pos) + _binary.NDArraySerializer(RecordWithVlensSerializer(), 1).write(self._stream, value) + + def _write_record_with_nd_arrays(self, value: RecordWithNDArraysSingleDimension) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithNDArrays", pos) + RecordWithNDArraysSingleDimensionSerializer().write(self._stream, value) + + +class BinaryNDArraysSingleDimensionIndexedReader(_binary.BinaryProtocolIndexedReader, NDArraysSingleDimensionIndexedReaderBase): + """Binary indexed writer for the NDArraysSingleDimension protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + NDArraysSingleDimensionIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, NDArraysSingleDimensionIndexedReaderBase.schema) + + def _read_ints(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("Ints") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.int32_serializer, 1).read(self._stream) + + def _read_simple_record_array(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("SimpleRecordArray") + self._stream.seek(pos) + return _binary.NDArraySerializer(SimpleRecordSerializer(), 1).read(self._stream) + + def _read_record_with_vlens_array(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("RecordWithVlensArray") + self._stream.seek(pos) + return _binary.NDArraySerializer(RecordWithVlensSerializer(), 1).read(self._stream) + + def _read_record_with_nd_arrays(self) -> RecordWithNDArraysSingleDimension: + pos = self._index.get_step_offset("RecordWithNDArrays") + self._stream.seek(pos) + return RecordWithNDArraysSingleDimensionSerializer().read(self._stream) + +class BinaryDynamicNDArraysWriter(_binary.BinaryProtocolWriter, DynamicNDArraysWriterBase): + """Binary writer for the DynamicNDArrays protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + DynamicNDArraysWriterBase.__init__(self) + _binary.BinaryProtocolWriter.__init__(self, stream, DynamicNDArraysWriterBase.schema) + + def _write_ints(self, value: npt.NDArray[np.int32]) -> None: + _binary.DynamicNDArraySerializer(_binary.int32_serializer).write(self._stream, value) + + def _write_simple_record_array(self, value: npt.NDArray[np.void]) -> None: + _binary.DynamicNDArraySerializer(SimpleRecordSerializer()).write(self._stream, value) + + def _write_record_with_vlens_array(self, value: npt.NDArray[np.void]) -> None: + _binary.DynamicNDArraySerializer(RecordWithVlensSerializer()).write(self._stream, value) + + def _write_record_with_dynamic_nd_arrays(self, value: RecordWithDynamicNDArrays) -> None: + RecordWithDynamicNDArraysSerializer().write(self._stream, value) + +class BinaryDynamicNDArraysReader(_binary.BinaryProtocolReader, DynamicNDArraysReaderBase): + """Binary writer for the DynamicNDArrays protocol.""" def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: - NDArraysSingleDimensionReaderBase.__init__(self) - _binary.BinaryProtocolReader.__init__(self, stream, NDArraysSingleDimensionReaderBase.schema) + DynamicNDArraysReaderBase.__init__(self) + _binary.BinaryProtocolReader.__init__(self, stream, DynamicNDArraysReaderBase.schema) def _read_ints(self) -> npt.NDArray[np.int32]: - return _binary.NDArraySerializer(_binary.int32_serializer, 1).read(self._stream) + return _binary.DynamicNDArraySerializer(_binary.int32_serializer).read(self._stream) def _read_simple_record_array(self) -> npt.NDArray[np.void]: - return _binary.NDArraySerializer(SimpleRecordSerializer(), 1).read(self._stream) + return _binary.DynamicNDArraySerializer(SimpleRecordSerializer()).read(self._stream) def _read_record_with_vlens_array(self) -> npt.NDArray[np.void]: - return _binary.NDArraySerializer(RecordWithVlensSerializer(), 1).read(self._stream) + return _binary.DynamicNDArraySerializer(RecordWithVlensSerializer()).read(self._stream) - def _read_record_with_nd_arrays(self) -> RecordWithNDArraysSingleDimension: - return RecordWithNDArraysSingleDimensionSerializer().read(self._stream) + def _read_record_with_dynamic_nd_arrays(self) -> RecordWithDynamicNDArrays: + return RecordWithDynamicNDArraysSerializer().read(self._stream) -class BinaryDynamicNDArraysWriter(_binary.BinaryProtocolWriter, DynamicNDArraysWriterBase): - """Binary writer for the DynamicNDArrays protocol.""" +class BinaryDynamicNDArraysIndexedWriter(_binary.BinaryProtocolIndexedWriter, DynamicNDArraysWriterBase): + """Binary indexed writer for the DynamicNDArrays protocol.""" def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: DynamicNDArraysWriterBase.__init__(self) - _binary.BinaryProtocolWriter.__init__(self, stream, DynamicNDArraysWriterBase.schema) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, DynamicNDArraysWriterBase.schema) def _write_ints(self, value: npt.NDArray[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Ints", pos) _binary.DynamicNDArraySerializer(_binary.int32_serializer).write(self._stream, value) def _write_simple_record_array(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("SimpleRecordArray", pos) _binary.DynamicNDArraySerializer(SimpleRecordSerializer()).write(self._stream, value) def _write_record_with_vlens_array(self, value: npt.NDArray[np.void]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithVlensArray", pos) _binary.DynamicNDArraySerializer(RecordWithVlensSerializer()).write(self._stream, value) def _write_record_with_dynamic_nd_arrays(self, value: RecordWithDynamicNDArrays) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithDynamicNDArrays", pos) RecordWithDynamicNDArraysSerializer().write(self._stream, value) -class BinaryDynamicNDArraysReader(_binary.BinaryProtocolReader, DynamicNDArraysReaderBase): - """Binary writer for the DynamicNDArrays protocol.""" - +class BinaryDynamicNDArraysIndexedReader(_binary.BinaryProtocolIndexedReader, DynamicNDArraysIndexedReaderBase): + """Binary indexed writer for the DynamicNDArrays protocol.""" def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: - DynamicNDArraysReaderBase.__init__(self) - _binary.BinaryProtocolReader.__init__(self, stream, DynamicNDArraysReaderBase.schema) + DynamicNDArraysIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, DynamicNDArraysIndexedReaderBase.schema) def _read_ints(self) -> npt.NDArray[np.int32]: + pos = self._index.get_step_offset("Ints") + self._stream.seek(pos) return _binary.DynamicNDArraySerializer(_binary.int32_serializer).read(self._stream) def _read_simple_record_array(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("SimpleRecordArray") + self._stream.seek(pos) return _binary.DynamicNDArraySerializer(SimpleRecordSerializer()).read(self._stream) def _read_record_with_vlens_array(self) -> npt.NDArray[np.void]: + pos = self._index.get_step_offset("RecordWithVlensArray") + self._stream.seek(pos) return _binary.DynamicNDArraySerializer(RecordWithVlensSerializer()).read(self._stream) def _read_record_with_dynamic_nd_arrays(self) -> RecordWithDynamicNDArrays: + pos = self._index.get_step_offset("RecordWithDynamicNDArrays") + self._stream.seek(pos) return RecordWithDynamicNDArraysSerializer().read(self._stream) class BinaryMultiDArraysWriter(_binary.BinaryProtocolWriter, MultiDArraysWriterBase): """Binary writer for the MultiDArrays protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: MultiDArraysWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, MultiDArraysWriterBase.schema) @@ -719,7 +1608,6 @@ def _write_frames(self, value: collections.abc.Iterable[npt.NDArray[np.float32]] class BinaryMultiDArraysReader(_binary.BinaryProtocolReader, MultiDArraysReaderBase): """Binary writer for the MultiDArrays protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: MultiDArraysReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, MultiDArraysReaderBase.schema) @@ -730,10 +1618,53 @@ def _read_images(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: def _read_frames(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: return _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (1, 1, 64, 32,))).read(self._stream) + +class BinaryMultiDArraysIndexedWriter(_binary.BinaryProtocolIndexedWriter, MultiDArraysWriterBase): + """Binary indexed writer for the MultiDArrays protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + MultiDArraysWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, MultiDArraysWriterBase.schema) + + def _write_images(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Images", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.NDArraySerializer(_binary.float32_serializer, 4)).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("Images", offsets, num_blocks) + + def _write_frames(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Frames", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (1, 1, 64, 32,))).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("Frames", offsets, num_blocks) + + +class BinaryMultiDArraysIndexedReader(_binary.BinaryProtocolIndexedReader, MultiDArraysIndexedReaderBase): + """Binary indexed writer for the MultiDArrays protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + MultiDArraysIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, MultiDArraysIndexedReaderBase.schema) + + def _read_images(self, idx: int) -> collections.abc.Iterable[npt.NDArray[np.float32]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("Images", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.NDArraySerializer(_binary.float32_serializer, 4)).read_mid_stream(self._stream, remaining) + + def _count_images(self) -> int: + return self._index.get_stream_size("Images") + + def _read_frames(self, idx: int) -> collections.abc.Iterable[npt.NDArray[np.float32]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("Frames", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (1, 1, 64, 32,))).read_mid_stream(self._stream, remaining) + + def _count_frames(self) -> int: + return self._index.get_stream_size("Frames") + class BinaryComplexArraysWriter(_binary.BinaryProtocolWriter, ComplexArraysWriterBase): """Binary writer for the ComplexArrays protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: ComplexArraysWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, ComplexArraysWriterBase.schema) @@ -748,7 +1679,6 @@ def _write_doubles(self, value: npt.NDArray[np.complex128]) -> None: class BinaryComplexArraysReader(_binary.BinaryProtocolReader, ComplexArraysReaderBase): """Binary writer for the ComplexArrays protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: ComplexArraysReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, ComplexArraysReaderBase.schema) @@ -759,10 +1689,45 @@ def _read_floats(self) -> npt.NDArray[np.complex64]: def _read_doubles(self) -> npt.NDArray[np.complex128]: return _binary.NDArraySerializer(_binary.complexfloat64_serializer, 2).read(self._stream) + +class BinaryComplexArraysIndexedWriter(_binary.BinaryProtocolIndexedWriter, ComplexArraysWriterBase): + """Binary indexed writer for the ComplexArrays protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + ComplexArraysWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, ComplexArraysWriterBase.schema) + + def _write_floats(self, value: npt.NDArray[np.complex64]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Floats", pos) + _binary.DynamicNDArraySerializer(_binary.complexfloat32_serializer).write(self._stream, value) + + def _write_doubles(self, value: npt.NDArray[np.complex128]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Doubles", pos) + _binary.NDArraySerializer(_binary.complexfloat64_serializer, 2).write(self._stream, value) + + +class BinaryComplexArraysIndexedReader(_binary.BinaryProtocolIndexedReader, ComplexArraysIndexedReaderBase): + """Binary indexed writer for the ComplexArrays protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + ComplexArraysIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, ComplexArraysIndexedReaderBase.schema) + + def _read_floats(self) -> npt.NDArray[np.complex64]: + pos = self._index.get_step_offset("Floats") + self._stream.seek(pos) + return _binary.DynamicNDArraySerializer(_binary.complexfloat32_serializer).read(self._stream) + + def _read_doubles(self) -> npt.NDArray[np.complex128]: + pos = self._index.get_step_offset("Doubles") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.complexfloat64_serializer, 2).read(self._stream) + class BinaryMapsWriter(_binary.BinaryProtocolWriter, MapsWriterBase): """Binary writer for the Maps protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: MapsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, MapsWriterBase.schema) @@ -786,7 +1751,6 @@ def _write_records(self, value: list[RecordWithMaps]) -> None: class BinaryMapsReader(_binary.BinaryProtocolReader, MapsReaderBase): """Binary writer for the Maps protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: MapsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, MapsReaderBase.schema) @@ -806,10 +1770,75 @@ def _read_aliased_generic(self) -> basic_types.AliasedMap[str, yardl.Int32]: def _read_records(self) -> list[RecordWithMaps]: return _binary.VectorSerializer(RecordWithMapsSerializer()).read(self._stream) + +class BinaryMapsIndexedWriter(_binary.BinaryProtocolIndexedWriter, MapsWriterBase): + """Binary indexed writer for the Maps protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + MapsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, MapsWriterBase.schema) + + def _write_string_to_int(self, value: dict[str, yardl.Int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("StringToInt", pos) + _binary.MapSerializer(_binary.string_serializer, _binary.int32_serializer).write(self._stream, value) + + def _write_int_to_string(self, value: dict[yardl.Int32, str]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntToString", pos) + _binary.MapSerializer(_binary.int32_serializer, _binary.string_serializer).write(self._stream, value) + + def _write_string_to_union(self, value: dict[str, StringOrInt32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("StringToUnion", pos) + _binary.MapSerializer(_binary.string_serializer, _binary.UnionSerializer(StringOrInt32, [(StringOrInt32.String, _binary.string_serializer), (StringOrInt32.Int32, _binary.int32_serializer)])).write(self._stream, value) + + def _write_aliased_generic(self, value: basic_types.AliasedMap[str, yardl.Int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedGeneric", pos) + _binary.MapSerializer(_binary.string_serializer, _binary.int32_serializer).write(self._stream, value) + + def _write_records(self, value: list[RecordWithMaps]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Records", pos) + _binary.VectorSerializer(RecordWithMapsSerializer()).write(self._stream, value) + + +class BinaryMapsIndexedReader(_binary.BinaryProtocolIndexedReader, MapsIndexedReaderBase): + """Binary indexed writer for the Maps protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + MapsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, MapsIndexedReaderBase.schema) + + def _read_string_to_int(self) -> dict[str, yardl.Int32]: + pos = self._index.get_step_offset("StringToInt") + self._stream.seek(pos) + return _binary.MapSerializer(_binary.string_serializer, _binary.int32_serializer).read(self._stream) + + def _read_int_to_string(self) -> dict[yardl.Int32, str]: + pos = self._index.get_step_offset("IntToString") + self._stream.seek(pos) + return _binary.MapSerializer(_binary.int32_serializer, _binary.string_serializer).read(self._stream) + + def _read_string_to_union(self) -> dict[str, StringOrInt32]: + pos = self._index.get_step_offset("StringToUnion") + self._stream.seek(pos) + return _binary.MapSerializer(_binary.string_serializer, _binary.UnionSerializer(StringOrInt32, [(StringOrInt32.String, _binary.string_serializer), (StringOrInt32.Int32, _binary.int32_serializer)])).read(self._stream) + + def _read_aliased_generic(self) -> basic_types.AliasedMap[str, yardl.Int32]: + pos = self._index.get_step_offset("AliasedGeneric") + self._stream.seek(pos) + return _binary.MapSerializer(_binary.string_serializer, _binary.int32_serializer).read(self._stream) + + def _read_records(self) -> list[RecordWithMaps]: + pos = self._index.get_step_offset("Records") + self._stream.seek(pos) + return _binary.VectorSerializer(RecordWithMapsSerializer()).read(self._stream) + class BinaryUnionsWriter(_binary.BinaryProtocolWriter, UnionsWriterBase): """Binary writer for the Unions protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: UnionsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, UnionsWriterBase.schema) @@ -830,7 +1859,6 @@ def _write_record_with_unions(self, value: basic_types.RecordWithUnions) -> None class BinaryUnionsReader(_binary.BinaryProtocolReader, UnionsReaderBase): """Binary writer for the Unions protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: UnionsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, UnionsReaderBase.schema) @@ -847,10 +1875,65 @@ def _read_monosotate_or_int_or_simple_record(self) -> typing.Optional[Int32OrSim def _read_record_with_unions(self) -> basic_types.RecordWithUnions: return basic_types.binary.RecordWithUnionsSerializer().read(self._stream) + +class BinaryUnionsIndexedWriter(_binary.BinaryProtocolIndexedWriter, UnionsWriterBase): + """Binary indexed writer for the Unions protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + UnionsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, UnionsWriterBase.schema) + + def _write_int_or_simple_record(self, value: Int32OrSimpleRecord) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntOrSimpleRecord", pos) + _binary.UnionSerializer(Int32OrSimpleRecord, [(Int32OrSimpleRecord.Int32, _binary.int32_serializer), (Int32OrSimpleRecord.SimpleRecord, SimpleRecordSerializer())]).write(self._stream, value) + + def _write_int_or_record_with_vlens(self, value: Int32OrRecordWithVlens) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntOrRecordWithVlens", pos) + _binary.UnionSerializer(Int32OrRecordWithVlens, [(Int32OrRecordWithVlens.Int32, _binary.int32_serializer), (Int32OrRecordWithVlens.RecordWithVlens, RecordWithVlensSerializer())]).write(self._stream, value) + + def _write_monosotate_or_int_or_simple_record(self, value: typing.Optional[Int32OrSimpleRecord]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("MonosotateOrIntOrSimpleRecord", pos) + _binary.UnionSerializer(Int32OrSimpleRecord, [None, (Int32OrSimpleRecord.Int32, _binary.int32_serializer), (Int32OrSimpleRecord.SimpleRecord, SimpleRecordSerializer())]).write(self._stream, value) + + def _write_record_with_unions(self, value: basic_types.RecordWithUnions) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithUnions", pos) + basic_types.binary.RecordWithUnionsSerializer().write(self._stream, value) + + +class BinaryUnionsIndexedReader(_binary.BinaryProtocolIndexedReader, UnionsIndexedReaderBase): + """Binary indexed writer for the Unions protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + UnionsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, UnionsIndexedReaderBase.schema) + + def _read_int_or_simple_record(self) -> Int32OrSimpleRecord: + pos = self._index.get_step_offset("IntOrSimpleRecord") + self._stream.seek(pos) + return _binary.UnionSerializer(Int32OrSimpleRecord, [(Int32OrSimpleRecord.Int32, _binary.int32_serializer), (Int32OrSimpleRecord.SimpleRecord, SimpleRecordSerializer())]).read(self._stream) + + def _read_int_or_record_with_vlens(self) -> Int32OrRecordWithVlens: + pos = self._index.get_step_offset("IntOrRecordWithVlens") + self._stream.seek(pos) + return _binary.UnionSerializer(Int32OrRecordWithVlens, [(Int32OrRecordWithVlens.Int32, _binary.int32_serializer), (Int32OrRecordWithVlens.RecordWithVlens, RecordWithVlensSerializer())]).read(self._stream) + + def _read_monosotate_or_int_or_simple_record(self) -> typing.Optional[Int32OrSimpleRecord]: + pos = self._index.get_step_offset("MonosotateOrIntOrSimpleRecord") + self._stream.seek(pos) + return _binary.UnionSerializer(Int32OrSimpleRecord, [None, (Int32OrSimpleRecord.Int32, _binary.int32_serializer), (Int32OrSimpleRecord.SimpleRecord, SimpleRecordSerializer())]).read(self._stream) + + def _read_record_with_unions(self) -> basic_types.RecordWithUnions: + pos = self._index.get_step_offset("RecordWithUnions") + self._stream.seek(pos) + return basic_types.binary.RecordWithUnionsSerializer().read(self._stream) + class BinaryStreamsOfUnionsWriter(_binary.BinaryProtocolWriter, StreamsOfUnionsWriterBase): """Binary writer for the StreamsOfUnions protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: StreamsOfUnionsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, StreamsOfUnionsWriterBase.schema) @@ -868,7 +1951,6 @@ def _write_many_cases(self, value: collections.abc.Iterable[Int32OrFloat32OrStri class BinaryStreamsOfUnionsReader(_binary.BinaryProtocolReader, StreamsOfUnionsReaderBase): """Binary writer for the StreamsOfUnions protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: StreamsOfUnionsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, StreamsOfUnionsReaderBase.schema) @@ -882,10 +1964,67 @@ def _read_nullable_int_or_simple_record(self) -> collections.abc.Iterable[typing def _read_many_cases(self) -> collections.abc.Iterable[Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray]: return _binary.StreamSerializer(_binary.UnionSerializer(Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray, [(Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.Int32, _binary.int32_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.Float32, _binary.float32_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.String, _binary.string_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.SimpleRecord, SimpleRecordSerializer()), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.NamedFixedNDArray, _binary.FixedNDArraySerializer(_binary.int32_serializer, (2, 4,)))])).read(self._stream) + +class BinaryStreamsOfUnionsIndexedWriter(_binary.BinaryProtocolIndexedWriter, StreamsOfUnionsWriterBase): + """Binary indexed writer for the StreamsOfUnions protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + StreamsOfUnionsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, StreamsOfUnionsWriterBase.schema) + + def _write_int_or_simple_record(self, value: collections.abc.Iterable[Int32OrSimpleRecord]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntOrSimpleRecord", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.UnionSerializer(Int32OrSimpleRecord, [(Int32OrSimpleRecord.Int32, _binary.int32_serializer), (Int32OrSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("IntOrSimpleRecord", offsets, num_blocks) + + def _write_nullable_int_or_simple_record(self, value: collections.abc.Iterable[typing.Optional[Int32OrSimpleRecord]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("NullableIntOrSimpleRecord", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.UnionSerializer(Int32OrSimpleRecord, [None, (Int32OrSimpleRecord.Int32, _binary.int32_serializer), (Int32OrSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("NullableIntOrSimpleRecord", offsets, num_blocks) + + def _write_many_cases(self, value: collections.abc.Iterable[Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("ManyCases", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.UnionSerializer(Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray, [(Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.Int32, _binary.int32_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.Float32, _binary.float32_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.String, _binary.string_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.SimpleRecord, SimpleRecordSerializer()), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.NamedFixedNDArray, _binary.FixedNDArraySerializer(_binary.int32_serializer, (2, 4,)))])).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("ManyCases", offsets, num_blocks) + + +class BinaryStreamsOfUnionsIndexedReader(_binary.BinaryProtocolIndexedReader, StreamsOfUnionsIndexedReaderBase): + """Binary indexed writer for the StreamsOfUnions protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + StreamsOfUnionsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, StreamsOfUnionsIndexedReaderBase.schema) + + def _read_int_or_simple_record(self, idx: int) -> collections.abc.Iterable[Int32OrSimpleRecord]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("IntOrSimpleRecord", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.UnionSerializer(Int32OrSimpleRecord, [(Int32OrSimpleRecord.Int32, _binary.int32_serializer), (Int32OrSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).read_mid_stream(self._stream, remaining) + + def _count_int_or_simple_record(self) -> int: + return self._index.get_stream_size("IntOrSimpleRecord") + + def _read_nullable_int_or_simple_record(self, idx: int) -> collections.abc.Iterable[typing.Optional[Int32OrSimpleRecord]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("NullableIntOrSimpleRecord", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.UnionSerializer(Int32OrSimpleRecord, [None, (Int32OrSimpleRecord.Int32, _binary.int32_serializer), (Int32OrSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).read_mid_stream(self._stream, remaining) + + def _count_nullable_int_or_simple_record(self) -> int: + return self._index.get_stream_size("NullableIntOrSimpleRecord") + + def _read_many_cases(self, idx: int) -> collections.abc.Iterable[Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("ManyCases", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.UnionSerializer(Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray, [(Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.Int32, _binary.int32_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.Float32, _binary.float32_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.String, _binary.string_serializer), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.SimpleRecord, SimpleRecordSerializer()), (Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray.NamedFixedNDArray, _binary.FixedNDArraySerializer(_binary.int32_serializer, (2, 4,)))])).read_mid_stream(self._stream, remaining) + + def _count_many_cases(self) -> int: + return self._index.get_stream_size("ManyCases") + class BinaryEnumsWriter(_binary.BinaryProtocolWriter, EnumsWriterBase): """Binary writer for the Enums protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: EnumsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, EnumsWriterBase.schema) @@ -906,7 +2045,6 @@ def _write_rec(self, value: RecordWithEnums) -> None: class BinaryEnumsReader(_binary.BinaryProtocolReader, EnumsReaderBase): """Binary writer for the Enums protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: EnumsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, EnumsReaderBase.schema) @@ -923,10 +2061,65 @@ def _read_size(self) -> SizeBasedEnum: def _read_rec(self) -> RecordWithEnums: return RecordWithEnumsSerializer().read(self._stream) + +class BinaryEnumsIndexedWriter(_binary.BinaryProtocolIndexedWriter, EnumsWriterBase): + """Binary indexed writer for the Enums protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + EnumsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, EnumsWriterBase.schema) + + def _write_single(self, value: Fruits) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Single", pos) + _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits).write(self._stream, value) + + def _write_vec(self, value: list[Fruits]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Vec", pos) + _binary.VectorSerializer(_binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits)).write(self._stream, value) + + def _write_size(self, value: SizeBasedEnum) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Size", pos) + _binary.EnumSerializer(_binary.size_serializer, SizeBasedEnum).write(self._stream, value) + + def _write_rec(self, value: RecordWithEnums) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Rec", pos) + RecordWithEnumsSerializer().write(self._stream, value) + + +class BinaryEnumsIndexedReader(_binary.BinaryProtocolIndexedReader, EnumsIndexedReaderBase): + """Binary indexed writer for the Enums protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + EnumsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, EnumsIndexedReaderBase.schema) + + def _read_single(self) -> Fruits: + pos = self._index.get_step_offset("Single") + self._stream.seek(pos) + return _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits).read(self._stream) + + def _read_vec(self) -> list[Fruits]: + pos = self._index.get_step_offset("Vec") + self._stream.seek(pos) + return _binary.VectorSerializer(_binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits)).read(self._stream) + + def _read_size(self) -> SizeBasedEnum: + pos = self._index.get_step_offset("Size") + self._stream.seek(pos) + return _binary.EnumSerializer(_binary.size_serializer, SizeBasedEnum).read(self._stream) + + def _read_rec(self) -> RecordWithEnums: + pos = self._index.get_step_offset("Rec") + self._stream.seek(pos) + return RecordWithEnumsSerializer().read(self._stream) + class BinaryFlagsWriter(_binary.BinaryProtocolWriter, FlagsWriterBase): """Binary writer for the Flags protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: FlagsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, FlagsWriterBase.schema) @@ -941,7 +2134,6 @@ def _write_formats(self, value: collections.abc.Iterable[TextFormat]) -> None: class BinaryFlagsReader(_binary.BinaryProtocolReader, FlagsReaderBase): """Binary writer for the Flags protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: FlagsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, FlagsReaderBase.schema) @@ -952,10 +2144,53 @@ def _read_days(self) -> collections.abc.Iterable[DaysOfWeek]: def _read_formats(self) -> collections.abc.Iterable[TextFormat]: return _binary.StreamSerializer(_binary.EnumSerializer(_binary.uint64_serializer, basic_types.TextFormat)).read(self._stream) + +class BinaryFlagsIndexedWriter(_binary.BinaryProtocolIndexedWriter, FlagsWriterBase): + """Binary indexed writer for the Flags protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + FlagsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, FlagsWriterBase.schema) + + def _write_days(self, value: collections.abc.Iterable[DaysOfWeek]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Days", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.EnumSerializer(_binary.int32_serializer, basic_types.DaysOfWeek)).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("Days", offsets, num_blocks) + + def _write_formats(self, value: collections.abc.Iterable[TextFormat]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Formats", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.EnumSerializer(_binary.uint64_serializer, basic_types.TextFormat)).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("Formats", offsets, num_blocks) + + +class BinaryFlagsIndexedReader(_binary.BinaryProtocolIndexedReader, FlagsIndexedReaderBase): + """Binary indexed writer for the Flags protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + FlagsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, FlagsIndexedReaderBase.schema) + + def _read_days(self, idx: int) -> collections.abc.Iterable[DaysOfWeek]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("Days", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.EnumSerializer(_binary.int32_serializer, basic_types.DaysOfWeek)).read_mid_stream(self._stream, remaining) + + def _count_days(self) -> int: + return self._index.get_stream_size("Days") + + def _read_formats(self, idx: int) -> collections.abc.Iterable[TextFormat]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("Formats", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.EnumSerializer(_binary.uint64_serializer, basic_types.TextFormat)).read_mid_stream(self._stream, remaining) + + def _count_formats(self) -> int: + return self._index.get_stream_size("Formats") + class BinaryStateTestWriter(_binary.BinaryProtocolWriter, StateTestWriterBase): """Binary writer for the StateTest protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: StateTestWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, StateTestWriterBase.schema) @@ -964,33 +2199,81 @@ def _write_an_int(self, value: yardl.Int32) -> None: _binary.int32_serializer.write(self._stream, value) def _write_a_stream(self, value: collections.abc.Iterable[yardl.Int32]) -> None: - _binary.StreamSerializer(_binary.int32_serializer).write(self._stream, value) + _binary.StreamSerializer(_binary.int32_serializer).write(self._stream, value) + + def _write_another_int(self, value: yardl.Int32) -> None: + _binary.int32_serializer.write(self._stream, value) + + +class BinaryStateTestReader(_binary.BinaryProtocolReader, StateTestReaderBase): + """Binary writer for the StateTest protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + StateTestReaderBase.__init__(self) + _binary.BinaryProtocolReader.__init__(self, stream, StateTestReaderBase.schema) + + def _read_an_int(self) -> yardl.Int32: + return _binary.int32_serializer.read(self._stream) + + def _read_a_stream(self) -> collections.abc.Iterable[yardl.Int32]: + return _binary.StreamSerializer(_binary.int32_serializer).read(self._stream) + + def _read_another_int(self) -> yardl.Int32: + return _binary.int32_serializer.read(self._stream) + + +class BinaryStateTestIndexedWriter(_binary.BinaryProtocolIndexedWriter, StateTestWriterBase): + """Binary indexed writer for the StateTest protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + StateTestWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, StateTestWriterBase.schema) + + def _write_an_int(self, value: yardl.Int32) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AnInt", pos) + _binary.int32_serializer.write(self._stream, value) + + def _write_a_stream(self, value: collections.abc.Iterable[yardl.Int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AStream", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.int32_serializer).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("AStream", offsets, num_blocks) def _write_another_int(self, value: yardl.Int32) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AnotherInt", pos) _binary.int32_serializer.write(self._stream, value) -class BinaryStateTestReader(_binary.BinaryProtocolReader, StateTestReaderBase): - """Binary writer for the StateTest protocol.""" - +class BinaryStateTestIndexedReader(_binary.BinaryProtocolIndexedReader, StateTestIndexedReaderBase): + """Binary indexed writer for the StateTest protocol.""" def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: - StateTestReaderBase.__init__(self) - _binary.BinaryProtocolReader.__init__(self, stream, StateTestReaderBase.schema) + StateTestIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, StateTestIndexedReaderBase.schema) def _read_an_int(self) -> yardl.Int32: + pos = self._index.get_step_offset("AnInt") + self._stream.seek(pos) return _binary.int32_serializer.read(self._stream) - def _read_a_stream(self) -> collections.abc.Iterable[yardl.Int32]: - return _binary.StreamSerializer(_binary.int32_serializer).read(self._stream) + def _read_a_stream(self, idx: int) -> collections.abc.Iterable[yardl.Int32]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("AStream", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.int32_serializer).read_mid_stream(self._stream, remaining) + + def _count_a_stream(self) -> int: + return self._index.get_stream_size("AStream") def _read_another_int(self) -> yardl.Int32: + pos = self._index.get_step_offset("AnotherInt") + self._stream.seek(pos) return _binary.int32_serializer.read(self._stream) class BinarySimpleGenericsWriter(_binary.BinaryProtocolWriter, SimpleGenericsWriterBase): """Binary writer for the SimpleGenerics protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: SimpleGenericsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, SimpleGenericsWriterBase.schema) @@ -1026,7 +2309,6 @@ def _write_stream_of_type_variants(self, value: collections.abc.Iterable[ImageFl class BinarySimpleGenericsReader(_binary.BinaryProtocolReader, SimpleGenericsReaderBase): """Binary writer for the SimpleGenerics protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: SimpleGenericsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, SimpleGenericsReaderBase.schema) @@ -1058,10 +2340,119 @@ def _read_int_string_tuple(self) -> tuples.Tuple[yardl.Int32, str]: def _read_stream_of_type_variants(self) -> collections.abc.Iterable[ImageFloatOrImageDouble]: return _binary.StreamSerializer(_binary.UnionSerializer(ImageFloatOrImageDouble, [(ImageFloatOrImageDouble.ImageFloat, _binary.NDArraySerializer(_binary.float32_serializer, 2)), (ImageFloatOrImageDouble.ImageDouble, _binary.NDArraySerializer(_binary.float64_serializer, 2))])).read(self._stream) + +class BinarySimpleGenericsIndexedWriter(_binary.BinaryProtocolIndexedWriter, SimpleGenericsWriterBase): + """Binary indexed writer for the SimpleGenerics protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + SimpleGenericsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, SimpleGenericsWriterBase.schema) + + def _write_float_image(self, value: image.FloatImage) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FloatImage", pos) + _binary.NDArraySerializer(_binary.float32_serializer, 2).write(self._stream, value) + + def _write_int_image(self, value: image.IntImage) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntImage", pos) + _binary.NDArraySerializer(_binary.int32_serializer, 2).write(self._stream, value) + + def _write_int_image_alternate_syntax(self, value: Image[np.int32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntImageAlternateSyntax", pos) + _binary.NDArraySerializer(_binary.int32_serializer, 2).write(self._stream, value) + + def _write_string_image(self, value: Image[np.object_]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("StringImage", pos) + _binary.NDArraySerializer(_binary.string_serializer, 2).write(self._stream, value) + + def _write_int_float_tuple(self, value: tuples.Tuple[yardl.Int32, yardl.Float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntFloatTuple", pos) + tuples.binary.TupleSerializer(_binary.int32_serializer, _binary.float32_serializer).write(self._stream, value) + + def _write_float_float_tuple(self, value: tuples.Tuple[yardl.Float32, yardl.Float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FloatFloatTuple", pos) + tuples.binary.TupleSerializer(_binary.float32_serializer, _binary.float32_serializer).write(self._stream, value) + + def _write_int_float_tuple_alternate_syntax(self, value: tuples.Tuple[yardl.Int32, yardl.Float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntFloatTupleAlternateSyntax", pos) + tuples.binary.TupleSerializer(_binary.int32_serializer, _binary.float32_serializer).write(self._stream, value) + + def _write_int_string_tuple(self, value: tuples.Tuple[yardl.Int32, str]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntStringTuple", pos) + tuples.binary.TupleSerializer(_binary.int32_serializer, _binary.string_serializer).write(self._stream, value) + + def _write_stream_of_type_variants(self, value: collections.abc.Iterable[ImageFloatOrImageDouble]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("StreamOfTypeVariants", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.UnionSerializer(ImageFloatOrImageDouble, [(ImageFloatOrImageDouble.ImageFloat, _binary.NDArraySerializer(_binary.float32_serializer, 2)), (ImageFloatOrImageDouble.ImageDouble, _binary.NDArraySerializer(_binary.float64_serializer, 2))])).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("StreamOfTypeVariants", offsets, num_blocks) + + +class BinarySimpleGenericsIndexedReader(_binary.BinaryProtocolIndexedReader, SimpleGenericsIndexedReaderBase): + """Binary indexed writer for the SimpleGenerics protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + SimpleGenericsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, SimpleGenericsIndexedReaderBase.schema) + + def _read_float_image(self) -> image.FloatImage: + pos = self._index.get_step_offset("FloatImage") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.float32_serializer, 2).read(self._stream) + + def _read_int_image(self) -> image.IntImage: + pos = self._index.get_step_offset("IntImage") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.int32_serializer, 2).read(self._stream) + + def _read_int_image_alternate_syntax(self) -> Image[np.int32]: + pos = self._index.get_step_offset("IntImageAlternateSyntax") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.int32_serializer, 2).read(self._stream) + + def _read_string_image(self) -> Image[np.object_]: + pos = self._index.get_step_offset("StringImage") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.string_serializer, 2).read(self._stream) + + def _read_int_float_tuple(self) -> tuples.Tuple[yardl.Int32, yardl.Float32]: + pos = self._index.get_step_offset("IntFloatTuple") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.int32_serializer, _binary.float32_serializer).read(self._stream) + + def _read_float_float_tuple(self) -> tuples.Tuple[yardl.Float32, yardl.Float32]: + pos = self._index.get_step_offset("FloatFloatTuple") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.float32_serializer, _binary.float32_serializer).read(self._stream) + + def _read_int_float_tuple_alternate_syntax(self) -> tuples.Tuple[yardl.Int32, yardl.Float32]: + pos = self._index.get_step_offset("IntFloatTupleAlternateSyntax") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.int32_serializer, _binary.float32_serializer).read(self._stream) + + def _read_int_string_tuple(self) -> tuples.Tuple[yardl.Int32, str]: + pos = self._index.get_step_offset("IntStringTuple") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.int32_serializer, _binary.string_serializer).read(self._stream) + + def _read_stream_of_type_variants(self, idx: int) -> collections.abc.Iterable[ImageFloatOrImageDouble]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("StreamOfTypeVariants", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.UnionSerializer(ImageFloatOrImageDouble, [(ImageFloatOrImageDouble.ImageFloat, _binary.NDArraySerializer(_binary.float32_serializer, 2)), (ImageFloatOrImageDouble.ImageDouble, _binary.NDArraySerializer(_binary.float64_serializer, 2))])).read_mid_stream(self._stream, remaining) + + def _count_stream_of_type_variants(self) -> int: + return self._index.get_stream_size("StreamOfTypeVariants") + class BinaryAdvancedGenericsWriter(_binary.BinaryProtocolWriter, AdvancedGenericsWriterBase): """Binary writer for the AdvancedGenerics protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: AdvancedGenericsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, AdvancedGenericsWriterBase.schema) @@ -1085,7 +2476,6 @@ def _write_tuple_of_vectors(self, value: MyTuple[list[yardl.Int32], list[yardl.F class BinaryAdvancedGenericsReader(_binary.BinaryProtocolReader, AdvancedGenericsReaderBase): """Binary writer for the AdvancedGenerics protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: AdvancedGenericsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, AdvancedGenericsReaderBase.schema) @@ -1105,10 +2495,75 @@ def _read_tuple_of_optionals_alternate_syntax(self) -> MyTuple[typing.Optional[y def _read_tuple_of_vectors(self) -> MyTuple[list[yardl.Int32], list[yardl.Float32]]: return tuples.binary.TupleSerializer(_binary.VectorSerializer(_binary.int32_serializer), _binary.VectorSerializer(_binary.float32_serializer)).read(self._stream) + +class BinaryAdvancedGenericsIndexedWriter(_binary.BinaryProtocolIndexedWriter, AdvancedGenericsWriterBase): + """Binary indexed writer for the AdvancedGenerics protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + AdvancedGenericsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, AdvancedGenericsWriterBase.schema) + + def _write_float_image_image(self, value: Image[np.object_]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("FloatImageImage", pos) + _binary.NDArraySerializer(_binary.NDArraySerializer(_binary.float32_serializer, 2), 2).write(self._stream, value) + + def _write_generic_record_1(self, value: GenericRecord[yardl.Int32, str, np.object_]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("GenericRecord1", pos) + GenericRecordSerializer(_binary.int32_serializer, _binary.string_serializer).write(self._stream, value) + + def _write_tuple_of_optionals(self, value: MyTuple[typing.Optional[yardl.Int32], typing.Optional[str]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("TupleOfOptionals", pos) + tuples.binary.TupleSerializer(_binary.OptionalSerializer(_binary.int32_serializer), _binary.OptionalSerializer(_binary.string_serializer)).write(self._stream, value) + + def _write_tuple_of_optionals_alternate_syntax(self, value: MyTuple[typing.Optional[yardl.Int32], typing.Optional[str]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("TupleOfOptionalsAlternateSyntax", pos) + tuples.binary.TupleSerializer(_binary.OptionalSerializer(_binary.int32_serializer), _binary.OptionalSerializer(_binary.string_serializer)).write(self._stream, value) + + def _write_tuple_of_vectors(self, value: MyTuple[list[yardl.Int32], list[yardl.Float32]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("TupleOfVectors", pos) + tuples.binary.TupleSerializer(_binary.VectorSerializer(_binary.int32_serializer), _binary.VectorSerializer(_binary.float32_serializer)).write(self._stream, value) + + +class BinaryAdvancedGenericsIndexedReader(_binary.BinaryProtocolIndexedReader, AdvancedGenericsIndexedReaderBase): + """Binary indexed writer for the AdvancedGenerics protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + AdvancedGenericsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, AdvancedGenericsIndexedReaderBase.schema) + + def _read_float_image_image(self) -> Image[np.object_]: + pos = self._index.get_step_offset("FloatImageImage") + self._stream.seek(pos) + return _binary.NDArraySerializer(_binary.NDArraySerializer(_binary.float32_serializer, 2), 2).read(self._stream) + + def _read_generic_record_1(self) -> GenericRecord[yardl.Int32, str, np.object_]: + pos = self._index.get_step_offset("GenericRecord1") + self._stream.seek(pos) + return GenericRecordSerializer(_binary.int32_serializer, _binary.string_serializer).read(self._stream) + + def _read_tuple_of_optionals(self) -> MyTuple[typing.Optional[yardl.Int32], typing.Optional[str]]: + pos = self._index.get_step_offset("TupleOfOptionals") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.OptionalSerializer(_binary.int32_serializer), _binary.OptionalSerializer(_binary.string_serializer)).read(self._stream) + + def _read_tuple_of_optionals_alternate_syntax(self) -> MyTuple[typing.Optional[yardl.Int32], typing.Optional[str]]: + pos = self._index.get_step_offset("TupleOfOptionalsAlternateSyntax") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.OptionalSerializer(_binary.int32_serializer), _binary.OptionalSerializer(_binary.string_serializer)).read(self._stream) + + def _read_tuple_of_vectors(self) -> MyTuple[list[yardl.Int32], list[yardl.Float32]]: + pos = self._index.get_step_offset("TupleOfVectors") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.VectorSerializer(_binary.int32_serializer), _binary.VectorSerializer(_binary.float32_serializer)).read(self._stream) + class BinaryAliasesWriter(_binary.BinaryProtocolWriter, AliasesWriterBase): """Binary writer for the Aliases protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: AliasesWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, AliasesWriterBase.schema) @@ -1147,7 +2602,6 @@ def _write_stream_of_aliased_generic_union_2(self, value: collections.abc.Iterab class BinaryAliasesReader(_binary.BinaryProtocolReader, AliasesReaderBase): """Binary writer for the Aliases protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: AliasesReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, AliasesReaderBase.schema) @@ -1182,10 +2636,129 @@ def _read_aliased_generic_fixed_vector(self) -> AliasedGenericFixedVector[yardl. def _read_stream_of_aliased_generic_union_2(self) -> collections.abc.Iterable[AliasedGenericUnion2[AliasedString, AliasedEnum]]: return _binary.StreamSerializer(_binary.UnionSerializer(basic_types.GenericUnion2, [(basic_types.GenericUnion2.T1, _binary.string_serializer), (basic_types.GenericUnion2.T2, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits))])).read(self._stream) + +class BinaryAliasesIndexedWriter(_binary.BinaryProtocolIndexedWriter, AliasesWriterBase): + """Binary indexed writer for the Aliases protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + AliasesWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, AliasesWriterBase.schema) + + def _write_aliased_string(self, value: AliasedString) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedString", pos) + _binary.string_serializer.write(self._stream, value) + + def _write_aliased_enum(self, value: AliasedEnum) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedEnum", pos) + _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits).write(self._stream, value) + + def _write_aliased_open_generic(self, value: AliasedOpenGeneric[AliasedString, AliasedEnum]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedOpenGeneric", pos) + tuples.binary.TupleSerializer(_binary.string_serializer, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits)).write(self._stream, value) + + def _write_aliased_closed_generic(self, value: AliasedClosedGeneric) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedClosedGeneric", pos) + tuples.binary.TupleSerializer(_binary.string_serializer, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits)).write(self._stream, value) + + def _write_aliased_optional(self, value: AliasedOptional) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedOptional", pos) + _binary.OptionalSerializer(_binary.int32_serializer).write(self._stream, value) + + def _write_aliased_generic_optional(self, value: AliasedGenericOptional[yardl.Float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedGenericOptional", pos) + _binary.OptionalSerializer(_binary.float32_serializer).write(self._stream, value) + + def _write_aliased_generic_union_2(self, value: AliasedGenericUnion2[AliasedString, AliasedEnum]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedGenericUnion2", pos) + _binary.UnionSerializer(basic_types.GenericUnion2, [(basic_types.GenericUnion2.T1, _binary.string_serializer), (basic_types.GenericUnion2.T2, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits))]).write(self._stream, value) + + def _write_aliased_generic_vector(self, value: AliasedGenericVector[yardl.Float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedGenericVector", pos) + _binary.VectorSerializer(_binary.float32_serializer).write(self._stream, value) + + def _write_aliased_generic_fixed_vector(self, value: AliasedGenericFixedVector[yardl.Float32]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("AliasedGenericFixedVector", pos) + _binary.FixedVectorSerializer(_binary.float32_serializer, 3).write(self._stream, value) + + def _write_stream_of_aliased_generic_union_2(self, value: collections.abc.Iterable[AliasedGenericUnion2[AliasedString, AliasedEnum]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("StreamOfAliasedGenericUnion2", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.UnionSerializer(basic_types.GenericUnion2, [(basic_types.GenericUnion2.T1, _binary.string_serializer), (basic_types.GenericUnion2.T2, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits))])).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("StreamOfAliasedGenericUnion2", offsets, num_blocks) + + +class BinaryAliasesIndexedReader(_binary.BinaryProtocolIndexedReader, AliasesIndexedReaderBase): + """Binary indexed writer for the Aliases protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + AliasesIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, AliasesIndexedReaderBase.schema) + + def _read_aliased_string(self) -> AliasedString: + pos = self._index.get_step_offset("AliasedString") + self._stream.seek(pos) + return _binary.string_serializer.read(self._stream) + + def _read_aliased_enum(self) -> AliasedEnum: + pos = self._index.get_step_offset("AliasedEnum") + self._stream.seek(pos) + return _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits).read(self._stream) + + def _read_aliased_open_generic(self) -> AliasedOpenGeneric[AliasedString, AliasedEnum]: + pos = self._index.get_step_offset("AliasedOpenGeneric") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.string_serializer, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits)).read(self._stream) + + def _read_aliased_closed_generic(self) -> AliasedClosedGeneric: + pos = self._index.get_step_offset("AliasedClosedGeneric") + self._stream.seek(pos) + return tuples.binary.TupleSerializer(_binary.string_serializer, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits)).read(self._stream) + + def _read_aliased_optional(self) -> AliasedOptional: + pos = self._index.get_step_offset("AliasedOptional") + self._stream.seek(pos) + return _binary.OptionalSerializer(_binary.int32_serializer).read(self._stream) + + def _read_aliased_generic_optional(self) -> AliasedGenericOptional[yardl.Float32]: + pos = self._index.get_step_offset("AliasedGenericOptional") + self._stream.seek(pos) + return _binary.OptionalSerializer(_binary.float32_serializer).read(self._stream) + + def _read_aliased_generic_union_2(self) -> AliasedGenericUnion2[AliasedString, AliasedEnum]: + pos = self._index.get_step_offset("AliasedGenericUnion2") + self._stream.seek(pos) + return _binary.UnionSerializer(basic_types.GenericUnion2, [(basic_types.GenericUnion2.T1, _binary.string_serializer), (basic_types.GenericUnion2.T2, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits))]).read(self._stream) + + def _read_aliased_generic_vector(self) -> AliasedGenericVector[yardl.Float32]: + pos = self._index.get_step_offset("AliasedGenericVector") + self._stream.seek(pos) + return _binary.VectorSerializer(_binary.float32_serializer).read(self._stream) + + def _read_aliased_generic_fixed_vector(self) -> AliasedGenericFixedVector[yardl.Float32]: + pos = self._index.get_step_offset("AliasedGenericFixedVector") + self._stream.seek(pos) + return _binary.FixedVectorSerializer(_binary.float32_serializer, 3).read(self._stream) + + def _read_stream_of_aliased_generic_union_2(self, idx: int) -> collections.abc.Iterable[AliasedGenericUnion2[AliasedString, AliasedEnum]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("StreamOfAliasedGenericUnion2", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.UnionSerializer(basic_types.GenericUnion2, [(basic_types.GenericUnion2.T1, _binary.string_serializer), (basic_types.GenericUnion2.T2, _binary.EnumSerializer(_binary.int32_serializer, basic_types.Fruits))])).read_mid_stream(self._stream, remaining) + + def _count_stream_of_aliased_generic_union_2(self) -> int: + return self._index.get_stream_size("StreamOfAliasedGenericUnion2") + class BinaryStreamsOfAliasedUnionsWriter(_binary.BinaryProtocolWriter, StreamsOfAliasedUnionsWriterBase): """Binary writer for the StreamsOfAliasedUnions protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: StreamsOfAliasedUnionsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, StreamsOfAliasedUnionsWriterBase.schema) @@ -1200,7 +2773,6 @@ def _write_nullable_int_or_simple_record(self, value: collections.abc.Iterable[t class BinaryStreamsOfAliasedUnionsReader(_binary.BinaryProtocolReader, StreamsOfAliasedUnionsReaderBase): """Binary writer for the StreamsOfAliasedUnions protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: StreamsOfAliasedUnionsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, StreamsOfAliasedUnionsReaderBase.schema) @@ -1211,10 +2783,53 @@ def _read_int_or_simple_record(self) -> collections.abc.Iterable[AliasedIntOrSim def _read_nullable_int_or_simple_record(self) -> collections.abc.Iterable[typing.Optional[AliasedNullableIntSimpleRecord]]: return _binary.StreamSerializer(_binary.UnionSerializer(AliasedNullableIntSimpleRecord, [None, (AliasedNullableIntSimpleRecord.Int32, _binary.int32_serializer), (AliasedNullableIntSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).read(self._stream) + +class BinaryStreamsOfAliasedUnionsIndexedWriter(_binary.BinaryProtocolIndexedWriter, StreamsOfAliasedUnionsWriterBase): + """Binary indexed writer for the StreamsOfAliasedUnions protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + StreamsOfAliasedUnionsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, StreamsOfAliasedUnionsWriterBase.schema) + + def _write_int_or_simple_record(self, value: collections.abc.Iterable[AliasedIntOrSimpleRecord]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("IntOrSimpleRecord", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.UnionSerializer(AliasedIntOrSimpleRecord, [(AliasedIntOrSimpleRecord.Int32, _binary.int32_serializer), (AliasedIntOrSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("IntOrSimpleRecord", offsets, num_blocks) + + def _write_nullable_int_or_simple_record(self, value: collections.abc.Iterable[typing.Optional[AliasedNullableIntSimpleRecord]]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("NullableIntOrSimpleRecord", pos) + offsets, num_blocks = _binary.StreamSerializer(_binary.UnionSerializer(AliasedNullableIntSimpleRecord, [None, (AliasedNullableIntSimpleRecord.Int32, _binary.int32_serializer), (AliasedNullableIntSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("NullableIntOrSimpleRecord", offsets, num_blocks) + + +class BinaryStreamsOfAliasedUnionsIndexedReader(_binary.BinaryProtocolIndexedReader, StreamsOfAliasedUnionsIndexedReaderBase): + """Binary indexed writer for the StreamsOfAliasedUnions protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + StreamsOfAliasedUnionsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, StreamsOfAliasedUnionsIndexedReaderBase.schema) + + def _read_int_or_simple_record(self, idx: int) -> collections.abc.Iterable[AliasedIntOrSimpleRecord]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("IntOrSimpleRecord", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.UnionSerializer(AliasedIntOrSimpleRecord, [(AliasedIntOrSimpleRecord.Int32, _binary.int32_serializer), (AliasedIntOrSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).read_mid_stream(self._stream, remaining) + + def _count_int_or_simple_record(self) -> int: + return self._index.get_stream_size("IntOrSimpleRecord") + + def _read_nullable_int_or_simple_record(self, idx: int) -> collections.abc.Iterable[typing.Optional[AliasedNullableIntSimpleRecord]]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("NullableIntOrSimpleRecord", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(_binary.UnionSerializer(AliasedNullableIntSimpleRecord, [None, (AliasedNullableIntSimpleRecord.Int32, _binary.int32_serializer), (AliasedNullableIntSimpleRecord.SimpleRecord, SimpleRecordSerializer())])).read_mid_stream(self._stream, remaining) + + def _count_nullable_int_or_simple_record(self) -> int: + return self._index.get_stream_size("NullableIntOrSimpleRecord") + class BinaryProtocolWithComputedFieldsWriter(_binary.BinaryProtocolWriter, ProtocolWithComputedFieldsWriterBase): """Binary writer for the ProtocolWithComputedFields protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: ProtocolWithComputedFieldsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, ProtocolWithComputedFieldsWriterBase.schema) @@ -1226,7 +2841,6 @@ def _write_record_with_computed_fields(self, value: RecordWithComputedFields) -> class BinaryProtocolWithComputedFieldsReader(_binary.BinaryProtocolReader, ProtocolWithComputedFieldsReaderBase): """Binary writer for the ProtocolWithComputedFields protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: ProtocolWithComputedFieldsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, ProtocolWithComputedFieldsReaderBase.schema) @@ -1234,10 +2848,35 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_record_with_computed_fields(self) -> RecordWithComputedFields: return RecordWithComputedFieldsSerializer().read(self._stream) + +class BinaryProtocolWithComputedFieldsIndexedWriter(_binary.BinaryProtocolIndexedWriter, ProtocolWithComputedFieldsWriterBase): + """Binary indexed writer for the ProtocolWithComputedFields protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + ProtocolWithComputedFieldsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, ProtocolWithComputedFieldsWriterBase.schema) + + def _write_record_with_computed_fields(self, value: RecordWithComputedFields) -> None: + pos = self._stream.pos() + self._index.set_step_offset("RecordWithComputedFields", pos) + RecordWithComputedFieldsSerializer().write(self._stream, value) + + +class BinaryProtocolWithComputedFieldsIndexedReader(_binary.BinaryProtocolIndexedReader, ProtocolWithComputedFieldsIndexedReaderBase): + """Binary indexed writer for the ProtocolWithComputedFields protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + ProtocolWithComputedFieldsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, ProtocolWithComputedFieldsIndexedReaderBase.schema) + + def _read_record_with_computed_fields(self) -> RecordWithComputedFields: + pos = self._index.get_step_offset("RecordWithComputedFields") + self._stream.seek(pos) + return RecordWithComputedFieldsSerializer().read(self._stream) + class BinaryProtocolWithKeywordStepsWriter(_binary.BinaryProtocolWriter, ProtocolWithKeywordStepsWriterBase): """Binary writer for the ProtocolWithKeywordSteps protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: ProtocolWithKeywordStepsWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, ProtocolWithKeywordStepsWriterBase.schema) @@ -1252,7 +2891,6 @@ def _write_float(self, value: EnumWithKeywordSymbols) -> None: class BinaryProtocolWithKeywordStepsReader(_binary.BinaryProtocolReader, ProtocolWithKeywordStepsReaderBase): """Binary writer for the ProtocolWithKeywordSteps protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: ProtocolWithKeywordStepsReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, ProtocolWithKeywordStepsReaderBase.schema) @@ -1263,10 +2901,49 @@ def _read_int(self) -> collections.abc.Iterable[RecordWithKeywordFields]: def _read_float(self) -> EnumWithKeywordSymbols: return _binary.EnumSerializer(_binary.int32_serializer, EnumWithKeywordSymbols).read(self._stream) + +class BinaryProtocolWithKeywordStepsIndexedWriter(_binary.BinaryProtocolIndexedWriter, ProtocolWithKeywordStepsWriterBase): + """Binary indexed writer for the ProtocolWithKeywordSteps protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + ProtocolWithKeywordStepsWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, ProtocolWithKeywordStepsWriterBase.schema) + + def _write_int(self, value: collections.abc.Iterable[RecordWithKeywordFields]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Int", pos) + offsets, num_blocks = _binary.StreamSerializer(RecordWithKeywordFieldsSerializer()).write_and_save_offsets(self._stream, value) + self._index.add_stream_offsets("Int", offsets, num_blocks) + + def _write_float(self, value: EnumWithKeywordSymbols) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Float", pos) + _binary.EnumSerializer(_binary.int32_serializer, EnumWithKeywordSymbols).write(self._stream, value) + + +class BinaryProtocolWithKeywordStepsIndexedReader(_binary.BinaryProtocolIndexedReader, ProtocolWithKeywordStepsIndexedReaderBase): + """Binary indexed writer for the ProtocolWithKeywordSteps protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + ProtocolWithKeywordStepsIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, ProtocolWithKeywordStepsIndexedReaderBase.schema) + + def _read_int(self, idx: int) -> collections.abc.Iterable[RecordWithKeywordFields]: # pyright: ignore [reportIncompatibleMethodOverride] + offset, remaining = self._index.find_stream_item("Int", idx) + self._stream.seek(offset) + return _binary.StreamSerializer(RecordWithKeywordFieldsSerializer()).read_mid_stream(self._stream, remaining) + + def _count_int(self) -> int: + return self._index.get_stream_size("Int") + + def _read_float(self) -> EnumWithKeywordSymbols: + pos = self._index.get_step_offset("Float") + self._stream.seek(pos) + return _binary.EnumSerializer(_binary.int32_serializer, EnumWithKeywordSymbols).read(self._stream) + class BinaryProtocolWithOptionalDateWriter(_binary.BinaryProtocolWriter, ProtocolWithOptionalDateWriterBase): """Binary writer for the ProtocolWithOptionalDate protocol.""" - def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: ProtocolWithOptionalDateWriterBase.__init__(self) _binary.BinaryProtocolWriter.__init__(self, stream, ProtocolWithOptionalDateWriterBase.schema) @@ -1278,7 +2955,6 @@ def _write_record(self, value: typing.Optional[RecordWithOptionalDate]) -> None: class BinaryProtocolWithOptionalDateReader(_binary.BinaryProtocolReader, ProtocolWithOptionalDateReaderBase): """Binary writer for the ProtocolWithOptionalDate protocol.""" - def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: ProtocolWithOptionalDateReaderBase.__init__(self) _binary.BinaryProtocolReader.__init__(self, stream, ProtocolWithOptionalDateReaderBase.schema) @@ -1286,6 +2962,32 @@ def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.Bi def _read_record(self) -> typing.Optional[RecordWithOptionalDate]: return _binary.OptionalSerializer(RecordWithOptionalDateSerializer()).read(self._stream) + +class BinaryProtocolWithOptionalDateIndexedWriter(_binary.BinaryProtocolIndexedWriter, ProtocolWithOptionalDateWriterBase): + """Binary indexed writer for the ProtocolWithOptionalDate protocol.""" + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + ProtocolWithOptionalDateWriterBase.__init__(self) + _binary.BinaryProtocolIndexedWriter.__init__(self, stream, ProtocolWithOptionalDateWriterBase.schema) + + def _write_record(self, value: typing.Optional[RecordWithOptionalDate]) -> None: + pos = self._stream.pos() + self._index.set_step_offset("Record", pos) + _binary.OptionalSerializer(RecordWithOptionalDateSerializer()).write(self._stream, value) + + +class BinaryProtocolWithOptionalDateIndexedReader(_binary.BinaryProtocolIndexedReader, ProtocolWithOptionalDateIndexedReaderBase): + """Binary indexed writer for the ProtocolWithOptionalDate protocol.""" + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + ProtocolWithOptionalDateIndexedReaderBase.__init__(self) + _binary.BinaryProtocolIndexedReader.__init__(self, stream, ProtocolWithOptionalDateIndexedReaderBase.schema) + + def _read_record(self) -> typing.Optional[RecordWithOptionalDate]: + pos = self._index.get_step_offset("Record") + self._stream.seek(pos) + return _binary.OptionalSerializer(RecordWithOptionalDateSerializer()).read(self._stream) + class SmallBenchmarkRecordSerializer(_binary.RecordSerializer[SmallBenchmarkRecord]): def __init__(self) -> None: super().__init__([("a", _binary.float64_serializer), ("b", _binary.float32_serializer), ("c", _binary.float32_serializer)]) diff --git a/python/test_model/protocols.py b/python/test_model/protocols.py index 92d0a41..801988c 100644 --- a/python/test_model/protocols.py +++ b/python/test_model/protocols.py @@ -17,7 +17,6 @@ class BenchmarkFloat256x256WriterBase(abc.ABC): """Abstract writer for the BenchmarkFloat256x256 protocol.""" - def __init__(self) -> None: self._state = 0 @@ -77,8 +76,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class BenchmarkFloat256x256ReaderBase(abc.ABC): - """Abstract reader for the BenchmarkFloat256x256 protocol.""" - + """Abstract indexed reader for the BenchmarkFloat256x256 protocol.""" def __init__(self) -> None: self._state = 0 @@ -93,7 +91,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = BenchmarkFloat256x256WriterBase.schema def __enter__(self): @@ -146,10 +143,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_float256x256' return "" +class BenchmarkFloat256x256IndexedReaderBase(BenchmarkFloat256x256ReaderBase): + """Abstract reader for the BenchmarkFloat256x256 protocol.""" + + def close(self) -> None: + self._close() + + def read_float256x256(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + value = self._read_float256x256(idx) + return self._wrap_iterable(value, 2) + + def count_float256x256(self) -> int: + return self._count_float256x256() + + @abc.abstractmethod + def _read_float256x256(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_float256x256(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class BenchmarkInt256x256WriterBase(abc.ABC): """Abstract writer for the BenchmarkInt256x256 protocol.""" - def __init__(self) -> None: self._state = 0 @@ -209,8 +228,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class BenchmarkInt256x256ReaderBase(abc.ABC): - """Abstract reader for the BenchmarkInt256x256 protocol.""" - + """Abstract indexed reader for the BenchmarkInt256x256 protocol.""" def __init__(self) -> None: self._state = 0 @@ -225,7 +243,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = BenchmarkInt256x256WriterBase.schema def __enter__(self): @@ -278,10 +295,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_int256x256' return "" +class BenchmarkInt256x256IndexedReaderBase(BenchmarkInt256x256ReaderBase): + """Abstract reader for the BenchmarkInt256x256 protocol.""" + + def close(self) -> None: + self._close() + + def read_int256x256(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.int32]]: + value = self._read_int256x256(idx) + return self._wrap_iterable(value, 2) + + def count_int256x256(self) -> int: + return self._count_int256x256() + + @abc.abstractmethod + def _read_int256x256(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.int32]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_int256x256(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class BenchmarkFloatVlenWriterBase(abc.ABC): """Abstract writer for the BenchmarkFloatVlen protocol.""" - def __init__(self) -> None: self._state = 0 @@ -341,8 +380,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class BenchmarkFloatVlenReaderBase(abc.ABC): - """Abstract reader for the BenchmarkFloatVlen protocol.""" - + """Abstract indexed reader for the BenchmarkFloatVlen protocol.""" def __init__(self) -> None: self._state = 0 @@ -357,7 +395,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = BenchmarkFloatVlenWriterBase.schema def __enter__(self): @@ -410,10 +447,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_float_array' return "" +class BenchmarkFloatVlenIndexedReaderBase(BenchmarkFloatVlenReaderBase): + """Abstract reader for the BenchmarkFloatVlen protocol.""" + + def close(self) -> None: + self._close() + + def read_float_array(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + value = self._read_float_array(idx) + return self._wrap_iterable(value, 2) + + def count_float_array(self) -> int: + return self._count_float_array() + + @abc.abstractmethod + def _read_float_array(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_float_array(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class BenchmarkSmallRecordWriterBase(abc.ABC): """Abstract writer for the BenchmarkSmallRecord protocol.""" - def __init__(self) -> None: self._state = 0 @@ -473,8 +532,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class BenchmarkSmallRecordReaderBase(abc.ABC): - """Abstract reader for the BenchmarkSmallRecord protocol.""" - + """Abstract indexed reader for the BenchmarkSmallRecord protocol.""" def __init__(self) -> None: self._state = 0 @@ -489,7 +547,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = BenchmarkSmallRecordWriterBase.schema def __enter__(self): @@ -542,10 +599,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_small_record' return "" +class BenchmarkSmallRecordIndexedReaderBase(BenchmarkSmallRecordReaderBase): + """Abstract reader for the BenchmarkSmallRecord protocol.""" + + def close(self) -> None: + self._close() + + def read_small_record(self, idx: int = 0) -> collections.abc.Iterable[SmallBenchmarkRecord]: + value = self._read_small_record(idx) + return self._wrap_iterable(value, 2) + + def count_small_record(self) -> int: + return self._count_small_record() + + @abc.abstractmethod + def _read_small_record(self, idx: int = 0) -> collections.abc.Iterable[SmallBenchmarkRecord]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_small_record(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class BenchmarkSmallRecordWithOptionalsWriterBase(abc.ABC): """Abstract writer for the BenchmarkSmallRecordWithOptionals protocol.""" - def __init__(self) -> None: self._state = 0 @@ -605,8 +684,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class BenchmarkSmallRecordWithOptionalsReaderBase(abc.ABC): - """Abstract reader for the BenchmarkSmallRecordWithOptionals protocol.""" - + """Abstract indexed reader for the BenchmarkSmallRecordWithOptionals protocol.""" def __init__(self) -> None: self._state = 0 @@ -621,7 +699,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = BenchmarkSmallRecordWithOptionalsWriterBase.schema def __enter__(self): @@ -674,10 +751,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_small_record' return "" +class BenchmarkSmallRecordWithOptionalsIndexedReaderBase(BenchmarkSmallRecordWithOptionalsReaderBase): + """Abstract reader for the BenchmarkSmallRecordWithOptionals protocol.""" + + def close(self) -> None: + self._close() + + def read_small_record(self, idx: int = 0) -> collections.abc.Iterable[SimpleEncodingCounters]: + value = self._read_small_record(idx) + return self._wrap_iterable(value, 2) + + def count_small_record(self) -> int: + return self._count_small_record() + + @abc.abstractmethod + def _read_small_record(self, idx: int = 0) -> collections.abc.Iterable[SimpleEncodingCounters]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_small_record(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class BenchmarkSimpleMrdWriterBase(abc.ABC): """Abstract writer for the BenchmarkSimpleMrd protocol.""" - def __init__(self) -> None: self._state = 0 @@ -737,8 +836,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class BenchmarkSimpleMrdReaderBase(abc.ABC): - """Abstract reader for the BenchmarkSimpleMrd protocol.""" - + """Abstract indexed reader for the BenchmarkSimpleMrd protocol.""" def __init__(self) -> None: self._state = 0 @@ -753,7 +851,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = BenchmarkSimpleMrdWriterBase.schema def __enter__(self): @@ -806,10 +903,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_data' return "" +class BenchmarkSimpleMrdIndexedReaderBase(BenchmarkSimpleMrdReaderBase): + """Abstract reader for the BenchmarkSimpleMrd protocol.""" + + def close(self) -> None: + self._close() + + def read_data(self, idx: int = 0) -> collections.abc.Iterable[AcquisitionOrImage]: + value = self._read_data(idx) + return self._wrap_iterable(value, 2) + + def count_data(self) -> int: + return self._count_data() + + @abc.abstractmethod + def _read_data(self, idx: int = 0) -> collections.abc.Iterable[AcquisitionOrImage]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_data(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class ScalarsWriterBase(abc.ABC): """Abstract writer for the Scalars protocol.""" - def __init__(self) -> None: self._state = 0 @@ -878,8 +997,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class ScalarsReaderBase(abc.ABC): - """Abstract reader for the Scalars protocol.""" - + """Abstract indexed reader for the Scalars protocol.""" def __init__(self) -> None: self._state = 0 @@ -894,7 +1012,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = ScalarsWriterBase.schema def __enter__(self): @@ -964,10 +1081,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record' return "" +class ScalarsIndexedReaderBase(ScalarsReaderBase): + """Abstract reader for the Scalars protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class ScalarOptionalsWriterBase(abc.ABC): """Abstract writer for the ScalarOptionals protocol.""" - def __init__(self) -> None: self._state = 0 @@ -1066,8 +1190,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class ScalarOptionalsReaderBase(abc.ABC): - """Abstract reader for the ScalarOptionals protocol.""" - + """Abstract indexed reader for the ScalarOptionals protocol.""" def __init__(self) -> None: self._state = 0 @@ -1082,7 +1205,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = ScalarOptionalsWriterBase.schema def __enter__(self): @@ -1186,10 +1308,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_optional_record_with_optional_fields' return "" +class ScalarOptionalsIndexedReaderBase(ScalarOptionalsReaderBase): + """Abstract reader for the ScalarOptionals protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class NestedRecordsWriterBase(abc.ABC): """Abstract writer for the NestedRecords protocol.""" - def __init__(self) -> None: self._state = 0 @@ -1243,8 +1372,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class NestedRecordsReaderBase(abc.ABC): - """Abstract reader for the NestedRecords protocol.""" - + """Abstract indexed reader for the NestedRecords protocol.""" def __init__(self) -> None: self._state = 0 @@ -1259,7 +1387,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = NestedRecordsWriterBase.schema def __enter__(self): @@ -1312,10 +1439,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_tuple_with_records' return "" +class NestedRecordsIndexedReaderBase(NestedRecordsReaderBase): + """Abstract reader for the NestedRecords protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class VlensWriterBase(abc.ABC): """Abstract writer for the Vlens protocol.""" - def __init__(self) -> None: self._state = 0 @@ -1414,8 +1548,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class VlensReaderBase(abc.ABC): - """Abstract reader for the Vlens protocol.""" - + """Abstract indexed reader for the Vlens protocol.""" def __init__(self) -> None: self._state = 0 @@ -1430,7 +1563,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = VlensWriterBase.schema def __enter__(self): @@ -1534,10 +1666,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_vlen_of_record_with_vlens' return "" +class VlensIndexedReaderBase(VlensReaderBase): + """Abstract reader for the Vlens protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class StringsWriterBase(abc.ABC): """Abstract writer for the Strings protocol.""" - def __init__(self) -> None: self._state = 0 @@ -1606,8 +1745,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class StringsReaderBase(abc.ABC): - """Abstract reader for the Strings protocol.""" - + """Abstract indexed reader for the Strings protocol.""" def __init__(self) -> None: self._state = 0 @@ -1622,7 +1760,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = StringsWriterBase.schema def __enter__(self): @@ -1692,10 +1829,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_rec_with_string' return "" +class StringsIndexedReaderBase(StringsReaderBase): + """Abstract reader for the Strings protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class OptionalVectorsWriterBase(abc.ABC): """Abstract writer for the OptionalVectors protocol.""" - def __init__(self) -> None: self._state = 0 @@ -1749,8 +1893,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class OptionalVectorsReaderBase(abc.ABC): - """Abstract reader for the OptionalVectors protocol.""" - + """Abstract indexed reader for the OptionalVectors protocol.""" def __init__(self) -> None: self._state = 0 @@ -1765,7 +1908,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = OptionalVectorsWriterBase.schema def __enter__(self): @@ -1818,10 +1960,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record_with_optional_vector' return "" +class OptionalVectorsIndexedReaderBase(OptionalVectorsReaderBase): + """Abstract reader for the OptionalVectors protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class FixedVectorsWriterBase(abc.ABC): """Abstract writer for the FixedVectors protocol.""" - def __init__(self) -> None: self._state = 0 @@ -1920,8 +2069,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class FixedVectorsReaderBase(abc.ABC): - """Abstract reader for the FixedVectors protocol.""" - + """Abstract indexed reader for the FixedVectors protocol.""" def __init__(self) -> None: self._state = 0 @@ -1936,7 +2084,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = FixedVectorsWriterBase.schema def __enter__(self): @@ -2040,10 +2187,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record_with_fixed_vectors' return "" +class FixedVectorsIndexedReaderBase(FixedVectorsReaderBase): + """Abstract reader for the FixedVectors protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class StreamsWriterBase(abc.ABC): """Abstract writer for the Streams protocol.""" - def __init__(self) -> None: self._state = 0 @@ -2157,8 +2311,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class StreamsReaderBase(abc.ABC): - """Abstract reader for the Streams protocol.""" - + """Abstract indexed reader for the Streams protocol.""" def __init__(self) -> None: self._state = 0 @@ -2173,7 +2326,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = StreamsWriterBase.schema def __enter__(self): @@ -2277,10 +2429,77 @@ def _state_to_method_name(self, state: int) -> str: return 'read_fixed_vector' return "" +class StreamsIndexedReaderBase(StreamsReaderBase): + """Abstract reader for the Streams protocol.""" + + def close(self) -> None: + self._close() + + def read_int_data(self, idx: int = 0) -> collections.abc.Iterable[yardl.Int32]: + value = self._read_int_data(idx) + return self._wrap_iterable(value, 2) + + def count_int_data(self) -> int: + return self._count_int_data() + + def read_optional_int_data(self, idx: int = 0) -> collections.abc.Iterable[typing.Optional[yardl.Int32]]: + value = self._read_optional_int_data(idx) + return self._wrap_iterable(value, 4) + + def count_optional_int_data(self) -> int: + return self._count_optional_int_data() + + def read_record_with_optional_vector_data(self, idx: int = 0) -> collections.abc.Iterable[RecordWithOptionalVector]: + value = self._read_record_with_optional_vector_data(idx) + return self._wrap_iterable(value, 6) + + def count_record_with_optional_vector_data(self) -> int: + return self._count_record_with_optional_vector_data() + + def read_fixed_vector(self, idx: int = 0) -> collections.abc.Iterable[list[yardl.Int32]]: + value = self._read_fixed_vector(idx) + return self._wrap_iterable(value, 8) + + def count_fixed_vector(self) -> int: + return self._count_fixed_vector() + + @abc.abstractmethod + def _read_int_data(self, idx: int = 0) -> collections.abc.Iterable[yardl.Int32]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_int_data(self) -> int: + raise NotImplementedError() + + @abc.abstractmethod + def _read_optional_int_data(self, idx: int = 0) -> collections.abc.Iterable[typing.Optional[yardl.Int32]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_optional_int_data(self) -> int: + raise NotImplementedError() + + @abc.abstractmethod + def _read_record_with_optional_vector_data(self, idx: int = 0) -> collections.abc.Iterable[RecordWithOptionalVector]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_record_with_optional_vector_data(self) -> int: + raise NotImplementedError() + + @abc.abstractmethod + def _read_fixed_vector(self, idx: int = 0) -> collections.abc.Iterable[list[yardl.Int32]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_fixed_vector(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class FixedArraysWriterBase(abc.ABC): """Abstract writer for the FixedArrays protocol.""" - def __init__(self) -> None: self._state = 0 @@ -2394,8 +2613,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class FixedArraysReaderBase(abc.ABC): - """Abstract reader for the FixedArrays protocol.""" - + """Abstract indexed reader for the FixedArrays protocol.""" def __init__(self) -> None: self._state = 0 @@ -2410,7 +2628,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = FixedArraysWriterBase.schema def __enter__(self): @@ -2531,10 +2748,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_named_array' return "" +class FixedArraysIndexedReaderBase(FixedArraysReaderBase): + """Abstract reader for the FixedArrays protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class SubarraysWriterBase(abc.ABC): """Abstract writer for the Subarrays protocol.""" - def __init__(self) -> None: self._state = 0 @@ -2708,8 +2932,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class SubarraysReaderBase(abc.ABC): - """Abstract reader for the Subarrays protocol.""" - + """Abstract indexed reader for the Subarrays protocol.""" def __init__(self) -> None: self._state = 0 @@ -2724,7 +2947,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = SubarraysWriterBase.schema def __enter__(self): @@ -2913,10 +3135,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_generic_subarray' return "" +class SubarraysIndexedReaderBase(SubarraysReaderBase): + """Abstract reader for the Subarrays protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class SubarraysInRecordsWriterBase(abc.ABC): """Abstract writer for the SubarraysInRecords protocol.""" - def __init__(self) -> None: self._state = 0 @@ -2985,8 +3214,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class SubarraysInRecordsReaderBase(abc.ABC): - """Abstract reader for the SubarraysInRecords protocol.""" - + """Abstract indexed reader for the SubarraysInRecords protocol.""" def __init__(self) -> None: self._state = 0 @@ -3001,7 +3229,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = SubarraysInRecordsWriterBase.schema def __enter__(self): @@ -3071,10 +3298,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_with_vlen_subarrays' return "" +class SubarraysInRecordsIndexedReaderBase(SubarraysInRecordsReaderBase): + """Abstract reader for the SubarraysInRecords protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class NDArraysWriterBase(abc.ABC): """Abstract writer for the NDArrays protocol.""" - def __init__(self) -> None: self._state = 0 @@ -3188,8 +3422,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class NDArraysReaderBase(abc.ABC): - """Abstract reader for the NDArrays protocol.""" - + """Abstract indexed reader for the NDArrays protocol.""" def __init__(self) -> None: self._state = 0 @@ -3204,7 +3437,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = NDArraysWriterBase.schema def __enter__(self): @@ -3325,10 +3557,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_named_array' return "" +class NDArraysIndexedReaderBase(NDArraysReaderBase): + """Abstract reader for the NDArrays protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class NDArraysSingleDimensionWriterBase(abc.ABC): """Abstract writer for the NDArraysSingleDimension protocol.""" - def __init__(self) -> None: self._state = 0 @@ -3427,8 +3666,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class NDArraysSingleDimensionReaderBase(abc.ABC): - """Abstract reader for the NDArraysSingleDimension protocol.""" - + """Abstract indexed reader for the NDArraysSingleDimension protocol.""" def __init__(self) -> None: self._state = 0 @@ -3443,7 +3681,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = NDArraysSingleDimensionWriterBase.schema def __enter__(self): @@ -3547,10 +3784,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record_with_nd_arrays' return "" +class NDArraysSingleDimensionIndexedReaderBase(NDArraysSingleDimensionReaderBase): + """Abstract reader for the NDArraysSingleDimension protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class DynamicNDArraysWriterBase(abc.ABC): """Abstract writer for the DynamicNDArrays protocol.""" - def __init__(self) -> None: self._state = 0 @@ -3649,8 +3893,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class DynamicNDArraysReaderBase(abc.ABC): - """Abstract reader for the DynamicNDArrays protocol.""" - + """Abstract indexed reader for the DynamicNDArrays protocol.""" def __init__(self) -> None: self._state = 0 @@ -3665,7 +3908,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = DynamicNDArraysWriterBase.schema def __enter__(self): @@ -3769,10 +4011,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record_with_dynamic_nd_arrays' return "" +class DynamicNDArraysIndexedReaderBase(DynamicNDArraysReaderBase): + """Abstract reader for the DynamicNDArrays protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class MultiDArraysWriterBase(abc.ABC): """Abstract writer for the MultiDArrays protocol.""" - def __init__(self) -> None: self._state = 0 @@ -3850,8 +4099,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class MultiDArraysReaderBase(abc.ABC): - """Abstract reader for the MultiDArrays protocol.""" - + """Abstract indexed reader for the MultiDArrays protocol.""" def __init__(self) -> None: self._state = 0 @@ -3866,7 +4114,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = MultiDArraysWriterBase.schema def __enter__(self): @@ -3936,10 +4183,47 @@ def _state_to_method_name(self, state: int) -> str: return 'read_frames' return "" +class MultiDArraysIndexedReaderBase(MultiDArraysReaderBase): + """Abstract reader for the MultiDArrays protocol.""" + + def close(self) -> None: + self._close() + + def read_images(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + value = self._read_images(idx) + return self._wrap_iterable(value, 2) + + def count_images(self) -> int: + return self._count_images() + + def read_frames(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + value = self._read_frames(idx) + return self._wrap_iterable(value, 4) + + def count_frames(self) -> int: + return self._count_frames() + + @abc.abstractmethod + def _read_images(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_images(self) -> int: + raise NotImplementedError() + + @abc.abstractmethod + def _read_frames(self, idx: int = 0) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_frames(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class ComplexArraysWriterBase(abc.ABC): """Abstract writer for the ComplexArrays protocol.""" - def __init__(self) -> None: self._state = 0 @@ -4008,8 +4292,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class ComplexArraysReaderBase(abc.ABC): - """Abstract reader for the ComplexArrays protocol.""" - + """Abstract indexed reader for the ComplexArrays protocol.""" def __init__(self) -> None: self._state = 0 @@ -4024,7 +4307,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = ComplexArraysWriterBase.schema def __enter__(self): @@ -4094,10 +4376,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_doubles' return "" +class ComplexArraysIndexedReaderBase(ComplexArraysReaderBase): + """Abstract reader for the ComplexArrays protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class MapsWriterBase(abc.ABC): """Abstract writer for the Maps protocol.""" - def __init__(self) -> None: self._state = 0 @@ -4211,8 +4500,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class MapsReaderBase(abc.ABC): - """Abstract reader for the Maps protocol.""" - + """Abstract indexed reader for the Maps protocol.""" def __init__(self) -> None: self._state = 0 @@ -4227,7 +4515,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = MapsWriterBase.schema def __enter__(self): @@ -4348,10 +4635,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_records' return "" +class MapsIndexedReaderBase(MapsReaderBase): + """Abstract reader for the Maps protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class UnionsWriterBase(abc.ABC): """Abstract writer for the Unions protocol.""" - def __init__(self) -> None: self._state = 0 @@ -4450,8 +4744,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class UnionsReaderBase(abc.ABC): - """Abstract reader for the Unions protocol.""" - + """Abstract indexed reader for the Unions protocol.""" def __init__(self) -> None: self._state = 0 @@ -4466,7 +4759,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = UnionsWriterBase.schema def __enter__(self): @@ -4570,10 +4862,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record_with_unions' return "" +class UnionsIndexedReaderBase(UnionsReaderBase): + """Abstract reader for the Unions protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class StreamsOfUnionsWriterBase(abc.ABC): """Abstract writer for the StreamsOfUnions protocol.""" - def __init__(self) -> None: self._state = 0 @@ -4669,8 +4968,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class StreamsOfUnionsReaderBase(abc.ABC): - """Abstract reader for the StreamsOfUnions protocol.""" - + """Abstract indexed reader for the StreamsOfUnions protocol.""" def __init__(self) -> None: self._state = 0 @@ -4685,7 +4983,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = StreamsOfUnionsWriterBase.schema def __enter__(self): @@ -4772,10 +5069,62 @@ def _state_to_method_name(self, state: int) -> str: return 'read_many_cases' return "" +class StreamsOfUnionsIndexedReaderBase(StreamsOfUnionsReaderBase): + """Abstract reader for the StreamsOfUnions protocol.""" + + def close(self) -> None: + self._close() + + def read_int_or_simple_record(self, idx: int = 0) -> collections.abc.Iterable[Int32OrSimpleRecord]: + value = self._read_int_or_simple_record(idx) + return self._wrap_iterable(value, 2) + + def count_int_or_simple_record(self) -> int: + return self._count_int_or_simple_record() + + def read_nullable_int_or_simple_record(self, idx: int = 0) -> collections.abc.Iterable[typing.Optional[Int32OrSimpleRecord]]: + value = self._read_nullable_int_or_simple_record(idx) + return self._wrap_iterable(value, 4) + + def count_nullable_int_or_simple_record(self) -> int: + return self._count_nullable_int_or_simple_record() + + def read_many_cases(self, idx: int = 0) -> collections.abc.Iterable[Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray]: + value = self._read_many_cases(idx) + return self._wrap_iterable(value, 6) + + def count_many_cases(self) -> int: + return self._count_many_cases() + + @abc.abstractmethod + def _read_int_or_simple_record(self, idx: int = 0) -> collections.abc.Iterable[Int32OrSimpleRecord]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_int_or_simple_record(self) -> int: + raise NotImplementedError() + + @abc.abstractmethod + def _read_nullable_int_or_simple_record(self, idx: int = 0) -> collections.abc.Iterable[typing.Optional[Int32OrSimpleRecord]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_nullable_int_or_simple_record(self) -> int: + raise NotImplementedError() + + @abc.abstractmethod + def _read_many_cases(self, idx: int = 0) -> collections.abc.Iterable[Int32OrFloat32OrStringOrSimpleRecordOrNamedFixedNDArray]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_many_cases(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class EnumsWriterBase(abc.ABC): """Abstract writer for the Enums protocol.""" - def __init__(self) -> None: self._state = 0 @@ -4874,8 +5223,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class EnumsReaderBase(abc.ABC): - """Abstract reader for the Enums protocol.""" - + """Abstract indexed reader for the Enums protocol.""" def __init__(self) -> None: self._state = 0 @@ -4890,7 +5238,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = EnumsWriterBase.schema def __enter__(self): @@ -4994,10 +5341,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_rec' return "" +class EnumsIndexedReaderBase(EnumsReaderBase): + """Abstract reader for the Enums protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class FlagsWriterBase(abc.ABC): """Abstract writer for the Flags protocol.""" - def __init__(self) -> None: self._state = 0 @@ -5075,8 +5429,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class FlagsReaderBase(abc.ABC): - """Abstract reader for the Flags protocol.""" - + """Abstract indexed reader for the Flags protocol.""" def __init__(self) -> None: self._state = 0 @@ -5091,7 +5444,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = FlagsWriterBase.schema def __enter__(self): @@ -5161,10 +5513,47 @@ def _state_to_method_name(self, state: int) -> str: return 'read_formats' return "" +class FlagsIndexedReaderBase(FlagsReaderBase): + """Abstract reader for the Flags protocol.""" + + def close(self) -> None: + self._close() + + def read_days(self, idx: int = 0) -> collections.abc.Iterable[DaysOfWeek]: + value = self._read_days(idx) + return self._wrap_iterable(value, 2) + + def count_days(self) -> int: + return self._count_days() + + def read_formats(self, idx: int = 0) -> collections.abc.Iterable[TextFormat]: + value = self._read_formats(idx) + return self._wrap_iterable(value, 4) + + def count_formats(self) -> int: + return self._count_formats() + + @abc.abstractmethod + def _read_days(self, idx: int = 0) -> collections.abc.Iterable[DaysOfWeek]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_days(self) -> int: + raise NotImplementedError() + + @abc.abstractmethod + def _read_formats(self, idx: int = 0) -> collections.abc.Iterable[TextFormat]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_formats(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class StateTestWriterBase(abc.ABC): """Abstract writer for the StateTest protocol.""" - def __init__(self) -> None: self._state = 0 @@ -5251,8 +5640,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class StateTestReaderBase(abc.ABC): - """Abstract reader for the StateTest protocol.""" - + """Abstract indexed reader for the StateTest protocol.""" def __init__(self) -> None: self._state = 0 @@ -5267,7 +5655,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = StateTestWriterBase.schema def __enter__(self): @@ -5354,10 +5741,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_another_int' return "" +class StateTestIndexedReaderBase(StateTestReaderBase): + """Abstract reader for the StateTest protocol.""" + + def close(self) -> None: + self._close() + + def read_a_stream(self, idx: int = 0) -> collections.abc.Iterable[yardl.Int32]: + value = self._read_a_stream(idx) + return self._wrap_iterable(value, 4) + + def count_a_stream(self) -> int: + return self._count_a_stream() + + @abc.abstractmethod + def _read_a_stream(self, idx: int = 0) -> collections.abc.Iterable[yardl.Int32]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_a_stream(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class SimpleGenericsWriterBase(abc.ABC): """Abstract writer for the SimpleGenerics protocol.""" - def __init__(self) -> None: self._state = 0 @@ -5537,8 +5946,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class SimpleGenericsReaderBase(abc.ABC): - """Abstract reader for the SimpleGenerics protocol.""" - + """Abstract indexed reader for the SimpleGenerics protocol.""" def __init__(self) -> None: self._state = 0 @@ -5553,7 +5961,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = SimpleGenericsWriterBase.schema def __enter__(self): @@ -5742,10 +6149,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_stream_of_type_variants' return "" +class SimpleGenericsIndexedReaderBase(SimpleGenericsReaderBase): + """Abstract reader for the SimpleGenerics protocol.""" + + def close(self) -> None: + self._close() + + def read_stream_of_type_variants(self, idx: int = 0) -> collections.abc.Iterable[ImageFloatOrImageDouble]: + value = self._read_stream_of_type_variants(idx) + return self._wrap_iterable(value, 18) + + def count_stream_of_type_variants(self) -> int: + return self._count_stream_of_type_variants() + + @abc.abstractmethod + def _read_stream_of_type_variants(self, idx: int = 0) -> collections.abc.Iterable[ImageFloatOrImageDouble]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_stream_of_type_variants(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class AdvancedGenericsWriterBase(abc.ABC): """Abstract writer for the AdvancedGenerics protocol.""" - def __init__(self) -> None: self._state = 0 @@ -5859,8 +6288,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class AdvancedGenericsReaderBase(abc.ABC): - """Abstract reader for the AdvancedGenerics protocol.""" - + """Abstract indexed reader for the AdvancedGenerics protocol.""" def __init__(self) -> None: self._state = 0 @@ -5875,7 +6303,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = AdvancedGenericsWriterBase.schema def __enter__(self): @@ -5996,10 +6423,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_tuple_of_vectors' return "" +class AdvancedGenericsIndexedReaderBase(AdvancedGenericsReaderBase): + """Abstract reader for the AdvancedGenerics protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class AliasesWriterBase(abc.ABC): """Abstract writer for the Aliases protocol.""" - def __init__(self) -> None: self._state = 0 @@ -6194,8 +6628,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class AliasesReaderBase(abc.ABC): - """Abstract reader for the Aliases protocol.""" - + """Abstract indexed reader for the Aliases protocol.""" def __init__(self) -> None: self._state = 0 @@ -6210,7 +6643,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = AliasesWriterBase.schema def __enter__(self): @@ -6416,10 +6848,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_stream_of_aliased_generic_union_2' return "" +class AliasesIndexedReaderBase(AliasesReaderBase): + """Abstract reader for the Aliases protocol.""" + + def close(self) -> None: + self._close() + + def read_stream_of_aliased_generic_union_2(self, idx: int = 0) -> collections.abc.Iterable[AliasedGenericUnion2[AliasedString, AliasedEnum]]: + value = self._read_stream_of_aliased_generic_union_2(idx) + return self._wrap_iterable(value, 20) + + def count_stream_of_aliased_generic_union_2(self) -> int: + return self._count_stream_of_aliased_generic_union_2() + + @abc.abstractmethod + def _read_stream_of_aliased_generic_union_2(self, idx: int = 0) -> collections.abc.Iterable[AliasedGenericUnion2[AliasedString, AliasedEnum]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_stream_of_aliased_generic_union_2(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class StreamsOfAliasedUnionsWriterBase(abc.ABC): """Abstract writer for the StreamsOfAliasedUnions protocol.""" - def __init__(self) -> None: self._state = 0 @@ -6497,8 +6951,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class StreamsOfAliasedUnionsReaderBase(abc.ABC): - """Abstract reader for the StreamsOfAliasedUnions protocol.""" - + """Abstract indexed reader for the StreamsOfAliasedUnions protocol.""" def __init__(self) -> None: self._state = 0 @@ -6513,7 +6966,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = StreamsOfAliasedUnionsWriterBase.schema def __enter__(self): @@ -6583,10 +7035,47 @@ def _state_to_method_name(self, state: int) -> str: return 'read_nullable_int_or_simple_record' return "" +class StreamsOfAliasedUnionsIndexedReaderBase(StreamsOfAliasedUnionsReaderBase): + """Abstract reader for the StreamsOfAliasedUnions protocol.""" + + def close(self) -> None: + self._close() + + def read_int_or_simple_record(self, idx: int = 0) -> collections.abc.Iterable[AliasedIntOrSimpleRecord]: + value = self._read_int_or_simple_record(idx) + return self._wrap_iterable(value, 2) + + def count_int_or_simple_record(self) -> int: + return self._count_int_or_simple_record() + + def read_nullable_int_or_simple_record(self, idx: int = 0) -> collections.abc.Iterable[typing.Optional[AliasedNullableIntSimpleRecord]]: + value = self._read_nullable_int_or_simple_record(idx) + return self._wrap_iterable(value, 4) + + def count_nullable_int_or_simple_record(self) -> int: + return self._count_nullable_int_or_simple_record() + + @abc.abstractmethod + def _read_int_or_simple_record(self, idx: int = 0) -> collections.abc.Iterable[AliasedIntOrSimpleRecord]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_int_or_simple_record(self) -> int: + raise NotImplementedError() + + @abc.abstractmethod + def _read_nullable_int_or_simple_record(self, idx: int = 0) -> collections.abc.Iterable[typing.Optional[AliasedNullableIntSimpleRecord]]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_nullable_int_or_simple_record(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class ProtocolWithComputedFieldsWriterBase(abc.ABC): """Abstract writer for the ProtocolWithComputedFields protocol.""" - def __init__(self) -> None: self._state = 0 @@ -6640,8 +7129,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class ProtocolWithComputedFieldsReaderBase(abc.ABC): - """Abstract reader for the ProtocolWithComputedFields protocol.""" - + """Abstract indexed reader for the ProtocolWithComputedFields protocol.""" def __init__(self) -> None: self._state = 0 @@ -6656,7 +7144,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = ProtocolWithComputedFieldsWriterBase.schema def __enter__(self): @@ -6709,10 +7196,17 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record_with_computed_fields' return "" +class ProtocolWithComputedFieldsIndexedReaderBase(ProtocolWithComputedFieldsReaderBase): + """Abstract reader for the ProtocolWithComputedFields protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class ProtocolWithKeywordStepsWriterBase(abc.ABC): """Abstract writer for the ProtocolWithKeywordSteps protocol.""" - def __init__(self) -> None: self._state = 0 @@ -6784,8 +7278,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class ProtocolWithKeywordStepsReaderBase(abc.ABC): - """Abstract reader for the ProtocolWithKeywordSteps protocol.""" - + """Abstract indexed reader for the ProtocolWithKeywordSteps protocol.""" def __init__(self) -> None: self._state = 0 @@ -6800,7 +7293,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = ProtocolWithKeywordStepsWriterBase.schema def __enter__(self): @@ -6870,10 +7362,32 @@ def _state_to_method_name(self, state: int) -> str: return 'read_float' return "" +class ProtocolWithKeywordStepsIndexedReaderBase(ProtocolWithKeywordStepsReaderBase): + """Abstract reader for the ProtocolWithKeywordSteps protocol.""" + + def close(self) -> None: + self._close() + + def read_int(self, idx: int = 0) -> collections.abc.Iterable[RecordWithKeywordFields]: + value = self._read_int(idx) + return self._wrap_iterable(value, 2) + + def count_int(self) -> int: + return self._count_int() + + @abc.abstractmethod + def _read_int(self, idx: int = 0) -> collections.abc.Iterable[RecordWithKeywordFields]: + raise NotImplementedError() + + @abc.abstractmethod + def _count_int(self) -> int: + raise NotImplementedError() + + def _raise_unexpected_state(self, actual: int) -> None: + pass class ProtocolWithOptionalDateWriterBase(abc.ABC): """Abstract writer for the ProtocolWithOptionalDate protocol.""" - def __init__(self) -> None: self._state = 0 @@ -6927,8 +7441,7 @@ def _state_to_method_name(self, state: int) -> str: return "" class ProtocolWithOptionalDateReaderBase(abc.ABC): - """Abstract reader for the ProtocolWithOptionalDate protocol.""" - + """Abstract indexed reader for the ProtocolWithOptionalDate protocol.""" def __init__(self) -> None: self._state = 0 @@ -6943,7 +7456,6 @@ def close(self) -> None: expected_method = self._state_to_method_name(self._state) raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") - schema = ProtocolWithOptionalDateWriterBase.schema def __enter__(self): @@ -6996,3 +7508,11 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record' return "" +class ProtocolWithOptionalDateIndexedReaderBase(ProtocolWithOptionalDateReaderBase): + """Abstract reader for the ProtocolWithOptionalDate protocol.""" + + def close(self) -> None: + self._close() + + def _raise_unexpected_state(self, actual: int) -> None: + pass