1 //---------------------------------------------------------------------------- 2 // Anti-Grain Geometry - Version 2.2 3 // Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com) 4 // 5 // Permission to copy, use, modify, sell and distribute this software 6 // is granted provided this copyright notice appears in all copies. 7 // This software is provided "as is" without express or implied 8 // warranty, and with no claim as to its suitability for any purpose. 9 // 10 //---------------------------------------------------------------------------- 11 // Contact: mcseem@antigrain.com 12 // mcseemagg@yahoo.com 13 // http://www.antigrain.com 14 //---------------------------------------------------------------------------- 15 // 16 // SVG exception 17 // 18 //---------------------------------------------------------------------------- 19 20 #ifndef SVG_EXCEPTION_H 21 #define SVG_EXCEPTION_H 22 23 #include <stdio.h> 24 #include <string.h> 25 #include <stdarg.h> 26 27 namespace agg { 28 namespace svg { 29 30 class exception { 31 public: 32 33 ~exception() 34 { 35 delete [] m_msg; 36 } 37 38 exception() : m_msg(0) {} 39 40 exception(const char* fmt, ...) : 41 m_msg(0) 42 { 43 if(fmt) 44 { 45 m_msg = new char [4096]; 46 va_list arg; 47 va_start(arg, fmt); 48 vsprintf(m_msg, fmt, arg); 49 va_end(arg); 50 } 51 } 52 53 exception(const exception& exc) : 54 m_msg(exc.m_msg ? new char[strlen(exc.m_msg) + 1] : 0) 55 { 56 if(m_msg) strcpy(m_msg, exc.m_msg); 57 } 58 59 const char* msg() const { return m_msg; } 60 61 private: 62 char* m_msg; 63 }; 64 65 } // namespace svg 66 } // namespace agg 67 68 #endif // SVG_EXCEPTION_H 69