PLCnext API Documentation 25.0.2.69
Stream.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Core/PimplPtr.hxx"
9#include "Arp/Base/Commons/Io/SeekOrigin.hpp"
10
11namespace Arp::Base::Commons::Io
12{
13
14// forwards
15class NullStream;
16
19class ARP_EXPORT Stream
20{
21public: // Impl forward declaration
22 class Impl;
23
24public: // construction
25 Stream(bool canRead = false, bool canWrite = false, bool canSeek = false);
26
27 // canonical construction/destruction/assignment
28 Stream(const Stream& arg);
29 Stream(Stream&& arg)noexcept;
30 Stream& operator=(const Stream& arg);
31 Stream& operator=(Stream&& arg)noexcept;
32 virtual ~Stream(void);
33
34public: // static operations
35 static Stream& GetEmpty(void);
36
37public: // abstract setter/getter operations
38 virtual bool CanRead(void);
39 virtual bool CanWrite(void);
40 virtual bool CanSeek(void);
41 virtual void SetPosition(size_t value);
42 virtual size_t GetPosition(void);
43
44public: // abstract operations
45 virtual size_t Seek(size_t offset, SeekOrigin origin) = 0;
46 virtual size_t Read(byte* pBuffer, size_t bufferSize, size_t bufferOffset, size_t count) = 0;
47 virtual void Write(const byte* pBuffer, size_t bufferSize, size_t bufferOffset, size_t count) = 0;
48 virtual void Flush(void) = 0;
49
50public: // virtual operations
51 virtual byte ReadByte(void);
52 virtual void WriteByte(byte value);
53 virtual void WriteTo(Stream& other);
54 virtual void ReadFrom(Stream& other);
55
56private: // internal operations
57 Impl& GetImpl(void);
58 const Impl& GetImpl(void)const;
59
60private: // Impl usings
62
63private: // Impl fields
64 Pimpl pimpl;
65};
66
67} // end of namespace Arp::Base::Commons::Io
This abstract class shall be the base class of all stream implementations.
Definition: Stream.hpp:20
Stream(const Stream &arg)
Default copy constructor.
virtual ~Stream(void)
Default destructor.
Stream & operator=(const Stream &arg)
Default copy-assignment operator.
Stream & operator=(Stream &&arg) noexcept
Default move-assignment operator.
Stream(Stream &&arg) noexcept
Default move constructor.
Adapter class to implement PImpl idiom.
Definition: PimplPtr.hxx:15
@ Write
Specifies write access to the file. Data can be written to the file and the file pointer can be moved...
@ Read
Specifies read access to the file. Data can be read from the file and the file pointer can be moved....