Last change
on this file was
5437,
checked in by westram, 16 years ago
|
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
2.2 KB
|
Line | |
---|
1 | // ==================================================================== // |
---|
2 | // // |
---|
3 | // File : inline.h // |
---|
4 | // Purpose : general purpose inlined funcions // |
---|
5 | // Time-stamp: <Thu Jul/10/2008 11:57 MET Coder@ReallySoft.de> // |
---|
6 | // // |
---|
7 | // // |
---|
8 | // Coded by Ralf Westram (coder@reallysoft.de) in June 2002 // |
---|
9 | // Copyright Department of Microbiology (Technical University Munich) // |
---|
10 | // // |
---|
11 | // Visit our web site at: http://www.arb-home.de/ // |
---|
12 | // // |
---|
13 | // // |
---|
14 | // ==================================================================== // |
---|
15 | |
---|
16 | #ifndef INLINE_H |
---|
17 | #define INLINE_H |
---|
18 | |
---|
19 | #include <cctype> |
---|
20 | |
---|
21 | #ifndef __cplusplus |
---|
22 | // this header only works with c++ |
---|
23 | // those functions needed by ARBDB are duplicated in adstring.c (with GBS_-prefix) |
---|
24 | #error inline.h may be used in C++ only |
---|
25 | #endif |
---|
26 | |
---|
27 | /** Like strcmp but ignoring case */ |
---|
28 | inline int ARB_stricmp(const char *s1, const char *s2) { |
---|
29 | int cmp = 0; |
---|
30 | size_t idx = 0; |
---|
31 | while (!cmp) { |
---|
32 | if (!s1[idx]) return s2[idx] ? -1 : 0; |
---|
33 | if (!s2[idx]) return 1; |
---|
34 | cmp = tolower(s1[idx]) - tolower(s2[idx]); |
---|
35 | ++idx; |
---|
36 | } |
---|
37 | return cmp; |
---|
38 | } |
---|
39 | /** compares the beginning of two strings |
---|
40 | (Note: always returns 0 if one the the strings is empty) */ |
---|
41 | inline int ARB_strscmp(const char *s1, const char *s2) { |
---|
42 | int cmp = 0; |
---|
43 | size_t idx = 0; |
---|
44 | while (!cmp) { |
---|
45 | if (!s1[idx] || !s2[idx]) break; |
---|
46 | cmp = s1[idx] - s2[idx]; |
---|
47 | ++idx; |
---|
48 | } |
---|
49 | return cmp; |
---|
50 | } |
---|
51 | |
---|
52 | inline void ARB_strupper(char *s) { for (int i = 0; s[i]; ++i) s[i] = toupper(s[i]); } // strupr |
---|
53 | inline void ARB_strlower(char *s) { for (int i = 0; s[i]; ++i) s[i] = tolower(s[i]); } // strlwr |
---|
54 | |
---|
55 | inline unsigned char safeCharIndex(char c) { return static_cast<unsigned char>(c); } |
---|
56 | |
---|
57 | #else |
---|
58 | #error inline.h included twice |
---|
59 | #endif // INLINE_H |
---|
60 | |
---|
Note: See
TracBrowser
for help on using the repository browser.