Просмотр исходного кода

- 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
aramis_acg 14 лет назад
Родитель
Сommit
1eee9890a9
2 измененных файлов с 45 добавлено и 43 удалено
  1. 42 2
      code/ByteSwap.h
  2. 3 41
      code/StreamReader.h

+ 42 - 2
code/ByteSwap.h

@@ -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

+ 3 - 41
code/StreamReader.h

@@ -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();
 	}