source: tags/ms_r18q1/AISC/aisc_inline.h

Last change on this file was 16763, checked in by westram, 6 years ago
File size: 1.8 KB
Line 
1//   Coded by Ralf Westram (coder@reallysoft.de)                 //
2//   Institute of Microbiology (Technical University Munich)     //
3//   http://www.arb-home.de/                                     //
4
5#ifndef AISC_INLINE_H
6#define AISC_INLINE_H
7
8#ifndef _STRING_H
9#include <string.h>
10#endif
11#ifndef _STDLIB_H
12#include <stdlib.h>
13#endif
14
15#define EOSTR    0
16#define BEG_STR1 '('
17#define BEG_STR2 '~'
18#define END_STR1 '~'
19#define END_STR2 ')'
20
21CONSTEXPR_INLINE bool is_SPACE(char c) { return c == ' ' || c == '\t'; }
22CONSTEXPR_INLINE bool is_SEP(char c)   { return c == ',' || c == ';'; }
23CONSTEXPR_INLINE bool is_LF(char c)    { return c == '\n'; }
24CONSTEXPR_INLINE bool is_EOS(char c)   { return c == EOSTR; }
25
26CONSTEXPR_INLINE bool is_SPACE_LF(char c)         { return is_SPACE(c) || is_LF(c); }
27CONSTEXPR_INLINE bool is_SPACE_LF_EOS(char c)     { return is_SPACE_LF(c) || is_EOS(c); }
28CONSTEXPR_INLINE bool is_SPACE_SEP_LF_EOS(char c) { return is_SPACE_LF_EOS(c) || is_SEP(c); }
29CONSTEXPR_INLINE bool is_LF_EOS(char c)           { return is_LF(c) || is_EOS(c); }
30CONSTEXPR_INLINE bool is_SEP_LF_EOS(char c)       { return is_SEP(c) || is_LF_EOS(c); }
31
32inline void SKIP_SPACE_LF(const char *& var) { while (is_SPACE_LF(*var)) ++var; }
33inline void SKIP_SPACE_LF(char *& var)       { while (is_SPACE_LF(*var)) ++var; }
34
35inline void SKIP_SPACE_LF_BACKWARD(const char *& var, const char *strStart) {
36    aisc_assert(var>=strStart);
37    while (is_SPACE_LF(*var) && var>strStart) --var;
38}
39
40
41
42inline char *strduplen(const char *s, int len) {
43    char *d = (char*)malloc(len+1);
44    memcpy(d, s, len);
45    d[len] = 0;
46    return d;
47}
48
49inline char *copy_string_part(const char *first, const char *last) {
50    return strduplen(first, last-first+1);
51}
52
53
54#else
55#error aisc_inline.h included twice
56#endif // AISC_INLINE_H
Note: See TracBrowser for help on using the repository browser.