Debian Codegraph @

examples/svg_viewer/agg_svg_exception.h

raw
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 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: [email protected]
12 // [email protected]
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
15 //
16 // SVG exception
17 //
18 //----------------------------------------------------------------------------
19
20 #ifndef AGG_SVG_EXCEPTION_INCLUDED
21 #define AGG_SVG_EXCEPTION_INCLUDED
22
23 #include <stdio.h>
24 #include <string.h>
25 #include <stdarg.h>
26
27 namespace agg
28 {
29 namespace svg
30 {
31 class exception
32 {
33 public:
34 ~exception()
35 {
36 delete [] m_msg;
37 }
38
39 exception() : m_msg(0) {}
40
41 exception(const char* fmt, ...) :
42 m_msg(0)
43 {
44 if(fmt)
45 {
46 m_msg = new char [4096];
47 va_list arg;
48 va_start(arg, fmt);
49 vsprintf(m_msg, fmt, arg);
50 va_end(arg);
51 }
52 }
53
54 exception(const exception& exc) :
55 m_msg(exc.m_msg ? new char[strlen(exc.m_msg) + 1] : 0)
56 {
57 if(m_msg) strcpy(m_msg, exc.m_msg);
58 }
59
60 const char* msg() const { return m_msg; }
61
62 private:
63 char* m_msg;
64 };
65
66 }
67 }
68
69 #endif