forked from octocat/linguist
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrfc_string.h
More file actions
1459 lines (1357 loc) · 91.2 KB
/
rfc_string.h
File metadata and controls
1459 lines (1357 loc) · 91.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
** Copyright (c) 2011-2012, Karapetsas Eleftherios
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
** 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the distribution.
** 3. Neither the name of the Original Author of Refu nor the names of its contributors may be used to endorse or promote products derived from
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
** SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#ifndef REFU_USTRING_H
#define REFU_USTRING_H
#include <rf_options.h>
#ifdef RF_MODULE_STRINGS// check if the strings are included as a module
#include <stdio.h>
#include <rf_setup.h>
#include <Preprocessor/rf_xmacro_argcount.h> // for the argument count
#include <rf_localmem.h> // for the local memory function wrapping functionality
#include <IO/rf_unicode.h>// for unicode
#ifdef __cplusplus
extern "C"
{// opening bracket for calling from C++
#endif
// An option for some string functions. Means that the case should not be exactly matched in the string replacing,finding e.t.c.
#define RF_CASE_IGNORE 0x1
// An options for some string functions. Means that the exact string should be found/replaced e.t.c.
#define RF_MATCH_WORD 0x2
// Denotes that a requested character/byte index in an RF_String is out of bounds
#define RF_STRING_INDEX_OUT_OF_BOUNDS ((uint32_t)0xFF0FFFF)
/* These are here so that the iteration macros can work*/
// Checks if a given byte is a continuation byte
#define rfUTF8_IsContinuationByte2(b__) ( b__ >= 0x80 && b__<= 0xBF )
#pragma pack(push,1)
/**
** @internal
** @author Lefteris
** @date 09/12/2010
** @endinternal
** @brief A unicode String with UTF-8 internal representation
**
** The Refu String is a Unicode String that has two versions. One is this and for the other check @ref RF_StringX to see what operations can be performed on extended Strings.
** Functions to convert to and from all UTF encoding exists but the internal representation is always at UTF-8. Once a
** a String has been created it is always assumed that the stream of bytes inside it is valid UTF-8 since every function
** performs a UTF-8 check unless otherwise specified.
**
** All the functions which have @isinherited{StringX} on their description can be used with extended strings safely, since no specific
** version of the function exists, or needs to exist to manipulate Extended Strings. To make the documentation even clearer the functions that should not
** be used with the extended string are marked with @notinherited{StringX}
** @internal
** @cppcode
** //default constructor
** String(){this->i_StringCHandle = rfString_Create("");}
** @endcpp
** @endinternal
*/
typedef struct RF_String
{
// The string's data
char* bytes;
// The string's length in bytes (not including the null termination). The string keeps its length in bytes
// to avoid multiple calls to strlen()
uint32_t byteLength;
}RF_String;
#pragma pack(pop)
// @memberof RF_String
// @brief Create a termporary String from a String literal
//
// A macro to be used only inside a function call that accepts an @ref RF_String to create a Temporary RF_String*
// that will be used by the function. This macro accepts from 1 to N arguments.
//
// The first argument shall either be a String literal or a printf styled string literal
// given in the source file's encoding(default is UTF-8). For other encodings look at the compile time
// option @c RF_OPTION_SOURCE_ENCODING that can be provided during building the library, but it is
// @b strongly recommended to use UTF-8 encoded source files.
//
// Optionally the first argument can be followed by a sequence of additional arguments,
// each containing one value to be inserted instead of each %-tag specified in the string literal
// parameter, if any. There should be
// the same number of these arguments as the number of %-tags that expect a value.
// Basically the usage is the same as @ref rfString_Create
//
// @param s The formatted string that will constitute the RF_String. Must be in the same encoding as that of the source file.
// Default is UTF-8.
// @param ... \rfoptional{nothing} Depending on the string literal, the function may expect a sequence of additional arguments,
// each containing one value to be inserted instead of each %-tag specified in the @c slit parameter, if any. There should be
// the same number of these arguments as the number of %-tags that expect a value.
// @return Returns true in case of correct initialization and false , due to invalid byte sequence for the given encoding
// @isinherited{StringX}
#ifdef RF_IAMHERE_FOR_DOXYGEN
RF_String* RFS_(const char* s,...);
#else
#define RFS_(...) i_rfString_CreateLocal(__VA_ARGS__)
#endif
/*-------------------------------------------------------------------------Methods to create an RF_String-------------------------------------------------------------------------------*/
// @name Creating an RF_String
// @{
// @memberof RF_String
// @opassign
// @brief Allocates and returns a string with the given characters
//
// Given characters have to be in UTF-8. A check for valid sequence of bytes is performed. @notinherited{StringX}
// @param s The sequence of bytes for the characters in UTF-8 (the default). Can also follow a printf-like format which will be formatted with
// the variables that follow it. A check to see if it is a valid UTF-8 sequence is performed
// @param ... \rfoptional{nothing} Depending on the string literal, the function may expect a sequence of additional arguments,
// each containing one value to be inserted instead of each %-tag specified in the @c slit parameter, if any. There should be
// the same number of these arguments as the number of %-tags that expect a value.
// @return Returns the initialized RF_string or null in case of failure to initialize, due to invalid utf-8 sequence
#ifndef RF_OPTION_DEFAULT_ARGUMENTS
i_DECLIMEX_ RF_String* rfString_Create(const char* s,...);
#else
i_DECLIMEX_ RF_String* i_rfString_Create(const char* s,...);
i_DECLIMEX_ RF_String* i_NVrfString_Create(const char* s);
#define rfString_Create(...) RP_SELECT_FUNC_IF_NARGIS(i_SELECT_RF_STRING_CREATE,1,__VA_ARGS__)
#define i_SELECT_RF_STRING_CREATE1(...) i_NVrfString_Create(__VA_ARGS__)
#define i_SELECT_RF_STRING_CREATE0(...) i_rfString_Create(__VA_ARGS__)
#endif
///Internal function that creates a temporary RF_String*
i_DECLIMEX_ RF_String* i_rfString_CreateLocal1(const char* s,...);
i_DECLIMEX_ RF_String* i_NVrfString_CreateLocal(const char* s);
#define i_rfString_CreateLocal(...) RP_SELECT_FUNC_IF_NARGIS(i_SELECT_RF_STRING_CREATELOCAL,1,__VA_ARGS__)
#define i_SELECT_RF_STRING_CREATELOCAL1(...) i_NVrfString_CreateLocal(__VA_ARGS__)
#define i_SELECT_RF_STRING_CREATELOCAL0(...) i_rfString_CreateLocal1(__VA_ARGS__)
// @memberof RF_String
// @brief Initializes a string with the given characters.
//
// @notinherited{StringX}
// Given characters have to be in UTF-8. A check for valide sequence of bytes is performed.
// @param str The string to initialize
// @param s The sequence of bytes for the characters in UTF-8 (the default).Can also follow a printf-like format which will be formatted with
// the variables that follow it. A check to see if it is a valid UTF-8 sequence is performed
// @param ... \rfoptional{nothing} Depending on the string literal, the function may expect a sequence of additional arguments,
// each containing one value to be inserted instead of each %-tag specified in the @c slit parameter, if any. There should be
// the same number of these arguments as the number of %-tags that expect a value.
// @return Returns true in case of correct initialization and false , due to invalid utf-8 sequence
#ifndef RF_OPTION_DEFAULT_ARGUMENTS
i_DECLIMEX_ char rfString_Init(RF_String* str,const char* s,...);
#else
i_DECLIMEX_ char i_rfString_Init(RF_String* str,const char* s,...);
i_DECLIMEX_ char i_NVrfString_Init(RF_String* str,const char* s);
#define rfString_Init(...) RP_SELECT_FUNC_IF_NARGIS(i_SELECT_RF_STRING_INIT,2,__VA_ARGS__)
#define i_SELECT_RF_STRING_INIT1(...) i_NVrfString_Init(__VA_ARGS__)
#define i_SELECT_RF_STRING_INIT0(...) i_rfString_Init(__VA_ARGS__)
#endif
// @memberof RF_String
// @cppnotctor
// @brief Allocates a String by turning a unicode code point in a String (encoded in UTF-8).
//
// @notinherited{StringX}
// @param code The unicode code point to encode
// @return A String with the code point encoded in it or a null pointer in case of an illegal code point value
i_DECLIMEX_ RF_String* rfString_Create_cp(uint32_t code);
// @memberof RF_String
// @brief Initializes a string by turning a unicode code point in a String (encoded in UTF-8).
//
// @notinherited{StringX}
// @param str The string to initialize
// @param code The unicode code point to encode
// @return Returns true in case of correct initialization and false , due to illegal code point value
i_DECLIMEX_ char rfString_Init_cp(RF_String* str,uint32_t code);
#ifndef RF_OPTION_DEFAULT_ARGUMENTS
// @memberof RF_String
// @cppnotctor
// @brief Allocates and returns a string with the given characters with no checking.
//
// @notinherited{StringX}
// @warning NO VALID-UTF8 check is performed.
// @param s The sequence of bytes for the characters in UTF-8 (the default).Can also follow a printf-like format which will be formatted with
// the variables that follow it. No check for valid bytestream is performed
// @param ... \rfoptional{nothing} Depending on the string literal, the function may expect a sequence of additional arguments,
// each containing one value to be inserted instead of each %-tag specified in the @c slit parameter, if any. There should be
// the same number of these arguments as the number of %-tags that expect a value.
// @return Returns the initialized RF_string or null in case of failure to initialize
i_DECLIMEX_ RF_String* rfString_Create_nc(const char* s,...);
#else
i_DECLIMEX_ RF_String* i_rfString_Create_nc(const char* s,...);
i_DECLIMEX_ RF_String* i_NVrfString_Create_nc(const char* s);
#define rfString_Create_nc(...) RP_SELECT_FUNC_IF_NARGIS(i_SELECT_RF_STRING_CREATE_NC,1,__VA_ARGS__)
#define i_SELECT_RF_STRING_CREATE_NC1(...) i_NVrfString_Create_nc(__VA_ARGS__)
#define i_SELECT_RF_STRING_CREATE_NC0(...) i_rfString_Create_nc(__VA_ARGS__)
#endif
#ifndef RF_OPTION_DEFAULT_ARGUMENTS
// @memberof RF_String
// @brief Initializes a string with the given characters with no checking
//
// @notinherited{StringX}
// @warning NO VALID-UTF8 check is performed.
// @param str The string to initialize
// @param s The sequence of bytes for the characters in UTF-8 (the default).Can also follow a printf-like format which will be formatted with
// the variables that follow it. No check for valid bytestream is performed
// @param ... \rfoptional{nothing} Depending on the string literal, the function may expect a sequence of additional arguments,
// each containing one value to be inserted instead of each %-tag specified in the @c slit parameter, if any. There should be
// the same number of these arguments as the number of %-tags that expect a value.
// @return Returns true in case of correct initialization and false otherwise
i_DECLIMEX_ char rfString_Init_nc(RF_String* str,const char* s,...);
#else
i_DECLIMEX_ char i_rfString_Init_nc(RF_String* str,const char* s,...);
i_DECLIMEX_ char i_NVrfString_Init_nc(RF_String* str,const char* s);
#define rfString_Init_nc(...) RP_SELECT_FUNC_IF_NARGIS(i_SELECT_RF_STRING_INIT_NC,2,__VA_ARGS__)
#define i_SELECT_RF_STRING_INIT_NC1(...) i_NVrfString_Init_nc(__VA_ARGS__)
#define i_SELECT_RF_STRING_INIT_NC0(...) i_rfString_Init_nc(__VA_ARGS__)
#endif
// @memberof RF_String
// @opassign
// @brief Allocates and returns a string with the given integer.
//
// @notinherited{StringX}
// @param i The integer to turn into a string
// @return Returns the initialized RF_string
i_DECLIMEX_ RF_String* rfString_Create_i(int32_t i);
// @memberof RF_String
// @brief Initializes a string with the given integer.
//
// @notinherited{StringX}
// @param str The string to initialize
// @param i The integer to turn into a string
// @return Returns true in case of correct initialization and false otherwise
i_DECLIMEX_ char rfString_Init_i(RF_String* str,int32_t i);
// @memberof RF_String
// @opassign
// @brief Allocates and returns a string with the given float.
//
// @notinherited{StringX}
// @param f The float to turn into a string
// @return Returns the initialized RF_string
i_DECLIMEX_ RF_String* rfString_Create_f(float f);
// @memberof RF_String
// @brief Initializes a string with the given float.
//
// @notinherited{StringX}
// @param str The string to initialize
// @param f The float to turn into a string
// @return Returns true in case of correct initialization and false otherwise
i_DECLIMEX_ char rfString_Init_f(RF_String* str,float f);
// @memberof RF_String
// @brief Allocates and returns a string with the given UTF-16 byte sequence.
//
// @notinherited{StringX}
// Given characters have to be in UTF-16
// @param s The sequence of bytes for the characters in UTF-16.
// @param endianess A flag that determined in what endianess the sequence of UTF-16 bytes is in. Possible values here is
// @c RF_LITTLE_ENDIAN and @c RF_BIG_ENDIAN.
// @return Returns the initialized RF_string or null in case of failure to initialize, due to invalid utf-16 sequence or illegal endianess value
i_DECLIMEX_ RF_String* rfString_Create_UTF16(const char* s,char endianess);
// @memberof RF_String
// @brief Initializes a string with the given UTF-16 byte sequence.
//
// @notinherited{StringX}
// Given characters have to be in UTF-16
// @param str The string to initialize
// @param s The sequence of bytes for the characters in UTF-16.
// @param endianess A flag that determined in what endianess the sequence of UTF-16 bytes is in. Possible values here is
// @c RF_LITTLE_ENDIAN and @c RF_BIG_ENDIAN.
// @return Returns true for succesfull initialization and false otherwise due to invalid utf-16 sequence or illegal endianess value
i_DECLIMEX_ char rfString_Init_UTF16(RF_String* str,const char* s,char endianess);
// @memberof RF_String
// @cppnotctor
// @brief Allocates and returns a string with the given UTF-32 byte sequence.
//
// @notinherited{StringX}
// Given characters have to be in UTF-32
// @param s The sequence of bytes for the characters in UTF-32. Needs to be null terminated.
// @return Returns the initialized RF_string or null in case of failure to initialize
i_DECLIMEX_ RF_String* rfString_Create_UTF32(const char* s);
// @memberof RF_String
// @brief Initializes a string with the given UTF-32 byte sequence.
//
// @notinherited{StringX}
// Given characters have to be in UTF-32
// @param str The string to initialize
// @param s The sequence of bytes for the characters in UTF-32. Needs to be null terminated.
// @return Returns true for successful initialization and false otherwise
i_DECLIMEX_ char rfString_Init_UTF32(RF_String* str,const char* s);
//@}
/*-------------------------------------------------------------------------Methods to copy/assign an RF_String-------------------------------------------------------------------------------*/
// @name Copying - Assigning a String
// @{
// @memberof RF_String
// @brief Assigns the value of the source string to the destination.
//
// @notinherited{StringX}
// @lmsFunction
// Both strings should already be initialized and hold a value. It is an error to give null parameters.
// @param dest The destination string, which should get assigned
// @param source The source string, whose values to copy. @inhtype{String,StringX} @tmpSTR
#if defined(RF_IAMHERE_FOR_DOXYGEN)
void rfString_Assign(RF_String* dest,void* source);
#else
i_DECLIMEX_ void i_rfString_Assign(RF_String* dest,void* source);
#define rfString_Assign(i_DESTINATION_,i_SOURCE_) i_rfLMS_WRAP2(void,i_rfString_Assign,i_DESTINATION_,i_SOURCE_)
#endif
// @memberof RF_String
// @brief Assigns the value of a unicode character to the string
//
// @notinherited{StringX}
// @param thisstr The string to assign to
// @param character The unicode character codepoint to assign to the String
// @return Returns @c true for succesfull assignment and @c false if the given @c character was not a valid unicode codepoint
i_DECLIMEX_ char rfString_Assign_char(RF_String* thisstr,uint32_t character);
// @}
/*-------------------------------------------------------------------------Methods to get rid of an RF_String-------------------------------------------------------------------------------*/
// @name Getting rid of an RF_String
// @{
// @memberof RF_String
// @cppignore
// @brief Deletes a string object and also frees its pointer.
//
// @notinherited{StringX}
// It is an error to give a NULL(0x0) string for deleting. Will most probably lead to a segmentation fault
// Use it for strings made with _Create
// @param s The string for deletion
i_DECLIMEX_ void rfString_Destroy(RF_String* s);
// @memberof RF_String
// @cppignore
// @brief Deletes a string object only, not its memory.
//
// @notinherited{StringX}
// It is an error to give a NULL(0x0) string for deleting. Will most probably lead to a segmentation fault
// Use it for strings made with _Init
// @param s The string for deletion
i_DECLIMEX_ void rfString_Deinit(RF_String* s);
// @}
/*------------------------------------------------------------------------ RF_String unicode conversion-------------------------------------------------------------------------------*/
// @name Unicode Conversion Functions
// @{
// @memberof RF_String
// @brief Returns the strings contents as a UTF-8 buffer
//
// @isinherited{StringX}
// This is just a macro wrapper of @ref rfString_ToStr() and exists here
// just so that users can guess function names for all unicode encodings.
//
// Note that just like in @ref rfString_ToStr() this is just a pointer to
// the String's internal UTF8 buffer and as such should be read only. If there
// is a need to do anything other than that copy the buffer.
// @param s The string in question
// @return Returns a pointer to the String's internal UTF-8 uffer
#if defined(RF_IAMHERE_FOR_DOXYGEN)
i_DECLIMEX_ const char* rfString_ToUTF8(RF_String* s);
#else
#define rfString_ToUTF8(i_STRING_) rfString_ToCstr(i_STRING_)
#endif
// @memberof RF_String
// @brief Returns the strings contents as a UTF-16 buffer
//
// @isinherited{StringX}
// This function allocates a UTF-16 buffer in which the string's
// UTF-8 contents are encoded as UTF-16. The endianess of the buffer
// is that of the system. The returned buffer needs to be freed by the user
// later.
// @param[in] s The string in question
// @param[out] length Give a reference to a uint32_t in this argument to receive the length of
// the returned UTF-16 buffer in 16-bit words
// @return Returns an allocated UTF-16 buffer. Needs to be freed by the user later.
i_DECLIMEX_ uint16_t* rfString_ToUTF16(RF_String* s,uint32_t* length);
// @memberof RF_String
// @brief Returns the strings contents as a UTF-32 buffer
//
// @isinherited{StringX}
// This function allocates a UTF-32 buffer in which the string's
// UTF-8 contents are encoded as UTF-32. The endianess of the buffer
// is that of the system. The returned buffer needs to be freed by the user
// later.
// @param[in] s The string in question
// @param[out] length Give a reference to a uint32_t in this argument to receive the length
// of the returned UTF-32 buffer in codepoints. (32-bit) words
// @return Returns an allocated UTF-16 buffer. Needs to be freed by the user later.
i_DECLIMEX_ uint32_t* rfString_ToUTF32(RF_String* s,uint32_t*length);
// @}
/*------------------------------------------------------------------------ RF_String retrieval functions-------------------------------------------------------------------------------*/
// @name String Retrieval
// @{
//-- String iteration --/ /
// Two macros to accomplish iteration of an RF_String from any given character going forwards. This macro should be used with its end pair.
// We take advantage of the fact that an RF_String is always guaranteed to contain a valid UTF-8 sequence and thus no checks are performed.
/**
** @memberof RF_String
** @cppignore
** @brief Starts an RF_String forward iteration scope.
**
** @isinherited{StringX}
** Use this macro to iterate every character inside an RF_String or RF_StringX\n
** Must be used with its pair macro #rfString_Iterate_End.\n
** As an example consider this code that iterates every character of a string from the start to finish
** @code
** uint32_t i = 0;
** uint32_t charValue;
** RF_String foo;rfString_Init(&foo,"I am a String");
** rfString_Iterate_Start(&foo,i,charValue)
** //for every character in the string,let's print it
** printf("Character at index %d is %c\n",i,charValue);
** rfString_Iterate_End(i)
** @endcode
** @param[in] string_ The string to iterate. Must be a pointer to string
** @param[in,out] startCharacterPos_ Here give an uint32_t which will be the character position from which to start the iteration. In each iteration this will hold the character index. If the given position is out of bounds then the iteration does not happen
** @param[in,out] characterUnicodeValue_ Here pass an uint32_t which in each iteration will hold the unicode code point of the character at position startCharacterPos_
**/
#define rfString_Iterate_Start(string_,startCharacterPos_,characterUnicodeValue_) {\
/* b index sec is the byte index and j the character index*/\
uint32_t byteIndex_ = 0;uint32_t j_=0;\
/*iterate until we find the character position requested and its equivalent byte position*/\
while(j_!=startCharacterPos_)\
{\
if( rfUTF8_IsContinuationByte( (string_)->bytes[byteIndex_]) ==false)\
{\
j_++;\
}\
byteIndex_++;\
}\
/*now start the requested iteration*/\
while( (string_)->bytes[byteIndex_]!='\0')\
{\
/*if it's a character*/\
if( rfUTF8_IsContinuationByte( (string_)->bytes[byteIndex_]) ==false)\
{/*Give the character value to the user*/\
characterUnicodeValue_ = rfString_BytePosToCodePoint( (string_),byteIndex_);
// @memberof RF_String
// @cppignore
// @brief Ends an RF_String/RF_StringX forward iteration scope.
//
// @isinherited{StringX}
// Look at #rfString_Iterate_Start for an example usage
// @param[in,out] startCharacterPos_ Here give the uint32_t given to #rfString_Iterate_Start
#define rfString_Iterate_End(startCharacterPos_) startCharacterPos_++;}byteIndex_++;}}
//Two macros to accomplish iteration of an RF_String from any given character going backwards. This macro should be used with its end pair.
// We take advantage of the fact that an RF_String is always guaranteed to contain a valid UTF-8 sequence and thus no checks are performed.
/**
** @memberof RF_String
** @cppignore
** @brief Starts an RF_String backward iteration scope.
**
** @isinherited{StringX}
** Use this macro to iterate every character inside an RF_String or RF_StringX going backwards\n
** Must be used with its pair macro #rfString_IterateB_End.\n
**
** As an example consider this code that iterates every character of a string from the start to finish
** @code
** uint32_t charValue;
** RF_String foo;rfString_Init(&foo,"I am a String");
** uint32_t i = rfString_Length(&foo);
** rfString_IterateB_Start(&foo,i,charValue)
** //for every character in the string,let's print it
** printf("Character at index %d is %c\n",i,charValue);
** rfString_IterateB_End(i)
** @endcode
** @param[in] string_ The string to iterate. Must be a pointer to string
** @param[in,out] characterPos_ Here give an uint32_t which will be the character position from which to start the iteration. In each iteration this will hold the character index. If the given position is out of bounds then the iteration does not happen
** @param[in,out] characterUnicodeValue_ Here pass an uint32_t which in each iteration will hold the unicode code point of the character at position characterPos_
**/
#define rfString_IterateB_Start(string_,characterPos_,characterUnicodeValue_) {\
/* b index is the byte index and j the character index*/\
uint32_t b_index_ = 0;uint32_t j_=0;\
/* c index sec is another signed copy of the character index (and is int64_t so that it can cater for any situation). Reason is cause going backwards we gotta have -1 too */\
int64_t c_index_ = characterPos_;\
/*iterate until we find the character position requested and its equivalent byte position*/\
while(j_!=characterPos_)\
{\
if( rfUTF8_IsContinuationByte( (string_)->bytes[b_index_]) ==false)\
{\
j_++;\
}\
b_index_++;\
}\
/*now start the requested iteration - notice that the end condition is to reach the first character position*/\
while(c_index_!=-1)\
{\
/*if it's a character*/\
if( rfUTF8_IsContinuationByte( (string_)->bytes[b_index_]) ==false)\
{/*Give the character value to the user*/\
characterUnicodeValue_ = rfString_BytePosToCodePoint( (string_),b_index_);
// @memberof RF_String
// @cppignore
// @brief Ends an RF_String/RF_StringX backward iteration scope.
//
// @isinherited{StringX}
// Look at #rfString_IterateB_Start for an example usage
// @param[in,out] characterPos_ Here give the uint32_t given to #rfString_IterateB_Start
#define rfString_IterateB_End(characterPos_) c_index_-- ;characterPos_--;}b_index_--;}}
// @memberof RF_String
// @brief Finds the length of the string in characters.
//
// @isinherited{StringX}
// @param s The string whose number of characters to find. @inhtype{String,StringX}
// @return Returns the length of the sting in characters, not including the null termintion character
i_DECLIMEX_ uint32_t rfString_Length(void * s);
// @memberof RF_String
// @brief Retrieves the unicode code point of the parameter character.
//
// @isinherited{StringX}
// If the character position is out of bounds RF_STRING_INDEX_OUT_OF_BOUNDS is returned.
// @param thisstr The string whose character code point we need. @inhtype{String,StringX}
// @param c The character index whose unicode code point to return. Must be a positive (including zero) integer.
// @return Returns the code point as an uint32_t or the value RF_STRING_INDEX_OUT_OF_BOUNDS if the requested character index is out of bounds
i_DECLIMEX_ uint32_t rfString_GetChar(void* thisstr,uint32_t c);
// @internal
// @memberof RF_String
// @cppignore
// @brief Retrieves the unicode code point of the parameter bytepos of the string.
//
// @isinherited{StringX}
// This is an internal function, there is no need to use it. The reason it is exposed here is that it is utilized in the iteration macros.
// @warning DO NOT use this function unless you know what you are doing
// @param thisstr The string whose byte position code point we need. @inhtype{String,StringX}
// @param bytepos The byte position of the string from where to get the code point.
// @warning If this is out of bounds then nothing can detect it and at best it will cause a SEG FAULT.
// Moreover no check to see if this is not a continutation byte is made. All the checks must have been made before calling the function.
// @return Returns the code point of the byte position as an uint32_t
// @endinternal
i_DECLIMEX_ uint32_t rfString_BytePosToCodePoint(void* thisstr,uint32_t bytepos);
// @internal
// @memberof RF_String
// @cppignore
// @brief Retrieves character position of a byte position
//
// @isinherited{StringX}
// This is an internal function, there is no need to use it. It attempts to retrieve character position from a byte position. If the byte
// position is a continutation byte and does not constitute the start of a character then depending on the option the function will find
// either the next character or the previous character position from this byte position
//
// @warning DO NOT use this function unless you know what you are doing
// @param thisstr The string whose byte position code point we need. @inhtype{String,StringX}
// @param bytepos The byte position of the string from where to get the character position
// @param before A boolean flag denoting the behaviour in case this byte position is a continutation byte. If @c before is true then
// the function will retrieve the first character position before the byte. If it is false, it will retrieve the first character position
// after the continuation byte.
// @endinternal
i_DECLIMEX_ uint32_t rfString_BytePosToCharPos(void* thisstr,uint32_t bytepos,char before);
// @memberof RF_String
// @opcmpeq
// @brief Compares two Strings and returns true if they are equal and false otherwise
//
// @isinherited{StringX}
// A macro comparing two String and returning true if they are equal and false otherwise. Use it to compare ONLY Strings here not string literals (c strings)
// If you need to compare a String with a string literal (c string) use #rfString_Equal_s
// @lmsFunction
// @param s1 The first string to compare @inhtype{String,StringX} @tmpSTR
// @param s2 The second string to compare @inhtype{String,StringX} @tmpSTR
// @return True in case the strings are equal and false otherwise
#if defined(RF_IAMHERE_FOR_DOXYGEN)
i_DECLIMEX_ char rfString_Equal(void* s1,void* s2);
#else
i_DECLIMEX_ char i_rfString_Equal(void* s1,void* s2);
#define rfString_Equal(i_STRING1_,i_STRING2_) i_rfLMSX_WRAP2(char,i_rfString_Equal,i_STRING1_,i_STRING2_)
#endif
// @memberof RF_String
// @brief Finds if a substring exists inside another string.
//
// @isinherited{StringX}
// Finds the existence of String sstr inside this string with the given options. You have the
// option to either match case or perform a case-insensitive search. In addition you can search
// for the exact string and not it just being a part of another string.
// @lmsFunction
// @param thisstr This string we want to search in @inhtype{String,StringX}
// @param sstr The substring string we want to search for @inhtype{String,StringX} @tmpSTR
// @param options \rfoptional{0}. Bitflag options denoting some options for the search.Can have values:
// + @c RF_CASE_IGNORE: If you want the found substring to ignore the case and returns success for any occurence of the string in any case.
// Default search option is to @b match the case. For now this works only for characters of the english language.
// + @c RF_MATCH_WORD: If you want the found substring to be exact. For example an exact search for @e "HELLO" in the string
// @e "HELLOWORLD" would return a failure. Default search is to return any found substring.
// @return Returns the character position of the found substring or RF_FAILURE for not found
#if defined(RF_IAMHERE_FOR_DOXYGEN)
i_DECLIMEX_ int32_t rfString_Find(const void* thisstr,const void* sstr,const char options);
#else
i_DECLIMEX_ int32_t i_rfString_Find(const void* thisstr,const void* sstr,const char* options);
#ifndef RF_OPTION_DEFAULT_ARGUMENTS
#define rfString_Find(i_THISSTR_,i_SEARCHSTR_,i_OPTIONS_) i_rfLMS_WRAP3(int32_t,i_rfString_Find,i_THISSTR_,i_SEARCHSTR_,i_RFI8_(i_OPTIONS_))
#else
#define rfString_Find(...) RF_SELECT_FUNC_IF_NARGGT(i_NPSELECT_RF_STRING_FIND,3,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_FIND1(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Find() accepts from 2 to 3 arguments\"")
#define i_NPSELECT_RF_STRING_FIND0(...) RF_SELECT_FUNC(i_SELECT_RF_STRING_FIND,__VA_ARGS__)
#define i_SELECT_RF_STRING_FIND2(i_THISSTR_,i_SEARCHSTR_) i_rfLMS_WRAP3(int32_t,i_rfString_Find,i_THISSTR_,i_SEARCHSTR_,i_RFI8_(0))
#define i_SELECT_RF_STRING_FIND3(i_THISSTR_,i_SEARCHSTR_,i_OPTIONS_) i_rfLMS_WRAP3(int32_t,i_rfString_Find,i_THISSTR_,i_SEARCHSTR_,i_RFI8_(i_OPTIONS_))
#define i_SELECT_RF_STRING_FIND1(...) RF_COMPILE_ERROR("message \"Illegal Arguments Number: Function rfString_Find() accepts from 2 to 3 arguments\"")
#define i_SELECT_RF_STRING_FIND0(...) RF_COMPILE_ERROR("message \"Illegal Arguments Number: Function rfString_Find() accepts from 2 to 3 arguments\"")
#endif
#endif
// @memberof RF_String
// @brief Returns the integer value of a String
//
// @isinherited{StringX}
// The parameter string must contains only numbers. If it contains anything else the function fails.
// @param thisstr The string whose integer value to return. @inhtype{String,StringX}
// @param[out] v A refence to an integer that will return the float value
// @return Returns true in case of succesfull conversion or false if no integer was represented by the string
i_DECLIMEX_ char rfString_ToInt(void* thisstr,int32_t* v);
// @memberof RF_String
// @brief Returns the double value of a String
//
// @isinherited{StringX}
// The parameter string must contain only a number. If it contains anything else the function fails.
// @param thisstr The string whose floating point value to return. @inhtype{String,StringX}
// @param[out] f A refence to a double that will return the floating point number value
// @return Returns RF_SUCCESS in case of succesfull conversion or error if there was failure. Possible errors are:
// + @c RE_STRING_TOFLOAT: There was a conversion error. The string probably does not represent a float
// + @c RE_STRING_TOFLOAT_RANGE: The represented floating point number is of a range bigger than what can be
// represented by the system
// + @c RE_STRING_TOFLOAT_UNDERFLOW: Representing the string's floating point number in a double would cause underflow
i_DECLIMEX_ int rfString_ToDouble(void* thisstr,double* f);
// @memberof RF_String
// @brief Returns a cstring version of the string
//
// @isinherited{StringX}
// Remember that this is just a pointer to the string data. It can't be modified. memcpy it if you need a copy of it.
// @param str The string whose cstring to return. @inhtype{String,StringX}
// @return Returns a c string version of the string
i_DECLIMEX_ const char* rfString_ToCstr(const void* str);
// @memberof RF_String
// @cppignore
// @brief Creates and returns an allocated copy of the given string
//
// @isinherited{StringX}
// @note The Returned Substring needs to be freed by the user. BEWARE when assigning to a string using this function since if any previous string exists there IS NOT getting freed. You have to free it explicitly
// @param src The string to copy from. @inhtype{String,StringX}
// @return Returns a string copied from the previous one or null if the original string was null
i_DECLIMEX_ RF_String* rfString_Copy_OUT(void* src);
// @memberof RF_String
// @cppignore
// @brief Copies all the contents of a string to another
//
// @isinherited{StringX}
// @param dst The string to copy in.
// @param src The string to copy from. @inhtype{String,StringX}
// If the value is bigger than the maximum number of characters then still all characters are copied.
i_DECLIMEX_ void rfString_Copy_IN(RF_String* dst,void* src);
// @memberof RF_String
// @brief Copies a certain number of characters from a string
//
// @isinherited{StringX}
// Copies @c n characters from @c src String into the destination @c dst string.
// @param dst The string to copy in
// @param src The string to copy from. @inhtype{String,StringX}
// @param n The number of characters to copy from the @c src string
// If the value is bigger than the maximum number of characters then still all characters are copied.
i_DECLIMEX_ void rfString_Copy_chars(RF_String* dst,void* src,uint32_t n);
// @memberof RF_String
// @brief Applies a limited version of sscanf after the specified substring
//
// @isinherited{StringX}
// @lmsFunction
// @param thisstr The current string. @inhtype{String,StringX}
// @param afterstr The substring after which to apply sscanf. @inhtype{String,StringX} @tmpSTR
// @param format The tokens parameter which give the format of scanf
// @param var A void* to pass in any variable we need to get a value
// @return Returns true if a value was read and false otherwise, substring not being found in the string or sscanf unable to read into the variable
#if defined(RF_IAMHERE_FOR_DOXYGEN)
i_DECLIMEX_ char rfString_ScanfAfter(void* thisstr,void* afterstr,const char* format,void* var);
#else
i_DECLIMEX_ char i_rfString_ScanfAfter(void* thisstr,void* afterstr,const char* format,void* var);
#define rfString_ScanfAfter(i_THISSTR_,i_AFTERSTR_,i_FORMAT_,i_VAR_) i_rfLMSX_WRAP4(char,i_rfString_ScanfAfter,i_THISSTR_,i_AFTERSTR_,i_FORMAT_,i_VAR_)
#endif
// @memberof RF_String
// @brief Counts how many times a substring occurs inside the string.
//
// @isinherited{StringX}
// @lmsFunction
// @param thisstr The string inside which to count. @inhtype{String,StringX}
// @param sstr The substring for which to search. @inhtype{String,StringX} @tmpSTR
// @param options \rfoptional{0}. Bitflag options denoting some options for the search. Give 0 for the defaults.Can have values:
// + @c RF_CASE_IGNORE: If you want the found substring to ignore the case and returns success for any occurence of the string in any case.
// Default search option is to @b match the case. For now this works only for characters of the english language.
// + @c RF_MATCH_WORD: If you want the found substring to be exact. For example an exact search for @e "HELLO" in the string
// @e "HELLOWORLD" would return a failure. Default search is to return any found substring.
// @return Returns the number of times cstr exists inside the string (0 is returned in case it's not found at all
#if defined(RF_IAMHERE_FOR_DOXYGEN)
i_DECLIMEX_ int32_t rfString_Count(void* thisstr,void* sstr,const char options);
#else
i_DECLIMEX_ int32_t i_rfString_Count(void* thisstr,void* sstr,const char* options);
#ifdef RF_OPTION_DEFAULT_ARGUMENTS
#define rfString_Count(...) RF_SELECT_FUNC_IF_NARGGT(i_NPSELECT_RF_STRING_COUNT,3,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_COUNT1(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Count() accepts from 2 to 3 arguments\"")
#define i_NPSELECT_RF_STRING_COUNT0(...) RF_SELECT_FUNC(i_SELECT_RF_STRING_COUNT,__VA_ARGS__)
#define i_SELECT_RF_STRING_COUNT2(i_THISSTR_,i_SEARCHSTR_) i_rfLMSX_WRAP3(int32_t,i_rfString_Count,i_THISSTR_,i_SEARCHSTR_,i_RFI8_(0))
#define i_SELECT_RF_STRING_COUNT3(i_THISSTR_,i_SEARCHSTR_,i_OPTIONS_) i_rfLMS_WRAP3(int32_t,i_rfString_Count,i_THISSTR_,i_SEARCHSTR_,i_RFI8_(i_OPTIONS_))
#define i_SELECT_RF_STRING_COUNT1(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Count() accepts from 2 to 3 arguments\"")
#define i_SELECT_RF_STRING_COUNT0(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Count() accepts from 2 to 3 arguments\"")
#else
#define rfString_Count(i_THISSTR_,i_SEARCHSTR_,i_OPTIONS_) i_rfLMSX_WRAP3(int32_t,i_rfString_Count,i_THISSTR_,i_SEARCHSTR_,i_RFI8_(i_OPTIONS_))
#endif
#endif
// @memberof RF_String
// @brief Tokenizes the given string
//
// @isinherited{StringX}
// Separates it into @c tokensN depending on how many substrings can be created from the @c sep separatior and stores them
// into the Array of RF_String* that should be passed to the function. The array gets initialized inside the function and
// <b>has to be freed explicitly</b> later by thg user. Also each String inside the array has to be Deinitialized too.
// Here is an example usage:
// @snippet Strings/tokenize.cpp Tokenize_C
// @cppsnippet Tokenize_CPP
// @param[in] thisstr The string to tokenize. @inhtype{String,StringX}
// @param[in] sep A string literal that will be used as a separator to tokenize the given string
// @param[out] tokensN The number of tokens that got created
// @param[out] tokens Pass a pointer to an array of RF_Strings. @keepptr
// @return Returns true in success and false in case the the separating character has not been found
// @internal @cppcode
// char String::Tokenize(char* sep,uint32_t* tokensN, String*** tokens)
// {
// RF_String* t;
// uint32_t i;
// if(rfString_Tokenize(this->i_StringCHandle,sep,tokensN,&t)==false)
// return false;
//
// *tokens = (String**) malloc(sizeof(String*)* (*tokensN));
// for(i=0;i<(*tokensN);i++)
// {
// (*tokens)[i] = new String((RF_String*)&t[i]);
// }
// return true;
// }
// @endcpp @endinternal
i_DECLIMEX_ char rfString_Tokenize(void* thisstr,char* sep,uint32_t* tokensN,RF_String** tokens);
// @memberof RF_String
// @brief Initializes the first substring, between two given strings
//
// @isinherited{StringX}
// Initializes the given string as the first substring existing between the left and right parameter substrings
// @lmsFunction
// @note The Returned Substring needs to be deinitialized by the user.
// @param thisstr This current string. @inhtype{String,StringX}
// @param[in] lstr The left substring that will define the new substring. @inhtype{String,StringX} @tmpSTR
// @param[in] rstr The right substring that will define the new substring. @inhtype{String,StringX} @tmpSTR
// @param[out] result The resulting substring.
// @param options \rfoptional{0} Bitflag options denoting the method with which to search for the substring literals inside the string. Give 0 for the defaults.
// Can have values:
// + @c RF_CASE_IGNORE: If you want to search for any occurence of the substring disregarding CAPS or not.
// Default search option is to @b match the case. For now this works only for characters of the english language.
// + @c RF_MATCH_WORD: If you to find only exact matches of the substring. For example an exact search for @e "HELLO" in the string
// @e "HELLOWORLD" would find nothing. Default is with this flag off.
// @return Returns true if the substring is found and initialized and false otherwise
#if defined(RF_IAMHERE_FOR_DOXYGEN)
i_DECLIMEX_ char rfString_Between(void* thisstr,void* lstr,void* rstr,RF_String* result,const char options);
#else
i_DECLIMEX_ char i_rfString_Between(void* thisstr,void* lstr,void* rstr,RF_String* result,const char* options);
#ifdef RF_OPTION_DEFAULT_ARGUMENTS
#define rfString_Between(...) RF_SELECT_FUNC_IF_NARGGT(i_NPSELECT_RF_STRING_BETWEEN,5,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_BETWEEN1(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Between() accepts from 4 to 5 arguments\"")
#define i_NPSELECT_RF_STRING_BETWEEN0(...) RF_SELECT_FUNC(i_SELECT_RF_STRING_BETWEEN,__VA_ARGS__)
#define i_SELECT_RF_STRING_BETWEEN4(i_THISSTR_,i_LEFTSTR_,i_RIGHTSTR_,i_RESULT_) \
i_rfLMSX_WRAP5(char,i_rfString_Between,i_THISSTR_,i_LEFTSTR_,i_RIGHTSTR_,i_RESULT_,i_RFI8_(0))
#define i_SELECT_RF_STRING_BETWEEN5(i_THISSTR_,i_LEFTSTR_,i_RIGHTSTR_,i_RESULT_,i_OPTIONS_) \
i_rfLMSX_WRAP5(char,i_rfString_Between,i_THISSTR_,i_LEFTSTR_,i_RIGHTSTR_,i_RESULT_,i_RFI8_(i_OPTIONS_))
#define i_SELECT_RF_STRING_BETWEEN3(...) RF_COMPILE_ERROR("message \"Illegal Arguments Number: Function rfString_Between() accepts from 4 to 5 arguments\"")
#define i_SELECT_RF_STRING_BETWEEN2(...) RF_COMPILE_ERROR("message \"Illegal Arguments Number: Function rfString_Between() accepts from 4 to 5 arguments\"")
#define i_SELECT_RF_STRING_BETWEEN1(...) RF_COMPILE_ERROR("message \"Illegal Arguments Number: Function rfString_Between() accepts from 4 to 5 arguments\"")
#define i_SELECT_RF_STRING_BETWEEN0(...) RF_COMPILE_ERROR("message \"Illegal Arguments Number: Function rfString_Between() accepts from 4 to 5 arguments\"")
#else
#define rfString_Between(i_THISSTR_,i_LEFTSTR_,i_RIGHTSTR_,i_RESULT_,i_OPTIONS_) \
i_rfLMSX_WRAP5(char,i_rfString_Between,i_THISSTR_,i_LEFTSTR_,i_RIGHTSTR_,i_RESULT_,i_RFI8_(i_OPTIONS_))
#endif
#endif
// @memberof RF_String
// @brief Initializes the given string as the substring from the start until any of the given Strings are found
//
// @isinherited{StringX}
// The parameters that have to be given as variable argument <b>must</b> be of type RF_String* or RF_StringX* or even
// string initialized with the temporary string macro
// @rfNoDefArgsWarn1
// @warning if the library has been compiled with @c DEFAULT_ARGUMENTS off then arguments @c options and @c parN are actually pointers
// to @c char and @c unsigned char respectively
// @lmsFunction
// @param thisstr The string to operate in. @inhtype{String,StringX}
// @param result The resulting substring.
// @param options Bitflag options denoting the method with which to search for the substring literals inside the string. Give 0 for the defaults.
// Can have values:
// + @c RF_CASE_IGNORE: If you want to search for any occurence of the substring disregarding CAPS or not.
// Default search option is to @b match the case. For now this works only for characters of the english language.
// + @c RF_MATCH_WORD: If you to find only exact matches of the substring. For example an exact search for @e "HELLO" in the string
// @e "HELLOWORLD" would find nothing. Default is with this flag off.
// @param parN The number of strings to search for
// @param ... The strings to search for. @inhtype{String,StringX} @tmpSTR
// @extraVarArgLim
// @return Returns true if the substring was initialized and false if none of the parameters were found or an invalid UTF-8 sequence was given. In the latter case an error is also logged.
#ifdef RF_IAMHERE_FOR_DOXYGEN
i_DECLIMEX_ char rfString_Beforev(void* thisstr,RF_String* result,const char options,const unsigned char parN, ...);
#endif
#ifdef RF_OPTION_DEFAULT_ARGUMENTS
i_DECLIMEX_ char i_rfString_Beforev(void* thisstr,RF_String* result,const char* options,const unsigned char* parN, ...);
#define rfString_Beforev(...) RF_SELECT_FUNC_IF_NARGGT(i_NPSELECT_RF_STRING_BEFOREV,4,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_BEFOREV1(...) RF_SELECT_FUNC_IF_NARGGT2(i_LIMSELECT_RF_STRING_BEFOREV,18,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_BEFOREV0(...) RF_COMPILE_ERROR("message \"Illegal Arguments Number: Function rfString_Beforev() needs to receive more than 4 arguments\"")
#define i_LIMSELECT_RF_STRING_BEFOREV1(...) RF_COMPILE_ERROR("message \"Extra Arguments Limit Reached: Function rfString_Beforev() received more extra arguments than the limit permits\"")
#define i_LIMSELECT_RF_STRING_BEFOREV0(...) RF_SELECT_FUNC(i_SELECT_RF_STRING_BEFOREV,__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV5(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) \
i_rfLMSX_WRAP5(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV6(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP6(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV7(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP7(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV8(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP8(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV9(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP9(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV10(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP10(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV11(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP11(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV12(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP12(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV13(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP13(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV14(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP14(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV15(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP15(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV16(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP16(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV17(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP17(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFOREV18(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP18(char,i_rfString_Beforev,i_ARG1_,i_ARG2_,i_RFI8_(i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#else
i_DECLIMEX_ char rfString_Beforev(void* thisstr,RF_String* result,const char* options,const unsigned char* parN, ...);
#endif
// @memberof RF_String
// @brief Initializes the given string as the substring from the start until the given string is found
//
// @isinherited{StringX}
// @lmsFunction
// @param thisstr The string to operate in. @inhtype{String,StringX}
// @param sstr The substring that we want to find inside the string @inhtype{String,StringX} @tmpSTR
// @param result The resulting substring.
// @param options \rfoptional{0} Bitflag options denoting the method with which to search for the substring literals inside the string. Give 0 for the defaults.
// Can have values:
// + @c RF_CASE_IGNORE: If you want to search for any occurence of the substring disregarding CAPS or not.
// Default search option is to @b match the case. For now this works only for characters of the english language.
// + @c RF_MATCH_WORD: If you to find only exact matches of the substring. For example an exact search for @e "HELLO" in the string
// @e "HELLOWORLD" would find nothing. Default is with this flag off.
// @return Returns true if the substring was initialized and false if none of the parameters were found or an invalid UTF-8 sequence was given. In the latter case an error is also logged.
#if defined(RF_IAMHERE_FOR_DOXYGEN)
i_DECLIMEX_ char rfString_Before(void* thisstr,void* sstr,RF_String* result,const char options);
#else
i_DECLIMEX_ char i_rfString_Before(void* thisstr,void* sstr,RF_String* result,const char* options);
#ifdef RF_OPTION_DEFAULT_ARGUMENTS
#define rfString_Before(...) RF_SELECT_FUNC_IF_NARGGT(i_NPSELECT_RF_STRING_BEFORE,4,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_BEFORE1(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Before() accepts from 3 to 4 arguments\"")
#define i_NPSELECT_RF_STRING_BEFORE0(...) RF_SELECT_FUNC(i_SELECT_RF_STRING_BEFORE,__VA_ARGS__)
#define i_SELECT_RF_STRING_BEFORE3(i_THISSTR_,i_SEARCHSTR_,i_RESULT_) i_rfLMSX_WRAP4(char,i_rfString_Before,i_THISSTR_,i_SEARCHSTR_,i_RESULT_,i_RFI8_(0))
#define i_SELECT_RF_STRING_BEFORE4(i_THISSTR_,i_SEARCHSTR_,i_RESULT_,i_OPTIONS_) i_rfLMSX_WRAP4(char,i_rfString_Before,i_THISSTR_,i_SEARCHSTR_,i_RESULT_,i_RFI8_(i_OPTIONS_))
#define i_SELECT_RF_STRING_BEFORE2(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Before() accepts from 3 to 4 arguments\"")
#define i_SELECT_RF_STRING_BEFORE1(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Before() accepts from 3 to 4 arguments\"")
#define i_SELECT_RF_STRING_BEFORE0(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Before() accepts from 3 to 4 arguments\"")
#else
#define rfString_Before(i_THISSTR_,i_SEARCHSTR_,i_RESULT_,i_OPTIONS_) i_rfLMSX_WRAP4(char,i_rfString_Before,i_THISSTR_,i_SEARCHSTR_,i_RESULT_,i_RFI8_(i_OPTIONS_))
#endif
#endif
// @memberof RF_String
// @brief Initialize a string after a given substring
//
// @isinherited{StringX}
// Initializes the given String with the substring located after (and not including) the after substring inside the parameter string. If the substring is not located the function returns false.
// @note The given String needs to be deinitialized by the user
// @lmsFunction
// @param[in] thisstr The parameter string from which the substring will be formed. @inhtype{String,StringX}
// @param[in] after The substring to search for inside the parameter string. @inhtype{String,StringX} @tmpSTR
// @param[out] out Pass a reference to a String inside which the substring of the original string after the @c after substring will be placed
// @param options \rfoptional{0} Bitflag options denoting the method with which to search for the substring literals inside the string. Give 0 for the defaults.
// Can have values:
// + @c RF_CASE_IGNORE: If you want to search for any occurence of the substring disregarding CAPS or not.
// Default search option is to @b match the case. For now this works only for characters of the english language.
// + @c RF_MATCH_WORD: If you to find only exact matches of the substring. For example an exact search for @e "HELLO" in the string
// @e "HELLOWORLD" would find nothing. Default is with this flag off.
// @return Returns true for success and false if the substring is not found in the parameter string.
#if defined(RF_IAMHERE_FOR_DOXYGEN)
i_DECLIMEX_ char rfString_After(void* thisstr,void* after,RF_String* out,const char options);
#else
i_DECLIMEX_ char i_rfString_After(void* thisstr,void* after,RF_String* out,const char* options);
#ifdef RF_OPTION_DEFAULT_ARGUMENTS
#define rfString_After(...) RF_SELECT_FUNC_IF_NARGGT(i_NPSELECT_RF_STRING_AFTER,4,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_AFTER1(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_After() accepts from 3 to 4 arguments\"")
#define i_NPSELECT_RF_STRING_AFTER0(...) RF_SELECT_FUNC(i_SELECT_RF_STRING_AFTER,__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTER3(i_THISSTR_,i_AFTERSTR_,i_OUTSTR_) i_rfLMSX_WRAP4(char,i_rfString_After,i_THISSTR_,i_AFTERSTR_,i_OUTSTR_,i_RFI8_(0))
#define i_SELECT_RF_STRING_AFTER4(i_THISSTR_,i_AFTERSTR_,i_OUTSTR_,i_OPTIONS_) i_rfLMSX_WRAP4(char,i_rfString_After,i_THISSTR_,i_AFTERSTR_,i_OUTSTR_,i_RFI8_(i_OPTIONS_))
#define i_SELECT_RF_STRING_AFTER2(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_After() accepts from 3 to 4 arguments\"")
#define i_SELECT_RF_STRING_AFTER1(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_After() accepts from 3 to 4 arguments\"")
#define i_SELECT_RF_STRING_AFTER0(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_After() accepts from 3 to 4 arguments\"")
#else
#define rfString_After(i_THISSTR_,i_AFTERSTR_,i_OUTSTR_,i_OPTIONS_) i_rfLMSX_WRAP4(char,i_rfString_After,i_THISSTR_,i_AFTERSTR_,i_OUTSTR_,i_RFI8_(i_OPTIONS_))
#endif
#endif
// @memberof RF_String
// @brief Initialize a string after the first of the given substrings found
//
// @isinherited{StringX}
// Initializes the given String with the substring located after (and not including) the after substring inside the parameter string. If the substring is not located the function returns false.
// The parameters that have to be given as variable argument <b>must</b> be of type RF_String* or RF_StringX* or even
// string initializes with the temporary string macro
// @rfNoDefArgsWarn1
// @warning if the library has been compiled with @c DEFAULT_ARGUMENTS off then arguments @c options and @c parN are actually pointers
// to @c char and @c unsigned char respectively
// @lmsFunction
// @param[in] thisstr The parameter string from which the substring will be formed. @inhtype{String,StringX}
// @param[out] out Pass a reference to a String inside which the substring of the original string
// after the found substring will be placed.
// @param options \rfoptional{0} Bitflag options denoting the method with which to search for the substring literals inside the string. Give 0 for the defaults.
// Can have values:
// + @c RF_CASE_IGNORE: If you want to search for any occurence of the substring disregarding CAPS or not.
// Default search option is to @b match the case. For now this works only for characters of the english language.
// + @c RF_MATCH_WORD: If you to find only exact matches of the substring. For example an exact search for @e "HELLO" in the string
// @e "HELLOWORLD" would find nothing. Default is with this flag off.
// @param parN The number of substrings to search for.
// @param ... The substrings to search for. @inhtype{String,StringX} @tmpSTR
// @extraVarArgLim
// @return Returns true for success and false if the substring is not found in the parameter string.
#ifdef RF_IAMHERE_FOR_DOXYGEN
i_DECLIMEX_ char rfString_Afterv(void* thisstr,RF_String* out,const char options,const unsigned char parN,...);
#endif
#ifdef RF_OPTION_DEFAULT_ARGUMENTS
i_DECLIMEX_ char i_rfString_Afterv(void* thisstr,RF_String* out,const char* options,const unsigned char* parN,...);
#define rfString_Afterv(...) RF_SELECT_FUNC_IF_NARGGT(i_NPSELECT_RF_STRING_AFTERV,4,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_AFTERV1(...) RF_SELECT_FUNC_IF_NARGGT2(i_LIMSELECT_RF_STRING_AFTERV,18,__VA_ARGS__)
#define i_NPSELECT_RF_STRING_AFTERV0(...) RF_COMPILE_ERROR("message \"Ileggal Arguments Number: Function rfString_Afterv() needs to receive more than 4 arguments\"")
#define i_LIMSELECT_RF_STRING_AFTERV1(...) RF_COMPILE_ERROR("message \"Extra Arguments Limit Reached: Function rfString_Afterv() received more extra arguments than the limit permits\"")
#define i_LIMSELECT_RF_STRING_AFTERV0(...) RF_SELECT_FUNC(i_SELECT_RF_STRING_AFTERV,__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV5(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP5(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV6(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP6(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV7(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP7(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV8(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP8(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV9(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP9(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV10(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP10(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV11(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP11(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV12(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP12(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV13(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP13(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV14(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP14(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV15(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP15(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV16(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP16(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV17(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP17(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#define i_SELECT_RF_STRING_AFTERV18(i_ARG1_,i_ARG2_,i_ARG3_,i_ARG4_,...) i_rfLMSX_WRAP18(char,i_rfString_Afterv,i_ARG1_,i_ARG2_,i_RFI8_((i_ARG3_),i_RFUI8_(i_ARG4_),__VA_ARGS__)
#else
char rfString_Afterv(void* thisstr,RF_String* out,const char* options,const unsigned char* parN,...);
#endif