PLCnext API Documentation 25.0.2.69
Stream.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
7#ifndef ARP_USE_ARP_SYSTEM_COMMONS
8#include "Arp/Base/Commons/Io/Stream.hpp"
10{
12using Arp::Base::Commons::Io::SeekOrigin;
13}
14#else
15#include "Arp/System/Core/Arp.h"
16#include "Arp/Base/Commons/Io/Stream.hpp"
17#include "Arp/System/Commons/Io/SeekOrigin.hpp"
18
19namespace Arp { namespace System { namespace Commons { namespace Io
20{
21
22// forwards
23class NullStream;
24
28class Stream
29{
30public: // construction/destruction
32 Stream(void) = default;
33
34public: // static properties
35 static NullStream Empty;
36
37public: // setter/getter operations
38 virtual bool CanRead(void) = 0;
39 virtual bool CanWrite(void) = 0;
40 virtual bool CanSeek(void) = 0;
41 virtual size_t GetLength(void) = 0;
42 virtual void SetLength(size_t length) = 0;
43 virtual size_t GetPosition(void) = 0;
44 virtual void SetPosition(size_t position) = 0;
45
46public: // abstract operations
47 virtual void Flush(void) = 0;
48 virtual size_t Seek(size_t offset, SeekOrigin origin) = 0;
49 virtual size_t Read(byte* pBuffer, size_t bufferSize, size_t offset, size_t count) = 0;
50 virtual void Write(const byte* pBuffer, size_t bufferSize, size_t offset, size_t count) = 0;
51 virtual void Close(void) = 0;
52
53public: // overridden operations
54 virtual byte ReadByte(void);
55 virtual void WriteByte(byte value);
56 virtual void WriteTo(Stream& other);
57 ARP_DEPRECATED("This operation is deprecated, use WriteTo(..) instead.")
58 void CopyTo(Stream& other);
59
60public: // operations
61 ARP_DEPRECATED("This operation is deprecated, implement destrcutor instead")
62 void Dispose(void);
63
64protected: // operations
65 ARP_DEPRECATED("This operation is deprecated")
66 bool IsDisposed(void);
67 ARP_DEPRECATED("This operation is deprecated")
68 void CheckDisposed(void);
69
70protected: // abstract operations
71 ARP_DEPRECATED("This operation is deprecated")
72 virtual void InternalDispose(void);
73
74private: // fields
75 bool isDisposed = false;
76};
77
78}}}} // end of namespace Arp::System::Commons::Io
79
80#endif // ndef ARP_USE_ARP_SYSTEM_COMMONS
This abstract class shall be the base class of all stream implementations.
Definition: Stream.hpp:20
virtual void WriteByte(byte value)
Writes a single byte to the stream.
Definition: Stream.cpp:118
virtual byte ReadByte(void)
Reads a single byte from the stream.
Definition: Stream.cpp:111
Stream(bool canRead=false, bool canWrite=false, bool canSeek=false)
This constructor is used to constructs a base stream instance.
Definition: Stream.cpp:59
virtual bool CanWrite(void)
Determines if the derived stream can write.
Definition: Stream.cpp:80
virtual bool CanSeek(void)
Determines if the derived stream can seek.
Definition: Stream.cpp:87
virtual void SetPosition(size_t value)
Sets the position of the stream, if it can seek.
Definition: Stream.cpp:95
virtual size_t GetPosition(void)
Gets the position of the stream, if it can seek.
Definition: Stream.cpp:103
virtual void WriteTo(Stream &other)
Writes the data this stream to another stream entirely.
Definition: Stream.cpp:125
virtual bool CanRead(void)
Determines if the derived stream can read.
Definition: Stream.cpp:73
@ Empty
No sink assigned to session yet.
Namespace for classes related to the filesystem and file I/O
@ 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....
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
Deprecated! The class implements an adapter for enums to define the string literals of the enum entri...
Definition: EnumStrings.hxx:38