2 strings.h - MaLa string handling
4 Copyright (C) 2004, 2005, 2006, Christian Thaeter <chth@gmx.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, contact me.
20 #ifndef MALA_STRINGS_H
21 #define MALA_STRINGS_H
26 #include "mala_types.h"
28 #include "stringbucket.h"
32 struct mala_string_struct
43 short str_alloc_type
:4;
44 short user_alloc_type
:4;
49 mala_string_acogc_mark (void*);
52 mala_string_acogc_initize (void*);
55 mala_string_acogc_finalize (void*);
59 mala_string_new_cstr (const char* cstr
, MalaStringBucket bucket
);
62 mala_string_new_literal_cstr (const char* cstr
, MalaStringBucket bucket
);
65 mala_string_new_attach_cstr (const char* cstr
, MalaStringBucket bucket
);
68 mala_string_new_cstr_n (const char* cstr
, const size_t n
, MalaStringBucket bucket
);
71 mala_string_new_2cstr (const char* cstr1
, const char* cstr2
, MalaStringBucket bucket
);
74 mala_string_new_print (MalaStringBucket bucket
, const char* fmt
,...);
77 mala_string_new_n (MalaString src
, const size_t n
, MalaStringBucket bucket
);
80 mala_string_new_prefix (const char* prefix
, MalaString str
, MalaStringBucket bucket
);
83 mala_string_scan (const_MalaString str
,const char* fmt
,...);
86 static inline const char*
87 mala_string_cstr (const_MalaString s
);
90 mala_string_length (const_MalaString s
);
93 mala_string_compare (const_MalaString a
, const_MalaString b
);
96 mala_string_compare_nocase (const_MalaString a
, const_MalaString b
);
100 static inline const char*
101 mala_string_cstr (const_MalaString s
)
103 return s
? s
->str
: NULL
;
108 mala_string_length (const_MalaString s
)
115 mala_string_compare (const_MalaString a
, const_MalaString b
)
117 return a
== b
? 0 : strcmp (mala_string_cstr (a
), mala_string_cstr (b
));
122 mala_string_compare_nocase (const_MalaString a
, const_MalaString b
)
124 return a
== b
? 0 : strcasecmp (mala_string_cstr (a
), mala_string_cstr (b
));
128 #endif /* MALA_STRINGS */
133 // c-file-style: "gnu"
135 // arch-tag: b43b7350-ecb6-4aa8-94d3-930da822e3ea