summaryrefslogtreecommitdiff
path: root/src/corelib/render/software/svg/agg_svg_exception.pas
blob: 0a52836e98df276c7ce98533abd2192b670a4a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4 (Public License)
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
// Pascal Port By: Milan Marusinec alias Milano
//                 milan@marusinec.sk
//                 http://www.aggpas.org
// Copyright (c) 2005-2006
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
//          mcseemagg@yahoo.com
//          http://www.antigrain.com
//
// [Pascal Port History] -----------------------------------------------------
//
// 23.06.2006-Milano: ptrcomp adjustments
// 24.04.2006-Milano: Unit port establishment
//
{ agg_svg_exception.pas }
unit
 agg_svg_exception ;

INTERFACE

{$I agg_mode.inc }

uses
 SysUtils ,
 agg_basics ;

{ TYPES DEFINITION }
type
 svg_exception_ptr = ^svg_exception;
 svg_exception = class(Exception )
   m_msg : pointer;

   constructor Construct; overload;
   constructor Construct(fmt : PChar ); overload;
   constructor Construct(exc : svg_exception_ptr ); overload;

   procedure Free;
   function  _msg : char_ptr;

  end;

{ GLOBAL PROCEDURES }
 function  get_double(ptr : agg_basics.char_ptr ) : double;
 

IMPLEMENTATION
{ LOCAL VARIABLES & CONSTANTS }
{ UNIT IMPLEMENTATION }
{ CONSTRUCT }
constructor svg_exception.Construct;
begin
 m_msg:=NIL;

end;

{ CONSTRUCT }
constructor svg_exception.Construct(fmt : PChar );
var
 max : int;

begin
 m_msg:=NIL;

 if agg_getmem(m_msg ,4096 ) then
  begin
   max:=StrLen(fmt );

   if max > 4095 then
    max:=4095;

   move(fmt[0 ] ,m_msg^ ,max );

   int8_ptr(ptrcomp(m_msg ) + max )^:=0;

  end;

end;

{ CONSTRUCT }
constructor svg_exception.Construct(exc : svg_exception_ptr );
var
 max : int;

begin
 m_msg:=NIL;

 if (exc <> NIL ) and
    (exc.m_msg <> NIL ) then
  if agg_getmem(m_msg ,4096 ) then
   begin
    max:=StrLen(exc.m_msg );

    if max > 4095 then
     max:=4095;

    move(exc.m_msg^ ,m_msg^ ,max );

    int8_ptr(ptrcomp(m_msg ) + max )^:=0;

   end;

end;

{ FREE }
procedure svg_exception.Free;
begin
 if m_msg <> NIL then
  agg_freemem(m_msg ,4096 );

end;

{ _MSG }
function svg_exception._msg;
begin
 result:=char_ptr(m_msg );

end;

{ GET_DOUBLE }
function get_double;
var
 buf : array[0..49 ] of char;
 dst ,
 max : char_ptr;
 err : integer;

begin
 dst:=@buf[0 ];
 max:=@buf[48 ];

 while ptr^ <> #0 do
  begin
   case ptr^ of
    '-' ,'.' ,'0'..'9' :
     if dst <> max then
      begin
       dst^:=ptr^;

       inc(ptrcomp(dst ) );

      end
     else
      break;

    else
     break;

   end;

   inc(ptrcomp(ptr ) );

  end;

 dst^:=#0; 

 val(PChar(@buf[0 ] ) ,result ,err );

end;

END.