Skip to content

Commit

Permalink
Changes to nv_num, including little endian support
Browse files Browse the repository at this point in the history
  • Loading branch information
jclehner committed Jun 29, 2023
1 parent 2ea96e8 commit aac72d6
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 190 deletions.
10 changes: 2 additions & 8 deletions nonvol2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ std::string desc(const nv_val::named& var)
return var.name + " (" + var.val->type() + ")";
}

template<typename T> void write_num(ostream& os, T num)
{
num = h_to_be(num);
os.write(reinterpret_cast<const char*>(&num), sizeof(T));
}

string pad(unsigned level)
{
return string(2 * (level + 1), ' ');
Expand Down Expand Up @@ -667,9 +661,9 @@ ostream& nv_string::write(ostream& os) const
size_t size = val.size() + ((m_flags & flag_size_includes_prefix) ? str_prefix_bytes(m_flags) : 0);

if (m_flags & flag_prefix_u8) {
write_num<uint8_t>(os, size);
nv_u8::write(os, size);
} else if (m_flags & flag_prefix_u16) {
write_num<uint16_t>(os, size);
nv_u16::write(os, size);
}

if (!(os << val)) {
Expand Down

0 comments on commit aac72d6

Please sign in to comment.