diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bc3b66..7e13ee3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,6 @@ project(lexio LANGUAGES C CXX) set(LEXIO_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/lexio/bufreader.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/include/lexio/bytes.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/lexio/core.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/lexio/lexio.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/lexio/ref.hpp" diff --git a/include/lexio/bytes.hpp b/include/lexio/bytes.hpp deleted file mode 100644 index c39fe3f..0000000 --- a/include/lexio/bytes.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// -// Copyright 2023 Lexi Mayfield -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#pragma once - -#include "./core.hpp" - -namespace LexIO -{ - -template >> -inline size_t ReadBytes(IT outStart, IT outEnd, READER &reader) -{ - const size_t count = std::distance(outStart, outEnd); - return Read(&(*outStart), count, reader); -} - -template >> -inline size_t WriteBytes(WRITER &writer, IT start, IT end) -{ - const size_t count = std::distance(start, end); - return Write(writer, &(*start), count); -} - -template >> -inline size_t ReadBytes(uint8_t (&outArray)[N], READER &reader) -{ - return Read(&outArray[0], N, reader); -} - -template >> -inline size_t WriteBytes(WRITER &writer, uint8_t (&array)[N]) -{ - return Write(writer, &array[0], N); -} - -} // namespace LexIO diff --git a/include/lexio/core.hpp b/include/lexio/core.hpp index 528ecb1..8bee4ee 100644 --- a/include/lexio/core.hpp +++ b/include/lexio/core.hpp @@ -335,6 +335,13 @@ inline size_t Read(uint8_t (&outArray)[N], READER &reader) return reader.LexRead(&outArray[0], N); } +template >> +inline size_t Read(IT outStart, IT outEnd, READER &reader) +{ + const size_t count = std::distance(outStart, outEnd); + return reader.LexRead(&(*outStart), count, reader); +} + /** * @brief Fill the internal buffer of data to the requested size without * advancing the offset. If EOF is encountered, the rest of the @@ -387,6 +394,19 @@ inline size_t Write(WRITER &writer, const uint8_t *src, const size_t count) return writer.LexWrite(src, count); } +template >> +inline size_t Write(WRITER &writer, uint8_t (&array)[N]) +{ + return writer.LexWrite(&array[0], N); +} + +template >> +inline size_t Write(WRITER &writer, IT start, IT end) +{ + const size_t count = std::distance(start, end); + return Write(writer, &(*start), count); +} + /** * @brief Flushes data to underlying storage. Can be a no-op. * diff --git a/include/lexio/lexio.hpp b/include/lexio/lexio.hpp index feb257f..a990330 100644 --- a/include/lexio/lexio.hpp +++ b/include/lexio/lexio.hpp @@ -19,7 +19,6 @@ #include "./core.hpp" #include "./bufreader.hpp" -#include "./bytes.hpp" #include "./ref.hpp" #include "./serialize.hpp" #include "./stream.hpp" diff --git a/include/lexio/stream/container.hpp b/include/lexio/stream/container.hpp index 038c9e9..967a765 100644 --- a/include/lexio/stream/container.hpp +++ b/include/lexio/stream/container.hpp @@ -22,8 +22,6 @@ #include "../core.hpp" -#include // Used by StdBufReader - namespace LexIO { diff --git a/tests/test_file.cpp b/tests/test_file.cpp index 96c3f08..2337bc4 100644 --- a/tests/test_file.cpp +++ b/tests/test_file.cpp @@ -70,7 +70,7 @@ TEST_CASE("Test file opened in read mode") // Test writing. uint8_t writeBuffer[32] = {0x00}; - REQUIRE_THROWS(LexIO::WriteBytes(file, writeBuffer)); + REQUIRE_THROWS(LexIO::Write(file, writeBuffer)); // Test seeking. size_t pos = LexIO::Seek(file, 2, LexIO::Whence::start);