11#ifndef FORTRAN_RUNTIME_IO_CONNECTION_H_
12#define FORTRAN_RUNTIME_IO_CONNECTION_H_
15#include "flang/Common/optional.h"
18namespace Fortran::runtime::io {
20class IoStatementState;
22enum class Direction { Output, Input };
23enum class Access { Sequential, Direct, Stream };
28 Access access{Access::Sequential};
29 Fortran::common::optional<bool> isUnformatted;
31 unsigned char internalIoCharKind{0};
32 Fortran::common::optional<std::int64_t> openRecl;
34 RT_API_ATTRS
bool IsRecordFile()
const {
36 return access != Access::Stream || !isUnformatted.value_or(
true);
39 template <
typename CHAR =
char>
constexpr RT_API_ATTRS
bool useUTF8()
const {
43 return internalIoCharKind == 0 && (
sizeof(CHAR) > 1 || isUTF8);
51 IsAfterEndfile()
const;
57 RT_API_ATTRS std::size_t RemainingSpaceInRecord()
const;
58 RT_API_ATTRS
bool NeedAdvance(std::size_t)
const;
59 RT_API_ATTRS
void HandleAbsolutePosition(std::int64_t);
60 RT_API_ATTRS
void HandleRelativePosition(std::int64_t);
62 RT_API_ATTRS
void BeginRecord() {
64 furthestPositionInRecord = 0;
65 unterminatedRecord =
false;
68 RT_API_ATTRS Fortran::common::optional<std::int64_t>
69 EffectiveRecordLength()
const {
72 return openRecl && recordLength && *openRecl < *recordLength ? openRecl
76 Fortran::common::optional<std::int64_t> recordLength;
78 std::int64_t currentRecordNumber{1};
84 std::int64_t positionInRecord{0};
89 std::int64_t furthestPositionInRecord{0};
92 Fortran::common::optional<std::int64_t>
97 Fortran::common::optional<std::int64_t> endfileRecordNumber;
106 bool pinnedFrame{
false};
110 bool unterminatedRecord{
false};
118 RT_API_ATTRS
void Cancel() { cancelled_ =
true; }
123 bool cancelled_{
false};
Definition: connection.h:114
Definition: connection.h:27
Definition: connection.h:47