Rudiments

- Main Page
- Classes

linkedlistutilinlines.h
1 // Copyright (c) 2003 David Muse
2 // See the COPYING file for more information
3 #ifndef RUDIMENTS_LINKEDLISTUTIL_H
4 #define RUDIMENTS_LINKEDLISTUTIL_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 _linkedlistutil_compare(char *value1, char *value2) {
15 return charstring::compare(value1,value2);
16 }
17
18 RUDIMENTS_TEMPLATE_INLINE
19 int32_t _linkedlistutil_compare(const char *value1, const char *value2) {
20 return charstring::compare(value1,value2);
21 }
22
23 template <class valuetype>
24 RUDIMENTS_TEMPLATE_INLINE
25 int32_t _linkedlistutil_compare(valuetype value1, valuetype value2) {
26 if (value1<value2) {
27 return -1;
28 } else if (value1==value2) {
29 return 0;
30 } else {
31 return 1;
32 }
33 }
34
35 RUDIMENTS_TEMPLATE_INLINE
36 void _linkedlistutil_print(const char *value) {
37 stdoutput.printf("%s",value);
38 }
39
40 RUDIMENTS_TEMPLATE_INLINE
41 void _linkedlistutil_print(char *value) {
42 stdoutput.printf("%s",value);
43 }
44
45 RUDIMENTS_TEMPLATE_INLINE
46 void _linkedlistutil_print(char value) {
47 stdoutput.printf("%c",value);
48 }
49
50 RUDIMENTS_TEMPLATE_INLINE
51 void _linkedlistutil_print(int16_t value) {
52 stdoutput.printf("%hd",value);
53 }
54
55 RUDIMENTS_TEMPLATE_INLINE
56 void _linkedlistutil_print(int32_t value) {
57 stdoutput.printf("%d",(int)value);
58 }
59
60 RUDIMENTS_TEMPLATE_INLINE
61 void _linkedlistutil_print(int64_t value) {
62 #ifdef RUDIMENTS_HAVE_LONG_LONG
63 stdoutput.printf("%lld",(long long)value);
64 #else
65 stdoutput.printf("%ld",(long)value);
66 #endif
67 }
68
69 RUDIMENTS_TEMPLATE_INLINE
70 void _linkedlistutil_print(unsigned const char *value) {
71 stdoutput.printf("%s",value);
72 }
73
74 RUDIMENTS_TEMPLATE_INLINE
75 void _linkedlistutil_print(unsigned char *value) {
76 stdoutput.printf("%s",value);
77 }
78
79 RUDIMENTS_TEMPLATE_INLINE
80 void _linkedlistutil_print(unsigned char value) {
81 stdoutput.printf("%c",value);
82 }
83
84 RUDIMENTS_TEMPLATE_INLINE
85 void _linkedlistutil_print(uint16_t value) {
86 stdoutput.printf("%hd",value);
87 }
88
89 RUDIMENTS_TEMPLATE_INLINE
90 void _linkedlistutil_print(uint32_t value) {
91 stdoutput.printf("%d",(unsigned int)value);
92 }
93
94 RUDIMENTS_TEMPLATE_INLINE
95 void _linkedlistutil_print(uint64_t value) {
96 #ifdef RUDIMENTS_HAVE_LONG_LONG
97 stdoutput.printf("%lld",(unsigned long long)value);
98 #else
99 stdoutput.printf("%ld",(unsigned long)value);
100 #endif
101 }
102
103 RUDIMENTS_TEMPLATE_INLINE
104 void _linkedlistutil_print(float value) {
105 stdoutput.printf("%f",value);
106 }
107
108 RUDIMENTS_TEMPLATE_INLINE
109 void _linkedlistutil_print(double value) {
110 stdoutput.printf("%f",value);
111 }
112
113 template <class valuetype>
114 RUDIMENTS_TEMPLATE_INLINE
115 void _linkedlistutil_print(valuetype value) {
116 stdoutput.printf("%p",value);
117 }
118
119 #endif
filedescriptor::printf
size_t printf(const char *format,...)
charstring::compare
static int32_t compare(const char *str1, const char *str2)