Author: post
Date: 2010-06-20 12:33:55 +0200 (Sun, 20 Jun 2010)
New Revision: 243

Modified:
   RawSpeed/TiffEntry.cpp
   RawSpeed/TiffEntryBE.cpp
   RawSpeed/TiffIFD.cpp
Log:
Use function to throw tiff parsing errors, should make debugging easier.

Modified: RawSpeed/TiffEntry.cpp
===================================================================
--- RawSpeed/TiffEntry.cpp      2010-06-20 10:33:09 UTC (rev 242)
+++ RawSpeed/TiffEntry.cpp      2010-06-20 10:33:55 UTC (rev 243)
@@ -34,7 +34,7 @@
   type = (TiffDataType)p[1];
   count = *(int*)f->getData(offset + 4);
   if (type > 13)
-    throw TiffParserException("Error reading TIFF structure. Unknown Type 
encountered.");
+    ThrowTPE("Error reading TIFF structure. Unknown Type 0x%x encountered.", 
type);
   uint32 bytesize = count << datashifts[type];
   if (bytesize <= 4) {
     data = f->getDataWrt(offset + 8);
@@ -63,7 +63,7 @@
 
 unsigned int TiffEntry::getInt() {
   if (!(type == TIFF_LONG || type == TIFF_SHORT))
-    throw TiffParserException("TIFF, getInt: Wrong type encountered. Expected 
Long");
+    ThrowTPE("TIFF, getInt: Wrong type 0x%x encountered. Expected Long", type);
   if (type == TIFF_SHORT)
     return getShort();
   return *(unsigned int*)&data[0];
@@ -71,25 +71,25 @@
 
 unsigned short TiffEntry::getShort() {
   if (type != TIFF_SHORT)
-    throw TiffParserException("TIFF, getShort: Wrong type encountered. 
Expected Short");
+    ThrowTPE("TIFF, getShort: Wrong type 0x%x encountered. Expected Short", 
type);
   return *(unsigned short*)&data[0];
 }
 
 const unsigned int* TiffEntry::getIntArray() {
   if (type != TIFF_LONG && type != TIFF_RATIONAL && type != TIFF_SRATIONAL && 
type != TIFF_UNDEFINED )
-    throw TiffParserException("TIFF, getIntArray: Wrong type encountered. 
Expected Long");
+    ThrowTPE("TIFF, getIntArray: Wrong type 0x%x encountered. Expected Long", 
type);
   return (unsigned int*)&data[0];
 }
 
 const unsigned short* TiffEntry::getShortArray() {
   if (type != TIFF_SHORT)
-    throw TiffParserException("TIFF, getShortArray: Wrong type encountered. 
Expected Short");
+    ThrowTPE("TIFF, getShortArray: Wrong type 0x%x encountered. Expected 
Short", type);
   return (unsigned short*)&data[0];
 }
 
 unsigned char TiffEntry::getByte() {
   if (type != TIFF_BYTE)
-    throw TiffParserException("TIFF, getByte: Wrong type encountered. Expected 
Byte");
+    ThrowTPE("TIFF, getByte: Wrong type 0x%x encountered. Expected Byte", 
type);
   return data[0];
 }
 
@@ -99,7 +99,7 @@
 
 float TiffEntry::getFloat() {
   if (!(type == TIFF_FLOAT || type == TIFF_DOUBLE || type == TIFF_RATIONAL || 
type == TIFF_SRATIONAL || type == TIFF_LONG || type == TIFF_SHORT))
-    throw TiffParserException("TIFF, getFloat: Wrong type encountered. 
Expected Float");
+    ThrowTPE("TIFF, getFloat: Wrong type 0x%x encountered. Expected Float", 
type);
   if (type == TIFF_DOUBLE) {
     return (float)*(double*)&data[0];
   } else if (type == TIFF_FLOAT) {
@@ -120,7 +120,7 @@
 
 string TiffEntry::getString() {
   if (type != TIFF_ASCII)
-    throw TiffParserException("TIFF, getString: Wrong type encountered. 
Expected Ascii");
+    ThrowTPE("TIFF, getString: Wrong type 0x%x encountered. Expected Ascii", 
type);
   data[count-1] = 0;  // Ensure string is not larger than count defines
   return string((char*)&data[0]);
 }

Modified: RawSpeed/TiffEntryBE.cpp
===================================================================
--- RawSpeed/TiffEntryBE.cpp    2010-06-20 10:33:09 UTC (rev 242)
+++ RawSpeed/TiffEntryBE.cpp    2010-06-20 10:33:55 UTC (rev 243)
@@ -35,7 +35,7 @@
   type = _type;         //Now we can set it to the proper type
 
   if (type > 13)
-    throw TiffParserException("Error reading TIFF structure. Unknown Type 
encountered.");
+    ThrowTPE("Error reading TIFF structure. Unknown Type 0x%x encountered.", 
type);
   uint32 bytesize = count << datashifts[type];
   if (bytesize <= 4) {
     data = f->getDataWrt(offset + 8);
@@ -61,7 +61,7 @@
 
 unsigned int TiffEntryBE::getInt() {
   if (!(type == TIFF_LONG || type == TIFF_SHORT || type == TIFF_UNDEFINED))
-    throw TiffParserException("TIFF, getInt: Wrong type encountered. Expected 
Int");
+    ThrowTPE("TIFF, getInt: Wrong type 0x%x encountered. Expected Int", type);
   if (type == TIFF_SHORT)
     return getShort();
   return (unsigned int)data[0] << 24 | (unsigned int)data[1] << 16 | (unsigned 
int)data[2] << 8 | (unsigned int)data[3];
@@ -69,14 +69,14 @@
 
 unsigned short TiffEntryBE::getShort() {
   if (!(type == TIFF_SHORT || type == TIFF_UNDEFINED))
-    throw TiffParserException("TIFF, getShort: Wrong type encountered. 
Expected Short");
+    ThrowTPE("TIFF, getShort: Wrong type 0x%x encountered. Expected Short", 
type);
   return (unsigned short)data[0] << 8 | (unsigned short)data[1];
 }
 
 const unsigned int* TiffEntryBE::getIntArray() {
   //TODO: Make critical section to avoid clashes.
   if (!(type == TIFF_LONG || type == TIFF_UNDEFINED || type == TIFF_RATIONAL 
||  type == TIFF_SRATIONAL))
-    throw TiffParserException("TIFF, getIntArray: Wrong type encountered. 
Expected Int");
+    ThrowTPE("TIFF, getIntArray: Wrong type 0x%x encountered. Expected Int", 
type);
   if (mDataSwapped)
     return (unsigned int*)&data[0];
 
@@ -91,7 +91,7 @@
 const unsigned short* TiffEntryBE::getShortArray() {
   //TODO: Make critical section to avoid clashes.
   if (!(type == TIFF_SHORT || type == TIFF_UNDEFINED))
-    throw TiffParserException("TIFF, getShortArray: Wrong type encountered. 
Expected Short");
+    ThrowTPE("TIFF, getShortArray: Wrong type 0x%x encountered. Expected 
Short", type);
 
   if (mDataSwapped)
     return (unsigned short*)&data[0];

Modified: RawSpeed/TiffIFD.cpp
===================================================================
--- RawSpeed/TiffIFD.cpp        2010-06-20 10:33:09 UTC (rev 242)
+++ RawSpeed/TiffIFD.cpp        2010-06-20 10:33:55 UTC (rev 243)
@@ -28,7 +28,7 @@
 #undef CHECKSIZE
 #endif
 
-#define CHECKSIZE(A) if (A >= size) throw TiffParserException("Error reading 
TIFF structure. File Corrupt")
+#define CHECKSIZE(A) if (A >= size) ThrowTPE("Error reading TIFF structure 
(invalid size). File Corrupt")
 
 TiffIFD::TiffIFD() {
   nextIFD = 0;


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to