Changeset 256 in Sophya for trunk/SophyaLib/BaseTools
- Timestamp:
- Apr 23, 1999, 2:38:18 PM (26 years ago)
- Location:
- trunk/SophyaLib/BaseTools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/SysTools.o.list
r255 r256 1 1 ctimer.o 2 2 md5.o 3 ndatablock.o 3 4 pdlmgr.o 4 5 peidainit.o -
trunk/SophyaLib/BaseTools/pexceptions.h
r251 r256 4 4 5 5 #include "machdefs.h" 6 //#include <exception>7 6 #include <string> 8 7 … … 12 11 13 12 // Ancestor for PError and PException 14 class PThrowable { // : public exception { 15 public: 16 explicit PThrowable(const string& m) : msg(m) {} 17 virtual ~PThrowable() { } 18 virtual string const& Msg() const {return msg;} 19 private: 20 string msg; 13 // It has a message, and an id to give more 14 // information on the exception. 15 class PThrowable { 16 public: 17 explicit PThrowable(const string& m, int ident=0) 18 : msg(m), id(ident) {} 19 virtual ~PThrowable() { } 20 virtual string const& Msg() const {return msg;} 21 private: 22 string msg; 23 int id; 21 24 }; 22 25 23 26 // A PError is a serious logic error. Usually not caught... 24 27 class PError : public PThrowable { 25 26 explicit PError(const string& m) : PThrowable(m) {}28 public: 29 explicit PError(const string& m, int id=0) : PThrowable(m,id) {} 27 30 }; 28 31 29 32 // A PException is not as serious... Can be caught. 30 33 class PException : public PThrowable { 31 public: 32 explicit PException(const string& m) : PThrowable(m) {} 34 public: 35 explicit PException(const string& m, int id=0) : PThrowable(m,id) {} 36 }; 37 38 // Errors 39 // Memory allocation failure 40 class AllocationError : public PError { 41 public: 42 explicit AllocationError(const string& m, int id=0) : PError(m,id) {} 43 }; 44 45 // Null pointer error 46 class NullPtrError : public PError { 47 public: 48 explicit NullPtrError(const string& m, int id=0) : PError(m,id) {} 49 }; 50 51 // Size mismatch between objects 52 class SzMismatchError : public PError { 53 public: 54 explicit SzMismatchError(const string& m, int id=0) : PError(m,id) {} 55 }; 56 57 // Out of bounds for array, matrix, etc. 58 class RangeCheckError : public PError { 59 public: 60 explicit RangeCheckError(const string& m, int id=0) : PError(m,id) {} 61 }; 62 63 // Invalid parameter to method/constructor... 64 class ParmError : public PError { 65 public: 66 explicit ParmError(const string& m, int id=0) : PError(m,id) {} 67 }; 68 69 // Calling a forbidden method, trying a forbidden operation 70 class ForbiddenError : public PError { 71 public: 72 explicit ForbiddenError(const string& m, int id=0) : PError(m,id) {} 73 }; 74 75 // ASSERT macro failure. The message is the assertion... 76 class AssertionFailedError : public PError { 77 public: 78 explicit AssertionFailedError(const string& m, int id=0) : PError(m,id) {} 79 }; 80 81 // Standard exceptions 82 // 83 // PException 84 // IOExc 85 // FileFormatExc 86 // TypeMismatchExc 87 // DuplicateIdExc 88 // NotFoundExc 89 // MathExc 90 // SingMatxExc 91 92 // generic IO Exception 93 class IOExc : public PException { 94 public: 95 explicit IOExc(const string& m, int id=0) : PException(m,id) {} 33 96 }; 34 97 35 // Errors36 class AllocationError : public PError{37 38 explicit AllocationError(const string& m) : PError(m) {}98 // Bad type -> keep ? 99 class TypeMismatchExc : public PException { 100 public: 101 explicit TypeMismatchExc(const string& m, int id=0) : PException(m,id) {} 39 102 }; 40 103 41 class NullPtrError : public PError { 42 public: 43 explicit NullPtrError(const string& m) : PError(m) {} 104 class MathExc : public PException { 105 public: 106 explicit MathExc(const string& m, int id=0) : PException(m,id) {} 107 }; 108 109 class DuplicateIdExc : public PException { 110 public: 111 explicit DuplicateIdExc(const string& m, int id=0) : PException(m,id) {} 112 }; 113 114 class NotFoundExc : public PException { 115 public: 116 explicit NotFoundExc(const string& m, int id=0) : PException(m,id) {} 117 }; 118 119 class CaughtSignalExc : public PException { 120 public: 121 explicit CaughtSignalExc(const string& m, int id=0) : PException(m,id) {} 44 122 }; 45 123 46 class SzMismatchError : public PError { 47 public: 48 explicit SzMismatchError(const string& m) : PError(m) {} 49 }; 50 51 class RangeCheckError : public PError { 52 public: 53 explicit RangeCheckError(const string& m) : PError(m) {} 54 }; 55 56 class ParmError : public PError { 57 public: 58 explicit ParmError(const string& m) : PError(m) {} 59 }; 60 61 class ForbiddenError : public PError { 62 public: 63 explicit ForbiddenError(const string& m) : PError(m) {} 64 }; 65 66 class AssertionFailedError : public PError { 67 public: 68 explicit AssertionFailedError(const string& m) : PError(m) {} 69 }; 70 71 // Standard exceptions 72 class TypeMismatchExc : public PException { 73 public: 74 explicit TypeMismatchExc(const string& m) : PException(m) {} 75 }; 76 77 class FileExc : public PException { 78 public: 79 explicit FileExc(const string& m) : PException(m) {} 80 }; 81 82 class FileFormatExc : public PException { 83 public: 84 explicit FileFormatExc(const string& m) : PException(m) {} 85 }; 86 87 class DuplicateIdExc : public PException { 88 public: 89 explicit DuplicateIdExc(const string& m) : PException(m) {} 90 }; 91 92 class NotFoundExc : public PException { 93 public: 94 explicit NotFoundExc(const string& m) : PException(m) {} 95 }; 96 97 class CaughtSignalExc : public PException { 98 public: 99 explicit CaughtSignalExc(const string& m) : PException(m) {} 124 // Bad file format 125 class FileFormatExc : public IOExc { 126 public: 127 explicit FileFormatExc(const string& m, int id=0) : IOExc(m,id) {} 100 128 }; 101 129 102 class SingMatrixExc : public PException{103 104 explicit SingMatrixExc(const string& m) : PException(m) {}130 class SingMatrixExc : public MathExc { 131 public: 132 explicit SingMatrixExc(const string& m, int id=0) : MathExc(m,id) {} 105 133 }; 106 134 107 135 108 136 } 109 137 … … 149 177 #define inconsistentErr ParmError("") 150 178 #define sizeMismatchErr SzMismatchError("") 151 #define fileErr FileExc("")179 #define fileErr IOExc("") 152 180 #define nullPtrErr NullPtrError("") 153 181 #define singMatxErr SingMatrixExc("") -
trunk/SophyaLib/BaseTools/ppersist.cc
r251 r256 150 150 s.GetRawByte(ppstype); 151 151 if (ppstype != PInPersist::PPS_OBJECT) { 152 throw TypeMismatchExc("PPersist::Read : not an object in flow");152 throw FileFormatExc("PPersist::Read : not an object in flow"); 153 153 } 154 154 … … 157 157 s.GetRawU8(classId); 158 158 if (classId != PIOPersist::Hash(typeid(*this).name())) { 159 throw TypeMismatchExc("PPersist::Read : not the same object type");159 throw FileFormatExc("PPersist::Read : not the same object type"); 160 160 } 161 161 … … 302 302 303 303 304 int 305 PInPersist::NbTags() 306 { 307 return tags.size(); 308 } 309 304 310 bool 305 311 PInPersist::GotoTag(string const& name) … … 312 318 return(true); 313 319 } 320 321 bool 322 PInPersist::GotoTagNum(int itag) 323 { 324 if (itag<0 || itag >= tags.size()) return false; 325 map<string, int_8>::iterator i = tags.begin(); 326 for (int j=0; j<itag; j++) i++; 327 s->seekg((*i).second); 328 return(true); 329 } 330 314 331 315 332 //++ … … 419 436 GetRawByte(ppstype); 420 437 if (ppstype != PPS_SIMPLE + datasz) 421 throw TypeMismatchExc("PInPersist::CheckTag bad type in ppersist file");438 throw FileFormatExc("PInPersist::CheckTag bad type in ppersist file"); 422 439 } 423 440 … … 430 447 if (sz <= 0x7fff) { 431 448 if (ppstype != PPS_SIMPLE_ARRAY + datasz) 432 throw TypeMismatchExc("PInPersist::CheckTag bad type in ppersist file");449 throw FileFormatExc("PInPersist::CheckTag bad type in ppersist file"); 433 450 int_2 ff; 434 451 GetRawI2(ff); filesz=ff; 435 452 } else if (sz <= 0x7fffffff) { 436 453 if (ppstype != PPS_SIMPLE_ARRAY4 + datasz) 437 throw TypeMismatchExc("PInPersist::CheckTag bad type in ppersist file");454 throw FileFormatExc("PInPersist::CheckTag bad type in ppersist file"); 438 455 int_4 ff; 439 456 GetRawI4(ff); filesz=ff; 440 457 } else { 441 458 if (ppstype != PPS_SIMPLE_ARRAY8 + datasz) 442 throw TypeMismatchExc("PInPersist::CheckTag bad type in ppersist file");459 throw FileFormatExc("PInPersist::CheckTag bad type in ppersist file"); 443 460 uint_8 ff; 444 461 GetRawU8(ff); filesz=ff; 445 462 } 446 463 if (filesz != sz) 447 throw TypeMismatchExc("PInPersist::CheckTag bad array size in ppersist file");464 throw FileFormatExc("PInPersist::CheckTag bad array size in ppersist file"); 448 465 } 449 466 … … 646 663 GetRawByte(ppstype); 647 664 if (ppstype != PPS_LINE) 648 throw TypeMismatchExc("PInPersist::GetLine bad type in ppersist file");665 throw FileFormatExc("PInPersist::GetLine bad type in ppersist file"); 649 666 s->getline(ptr, len, '\n'); 650 667 } … … 656 673 GetRawByte(ppstype); 657 674 if (ppstype != PPS_STRING) 658 throw TypeMismatchExc("PInPersist::GetLine bad type in ppersist file");675 throw FileFormatExc("PInPersist::GetLine bad type in ppersist file"); 659 676 int_2 len; 660 677 GetRawI2(len); … … 673 690 GetRawByte(ppstype); 674 691 if (ppstype != PPS_OBJECT && ppstype != PPS_REFERENCE && ppstype != PPS_NULL) { 675 throw TypeMismatchExc("PInPersist::ReadObject : not an object in flow");692 throw FileFormatExc("PInPersist::ReadObject : not an object in flow"); 676 693 } 677 694 -
trunk/SophyaLib/BaseTools/ppersist.h
r252 r256 107 107 108 108 bool GotoTag(string const& name); 109 int NbTags(); 110 bool GotoTagNum(int itag); // 0..NbTags-1 109 111 110 112 void GetByte (char& c);
Note:
See TracChangeset
for help on using the changeset viewer.