|
1 /************************************************************************* |
|
2 * |
|
3 * Copyright (C) 2001 Bjorn Reese and Daniel Stenberg. |
|
4 * |
|
5 * Permission to use, copy, modify, and distribute this software for any |
|
6 * purpose with or without fee is hereby granted, provided that the above |
|
7 * copyright notice and this permission notice appear in all copies. |
|
8 * |
|
9 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
|
10 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
|
11 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND |
|
12 * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. |
|
13 * |
|
14 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
15 ************************************************************************ |
|
16 */ |
|
17 |
|
18 /** @file |
|
19 @internalComponent |
|
20 @released |
|
21 */ |
|
22 |
|
23 #ifndef TRIO_TRIOSTR_H |
|
24 #define TRIO_TRIOSTR_H |
|
25 |
|
26 #include <assert.h> |
|
27 #include <stdlib.h> |
|
28 #include <string.h> |
|
29 #include <time.h> |
|
30 #include <xmlengtriodef.h> |
|
31 #include "libxml2_triop.h" |
|
32 |
|
33 enum { |
|
34 TRIO_HASH_NONE = 0, |
|
35 TRIO_HASH_PLAIN, |
|
36 TRIO_HASH_TWOSIGNED |
|
37 }; |
|
38 |
|
39 #if !defined(TRIO_STRING_PUBLIC) |
|
40 # if !defined(TRIO_PUBLIC) |
|
41 # define TRIO_PUBLIC |
|
42 # endif |
|
43 # define TRIO_STRING_PUBLIC TRIO_PUBLIC |
|
44 #endif |
|
45 |
|
46 /************************************************************************* |
|
47 * String functions |
|
48 */ |
|
49 |
|
50 TRIO_STRING_PUBLIC int trio_copy_max TRIO_PROTO((char *target, size_t max, const char *source)); |
|
51 TRIO_STRING_PUBLIC char *trio_create TRIO_PROTO((size_t size)); |
|
52 TRIO_STRING_PUBLIC void trio_destroy TRIO_PROTO((char *string)); |
|
53 TRIO_STRING_PUBLIC char *trio_duplicate TRIO_PROTO((const char *source)); |
|
54 TRIO_STRING_PUBLIC int trio_equal TRIO_PROTO((const char *first, const char *second)); |
|
55 TRIO_STRING_PUBLIC int trio_equal_case TRIO_PROTO((const char *first, const char *second)); |
|
56 TRIO_STRING_PUBLIC int trio_equal_locale TRIO_PROTO((const char *first, const char *second)); |
|
57 TRIO_STRING_PUBLIC int trio_equal_max TRIO_PROTO((const char *first, size_t max, const char *second)); |
|
58 TRIO_STRING_PUBLIC TRIO_CONST char *trio_error TRIO_PROTO((int)); |
|
59 TRIO_STRING_PUBLIC size_t trio_length TRIO_PROTO((const char *string)); |
|
60 TRIO_STRING_PUBLIC double trio_to_double TRIO_PROTO((const char *source, char **endp)); |
|
61 TRIO_STRING_PUBLIC long trio_to_long TRIO_PROTO((const char *source, char **endp, int base)); |
|
62 TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_PROTO((const char *source, char **endp)); |
|
63 TRIO_STRING_PUBLIC int trio_to_upper TRIO_PROTO((int source)); |
|
64 |
|
65 #if !defined(TRIO_MINIMAL) |
|
66 |
|
67 TRIO_STRING_PUBLIC int trio_append TRIO_PROTO((char *target, const char *source)); |
|
68 TRIO_STRING_PUBLIC int trio_append_max TRIO_PROTO((char *target, size_t max, const char *source)); |
|
69 TRIO_STRING_PUBLIC int trio_contains TRIO_PROTO((const char *string, const char *substring)); |
|
70 TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source)); |
|
71 TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max)); |
|
72 TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second)); |
|
73 TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_PROTO((char *target, size_t max, const char *format, const struct tm *datetime)); |
|
74 TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_PROTO((const char *string, int type)); |
|
75 TRIO_STRING_PUBLIC char *trio_index TRIO_PROTO((const char *string, int character)); |
|
76 TRIO_STRING_PUBLIC char *trio_index_last TRIO_PROTO((const char *string, int character)); |
|
77 TRIO_STRING_PUBLIC int trio_lower TRIO_PROTO((char *target)); |
|
78 TRIO_STRING_PUBLIC int trio_match TRIO_PROTO((const char *string, const char *pattern)); |
|
79 TRIO_STRING_PUBLIC int trio_match_case TRIO_PROTO((const char *string, const char *pattern)); |
|
80 TRIO_STRING_PUBLIC size_t trio_span_function TRIO_PROTO((char *target, const char *source, int (*Function) TRIO_PROTO((int)))); |
|
81 TRIO_STRING_PUBLIC char *trio_substring TRIO_PROTO((const char *string, const char *substring)); |
|
82 TRIO_STRING_PUBLIC char *trio_substring_max TRIO_PROTO((const char *string, size_t max, const char *substring)); |
|
83 TRIO_STRING_PUBLIC float trio_to_float TRIO_PROTO((const char *source, char **endp)); |
|
84 TRIO_STRING_PUBLIC int trio_to_lower TRIO_PROTO((int source)); |
|
85 TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_PROTO((const char *source, char **endp, int base)); |
|
86 TRIO_STRING_PUBLIC char *trio_tokenize TRIO_PROTO((char *string, const char *delimiters)); |
|
87 TRIO_STRING_PUBLIC int trio_upper TRIO_PROTO((char *target)); |
|
88 |
|
89 #endif /* !defined(TRIO_MINIMAL) */ |
|
90 |
|
91 /************************************************************************* |
|
92 * Dynamic string functions |
|
93 */ |
|
94 |
|
95 /* |
|
96 * Opaque type for dynamic strings |
|
97 */ |
|
98 |
|
99 typedef struct _trio_string_t trio_string_t; |
|
100 |
|
101 TRIO_STRING_PUBLIC void trio_string_destroy TRIO_PROTO((trio_string_t *self)); |
|
102 TRIO_STRING_PUBLIC char *trio_string_extract TRIO_PROTO((trio_string_t *self)); |
|
103 TRIO_STRING_PUBLIC int trio_string_size TRIO_PROTO((trio_string_t *self)); |
|
104 TRIO_STRING_PUBLIC void trio_string_terminate TRIO_PROTO((trio_string_t *self)); |
|
105 TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_PROTO((trio_string_t *self, char character)); |
|
106 TRIO_STRING_PUBLIC trio_string_t *trio_xstring_duplicate TRIO_PROTO((const char *other)); |
|
107 |
|
108 #if !defined(TRIO_MINIMAL) |
|
109 |
|
110 TRIO_STRING_PUBLIC trio_string_t *trio_string_create TRIO_PROTO((int initial_size)); |
|
111 TRIO_STRING_PUBLIC char *trio_string_get TRIO_PROTO((trio_string_t *self, int offset)); |
|
112 TRIO_STRING_PUBLIC void trio_xstring_set TRIO_PROTO((trio_string_t *self, char *buffer)); |
|
113 |
|
114 TRIO_STRING_PUBLIC int trio_string_append TRIO_PROTO((trio_string_t *self, trio_string_t *other)); |
|
115 TRIO_STRING_PUBLIC int trio_string_contains TRIO_PROTO((trio_string_t *self, trio_string_t *other)); |
|
116 TRIO_STRING_PUBLIC int trio_string_copy TRIO_PROTO((trio_string_t *self, trio_string_t *other)); |
|
117 TRIO_STRING_PUBLIC trio_string_t *trio_string_duplicate TRIO_PROTO((trio_string_t *other)); |
|
118 TRIO_STRING_PUBLIC int trio_string_equal TRIO_PROTO((trio_string_t *self, trio_string_t *other)); |
|
119 TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *second)); |
|
120 TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_PROTO((trio_string_t *self, trio_string_t *other)); |
|
121 TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *other)); |
|
122 TRIO_STRING_PUBLIC size_t trio_string_format_date_max TRIO_PROTO((trio_string_t *self, size_t max, const char *format, const struct tm *datetime)); |
|
123 TRIO_STRING_PUBLIC char *trio_string_index TRIO_PROTO((trio_string_t *self, int character)); |
|
124 TRIO_STRING_PUBLIC char *trio_string_index_last TRIO_PROTO((trio_string_t *self, int character)); |
|
125 TRIO_STRING_PUBLIC int trio_string_length TRIO_PROTO((trio_string_t *self)); |
|
126 TRIO_STRING_PUBLIC int trio_string_lower TRIO_PROTO((trio_string_t *self)); |
|
127 TRIO_STRING_PUBLIC int trio_string_match TRIO_PROTO((trio_string_t *self, trio_string_t *other)); |
|
128 TRIO_STRING_PUBLIC int trio_string_match_case TRIO_PROTO((trio_string_t *self, trio_string_t *other)); |
|
129 TRIO_STRING_PUBLIC char *trio_string_substring TRIO_PROTO((trio_string_t *self, trio_string_t *other)); |
|
130 TRIO_STRING_PUBLIC int trio_string_upper TRIO_PROTO((trio_string_t *self)); |
|
131 |
|
132 TRIO_STRING_PUBLIC int trio_xstring_append TRIO_PROTO((trio_string_t *self, const char *other)); |
|
133 TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_PROTO((trio_string_t *self, const char *other)); |
|
134 TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_PROTO((trio_string_t *self, const char *other)); |
|
135 TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_PROTO((trio_string_t *self, const char *other)); |
|
136 TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other)); |
|
137 TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_PROTO((trio_string_t *self, const char *other)); |
|
138 TRIO_STRING_PUBLIC int trio_xstring_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other)); |
|
139 TRIO_STRING_PUBLIC int trio_xstring_match TRIO_PROTO((trio_string_t *self, const char *other)); |
|
140 TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_PROTO((trio_string_t *self, const char *other)); |
|
141 TRIO_STRING_PUBLIC char *trio_xstring_substring TRIO_PROTO((trio_string_t *self, const char *other)); |
|
142 |
|
143 #endif /* !defined(TRIO_MINIMAL) */ |
|
144 |
|
145 #endif /* TRIO_TRIOSTR_H */ |
|
146 |