TaPAS  0.2
ccl-string.h
Go to the documentation of this file.
1 /*
2  * ccl-string.h -- String manipulation module
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Université Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the AltaRica Public License that comes with this
10  * package.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
22 #ifndef __CCL_STRING_H__
23 # define __CCL_STRING_H__
24 
25 # include <ccl/ccl-common.h>
26 # include <ccl/ccl-memory.h>
27 
28 BEGIN_C_DECLS
29 
34 typedef char *ccl_ustring;
35 
43 extern unsigned int
44 ccl_string_hash (const void *ptr);
45 
49 extern void
50 ccl_string_delete (void *ptr);
51 
65 extern int
66 ccl_string_equals (const void *str1, const void *str2);
67 
85 # define ccl_string_compare ((ccl_compare_func *) strcmp)
86 
92 # define ccl_string_cmp strcmp
93 
100 extern char *
101 ccl_string_dup (const char *s);
102 
115 extern char *
116 ccl_string_format_new (const char *fmt, ...);
117 
130 extern char *
131 ccl_string_format_new_va (const char *fmt, va_list pa);
132 
152 extern void
153 ccl_string_format (char **dst, size_t *size, const char *fmt, ...);
154 
168 extern void
169 ccl_string_format_va (char **dst, size_t *size, const char *fmt, va_list pa);
170 
184 extern void
185 ccl_string_format_append (char **dst, const char *fmt, ...);
186 
198 extern void
199 ccl_string_format_append_va (char **dst, const char *fmt, va_list pa);
200 
212 extern int
213 ccl_string_parse_int (const char *s);
214 
226 extern int
227 ccl_string_parse_boolean (const char *s);
228 
244 extern ccl_ustring
245 ccl_string_make_unique (const char *s);
246 
252 extern ccl_ustring
254 
255 extern const char *
256 ccl_string_has_prefix (const char *pref, const char *arg);
257 
258 extern char *
259 ccl_string_append_char (const char *s, char c);
260 
261 END_C_DECLS
262 
263 #endif /* ! __CCL_STRING_H__ */
ccl_ustring ccl_string_make_unique(const char *s)
Creates a unique string from the string s.
int ccl_string_equals(const void *str1, const void *str2)
Equality checking for strings.
void ccl_string_format_append_va(char **dst, const char *fmt, va_list pa)
Appends a formatted string to *dst.
char * ccl_string_dup(const char *s)
Duplicates the string s.
char * ccl_string_format_new(const char *fmt,...)
Allocates a formatted string.
void ccl_string_format_append(char **dst, const char *fmt,...)
Appends a formatted string to *dst.
ccl_ustring ccl_string_make_unique_from_int(int i)
Creates a unique string from an integer i.
Some useful and common macros.
void ccl_string_format_va(char **dst, size_t *size, const char *fmt, va_list pa)
Allocates a formatted string.
char * ccl_ustring
Alias type for strings that are stored in an internal dictionary and then can be used as identifiers ...
Definition: ccl-string.h:34
Memory Allocators.
int ccl_string_parse_boolean(const char *s)
Interprets s as a Boolean value.
unsigned int ccl_string_hash(const void *ptr)
Hashes the string pointed by ptr.
void ccl_string_format(char **dst, size_t *size, const char *fmt,...)
Allocates a formatted string.
int ccl_string_parse_int(const char *s)
Interprets s as an integer value.
char * ccl_string_format_new_va(const char *fmt, va_list pa)
Allocates a formatted string.
void ccl_string_delete(void *ptr)
Deletion function for a string.