|
@@ -1,5 +1,5 @@
|
|
/**
|
|
/**
|
|
- * Copyright (c) 2006-2015 LOVE Development Team
|
|
|
|
|
|
+ * Copyright (c) 2006-2022 LOVE Development Team
|
|
*
|
|
*
|
|
* This software is provided 'as-is', without any express or implied
|
|
* This software is provided 'as-is', without any express or implied
|
|
* warranty. In no event will the authors be held liable for any damages
|
|
* warranty. In no event will the authors be held liable for any damages
|
|
@@ -24,41 +24,92 @@
|
|
// LOVE
|
|
// LOVE
|
|
#include <stddef.h>
|
|
#include <stddef.h>
|
|
#include "Object.h"
|
|
#include "Object.h"
|
|
|
|
+#include "int.h"
|
|
|
|
|
|
namespace love
|
|
namespace love
|
|
{
|
|
{
|
|
|
|
|
|
|
|
+class Data;
|
|
|
|
+
|
|
class Stream : public Object
|
|
class Stream : public Object
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
|
|
+
|
|
|
|
+ enum SeekOrigin
|
|
|
|
+ {
|
|
|
|
+ SEEKORIGIN_BEGIN,
|
|
|
|
+ SEEKORIGIN_CURRENT,
|
|
|
|
+ SEEKORIGIN_END,
|
|
|
|
+ SEEKORIGIN_MAX_ENUM
|
|
|
|
+ };
|
|
|
|
+
|
|
static love::Type type;
|
|
static love::Type type;
|
|
|
|
|
|
virtual ~Stream() {}
|
|
virtual ~Stream() {}
|
|
|
|
|
|
- // getData and getSize are assumed to talk about
|
|
|
|
- // the buffer
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new copy of the Stream, with the same settings as the original.
|
|
|
|
+ * The seek position will be reset in the copy.
|
|
|
|
+ **/
|
|
|
|
+ virtual Stream *clone() = 0;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets whether read() is supported for this Stream.
|
|
|
|
+ **/
|
|
|
|
+ virtual bool isReadable() const = 0;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets whether write() is supported for this Stream.
|
|
|
|
+ **/
|
|
|
|
+ virtual bool isWritable() const = 0;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets whether seek(), tell(), and getSize() are supported for this Stream.
|
|
|
|
+ **/
|
|
|
|
+ virtual bool isSeekable() const = 0;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * A callback, gets called when some Stream consumer exhausts the data
|
|
|
|
|
|
+ * Reads data into the destination buffer, and returns the number of bytes
|
|
|
|
+ * actually read.
|
|
**/
|
|
**/
|
|
- virtual void fillBackBuffer() {}
|
|
|
|
|
|
+ virtual int64 read(void *dst, int64 size) = 0;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the front buffer, Streams are supposed to be (at least) double-buffered
|
|
|
|
|
|
+ * Reads data into a new Data object.
|
|
**/
|
|
**/
|
|
- virtual const void *getFrontBuffer() const = 0;
|
|
|
|
|
|
+ virtual Data *read(int64 size);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the size of any (and in particular the front) buffer
|
|
|
|
|
|
+ * Writes data from the source buffer into the Stream.
|
|
**/
|
|
**/
|
|
- virtual size_t getSize() const = 0;
|
|
|
|
|
|
+ virtual bool write(const void *src, int64 size) = 0;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Swap buffers. Returns true if there is new data in the front buffer,
|
|
|
|
- * false otherwise.
|
|
|
|
- * NOTE: If there is no back buffer ready, this call must be ignored
|
|
|
|
|
|
+ * Writes data from the source Data object into the Stream.
|
|
**/
|
|
**/
|
|
- virtual bool swapBuffers() = 0;
|
|
|
|
|
|
+ virtual bool write(Data *src, int64 offset, int64 size);
|
|
|
|
+ bool write(Data *src);
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Flushes all data written to the Stream.
|
|
|
|
+ **/
|
|
|
|
+ virtual bool flush() = 0;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the total size of the Stream, if supported.
|
|
|
|
+ **/
|
|
|
|
+ virtual int64 getSize() = 0;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets the current position in the Stream, if supported.
|
|
|
|
+ **/
|
|
|
|
+ virtual bool seek(int64 pos, SeekOrigin origin = SEEKORIGIN_BEGIN) = 0;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the current position in the Stream, if supported.
|
|
|
|
+ **/
|
|
|
|
+ virtual int64 tell() = 0;
|
|
|
|
+
|
|
}; // Stream
|
|
}; // Stream
|
|
|
|
|
|
} // love
|
|
} // love
|