ARB
aisc_inline.h
Go to the documentation of this file.
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 
21 CONSTEXPR_INLINE bool is_SPACE(char c) { return c == ' ' || c == '\t'; }
22 CONSTEXPR_INLINE bool is_SEP(char c) { return c == ',' || c == ';'; }
23 CONSTEXPR_INLINE bool is_LF(char c) { return c == '\n'; }
24 CONSTEXPR_INLINE bool is_EOS(char c) { return c == EOSTR; }
25 
26 CONSTEXPR_INLINE bool is_SPACE_LF(char c) { return is_SPACE(c) || is_LF(c); }
27 CONSTEXPR_INLINE bool is_SPACE_LF_EOS(char c) { return is_SPACE_LF(c) || is_EOS(c); }
29 CONSTEXPR_INLINE bool is_LF_EOS(char c) { return is_LF(c) || is_EOS(c); }
30 CONSTEXPR_INLINE bool is_SEP_LF_EOS(char c) { return is_SEP(c) || is_LF_EOS(c); }
31 
32 inline void SKIP_SPACE_LF(const char *& var) { while (is_SPACE_LF(*var)) ++var; }
33 inline void SKIP_SPACE_LF(char *& var) { while (is_SPACE_LF(*var)) ++var; }
34 
35 inline 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 
42 inline 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 
49 inline 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
CONSTEXPR_INLINE bool is_SPACE_LF_EOS(char c)
Definition: aisc_inline.h:27
char * copy_string_part(const char *first, const char *last)
Definition: aisc_inline.h:49
CONSTEXPR_INLINE bool is_SEP(char c)
Definition: aisc_inline.h:22
CONSTEXPR_INLINE bool is_LF(char c)
Definition: aisc_inline.h:23
CONSTEXPR_INLINE bool is_EOS(char c)
Definition: aisc_inline.h:24
CONSTEXPR_INLINE bool is_SEP_LF_EOS(char c)
Definition: aisc_inline.h:30
char * strduplen(const char *s, int len)
Definition: aisc_inline.h:42
#define CONSTEXPR_INLINE
Definition: cxxforward.h:92
CONSTEXPR_INLINE bool is_SPACE_SEP_LF_EOS(char c)
Definition: aisc_inline.h:28
CONSTEXPR_INLINE bool is_SPACE_LF(char c)
Definition: aisc_inline.h:26
void SKIP_SPACE_LF_BACKWARD(const char *&var, const char *strStart)
Definition: aisc_inline.h:35
CONSTEXPR_INLINE bool is_LF_EOS(char c)
Definition: aisc_inline.h:29
CONSTEXPR_INLINE bool is_SPACE(char c)
Definition: aisc_inline.h:21
#define EOSTR
Definition: aisc_inline.h:15
#define aisc_assert(cond)
Definition: aisc_def.h:11
void SKIP_SPACE_LF(const char *&var)
Definition: aisc_inline.h:32
GB_write_int const char s
Definition: AW_awar.cxx:156