debug.c needs dylib.h.
[SquirrelJME.git] / nanocoat / include / sjme / charSeq.h
blobc919e8e61569855a34bed870cde26512f9477eaa
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Character sequences.
13 * @since 2024/06/26
16 #ifndef SQUIRRELJME_CHARSEQ_H
17 #define SQUIRRELJME_CHARSEQ_H
19 #include "sjme/frontEnd.h"
20 #include "sjme/stdTypes.h"
21 #include "sjme/error.h"
23 /* Anti-C++. */
24 #ifdef __cplusplus
25 #ifndef SJME_CXX_IS_EXTERNED
26 #define SJME_CXX_IS_EXTERNED
27 #define SJME_CXX_SQUIRRELJME_CHARSEQ_H
28 extern "C" {
29 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
30 #endif /* #ifdef __cplusplus */
32 /*--------------------------------------------------------------------------*/
34 /**
35 * A character sequence which contains a set of characters within a string,
36 * may be modifiable or not.
38 * @since 2024/06/26
40 typedef struct sjme_charSeq sjme_charSeq;
42 /**
43 * Returns the character at the given index.
45 * @param inSeq The input character sequence.
46 * @param inIndex The index to get from.
47 * @param outChar The resultant character.
48 * @return Any resultant error, if any.
49 * @since 2024/06/27
51 typedef sjme_errorCode (*sjme_charSeq_charAtFunc)(
52 sjme_attrInNotNull const sjme_charSeq* inSeq,
53 sjme_attrInPositive sjme_jint inIndex,
54 sjme_attrOutNotNull sjme_jchar* outChar);
56 /**
57 * Deletes the given static character sequence.
59 * @param inSeq The input/output sequence.
60 * @return Any resultant error, if any.
61 * @since 2024/06/26
63 typedef sjme_errorCode (*sjme_charSeq_deleteFunc)(
64 sjme_attrInNotNull sjme_charSeq* inSeq);
66 /**
67 * Returns the length of the character sequence.
69 * @param inSeq The input character sequence.
70 * @param outLen The sequence length.
71 * @return Any resultant error, if any.
72 * @since 2024/06/27
74 typedef sjme_errorCode (*sjme_charSeq_lengthFunc)(
75 sjme_attrInNotNull const sjme_charSeq* inSeq,
76 sjme_attrOutNotNull sjme_jint* outLen);
78 /**
79 * Functions which are used to process character sequences.
81 * @since 2024/06/26
83 typedef struct sjme_charSeq_functions
85 /** The character at the given index. */
86 sjme_charSeq_charAtFunc charAt;
88 /** Deleting the sequence and freeing any resources. */
89 sjme_charSeq_deleteFunc delete;
91 /** The length of the character sequence. */
92 sjme_charSeq_lengthFunc length;
93 } sjme_charSeq_functions;
95 struct sjme_charSeq
97 /** Front end data, if any. */
98 sjme_frontEnd frontEnd;
100 /** Context pointer, if any. */
101 sjme_pointer context;
103 /** The API for accessing the character sequence. */
104 const sjme_charSeq_functions* impl;
108 * Returns the character at the given index.
110 * @param inSeq The input character sequence.
111 * @param inIndex The index to get from.
112 * @param outChar The resultant character.
113 * @return Any resultant error, if any.
114 * @since 2024/06/27
116 sjme_errorCode sjme_charSeq_charAt(
117 sjme_attrInNotNull const sjme_charSeq* inSeq,
118 sjme_attrInPositive sjme_jint inIndex,
119 sjme_attrOutNotNull sjme_jchar* outChar);
122 * Deletes the given static character sequence.
124 * @param inOutSeq The input/output sequence.
125 * @return Any resultant error, if any.
126 * @since 2024/06/26
128 sjme_errorCode sjme_charSeq_deleteStatic(
129 sjme_attrInNotNull sjme_charSeq* inOutSeq);
132 * Returns the length of the character sequence.
134 * @param inSeq The input character sequence.
135 * @param outLen The sequence length.
136 * @return Any resultant error, if any.
137 * @since 2024/06/27
139 sjme_errorCode sjme_charSeq_length(
140 sjme_attrInNotNull const sjme_charSeq* inSeq,
141 sjme_attrOutNotNull sjme_jint* outLen);
144 * Checks if the given character sequence equals the given character sequence.
146 * @param inSeq The sequence to check.
147 * @param outResult The result of the check.
148 * @param equalsSeq The char sequence to check for equality against.
149 * @return Any resultant error, if any.
150 * @since 2024/08/08
152 sjme_errorCode sjme_charSeq_equalsCharSeq(
153 sjme_attrInNotNull const sjme_charSeq* inSeq,
154 sjme_attrOutNotNull sjme_jboolean* outResult,
155 sjme_attrInNotNull const sjme_charSeq* equalsSeq);
158 * Checks if the given character sequence equals the given UTF string.
160 * @param inSeq The sequence to check.
161 * @param outResult The result of the check.
162 * @param equalsUtf The UTF sequence to check for equality against.
163 * @return Any resultant error, if any.
164 * @since 2024/08/08
166 sjme_errorCode sjme_charSeq_equalsUtf(
167 sjme_attrInNotNull const sjme_charSeq* inSeq,
168 sjme_attrOutNotNull sjme_jboolean* outResult,
169 sjme_attrInNotNull sjme_lpcstr equalsUtf);
172 * Checks if the given character sequence equals the given UTF string.
174 * @param inSeq The sequence to check.
175 * @param equalsUtf The UTF sequence to check for equality against.
176 * @return Returns whether it matches, note that if there is an error
177 * then @c SJME_JNI_FALSE will be returned and the error will be hidden.
178 * @since 2024/08/08
180 sjme_jboolean sjme_charSeq_equalsUtfR(
181 sjme_attrInNotNull const sjme_charSeq* inSeq,
182 sjme_attrInNotNull sjme_lpcstr equalsUtf);
185 * Initializes the given static character sequence.
187 * @param inOutSeq The input/output sequence.
188 * @param inFunctions The input functions for the character sequence.
189 * @param inOptContext The context to set.
190 * @param inOptFrontEnd The front end data to copy.
191 * @return Any resultant error, if any.
192 * @since 2024/06/27
194 sjme_errorCode sjme_charSeq_newStatic(
195 sjme_attrInNotNull sjme_charSeq* inOutSeq,
196 sjme_attrInNotNull const sjme_charSeq_functions* inFunctions,
197 sjme_attrInNullable sjme_pointer inOptContext,
198 sjme_attrInNullable sjme_frontEnd* inOptFrontEnd);
201 * Creates a character sequence that accesses the given standard C string
202 * as Utf characters.
204 * @param inOutSeq The resultant sequence.
205 * @param inString The string to wrap.
206 * @return Any resultant error, if any.
207 * @since 2024/07/26
209 sjme_errorCode sjme_charSeq_newUtfStatic(
210 sjme_attrInNotNull sjme_charSeq* inOutSeq,
211 sjme_attrInNotNull sjme_lpcstr inString);
214 * Checks if the given character sequence starts with the given character
215 * sequence.
217 * @param inSeq The sequence to check.
218 * @param outResult The result of the check.
219 * @param startsWithSeq The char sequence to check the start for.
220 * @return Any resultant error, if any.
221 * @since 2024/08/08
223 sjme_errorCode sjme_charSeq_startsWithCharSeq(
224 sjme_attrInNotNull const sjme_charSeq* inSeq,
225 sjme_attrOutNotNull sjme_jboolean* outResult,
226 sjme_attrInNotNull const sjme_charSeq* startsWithSeq);
229 * Checks if the given character sequence starts with the given UTF string.
231 * @param inSeq The sequence to check.
232 * @param outResult The result of the check.
233 * @param startsWithSeq The UTF sequence to check the start for.
234 * @return Any resultant error, if any.
235 * @since 2024/08/08
237 sjme_errorCode sjme_charSeq_startsWithUtf(
238 sjme_attrInNotNull const sjme_charSeq* inSeq,
239 sjme_attrOutNotNull sjme_jboolean* outResult,
240 sjme_attrInNotNull sjme_lpcstr startsWithUtf);
243 * Checks if the given character sequence starts with the given UTF string.
245 * @param inSeq The sequence to check.
246 * @param startsWithUtf The UTF sequence to check the start for.
247 * @return Returns whether it matches, note that if there is an error
248 * then @c SJME_JNI_FALSE will be returned and the error will be hidden.
249 * @since 2024/08/08
251 sjme_jboolean sjme_charSeq_startsWithUtfR(
252 sjme_attrInNotNull const sjme_charSeq* inSeq,
253 sjme_attrInNotNull sjme_lpcstr startsWithUtf);
255 /*--------------------------------------------------------------------------*/
257 /* Anti-C++. */
258 #ifdef __cplusplus
259 #ifdef SJME_CXX_SQUIRRELJME_CHARSEQ_H
261 #undef SJME_CXX_SQUIRRELJME_CHARSEQ_H
262 #undef SJME_CXX_IS_EXTERNED
263 #endif /* #ifdef SJME_CXX_SQUIRRELJME_CHARSEQ_H */
264 #endif /* #ifdef __cplusplus */
266 #endif /* SQUIRRELJME_CHARSEQ_H */