Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
string.h
1#ifndef CC_STRING_H
2#define CC_STRING_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/C/basic.h>
37
38#include <stdarg.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif /* __cplusplus */
43
44/* ********************************************************************** */
45
46enum cc_string_constants {
47 CC_STRING_MIN_SIZE = 128 - sizeof(char *) + sizeof(size_t),
48 CC_STRING_RESIZE = 128
49};
50
51struct cc_string {
52 char * pointer;
53 size_t bufsize;
54 char buffer[CC_STRING_MIN_SIZE];
55};
56
57typedef struct cc_string cc_string;
58
59typedef char (*cc_apply_f)(char);
60
61/* ********************************************************************** */
62
63COIN_DLL_API void cc_string_construct(cc_string * me);
64COIN_DLL_API cc_string * cc_string_construct_new(void);
65COIN_DLL_API cc_string * cc_string_clone(const cc_string * str);
66COIN_DLL_API void cc_string_clean(cc_string * str);
67COIN_DLL_API void cc_string_destruct(cc_string * str);
68
69COIN_DLL_API void cc_string_set_string(cc_string * str, const cc_string * str2);
70COIN_DLL_API void cc_string_set_text(cc_string * str, const char * text);
71COIN_DLL_API void cc_string_set_subtext(cc_string * str, const char * text, int start, int end);
72COIN_DLL_API void cc_string_set_integer(cc_string * str, int integer);
73
74COIN_DLL_API void cc_string_append_string(cc_string * str, const cc_string * str2);
75COIN_DLL_API void cc_string_append_text(cc_string * str, const char * text);
76COIN_DLL_API void cc_string_append_integer(cc_string * str, const int digits);
77COIN_DLL_API void cc_string_append_char(cc_string * str, const char c);
78
79COIN_DLL_API unsigned int cc_string_length(const cc_string * str);
80COIN_DLL_API int cc_string_is(const cc_string * str);
81COIN_DLL_API void cc_string_clear(cc_string * str);
82COIN_DLL_API void cc_string_clear_no_free(cc_string * str);
83COIN_DLL_API uint32_t cc_string_hash(const cc_string * str);
84COIN_DLL_API uint32_t cc_string_hash_text(const char * text);
85
86COIN_DLL_API const char * cc_string_get_text(const cc_string * str);
87COIN_DLL_API void cc_string_remove_substring(cc_string * str, int start, int end);
88
89COIN_DLL_API int cc_string_compare(const cc_string * lhs, const cc_string * rhs);
90COIN_DLL_API int cc_string_compare_text(const char * lhs, const char * rhs);
91COIN_DLL_API int cc_string_compare_subtext(const cc_string * str, const char * text, int offset);
92
93COIN_DLL_API void cc_string_apply(cc_string * str, cc_apply_f function);
94
95COIN_DLL_API void cc_string_sprintf(cc_string * str, const char * formatstr, ...);
96COIN_DLL_API void cc_string_vsprintf(cc_string * str, const char * formatstr, va_list args);
97
98COIN_DLL_API size_t cc_string_utf8_decode(const char * src, size_t srclen, uint32_t * value);
99COIN_DLL_API size_t cc_string_utf8_encode(char * buffer, size_t buflen, uint32_t value);
100COIN_DLL_API uint32_t cc_string_utf8_get_char(const char * str);
101COIN_DLL_API const char * cc_string_utf8_next_char(const char * str);
102COIN_DLL_API size_t cc_string_utf8_validate_length(const char * str);
103
104COIN_DLL_API void cc_string_set_wtext(cc_string * str, const wchar_t * text);
105
106
107/* ********************************************************************** */
108
109#ifdef __cplusplus
110} /* extern "C" */
111#endif /* __cplusplus */
112
113#endif /* ! CC_STRING_H */
The cc_string type is a C ADT for ASCII string management.
Definition string.h:51