diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d584386..80568fe2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,6 @@ target_include_directories(${CLP_FFI_JS_BIN_NAME} PRIVATE src/) set(CLP_FFI_JS_SRC_MAIN src/clp_ffi_js/ir/decoding_methods.cpp - src/clp_ffi_js/ir/IrStreamReader.cpp src/clp_ffi_js/ir/StreamReader.cpp ) diff --git a/src/clp_ffi_js/ir/IrStreamReader.cpp b/src/clp_ffi_js/ir/IrStreamReader.cpp index 8ec58c2e..3140eac0 100644 --- a/src/clp_ffi_js/ir/IrStreamReader.cpp +++ b/src/clp_ffi_js/ir/IrStreamReader.cpp @@ -212,11 +212,11 @@ IrStreamReader::IrStreamReader( )}, m_ts_pattern{m_stream_reader_data_context->get_deserializer().get_timestamp_pattern()} {} -auto IrStreamReader::create_deserializer_and_data_context( +auto IrStreamReader::create_data_context( std::unique_ptr&& zstd_decompressor, clp::Array&& data_buffer ) -> StreamReaderDataContext { - rewind_reader_and_verify_encoding_type(*zstd_decompressor); + rewind_reader_and_validate_encoding_type(*zstd_decompressor); auto result{ clp::ir::LogEventDeserializer::create(*zstd_decompressor) diff --git a/src/clp_ffi_js/ir/StreamReader.cpp b/src/clp_ffi_js/ir/StreamReader.cpp index 176af4d3..d2280a34 100644 --- a/src/clp_ffi_js/ir/StreamReader.cpp +++ b/src/clp_ffi_js/ir/StreamReader.cpp @@ -34,7 +34,7 @@ auto StreamReader::create(DataArrayTsType const& data_array) -> std::unique_ptr< auto const version{get_version(*zstd_decompressor)}; if (version == "v0.0.0") { - auto stream_reader_data_context{IrStreamReader::create_deserializer_and_data_context( + auto stream_reader_data_context{IrStreamReader::create_data_context( std::move(zstd_decompressor), std::move(data_buffer) )}; diff --git a/src/clp_ffi_js/ir/StreamReader.hpp b/src/clp_ffi_js/ir/StreamReader.hpp index ad9cbaa0..c74c9032 100644 --- a/src/clp_ffi_js/ir/StreamReader.hpp +++ b/src/clp_ffi_js/ir/StreamReader.hpp @@ -1,12 +1,15 @@ #ifndef CLP_FFI_JS_IR_STREAM_READER_HPP #define CLP_FFI_JS_IR_STREAM_READER_HPP +#include #include #include #include namespace clp_ffi_js::ir { +using clp::ir::four_byte_encoded_variable_t; + EMSCRIPTEN_DECLARE_VAL_TYPE(DataArrayTsType); EMSCRIPTEN_DECLARE_VAL_TYPE(DecodedResultsTsType); EMSCRIPTEN_DECLARE_VAL_TYPE(FilteredLogEventMapTsType); @@ -39,6 +42,7 @@ class StreamReader { // Delete move assignment operator since it's also disabled in `clp::ir::LogEventDeserializer`. auto operator=(StreamReader&&) -> StreamReader& = delete; + // Methods /** * @return The number of events buffered. */ diff --git a/src/clp_ffi_js/ir/decoding_methods.cpp b/src/clp_ffi_js/ir/decoding_methods.cpp index 81063f6a..3c420ecb 100644 --- a/src/clp_ffi_js/ir/decoding_methods.cpp +++ b/src/clp_ffi_js/ir/decoding_methods.cpp @@ -19,7 +19,7 @@ namespace clp_ffi_js::ir { auto get_version(clp::ReaderInterface& reader) -> std::string { // The encoding type bytes must be consumed before the metadata can be read. - rewind_reader_and_verify_encoding_type(reader); + rewind_reader_and_validate_encoding_type(reader); // Deserialize metadata bytes from preamble. clp::ffi::ir_stream::encoded_tag_t metadata_type{}; @@ -54,7 +54,7 @@ auto get_version(clp::ReaderInterface& reader) -> std::string { return version; } -auto rewind_reader_and_verify_encoding_type(clp::ReaderInterface& reader) -> void { +auto rewind_reader_and_validate_encoding_type(clp::ReaderInterface& reader) -> void { reader.seek_from_begin(0); bool is_four_bytes_encoding{true}; diff --git a/src/clp_ffi_js/ir/decoding_methods.hpp b/src/clp_ffi_js/ir/decoding_methods.hpp index 6791fd21..ec3e529b 100644 --- a/src/clp_ffi_js/ir/decoding_methods.hpp +++ b/src/clp_ffi_js/ir/decoding_methods.hpp @@ -7,7 +7,13 @@ namespace clp_ffi_js::ir { auto get_version(clp::ReaderInterface& reader) -> std::string; -auto rewind_reader_and_verify_encoding_type(clp::ReaderInterface& reader) -> void; +/** + * Rewinds the reader to the beginning and validates the CLP IR data encoding type. + * @param reader + * @throws ClpFfiJsException if the encoding type couldn't be decoded or the encoding type is + * unsupported. + */ +auto rewind_reader_and_validate_encoding_type(clp::ReaderInterface& reader) -> void; } // namespace clp_ffi_js::ir #endif // CLP_FFI_JS_IR_DECODING_METHODS_HPP