1 /******************************************************************************
2  * $Id$
3  *
4  * Project:  MapServer
5  * Purpose:  Declarations related to copyng mapObjs.  Provided by Mladen Turk
6  *           for resolution of bug 701
7  *           http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=701.
8  * Author:   Mladen Turk (and Sean Gilles?)
9  *
10  ******************************************************************************
11  * Copyright (c) 1996-2005 Regents of the University of Minnesota.
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included in
21  * all copies of this Software or works derived from this Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 /* Following works for GCC and MSVC.  That's ~98% of our users, if Tyler
33  * Mitchell's survey is correct
34  */
35 #define MS_COPYSTELEM(_name) (dst)->/**/_name = (src)->/**/_name
36 
37 #define MS_MACROBEGIN              do {
38 #define MS_MACROEND                } while (0)
39 
40 #define MS_COPYRECT(_dst, _src)       \
41     MS_MACROBEGIN                     \
42         (_dst)->minx = (_src)->minx;  \
43         (_dst)->miny = (_src)->miny;  \
44         (_dst)->maxx = (_src)->maxx;  \
45         (_dst)->maxy = (_src)->maxy;  \
46     MS_MACROEND
47 
48 #ifdef USE_POINT_Z_M
49 #define MS_COPYPOINT(_dst, _src)      \
50     MS_MACROBEGIN                     \
51         (_dst)->x = (_src)->x;        \
52         (_dst)->y = (_src)->y;        \
53         (_dst)->m = (_src)->m;        \
54     MS_MACROEND
55 #else
56 #define MS_COPYPOINT(_dst, _src)      \
57     MS_MACROBEGIN                     \
58         (_dst)->x = (_src)->x;        \
59         (_dst)->y = (_src)->y;        \
60     MS_MACROEND
61 #endif
62 
63 #define MS_COPYCOLOR(_dst, _src)      \
64     MS_MACROBEGIN                     \
65         (_dst)->red   = (_src)->red;  \
66         (_dst)->green = (_src)->green;\
67         (_dst)->blue  = (_src)->blue; \
68         (_dst)->alpha  = (_src)->alpha; \
69     MS_MACROEND
70 
71 #define MS_COPYSTRING(_dst, _src)     \
72     MS_MACROBEGIN                     \
73         if ((_dst) != NULL)           \
74             msFree((_dst));           \
75         if ((_src))                   \
76             (_dst) = msStrdup((_src));  \
77         else                          \
78             (_dst) = NULL;            \
79     MS_MACROEND
80 
81 
82