- move ByteSwap template code from StreamReader.h to ByteSwap.h, where it belongs to.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@915 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2011-03-08 16:23:37 +00:00
parent ee827e8870
commit 1eee9890a9
2 changed files with 45 additions and 43 deletions

View File

@ -198,8 +198,6 @@ template <typename T> struct ByteSwap::_swapper<T,8> {
}
};
} // Namespace Assimp
// --------------------------------------------------------------------------------------
// ByteSwap macros for BigEndian/LittleEndian support
@ -241,5 +239,47 @@ template <typename T> struct ByteSwap::_swapper<T,8> {
#endif
namespace Intern {
// --------------------------------------------------------------------------------------------
template <typename T, bool doit>
struct ByteSwapper {
void operator() (T* inout) {
ByteSwap::Swap(inout);
}
};
template <typename T>
struct ByteSwapper<T,false> {
void operator() (T*) {
}
};
// --------------------------------------------------------------------------------------------
template <bool SwapEndianess, typename T, bool RuntimeSwitch>
struct Getter {
void operator() (T* inout, bool le) {
#ifdef AI_BUILD_BIG_ENDIAN
le = le;
#else
le = !le;
#endif
if (le) {
ByteSwapper<T,(sizeof(T)>1?true:false)> () (inout);
}
else ByteSwapper<T,false> () (inout);
}
};
template <bool SwapEndianess, typename T>
struct Getter<SwapEndianess,T,false> {
void operator() (T* inout, bool le) {
// static branch
ByteSwapper<T,(SwapEndianess && sizeof(T)>1)> () (inout);
}
};
} // end Intern
} // end Assimp
#endif //!! AI_BYTESWAP_H_INC

View File

@ -46,48 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_STREAMREADER_H_INCLUDED
#include "ByteSwap.h"
namespace Assimp {
namespace Intern {
// --------------------------------------------------------------------------------------------
template <typename T, bool doit>
struct ByteSwapper {
void operator() (T* inout) {
ByteSwap::Swap(inout);
}
};
template <typename T>
struct ByteSwapper<T,false> {
void operator() (T*) {
}
};
// --------------------------------------------------------------------------------------------
template <bool SwapEndianess, typename T, bool RuntimeSwitch>
struct Getter {
void operator() (T* inout, bool le) {
#ifdef AI_BUILD_BIG_ENDIAN
le = le;
#else
le = !le;
#endif
if (le) {
ByteSwapper<T,(sizeof(T)>1?true:false)> () (inout);
}
else ByteSwapper<T,false> () (inout);
}
};
template <bool SwapEndianess, typename T>
struct Getter<SwapEndianess,T,false> {
void operator() (T* inout, bool le) {
// static branch
ByteSwapper<T,(SwapEndianess && sizeof(T)>1)> () (inout);
}
};
} // end Intern
namespace Assimp {
// --------------------------------------------------------------------------------------------
/** Wrapper class around IOStream to allow for consistent reading of binary data in both
@ -130,6 +90,7 @@ public:
: stream(stream)
, le(le)
{
ai_assert(stream);
_Begin();
}
@ -138,6 +99,7 @@ public:
: stream(boost::shared_ptr<IOStream>(stream))
, le(le)
{
ai_assert(stream);
_Begin();
}