ObjFW
OFUTF8String.h
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFString.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
20 @interface OFUTF8String: OFString
21 {
22  /*
23  * A pointer to the actual data.
24  *
25  * Since constant strings don't have `_storage`, they have to allocate
26  * it on the first access. Strings created at runtime just set the
27  * pointer to `&_storage`.
28  */
29  struct of_string_utf8_ivars {
30  char *cString;
31  size_t cStringLength;
32  bool isUTF8;
33  size_t length;
34  bool hashed;
35  unsigned long hash;
36  bool freeWhenDone;
37  } *restrict _s;
38  struct of_string_utf8_ivars _storage;
39 }
40 @end
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 extern int of_string_utf8_check(const char *, size_t, size_t *);
46 extern size_t of_string_utf8_get_index(const char *, size_t);
47 extern size_t of_string_utf8_get_position(const char *, size_t, size_t);
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 OF_ASSUME_NONNULL_END
A class for handling strings.
Definition: OFString.h:132