Skip to content

Commit

Permalink
Improvements in class design related to binary reading-writing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvov1 committed Jan 28, 2024
1 parent 86b186a commit 00ea2ca
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 67 deletions.
13 changes: 6 additions & 7 deletions Aesi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@ class Aesi final {
return ss;
}


/**
* @brief Read a number in binary from an input stream
* @param Istream stream
Expand All @@ -1285,20 +1286,18 @@ class Aesi final {
* @note Fills empty bits with 0s on eof of the stream
*/
template <typename Char> requires (std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>)
static constexpr auto readBinary(std::basic_istream<Char>& istream, bool bigEndian = true) -> Aesi {
Aesi result {}; result.sign = Positive;

constexpr auto readBinary(std::basic_istream<Char>& istream, bool bigEndian = true) -> void {
blocks = {}; sign = Positive;
if(bigEndian) {
for(auto it = result.blocks.rbegin(); it != result.blocks.rend(); ++it)
for(auto it = blocks.rbegin(); it != blocks.rend(); ++it)
if(!istream.read(reinterpret_cast<char*>(&*it), sizeof(block))) break;
} else {
for(auto& tBlock: result.blocks)
for(auto& tBlock: blocks)
if(!istream.read(reinterpret_cast<char*>(&tBlock), sizeof(block))) break;
}

return result;
}


/**
* @brief Write a number in binary to the output stream
* @param Ostream stream
Expand Down
Binary file modified test/benchmarks/measures.db
Binary file not shown.
Loading

0 comments on commit 00ea2ca

Please sign in to comment.