summaryrefslogtreecommitdiff
path: root/binaryreader.cpp
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2017-06-24 01:33:04 -0400
committerPeter LaFosse <peter@vector35.com>2017-07-01 10:02:27 -0400
commit0de62768c8afc5ca27576b59d4591ca8dbbd7cee (patch)
treebbd69585e0705905fddef54d32e2ab50aa91f6a6 /binaryreader.cpp
parentb0778fc4d0271a9ba16e7c81c2c4c67a8273cda6 (diff)
Adding settings system apis, and binaryview metadata apis
Diffstat (limited to 'binaryreader.cpp')
-rw-r--r--binaryreader.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/binaryreader.cpp b/binaryreader.cpp
index ad4859ff..7538e442 100644
--- a/binaryreader.cpp
+++ b/binaryreader.cpp
@@ -266,3 +266,40 @@ bool BinaryReader::IsEndOfFile() const
{
return BNIsEndOfFile(m_stream);
}
+
+
+template <typename T>
+T BinaryReader::Read()
+{
+ T value;
+ Read((char*)&value, sizeof(T));
+ return value;
+}
+
+template<typename T>
+vector<T> BinaryReader::ReadVector(size_t count)
+{
+ T* buff = new T[count];
+ Read((char*)buff, count * sizeof(T));
+ std::vector<T> out(buff, buff + count);
+ return out;
+}
+
+
+string BinaryReader::ReadCString(size_t maxSize)
+{
+ string result;
+ try
+ {
+ for (size_t i = 0; i < maxSize; i++)
+ {
+ char cur = Read8();
+ if (cur == 0)
+ break;
+ result.push_back(cur);
+ }
+ }
+ catch (ReadException& r)
+ {;}
+ return result;
+} \ No newline at end of file