ucx/string.h

Thu, 10 Apr 2014 11:32:59 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 10 Apr 2014 11:32:59 +0200
changeset 162
52dfe5f4ecd7
parent 160
302dddaf741d
child 173
31a8682fffb7
permissions
-rw-r--r--

added more tests for ucx_list_remove

20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
3 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
4 * Copyright 2013 Olaf Wintermann. All rights reserved.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
5 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
6 * Redistribution and use in source and binary forms, with or without
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
7 * modification, are permitted provided that the following conditions are met:
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
8 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
10 * notice, this list of conditions and the following disclaimer.
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
14 * documentation and/or other materials provided with the distribution.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
15 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
28 /**
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
29 * Bounded string implementation.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
30 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
31 * The UCX strings (<code>sstr_t</code>) provide an alternative to C strings.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
32 * The main difference to C strings is, that <code>sstr_t</code> does <b>not
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
33 * need to be <code>NULL</code>-terminated</b>. Instead the length is stored
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
34 * within the structure.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
35 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
36 * When using <code>sstr_t</code>, developers must be full aware of what type
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
37 * of string (<code>NULL</code>-terminated) or not) they are using, when
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
38 * accessing the <code>char* ptr</code> directly.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
39 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
40 * The UCX string module provides some common string functions, known from
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
41 * standard libc, working with <code>sstr_t</code>.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
42 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
43 * @file string.h
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
44 * @author Mike Becker
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
45 * @author Olaf Wintermann
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
46 */
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
48 #ifndef UCX_STRING_H
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
49 #define UCX_STRING_H
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 68
diff changeset
51 #include "ucx.h"
109
75cb6590358b added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
52 #include "allocator.h"
38
35f67a8ef875 added missing stddef includes
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
53 #include <stddef.h>
35f67a8ef875 added missing stddef includes
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
54
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
55 /** Shortcut for a <code>sstr_t struct</code> literal. */
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
56 #define ST(s) { (char*)s, sizeof(s)-1 }
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
57
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
58 /** Shortcut for the conversion of a C string to a <code>sstr_t</code>. */
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
59 #define S(s) sstrn((char*)s, sizeof(s)-1)
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 #ifdef __cplusplus
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 extern "C" {
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 #endif
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
65 /**
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
66 * The UCX string structure.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
67 */
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
68 typedef struct {
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
69 /** A reference to the string (<b>not necessarily <code>NULL</code>
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
70 * -terminated</b>) */
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 char *ptr;
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
72 /** The length of the string */
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 size_t length;
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 } sstr_t;
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
76 /**
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
77 * Creates a new sstr_t based on a C string.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
78 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
79 * The length is implicitly inferred by using a call to <code>strlen()</code>.
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 *
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
81 * <b>Note:</b> the sstr_t will hold a <i>reference</i> to the C string. If you
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
82 * do want a copy, use sstrdup() on the return value of this function.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
83 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
84 * @param cstring the C string to wrap
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
85 * @return a new sstr_t containing the C string
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
86 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
87 * @see sstrn()
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 */
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
89 sstr_t sstr(char *cstring);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
91 /**
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
92 * Creates a new sstr_t of the specified length based on a C string.
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 *
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
94 * <b>Note:</b> the sstr_t will hold a <i>reference</i> to the C string. If you
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
95 * do want a copy, use sstrdup() on the return value of this function.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
96 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
97 * @param cstring the C string to wrap
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
98 * @param length the length of the string
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
99 * @return a new sstr_t containing the C string
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
100 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
101 * @see sstr()
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
102 * @see S()
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 */
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
104 sstr_t sstrn(char *cstring, size_t length);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
107 /**
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
108 * Returns the cumulated length of all specified strings.
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 *
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
110 * At least one string must be specified.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
111 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
112 * <b>Attention:</b> if the count argument does not match the count of the
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
113 * specified strings, the behavior is undefined.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
114 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
115 * @param count the total number of specified strings (so at least 1)
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
116 * @param string the first string
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
117 * @param ... all other strings
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
118 * @return the cumulated length of all strings
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 */
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
120 size_t sstrnlen(size_t count, sstr_t string, ...);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
123 /**
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
124 * Concatenates strings.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
125 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
126 * At least one string must be specified and there must be enough memory
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
127 * available referenced by the destination sstr_t.ptr for this function to
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
128 * successfully concatenate all specified strings.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
129 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
130 * The sstr_t.length of the destination string specifies the capacity and
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
131 * should match the total memory available referenced by the destination
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
132 * sstr_t.ptr. This function <i>never</i> copies data beyond the capacity and
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
133 * does not modify any of the source strings.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
134 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
135 * <b>Attention:</b>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
136 * <ul>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
137 * <li>Any content in the destination string will be overwritten</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
138 * <li>The destination sstr_t.ptr is <b>NOT</b>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
139 * <code>NULL</code>-terminated</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
140 * <li>The destination sstr_t.length is set to the total length of the
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
141 * concatenated strings</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
142 * <li><i>Hint:</i> get a <code>NULL</code>-terminated string by performing
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
143 * <code>mystring.ptr[mystring.length]='\0'</code> after calling this
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
144 * function</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
145 * </ul>
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 119
diff changeset
146 *
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 119
diff changeset
147 * @param dest new sstr_t with capacity information and allocated memory
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
148 * @param count the total number of strings to concatenate
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
149 * @param src the first string
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
150 * @param ... all other strings
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
151 * @return the argument for <code>dest</code> is returned
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 119
diff changeset
153 sstr_t sstrncat(sstr_t dest, size_t count, sstr_t src, ...);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
156 /**
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
157 * Returns a substring starting at the specified location.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
158 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
159 * <b>Attention:</b> the new string references the same memory area as the
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
160 * input string and will <b>NOT</b> be <code>NULL</code>-terminated.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
161 * Use sstrdup() to get a copy.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
162 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
163 * @param string input string
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
164 * @param start start location of the substring
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
165 * @return a substring of <code>string</code> starting at <code>start</code>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
166 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
167 * @see sstrsubsl()
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
168 * @see sstrchr()
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 */
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
170 sstr_t sstrsubs(sstr_t string, size_t start);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
172 /**
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
173 * Returns a substring with a maximum length starting at the specified location.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
174 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
175 * <b>Attention:</b> the new string references the same memory area as the
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
176 * input string and will <b>NOT</b> be <code>NULL</code>-terminated.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
177 * Use sstrdup() to get a copy.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
178 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
179 * @param string input string
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
180 * @param start start location of the substring
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
181 * @param length the maximum length of the substring
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
182 * @return a substring of <code>string</code> starting at <code>start</code>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
183 * with a maximum length of <code>length</code>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
184 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
185 * @see sstrsubs()
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
186 * @see sstrchr()
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 */
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
188 sstr_t sstrsubsl(sstr_t string, size_t start, size_t length);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
190 /**
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
191 * Returns a substring starting at the location of the first occurrence of the
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
192 * specified character.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
193 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
194 * If the string does not contain the character, an empty string is returned.
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
195 *
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
196 * @param string the string where to locate the character
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
197 * @param chr the character to locate
148
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
198 * @return a substring starting at the first location of <code>chr</code>
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
199 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
200 * @see sstrsubs()
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
201 */
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
202 sstr_t sstrchr(sstr_t string, int chr);
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
203
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
204 /**
148
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
205 * Returns a substring starting at the location of the last occurrence of the
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
206 * specified character.
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
207 *
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
208 * If the string does not contain the character, an empty string is returned.
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
209 *
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
210 * @param string the string where to locate the character
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
211 * @param chr the character to locate
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
212 * @return a substring starting at the last location of <code>chr</code>
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
213 *
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
214 * @see sstrsubs()
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
215 */
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
216 sstr_t sstrrchr(sstr_t string, int chr);
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
217
c27c2425c0b1 added sstrrchr
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
218 /**
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
219 * Splits a string into parts by using a delimiter string.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
220 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
221 * This function will return <code>NULL</code>, if one of the following happens:
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
222 * <ul>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
223 * <li>the string length is zero</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
224 * <li>the delimeter length is zero</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
225 * <li>the string equals the delimeter</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
226 * <li>memory allocation fails</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
227 * </ul>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
228 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
229 * The integer referenced by <code>count</code> is used as input and determines
160
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
230 * the maximum size of the resulting array, i.e. the maximum count of splits to
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
231 * perform + 1.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
232 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
233 * The integer referenced by <code>count</code> is also used as output and is
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
234 * set to
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
235 * <ul>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
236 * <li>-2, on memory allocation errors</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
237 * <li>-1, if either the string or the delimiter is an empty string</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
238 * <li>0, if the string equals the delimiter</li>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
239 * <li>1, if the string does not contain the delimiter</li>
160
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
240 * <li>the count of array items, otherwise</li>
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
241 * </ul>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
242 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
243 * If the string starts with the delimiter, the first item of the resulting
160
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
244 * array will be an empty string.
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
245 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
246 * If the string ends with the delimiter and the maximum list size is not
160
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
247 * exceeded, the last array item will be an empty string.
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
248 *
160
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
249 * <b>Attention:</b> The array pointer <b>AND</b> all sstr_t.ptr of the array
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
250 * items must be manually passed to <code>free()</code>. Use sstrsplit_a() with
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
251 * an allocator to managed memory, to avoid this.
39
bf8ab7bb74ff added sstrsplit function
Mike Becker <universe@uap-core.de>
parents: 38
diff changeset
252 *
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
253 * @param string the string to split
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
254 * @param delim the delimiter string
160
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
255 * @param count IN: the maximum size of the resulting array (0 = no limit),
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
256 * OUT: the actual size of the array
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
257 * @return a sstr_t array containing the split strings or
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
258 * <code>NULL</code> on error
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
259 *
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
260 * @see sstrsplit_a()
39
bf8ab7bb74ff added sstrsplit function
Mike Becker <universe@uap-core.de>
parents: 38
diff changeset
261 */
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
262 sstr_t* sstrsplit(sstr_t string, sstr_t delim, size_t *count);
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
263
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
264 /**
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
265 * Performing sstrsplit() using an UcxAllocator.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
266 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
267 * <i>Read the description of sstrsplit() for details.</i>
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
268 *
160
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
269 * The memory for the sstr_t.ptr pointers of the array items and the memory for
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
270 * the sstr_t array itself are allocated by using the UcxAllocator.malloc()
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
271 * function.
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
272 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
273 * <b>Note:</b> the allocator is not used for memory that is freed within the
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
274 * same call of this function (locally scoped variables).
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
275 *
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
276 * @param allocator the UcxAllocator used for allocating memory
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
277 * @param string the string to split
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
278 * @param delim the delimiter string
160
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
279 * @param count IN: the maximum size of the resulting array (0 = no limit),
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
280 * OUT: the actual size of the array
302dddaf741d fixed documentation error in sstr_split
Mike Becker <universe@uap-core.de>
parents: 149
diff changeset
281 * @return a sstr_t array containing the split strings or
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
282 * <code>NULL</code> on error
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
283 *
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
284 * @see sstrsplit()
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
285 */
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
286 sstr_t* sstrsplit_a(UcxAllocator *allocator, sstr_t string, sstr_t delim,
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
287 size_t *count);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
289 /**
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
290 * Compares two UCX strings with standard <code>memcmp()</code>.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
291 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
292 * At first it compares the sstr_t.length attribute of the two strings. The
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
293 * <code>memcmp()</code> function is called, if and only if the lengths match.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
294 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
295 * @param s1 the first string
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
296 * @param s2 the second string
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
297 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
298 * length of s1 is greater than the length of s2 or the result of
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
299 * <code>memcmp()</code> otherwise (i.e. 0 if the strings match)
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
300 */
68
88dbea299440 removed const from string.*
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 67
diff changeset
301 int sstrcmp(sstr_t s1, sstr_t s2);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
303 /**
149
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
304 * Compares two UCX strings ignoring the case.
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
305 *
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
306 * At first it compares the sstr_t.length attribute of the two strings. If and
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
307 * only if the lengths match, both strings are compared char by char ignoring
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
308 * the case.
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
309 *
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
310 * @param s1 the first string
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
311 * @param s2 the second string
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
312 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
313 * length of s1 is greater than the length of s2 or the difference between the
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
314 * first two differing characters otherwise (i.e. 0 if the strings match and
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
315 * no characters differ)
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
316 */
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
317 int sstrcasecmp(sstr_t s1, sstr_t s2);
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
318
3bf87676d42d added sstrcasecmp
Mike Becker <universe@uap-core.de>
parents: 148
diff changeset
319 /**
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
320 * Creates a duplicate of the specified string.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
321 *
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
322 * The new sstr_t will contain a copy allocated by standard
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
323 * <code>malloc()</code>. So developers <b>MUST</b> pass the sstr_t.ptr to
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
324 * <code>free()</code>.
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
325 *
118
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
326 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
327 * terminated.
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
328 *
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
329 * @param string the string to duplicate
118
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
330 * @return a duplicate of the string
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
331 * @see sstrdup_a()
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
332 */
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
333 sstr_t sstrdup(sstr_t string);
118
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
334
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
335 /**
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
336 * Creates a duplicate of the specified string using an UcxAllocator.
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
337 *
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
338 * The new sstr_t will contain a copy allocated by the allocators
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
339 * ucx_allocator_malloc function. So it is implementation depended, whether the
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
340 * returned sstr_t.ptr pointer must be passed to the allocators
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
341 * ucx_allocator_free function manually.
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
342 *
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
343 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
344 * terminated.
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
345 *
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
346 * @param allocator a valid instance of an UcxAllocator
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
347 * @param string the string to duplicate
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
348 * @return a duplicate of the string
119
baa839a7633f completed documentation on sstr_t + sstrsplit overhaul + allocator version of sstrsplit
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
349 * @see sstrdup()
118
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
350 */
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
351 sstr_t sstrdup_a(UcxAllocator *allocator, sstr_t string);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352
118
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
353 /**
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
354 * Omits leading and trailing spaces.
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
355 *
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
356 * This function returns a new sstr_t containing a trimmed version of the
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
357 * specified string.
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
358 *
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
359 * <b>Note:</b> the new sstr_t references the same memory, thus you
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
360 * <b>MUST NOT</b> pass the sstr_t.ptr of the return value to
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
361 * <code>free()</code>. It is also highly recommended to avoid assignments like
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
362 * <code>mystr = sstrtrim(mystr);</code> as you lose the reference to the
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
363 * source string. Assignments of this type are only permitted, if the
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
364 * sstr_t.ptr of the source string does not need to be freed or if another
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
365 * reference to the source string exists.
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
366 *
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
367 * @param string the string that shall be trimmed
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
368 * @return a new sstr_t containing the trimmed string
151f5345f303 documented allocator + some further documentation for sstr_t
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
369 */
96
fbbff331beba added sstrtrim
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
370 sstr_t sstrtrim(sstr_t string);
fbbff331beba added sstrtrim
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 74
diff changeset
371
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
372 /**
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
373 * Checks, if a string has a specific prefix.
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
374 * @param string the string to check
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
375 * @param prefix the prefix the string should have
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
376 * @return 1, if and only if the string has the specified prefix, 0 otherwise
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
377 */
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
378 int sstrprefix(sstr_t string, sstr_t prefix);
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
379
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
380 /**
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
381 * Checks, if a string has a specific suffix.
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
382 * @param string the string to check
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
383 * @param suffix the suffix the string should have
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
384 * @return 1, if and only if the string has the specified suffix, 0 otherwise
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
385 */
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
386 int sstrsuffix(sstr_t string, sstr_t suffix);
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 125
diff changeset
387
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388 #ifdef __cplusplus
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 }
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 #endif
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
392 #endif /* UCX_STRING_H */

mercurial