From df199b16cefe6fcbd9778689a8fd57969389c1bb Mon Sep 17 00:00:00 2001 From: Gert van Valkenhoef Date: Tue, 15 Nov 2011 15:15:55 +0000 Subject: [PATCH] Move endian-ness detection into Reader class --- oberon.h | 3 --- reader/reader.h | 4 ++++ reader/util.cc | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/oberon.h b/oberon.h index 2f9e39b..9a2d58d 100644 --- a/oberon.h +++ b/oberon.h @@ -62,9 +62,6 @@ namespace odc { * String: string in the Unicode character set, followed by a 0000X * i.e. CHAR* */ - - bool isBigEndian(); - bool isLittleEndian(); } #endif diff --git a/reader/reader.h b/reader/reader.h index b7becc0..eb593b5 100644 --- a/reader/reader.h +++ b/reader/reader.h @@ -225,6 +225,10 @@ private: * Add another component to the current path. If first==true, start a new path. */ void addPathComponent(bool first, const std::string &typeName); + + static bool isBigEndian(); + static bool isLittleEndian(); + }; } // namespace odc diff --git a/reader/util.cc b/reader/util.cc index 31befb7..76cd6af 100644 --- a/reader/util.cc +++ b/reader/util.cc @@ -1,7 +1,7 @@ -#include "oberon.h" +#include "reader/reader.h" namespace odc { - bool isBigEndian() { // http://stackoverflow.com/questions/1001307/detecting-endianness-programmatically-in-a-c-program + bool Reader::isBigEndian() { // http://stackoverflow.com/questions/1001307/detecting-endianness-programmatically-in-a-c-program union { uint32_t i; uint8_t c[4]; @@ -9,7 +9,7 @@ namespace odc { return test.c[0] == 1; } - bool isLittleEndian() { + bool Reader::isLittleEndian() { return !isBigEndian(); } } -- 2.29.2