]> err.no Git - sope/blob - sope-appserver/NGObjWeb/WOResponse+private.h
Add libxml2-dev to libsope-xml4.7-dev deps
[sope] / sope-appserver / NGObjWeb / WOResponse+private.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGObjWeb_WOResponse_private_H__
23 #define __NGObjWeb_WOResponse_private_H__
24
25 #include <NGObjWeb/WOResponse.h>
26
27 // fast inline functions (non-WO)
28
29 #define WOResponse_AddChar(__R__,__C__) \
30   if (__R__) {__R__->addChar(__R__, @selector(appendContentCharacter:), \
31                              __C__);}
32
33 #define WOResponse_AddString(__R__,__C__) \
34   if (__R__) {__R__->addStr(__R__, @selector(appendContentString:), __C__);}
35 #define WOResponse_AddCString(__R__,__C__) \
36   if (__R__) {__R__->addCStr(__R__, @selector(appendContentCString:), \
37                              (const unsigned char *)__C__);}
38
39 #define WOResponse_AddHtmlString(__R__,__C__) \
40   if (__R__) {__R__->addHStr(__R__, @selector(appendContentHTMLString:), \
41                              __C__);}
42
43 #define WOResponse_AppendBeginTag(__R__,__C__) \
44 if (__R__) { \
45   __R__->addChar(__R__, @selector(appendContentCharacter:), '<'); \
46   __R__->addStr(__R__, @selector(appendContentString:), __C__); \
47 }
48 #define WOResponse_AppendBeginTagEnd(__R__) \
49 if (__R__) {__R__->addChar(__R__, @selector(appendContentCharacter:), '>');}
50
51 #define WOResponse_AppendEndTag(__R__,__C__) \
52 if (__R__) { \
53   __R__->addCStr(__R__, @selector(appendContentCString:), \
54                  (const unsigned char *)"</"); \
55   __R__->addStr(__R__, @selector(appendContentString:), __C__); \
56   __R__->addChar(__R__, @selector(appendContentCharacter:), '>'); \
57 }
58
59 #define WOResponse_AppendAttribute(__R__,__K__,__V__) \
60 if (__R__) { \
61   __R__->addChar(__R__, @selector(appendContentCharacter:), ' '); \
62   __R__->addStr(__R__, @selector(appendContentString:), __K__); \
63   __R__->addCStr(__R__, @selector(appendContentCString:), \
64                  (const unsigned char *)"=\""); \
65   __R__->addHStr(__R__, @selector(appendContentHTMLString:), __V__); \
66   __R__->addChar(__R__, @selector(appendContentCharacter:), '\"'); \
67 }
68
69 // TODO: performance ! - use static buffer and appendContentCString !
70
71 #define WOResponse_AddUInt(__R__,__C__) \
72   if (__R__) {\
73     switch(__C__) {\
74       case 0: __R__->addCStr(__R__, @selector(appendContentCString:),\
75                              (const unsigned char *)"0");break; \
76       case 1: __R__->addCStr(__R__, @selector(appendContentCString:),\
77                              (const unsigned char *)"1");break; \
78       case 2: __R__->addCStr(__R__, @selector(appendContentCString:),\
79                              (const unsigned char *)"2");break; \
80       case 3: __R__->addCStr(__R__, @selector(appendContentCString:),\
81                              (const unsigned char *)"3");break; \
82       case 4: __R__->addCStr(__R__, @selector(appendContentCString:),\
83                              (const unsigned char *)"4");break; \
84       default: {\
85         unsigned char buf[12]; \
86         sprintf((char *)buf,"%d", __C__);                       \
87         __R__->addCStr(__R__, @selector(appendContentCString:), buf);}\
88     }\
89   }
90
91 #define WOResponse_AddInt(__R__,__C__) \
92   if (__R__) {\
93     switch(__C__) {\
94       case 0: __R__->addCStr(__R__, @selector(appendContentCString:),\
95                              (const unsigned char *)"0");break; \
96       case 1: __R__->addCStr(__R__, @selector(appendContentCString:),\
97                              (const unsigned char *)"1");break; \
98       case 2: __R__->addCStr(__R__, @selector(appendContentCString:),\
99                              (const unsigned char *)"2");break; \
100       case 3: __R__->addCStr(__R__, @selector(appendContentCString:),\
101                              (const unsigned char *)"3");break; \
102       case 4: __R__->addCStr(__R__, @selector(appendContentCString:),\
103                              (const unsigned char *)"4");break; \
104       default: {\
105         unsigned char buf[12]; \
106         sprintf((char *)buf,"%d", __C__);                       \
107         __R__->addCStr(__R__, @selector(appendContentCString:), buf);}\
108     }\
109   }
110
111 #endif /* __NGObjWeb_WOResponse_private_H__ */