8 #include "../lib/vstguifwd.h" 15 static const uint32_t kStreamIOError = std::numeric_limits<uint32_t>::max ();
16 static const int64_t kStreamSeekError = -1;
24 explicit OutputStream (ByteOrder byteOrder = kNativeByteOrder) : byteOrder (byteOrder) {}
27 ByteOrder getByteOrder ()
const {
return byteOrder; }
28 void setByteOrder (ByteOrder newByteOrder) { byteOrder = newByteOrder; }
30 bool operator<< (
const int8_t& input);
31 bool operator<< (
const uint8_t& input);
32 bool operator<< (
const int16_t& input);
33 bool operator<< (
const uint16_t& input);
34 bool operator<< (
const int32_t& input);
35 bool operator<< (
const uint32_t& input);
36 bool operator<< (
const int64_t& input);
37 bool operator<< (
const uint64_t& input);
38 bool operator<< (
const double& input);
40 virtual bool operator<< (
const std::string& str) = 0;
42 virtual uint32_t writeRaw (
const void* buffer, uint32_t size) = 0;
53 explicit InputStream (ByteOrder byteOrder = kNativeByteOrder) : byteOrder (byteOrder) {}
56 ByteOrder getByteOrder ()
const {
return byteOrder; }
57 void setByteOrder (ByteOrder newByteOrder) { byteOrder = newByteOrder; }
59 bool operator>> (int8_t& output);
60 bool operator>> (uint8_t& output);
61 bool operator>> (int16_t& output);
62 bool operator>> (uint16_t& output);
63 bool operator>> (int32_t& output);
64 bool operator>> (uint32_t& output);
65 bool operator>> (int64_t& output);
66 bool operator>> (uint64_t& output);
67 bool operator>> (
double& output);
69 virtual bool operator>> (std::string&
string) = 0;
71 virtual uint32_t readRaw (
void* buffer, uint32_t size) = 0;
89 virtual int64_t
seek (int64_t pos, SeekMode mode) = 0;
90 virtual int64_t tell ()
const = 0;
91 virtual void rewind () = 0;
100 CMemoryStream (uint32_t initialSize = 1024, uint32_t delta = 1024,
bool binaryMode =
true, ByteOrder byteOrder = kNativeByteOrder);
101 CMemoryStream (
const int8_t* buffer, uint32_t bufferSize,
bool binaryMode =
true, ByteOrder byteOrder = kNativeByteOrder);
104 uint32_t writeRaw (
const void* buffer, uint32_t size)
override;
105 uint32_t readRaw (
void* buffer, uint32_t size)
override;
107 int64_t
seek (int64_t pos, SeekMode mode)
override;
108 int64_t tell ()
const override {
return static_cast<int64_t
> (pos); }
109 void rewind ()
override { pos = 0; }
111 const int8_t* getBuffer ()
const {
return buffer; }
113 bool operator<< (
const std::string& str)
override;
114 bool operator>> (std::string&
string)
override;
118 bool resize (uint32_t newSize);
141 kTruncateMode = 1 << 2,
145 bool open (UTF8StringPtr path, int32_t mode, ByteOrder byteOrder = kNativeByteOrder);
147 uint32_t writeRaw (
const void* buffer, uint32_t size)
override;
148 uint32_t readRaw (
void* buffer, uint32_t size)
override;
150 int64_t
seek (int64_t pos, SeekMode mode)
override;
151 int64_t tell ()
const override;
152 void rewind ()
override;
154 bool operator<< (
const std::string& str)
override;
155 bool operator>> (std::string&
string)
override;
161 static const int8_t unixPathSeparator =
'/';
162 static const int8_t windowsPathSeparator =
'\\';
166 inline void unixfyPath (std::string& path)
168 std::replace (path.begin (), path.end (), windowsPathSeparator, unixPathSeparator);
172 inline bool removeLastPathComponent (std::string& path)
174 size_t sepPos = path.find_last_of (unixPathSeparator);
175 if (sepPos != std::string::npos)
184 inline bool pathIsAbsolute (
const std::string& path)
187 return !path.empty () && path[0] == unixPathSeparator;
189 return path.length () >= 2 && path[1] ==
':';
206 bool operator>> (std::string&
string)
override {
return false; }
207 uint32_t readRaw (
void* buffer, uint32_t size)
override;
208 int64_t
seek (int64_t pos, SeekMode mode)
override;
209 int64_t tell ()
const override;
210 void rewind ()
override;
212 void* platformHandle;
Describes a resource by name or by ID.
Definition: cresourcedescription.h:16
int64_t seek(int64_t pos, SeekMode mode) override
returns -1 if seek fails otherwise new position
Definition: cstream.cpp:109
Definition: cstream.h:132
Definition: customcontrols.cpp:8
Definition: vstguibase.h:247
int64_t seek(int64_t pos, SeekMode mode) override
returns -1 if seek fails otherwise new position
Definition: cstream.cpp:261
virtual int64_t seek(int64_t pos, SeekMode mode)=0
returns -1 if seek fails otherwise new position