diff options
author | Ben Smith <binjimin@gmail.com> | 2017-07-12 19:42:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-12 19:42:30 -0700 |
commit | 9baa0e36730db024ba4cf5990d190206de457a62 (patch) | |
tree | 18abe1aa684fca1e519cb8530b0d65b0959b350c /src/stream.h | |
parent | 88be146bd125e01e49281b1a2ec6efde9012c260 (diff) | |
download | wabt-9baa0e36730db024ba4cf5990d190206de457a62.tar.gz wabt-9baa0e36730db024ba4cf5990d190206de457a62.tar.bz2 wabt-9baa0e36730db024ba4cf5990d190206de457a62.zip |
Use std::vector for DataSegment data (#567)
* Also switch ScriptModule data to std::vector
* In wast-parser.y:
- Change DupTextList to write to std::vector
- quoted_text uses CopyStringContents instead of DupTextList
Diffstat (limited to 'src/stream.h')
-rw-r--r-- | src/stream.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/stream.h b/src/stream.h index 0a673e89..7e92d90b 100644 --- a/src/stream.h +++ b/src/stream.h @@ -19,6 +19,7 @@ #include <cassert> #include <memory> +#include <vector> #include "common.h" #include "writer.h" @@ -57,7 +58,14 @@ class Stream { size_t size, const char* desc = nullptr, PrintChars = PrintChars::No); - void MoveData(size_t dst_offset, size_t src_offset, size_t size); + + template <typename T> + void WriteData(const std::vector<T> src, + const char* desc, + PrintChars print_chars = PrintChars::No) { + if (!src.empty()) + WriteData(src.data(), src.size() * sizeof(T), desc, print_chars); + } void WriteDataAt(size_t offset, const void* src, @@ -65,6 +73,8 @@ class Stream { const char* desc = nullptr, PrintChars = PrintChars::No); + void MoveData(size_t dst_offset, size_t src_offset, size_t size); + void WABT_PRINTF_FORMAT(2, 3) Writef(const char* format, ...); // Specified as uint32_t instead of uint8_t so we can check if the value |