Rudiments: /home/dmuse/src/rudiments/include/rudiments/private/nodeinlines.h Source File

Rudiments

- Main Page
- Classes

nodeinlines.h
1 // Copyright (c) 2003 David Muse
2 // See the COPYING file for more information
3 #ifndef RUDIMENTS_NODE_H
4 #define RUDIMENTS_NODE_H
5
6 #include <rudiments/charstring.h>
7 #include <rudiments/stdio.h>
8 #include <rudiments/private/rudimentsinlines.h>
9
10 // Ideally we'd use explicit specialization here but old enough
11 // compilers don't support it and this isn't any less efficient.
12
13 RUDIMENTS_TEMPLATE_INLINE
14 int32_t node_compare(char *value1, char *value2) {
15 return charstring::compare(value1,value2);
16 }
17
18 RUDIMENTS_TEMPLATE_INLINE
19 int32_t node_compare(const char *value1, const char *value2) {
20 return charstring::compare(value1,value2);
21 }
22
23 RUDIMENTS_TEMPLATE_INLINE
24 int32_t node_compare(const unsigned char *value1,
25 const unsigned char *value2) {
26 return charstring::compare((const char *)value1,(const char *)value2);
27 }
28
29 RUDIMENTS_TEMPLATE_INLINE
30 int32_t node_compare(unsigned char *value1, unsigned char *value2) {
31 return charstring::compare((const char *)value1,(const char *)value2);
32 }
33
34 RUDIMENTS_TEMPLATE_INLINE
35 int32_t node_compare(char value1, char value2) {
36 if (value1<value2) {
37 return -1;
38 } else if (value1==value2) {
39 return 0;
40 } else {
41 return 1;
42 }
43 }
44
45 RUDIMENTS_TEMPLATE_INLINE
46 int32_t node_compare(int16_t value1, int16_t value2) {
47 if (value1<value2) {
48 return -1;
49 } else if (value1==value2) {
50 return 0;
51 } else {
52 return 1;
53 }
54 }
55
56 RUDIMENTS_TEMPLATE_INLINE
57 int32_t node_compare(int32_t value1, int32_t value2) {
58 if (value1<value2) {
59 return -1;
60 } else if (value1==value2) {
61 return 0;
62 } else {
63 return 1;
64 }
65 }
66
67 RUDIMENTS_TEMPLATE_INLINE
68 int32_t node_compare(int64_t value1, int64_t value2) {
69 if (value1<value2) {
70 return -1;
71 } else if (value1==value2) {
72 return 0;
73 } else {
74 return 1;
75 }
76 }
77
78 RUDIMENTS_TEMPLATE_INLINE
79 int32_t node_compare(unsigned char value1, unsigned char value2) {
80 if (value1<value2) {
81 return -1;
82 } else if (value1==value2) {
83 return 0;
84 } else {
85 return 1;
86 }
87 }
88
89 RUDIMENTS_TEMPLATE_INLINE
90 int32_t node_compare(uint16_t value1, uint16_t value2) {
91 if (value1<value2) {
92 return -1;
93 } else if (value1==value2) {
94 return 0;
95 } else {
96 return 1;
97 }
98 }
99
100 RUDIMENTS_TEMPLATE_INLINE
101 int32_t node_compare(uint32_t value1, uint32_t value2) {
102 if (value1<value2) {
103 return -1;
104 } else if (value1==value2) {
105 return 0;
106 } else {
107 return 1;
108 }
109 }
110
111 RUDIMENTS_TEMPLATE_INLINE
112 int32_t node_compare(uint64_t value1, uint64_t value2) {
113 if (value1<value2) {
114 return -1;
115 } else if (value1==value2) {
116 return 0;
117 } else {
118 return 1;
119 }
120 }
121
122 RUDIMENTS_TEMPLATE_INLINE
123 int32_t node_compare(float value1, float value2) {
124 if (value1<value2) {
125 return -1;
126 } else if (value1==value2) {
127 return 0;
128 } else {
129 return 1;
130 }
131 }
132
133 RUDIMENTS_TEMPLATE_INLINE
134 int32_t node_compare(double value1, double value2) {
135 if (value1<value2) {
136 return -1;
137 } else if (value1==value2) {
138 return 0;
139 } else {
140 return 1;
141 }
142 }
143
144 RUDIMENTS_TEMPLATE_INLINE
145 int32_t node_compare(long double value1, long double value2) {
146 if (value1<value2) {
147 return -1;
148 } else if (value1==value2) {
149 return 0;
150 } else {
151 return 1;
152 }
153 }
154
155 RUDIMENTS_TEMPLATE_INLINE
156 int32_t node_compare(void *value1, void *value2) {
157 if (value1<value2) {
158 return -1;
159 } else if (value1==value2) {
160 return 0;
161 } else {
162 return 1;
163 }
164 }
165
166 RUDIMENTS_TEMPLATE_INLINE
167 void node_print(const char *value) {
168 stdoutput.printf("%s",value);
169 }
170
171 RUDIMENTS_TEMPLATE_INLINE
172 void node_print(char *value) {
173 stdoutput.printf("%s",value);
174 }
175
176 RUDIMENTS_TEMPLATE_INLINE
177 void node_print(char value) {
178 stdoutput.printf("%c",value);
179 }
180
181 RUDIMENTS_TEMPLATE_INLINE
182 void node_print(int16_t value) {
183 stdoutput.printf("%hd",value);
184 }
185
186 RUDIMENTS_TEMPLATE_INLINE
187 void node_print(int32_t value) {
188 stdoutput.printf("%d",(int)value);
189 }
190
191 RUDIMENTS_TEMPLATE_INLINE
192 void node_print(int64_t value) {
193 #ifdef RUDIMENTS_HAVE_LONG_LONG
194 stdoutput.printf("%lld",(long long)value);
195 #else
196 stdoutput.printf("%ld",(long)value);
197 #endif
198 }
199
200 RUDIMENTS_TEMPLATE_INLINE
201 void node_print(unsigned const char *value) {
202 stdoutput.printf("%s",value);
203 }
204
205 RUDIMENTS_TEMPLATE_INLINE
206 void node_print(unsigned char *value) {
207 stdoutput.printf("%s",value);
208 }
209
210 RUDIMENTS_TEMPLATE_INLINE
211 void node_print(unsigned char value) {
212 stdoutput.printf("%c",value);
213 }
214
215 RUDIMENTS_TEMPLATE_INLINE
216 void node_print(uint16_t value) {
217 stdoutput.printf("%hd",value);
218 }
219
220 RUDIMENTS_TEMPLATE_INLINE
221 void node_print(uint32_t value) {
222 stdoutput.printf("%d",(unsigned int)value);
223 }
224
225 RUDIMENTS_TEMPLATE_INLINE
226 void node_print(uint64_t value) {
227 #ifdef RUDIMENTS_HAVE_LONG_LONG
228 stdoutput.printf("%lld",(unsigned long long)value);
229 #else
230 stdoutput.printf("%ld",(unsigned long)value);
231 #endif
232 }
233
234 RUDIMENTS_TEMPLATE_INLINE
235 void node_print(float value) {
236 stdoutput.printf("%f",value);
237 }
238
239 RUDIMENTS_TEMPLATE_INLINE
240 void node_print(double value) {
241 stdoutput.printf("%f",value);
242 }
243
244 RUDIMENTS_TEMPLATE_INLINE
245 void node_print(long double value) {
246 stdoutput.printf("%Lf",value);
247 }
248
249 RUDIMENTS_TEMPLATE_INLINE
250 void node_print(void *value) {
251 stdoutput.printf("%08x",value);
252 }
253
254 #endif
filedescriptor::printf
size_t printf(const char *format,...)
charstring::compare
static int32_t compare(const char *str1, const char *str2)