diff --git a/M6502/HarteTest_6502/HarteTest_6502.vcxproj b/M6502/HarteTest_6502/HarteTest_6502.vcxproj index 3023c37..564fb21 100644 --- a/M6502/HarteTest_6502/HarteTest_6502.vcxproj +++ b/M6502/HarteTest_6502/HarteTest_6502.vcxproj @@ -106,7 +106,6 @@ Level3 true - true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) stdcpp17 Use @@ -115,7 +114,8 @@ false false true - AdvancedVectorExtensions + AdvancedVectorExtensions2 + AnySuitable Console @@ -142,7 +142,6 @@ Level3 true - true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) stdcpp17 Use @@ -151,7 +150,8 @@ false false true - AdvancedVectorExtensions + AdvancedVectorExtensions2 + AnySuitable Console @@ -167,6 +167,7 @@ + NotUsing @@ -192,6 +193,7 @@ + diff --git a/M6502/HarteTest_6502/HarteTest_6502.vcxproj.filters b/M6502/HarteTest_6502/HarteTest_6502.vcxproj.filters index a084986..eddd4ad 100644 --- a/M6502/HarteTest_6502/HarteTest_6502.vcxproj.filters +++ b/M6502/HarteTest_6502/HarteTest_6502.vcxproj.filters @@ -53,6 +53,9 @@ Source Files + + Source Files + @@ -91,5 +94,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.cpp b/M6502/HarteTest_6502/opcode_test_suite_t.cpp index d3a3ef2..3efbe46 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.cpp +++ b/M6502/HarteTest_6502/opcode_test_suite_t.cpp @@ -1,11 +1,5 @@ #include "stdafx.h" #include "opcode_test_suite_t.h" -simdjson::dom::parser opcode_test_suite_t::m_parser; - -opcode_test_suite_t::opcode_test_suite_t(const std::string path) -: m_path(path) {} - -void opcode_test_suite_t::load() { - m_raw = m_parser.load(path()); -} +opcode_test_suite_t::opcode_test_suite_t(const std::string path) noexcept +: parser_t(path) {} diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.h b/M6502/HarteTest_6502/opcode_test_suite_t.h index 6a20abb..69ad42c 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.h +++ b/M6502/HarteTest_6502/opcode_test_suite_t.h @@ -2,25 +2,15 @@ #include -#include "simdjson/simdjson.h" +#include "parser_t.h" -class opcode_test_suite_t final { +class opcode_test_suite_t final : public parser_t { private: - // N.B. - // The parser must be kept for the lifetime of any parsed data. - // Therefore, it can only be used for one document at a time. - static simdjson::dom::parser m_parser; - - std::string m_path; - simdjson::dom::array m_raw;; + [[nodiscard]] auto array() const noexcept { return raw().get_array(); } public: - opcode_test_suite_t(std::string path); + opcode_test_suite_t(std::string path) noexcept; - [[nodiscard]] constexpr const auto& path() const noexcept { return m_path; } - - void load(); - - [[nodiscard]] auto begin() const noexcept { return m_raw.begin(); } - [[nodiscard]] auto end() const noexcept { return m_raw.end(); } + [[nodiscard]] auto begin() const noexcept { return array().begin(); } + [[nodiscard]] auto end() const noexcept { return array().end(); } }; diff --git a/M6502/HarteTest_6502/parser_t.cpp b/M6502/HarteTest_6502/parser_t.cpp new file mode 100644 index 0000000..5f5a026 --- /dev/null +++ b/M6502/HarteTest_6502/parser_t.cpp @@ -0,0 +1,11 @@ +#include "stdafx.h" +#include "parser_t.h" + +simdjson::dom::parser parser_t::m_parser; + +parser_t::parser_t(const std::string path) noexcept +: m_path(path) {} + +void parser_t::load() { + m_raw = m_parser.load(path()); +} diff --git a/M6502/HarteTest_6502/parser_t.h b/M6502/HarteTest_6502/parser_t.h new file mode 100644 index 0000000..a059d76 --- /dev/null +++ b/M6502/HarteTest_6502/parser_t.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +#include "simdjson/simdjson.h" + +class parser_t { +private: + // N.B. + // The parser must be kept for the lifetime of any parsed data. + // Therefore, it can only be used for one document at a time. + static simdjson::dom::parser m_parser; + + std::string m_path; + simdjson::dom::element m_raw; + +public: + parser_t(std::string path) noexcept; + + [[nodiscard]] constexpr const auto& path() const noexcept { return m_path; } + [[nodiscard]] const auto raw() const noexcept { return m_raw; } + + virtual void load(); +};