Moved CharByte inside DataBuffer since that's where it belongs anyway.

Mon, 16 Jul 2012 04:15:49 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 16 Jul 2012 04:15:49 +0300
changeset 29
b4e09ae24bf1
parent 28
fb46d3d40064
child 30
6c4efed2dbdd

Moved CharByte inside DataBuffer since that's where it belongs anyway.

commands.def file | annotate | diff | comparison | revisions
common.h file | annotate | diff | comparison | revisions
objwriter.h file | annotate | diff | comparison | revisions
--- a/commands.def	Mon Jul 16 04:07:15 2012 +0300
+++ b/commands.def	Mon Jul 16 04:15:49 2012 +0300
@@ -1,5 +1,5 @@
-/* This file defines the commands botc will treat as valid. Do not edit unless
- * you know what you are doing!
+/* This file defines the commands botc will treat as valid.
+ * Do not edit unless you know what you are doing!
  *
  * Syntax: number:name:returntype:numargs:maxargs[:argumentlist]
  */
--- a/common.h	Mon Jul 16 04:07:15 2012 +0300
+++ b/common.h	Mon Jul 16 04:15:49 2012 +0300
@@ -100,20 +100,4 @@
 	return r;
 }
 
-template <class T> unsigned char CharByte (T a, unsigned int b) {
-	if (b >= sizeof (T))
-		error ("CharByte: tried to get byte %u out of a %u-byte %s\n",
-			b, sizeof (T), typeid(T).name());
-	
-	unsigned long p1 = pow<unsigned long> (256, b);
-	unsigned long p2 = pow<unsigned long> (256, b+1);
-	unsigned long r = (a % p2) / p1;
-	
-	if (r > 256)
-		error ("result %lu too big!", r);
-	
-	unsigned char ur = static_cast<unsigned char> (r);
-	return ur;
-}
-
 #endif // __COMMON_H__
\ No newline at end of file
--- a/objwriter.h	Mon Jul 16 04:07:15 2012 +0300
+++ b/objwriter.h	Mon Jul 16 04:15:49 2012 +0300
@@ -109,12 +109,29 @@
 			writepos++;
 		}
 	}
-
+	
 	template<class T> T Read() {
 		T result = buffer[readpos];
 		readpos += sizeof (T);
 		return result;
 	}
+
+private:
+	template <class T> unsigned char CharByte (T a, unsigned int b) {
+		if (b >= sizeof (T))
+			error ("CharByte: tried to get byte %u out of a %u-byte %s\n",
+				b, sizeof (T), typeid(T).name());
+		
+		unsigned long p1 = pow<unsigned long> (256, b);
+		unsigned long p2 = pow<unsigned long> (256, b+1);
+		unsigned long r = (a % p2) / p1;
+		
+		if (r > 256)
+			error ("result %lu too big!", r);
+		
+		unsigned char ur = static_cast<unsigned char> (r);
+		return ur;
+	}
 };
 
 class ObjWriter {

mercurial