- 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-9d2fd5bffc1fpull/1/head
parent
ee827e8870
commit
1eee9890a9
|
@ -198,8 +198,6 @@ template <typename T> struct ByteSwap::_swapper<T,8> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace Assimp
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// ByteSwap macros for BigEndian/LittleEndian support
|
// ByteSwap macros for BigEndian/LittleEndian support
|
||||||
|
@ -241,5 +239,47 @@ template <typename T> struct ByteSwap::_swapper<T,8> {
|
||||||
#endif
|
#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
|
#endif //!! AI_BYTESWAP_H_INC
|
||||||
|
|
|
@ -46,48 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_STREAMREADER_H_INCLUDED
|
#define AI_STREAMREADER_H_INCLUDED
|
||||||
|
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwap.h"
|
||||||
namespace Assimp {
|
|
||||||
namespace Intern {
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
namespace Assimp {
|
||||||
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
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
/** Wrapper class around IOStream to allow for consistent reading of binary data in both
|
/** Wrapper class around IOStream to allow for consistent reading of binary data in both
|
||||||
|
@ -130,6 +90,7 @@ public:
|
||||||
: stream(stream)
|
: stream(stream)
|
||||||
, le(le)
|
, le(le)
|
||||||
{
|
{
|
||||||
|
ai_assert(stream);
|
||||||
_Begin();
|
_Begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +99,7 @@ public:
|
||||||
: stream(boost::shared_ptr<IOStream>(stream))
|
: stream(boost::shared_ptr<IOStream>(stream))
|
||||||
, le(le)
|
, le(le)
|
||||||
{
|
{
|
||||||
|
ai_assert(stream);
|
||||||
_Begin();
|
_Begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue