summaryrefslogtreecommitdiffhomepage
path: root/FoundationEx/src/reader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'FoundationEx/src/reader.cpp')
-rw-r--r--FoundationEx/src/reader.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/FoundationEx/src/reader.cpp b/FoundationEx/src/reader.cpp
new file mode 100644
index 0000000..7bce34d
--- /dev/null
+++ b/FoundationEx/src/reader.cpp
@@ -0,0 +1,82 @@
+/* Starshatter: The Open Source Project
+ Copyright (c) 2021-2024, Starshatter: The Open Source Project Contributors
+ Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
+ Copyright (c) 1997-2006, Destroyer Studios LLC.
+*/
+
+#include <starshatter/foundation/reader.h>
+
+#include <memory>
+#include <utility>
+
+#include "reader/buffer.h"
+
+
+namespace starshatter
+{
+namespace foundation
+{
+
+
+Reader::Reader()
+{
+}
+
+
+Reader::Reader(Reader&& other) :
+ actual {std::move(other.actual)}
+{
+}
+
+
+Reader&
+Reader::operator=(Reader&& other)
+{
+ actual = std::move(other.actual);
+ return *this;
+}
+
+
+Reader::Reader(Base src) :
+ actual {std::move(src)}
+{
+}
+
+
+Reader::Reader(Chars src) :
+ actual {std::make_unique<BufferReader<Chars>>(std::move(src))}
+{
+}
+
+
+Reader::Reader(Chars src, Count bytes) :
+ actual {std::make_unique<BufferReader<Chars>>(std::move(src), bytes)}
+{
+}
+
+
+Reader::Reader(const char* src) :
+ actual {std::make_unique<BufferReader<const char*>>(src)}
+{
+}
+
+
+Reader::Reader(const char* src, Count bytes) :
+ actual {std::make_unique<BufferReader<const char*>>(src, bytes)}
+{
+}
+
+
+bool Reader::valid() const { return static_cast<bool>(actual); }
+Count Reader::available() const { return actual->available(); }
+Count Reader::seek(Count pos) { return actual->seek(pos); }
+Count Reader::seek(Offset offset, Direction dir) { return actual->seek(offset, dir); }
+Count Reader::read(char* dest) { return actual->read(dest); }
+Count Reader::read(char* dest, Count bytes) { return actual->read(dest, bytes); }
+Count Reader::peek(char* dest) const { return actual->peek(dest); }
+Count Reader::peek(char* dest, Count bytes) const { return actual->peek(dest, bytes); }
+const char* Reader::data() const { return actual->data(); }
+
+
+} // namespace foundation
+} // namespace starshatter