/*** Copyright (C) 2022-2023 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: AuProtocolStackSpecialWriter.cpp File: AuProtocolStack.cpp Date: 2022-8-24 Date: 2023-09-21 Author: Reece ***/ #include "Protocol.hpp" #include "AuProtocolStack.hpp" #include "AuProtocolStackSpecialWriter.hpp" namespace Aurora::IO::Protocol { SpecialWriter::SpecialWriter(ProtocolStack *pParent) : pParent(pParent) { } EStreamError SpecialWriter::IsOpen() { auto pStack = this->pParent; if (pStack->bDead) { return EStreamError::eErrorHandleClosed; } if (!pStack->pSourceBufer) { return EStreamError::eErrorStreamNotOpen; } return EStreamError::eErrorNone; } EStreamError SpecialWriter::Write(const Memory::MemoryViewStreamRead ¶meters) { parameters.outVariable = 0; auto pStack = this->pParent; if (pStack->bDead) { return EStreamError::eErrorHandleClosed; } auto pStackBuffer = pStack->pSourceBufer; //pStack->AsWritableByteBuffer(); if (!pStackBuffer) { return EStreamError::eErrorStreamNotOpen; } parameters.outVariable = pStackBuffer->Write(parameters.ptr, parameters.length); return EStreamError::eErrorNone; } void SpecialWriter::Close() { this->pParent->Terminate(); } void SpecialWriter::Flush() { this->pParent->DoTick(); } }