//===-- runtime/internal-unit.h ---------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // Fortran internal I/O "units" #ifndef FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_ #define FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_ #include "connection.h" #include "descriptor.h" #include #include namespace Fortran::runtime::io { class IoErrorHandler; // Points to (but does not own) a CHARACTER scalar or array for internal I/O. // Does not buffer. template class InternalDescriptorUnit : public ConnectionState { public: using Scalar = std::conditional_t; InternalDescriptorUnit(Scalar, std::size_t); InternalDescriptorUnit(const Descriptor &, const Terminator &); void EndIoStatement(); bool Emit(const char *, std::size_t, IoErrorHandler &); std::optional GetCurrentChar(IoErrorHandler &); bool AdvanceRecord(IoErrorHandler &); void BackspaceRecord(IoErrorHandler &); private: Descriptor &descriptor() { return staticDescriptor_.descriptor(); } const Descriptor &descriptor() const { return staticDescriptor_.descriptor(); } Scalar CurrentRecord() const { return descriptor().template ZeroBasedIndexedElement( currentRecordNumber - 1); } StaticDescriptor staticDescriptor_; }; extern template class InternalDescriptorUnit; extern template class InternalDescriptorUnit; } // namespace Fortran::runtime::io #endif // FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_