XStringArray re-implementation with template.

This commit is contained in:
jief 2020-04-26 13:12:05 +03:00
parent 3475414580
commit 7d43ca70d5
23 changed files with 866 additions and 794 deletions

View File

@ -123,20 +123,15 @@
9A637AE92430D928000B9474 /* XTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5E3262F2428F4EE002240E8 /* XTheme.cpp */; };
9A637AEA2430D928000B9474 /* XTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5E3262F2428F4EE002240E8 /* XTheme.cpp */; };
9A9AEB94243F7B5600FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */; };
9A9AEB95243F7B5600FBD7D8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB91243F7B5600FBD7D8 /* XStringArray.cpp */; };
9A9AEB96243F7B5600FBD7D8 /* XStringArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9AEB92243F7B5600FBD7D8 /* XStringArray.h */; };
9A9AEB97243F7B5600FBD7D8 /* unicode_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9AEB93243F7B5600FBD7D8 /* unicode_conversions.h */; };
9A9AEB99243F7B7A00FBD7D8 /* printf_lite-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9AEB98243F7B7900FBD7D8 /* printf_lite-test.h */; };
9A9AEB9A243F7B8400FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */; };
9A9AEB9B243F7B8400FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */; };
9A9AEB9C243F7B8400FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */; };
9A9AEB9D243F7B9000FBD7D8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB91243F7B5600FBD7D8 /* XStringArray.cpp */; };
9A9AEB9E243F7B9100FBD7D8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB91243F7B5600FBD7D8 /* XStringArray.cpp */; };
9A9AEB9F243F7B9200FBD7D8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB91243F7B5600FBD7D8 /* XStringArray.cpp */; };
9A9D3B2324221563006D8CD9 /* printf_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D3B2124221563006D8CD9 /* printf_lite-test.cpp */; };
9AC77FB924176C04005CDD5C /* XStringWArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringWArray_test.h */; };
9AC77FB924176C04005CDD5C /* XStringArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringArray_test.h */; };
9AC77FBA24176C04005CDD5C /* XArray_tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECD24176C04005CDD5C /* XArray_tests.h */; };
9AC77FBB24176C04005CDD5C /* XStringWArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringWArray_test.cpp */; };
9AC77FBB24176C04005CDD5C /* XStringArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringArray_test.cpp */; };
9AC77FC024176C04005CDD5C /* XObjArray_tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ED324176C04005CDD5C /* XObjArray_tests.h */; };
9AC77FC124176C04005CDD5C /* all_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ED424176C04005CDD5C /* all_tests.cpp */; };
9AC77FC224176C04005CDD5C /* XObjArray_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ED524176C04005CDD5C /* XObjArray_tests.cpp */; };
@ -281,8 +276,8 @@
9AC7808A24176C04005CDD5C /* memory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FA824176C04005CDD5C /* memory.h */; };
9AC7808B24176C04005CDD5C /* abort.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FA924176C04005CDD5C /* abort.h */; };
9AC7808C24176C04005CDD5C /* remove_ref.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAA24176C04005CDD5C /* remove_ref.h */; };
9AC7808D24176C04005CDD5C /* XStringWArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAC24176C04005CDD5C /* XStringWArray.h */; };
9AC7809024176C04005CDD5C /* XStringWArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FAF24176C04005CDD5C /* XStringWArray.cpp */; };
9AC7808D24176C04005CDD5C /* XStringArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAC24176C04005CDD5C /* XStringArray.h */; };
9AC7809024176C04005CDD5C /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FAF24176C04005CDD5C /* XStringArray.cpp */; };
9AC7809724176C04005CDD5C /* XArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FB624176C04005CDD5C /* XArray.h */; };
9AC7809824176C04005CDD5C /* XObjArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FB724176C04005CDD5C /* XObjArray.h */; };
9AC7809A24178F02005CDD5C /* menu_items.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC7809924178F02005CDD5C /* menu_items.cpp */; };
@ -295,7 +290,7 @@
9ACFE65324309AF80071CC93 /* nvidia.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3324176C04005CDD5C /* nvidia.h */; };
9ACFE65424309AF80071CC93 /* operatorNewDelete.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FA324176C04005CDD5C /* operatorNewDelete.h */; };
9ACFE65524309AF80071CC93 /* BasicIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF4173E242F15CC00D2644C /* BasicIO.h */; };
9ACFE65724309AF80071CC93 /* XStringWArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringWArray_test.h */; };
9ACFE65724309AF80071CC93 /* XStringArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringArray_test.h */; };
9ACFE65824309AF80071CC93 /* syslinux_mbr.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F1424176C04005CDD5C /* syslinux_mbr.h */; };
9ACFE65924309AF80071CC93 /* lodepng.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F6024176C04005CDD5C /* lodepng.h */; };
9ACFE65A24309AF80071CC93 /* loader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F8224176C04005CDD5C /* loader.h */; };
@ -309,7 +304,7 @@
9ACFE66924309AF80071CC93 /* XObjArray_tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ED324176C04005CDD5C /* XObjArray_tests.h */; };
9ACFE66A24309AF80071CC93 /* Events.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3424176C04005CDD5C /* Events.h */; };
9ACFE66B24309AF80071CC93 /* printlib-test-cpp_conf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF4155F242BABC700D2644C /* printlib-test-cpp_conf.h */; };
9ACFE66C24309AF80071CC93 /* XStringWArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAC24176C04005CDD5C /* XStringWArray.h */; };
9ACFE66C24309AF80071CC93 /* XStringArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAC24176C04005CDD5C /* XStringArray.h */; };
9ACFE66E24309AF80071CC93 /* strcmp_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A28CD2D241BC0DF00F3D247 /* strcmp_test.h */; };
9ACFE66F24309AF80071CC93 /* boot.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3824176C04005CDD5C /* boot.h */; };
9ACFE67024309AF80071CC93 /* ati.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F4624176C04005CDD5C /* ati.h */; };
@ -376,7 +371,7 @@
9ACFE6B824309AF80071CC93 /* hda.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F3F24176C04005CDD5C /* hda.cpp */; };
9ACFE6B924309AF80071CC93 /* egemb_icons_dark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F5E24176C04005CDD5C /* egemb_icons_dark.cpp */; };
9ACFE6BA24309AF80071CC93 /* scroll_images.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F6924176C04005CDD5C /* scroll_images.cpp */; };
9ACFE6BB24309AF80071CC93 /* XStringWArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FAF24176C04005CDD5C /* XStringWArray.cpp */; };
9ACFE6BB24309AF80071CC93 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FAF24176C04005CDD5C /* XStringArray.cpp */; };
9ACFE6BC24309AF80071CC93 /* PlatformDriverOverride.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F2724176C04005CDD5C /* PlatformDriverOverride.cpp */; };
9ACFE6BD24309AF80071CC93 /* HdaCodecDump.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F1924176C04005CDD5C /* HdaCodecDump.cpp */; };
9ACFE6BE24309AF80071CC93 /* Nvram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F3124176C04005CDD5C /* Nvram.cpp */; };
@ -443,7 +438,7 @@
9ACFE70624309AF80071CC93 /* icns.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F9324176C04005CDD5C /* icns.cpp */; };
9ACFE70724309AF80071CC93 /* strcmp_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD2C241BC0DF00F3D247 /* strcmp_test.cpp */; };
9ACFE70824309AF80071CC93 /* nanosvgrast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F6E24176C04005CDD5C /* nanosvgrast.cpp */; };
9ACFE70924309AF80071CC93 /* XStringWArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringWArray_test.cpp */; };
9ACFE70924309AF80071CC93 /* XStringArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringArray_test.cpp */; };
9ACFE70A24309AF80071CC93 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F9E24176C04005CDD5C /* main.cpp */; };
9ACFE70B24309AF80071CC93 /* nvidia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F5024176C04005CDD5C /* nvidia.cpp */; };
9ACFE70C24309AF80071CC93 /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CC91241AB33700F3D247 /* XString.cpp */; };
@ -484,7 +479,7 @@
9AF41587242CD75C00D2644C /* XTheme.h in Headers */ = {isa = PBXBuildFile; fileRef = A5E326302428F4EE002240E8 /* XTheme.h */; };
9AF41589242CD75C00D2644C /* nvidia.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3324176C04005CDD5C /* nvidia.h */; };
9AF4158A242CD75C00D2644C /* operatorNewDelete.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FA324176C04005CDD5C /* operatorNewDelete.h */; };
9AF4158C242CD75C00D2644C /* XStringWArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringWArray_test.h */; };
9AF4158C242CD75C00D2644C /* XStringArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringArray_test.h */; };
9AF4158D242CD75C00D2644C /* syslinux_mbr.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F1424176C04005CDD5C /* syslinux_mbr.h */; };
9AF4158F242CD75C00D2644C /* lodepng.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F6024176C04005CDD5C /* lodepng.h */; };
9AF41590242CD75C00D2644C /* loader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F8224176C04005CDD5C /* loader.h */; };
@ -497,7 +492,7 @@
9AF4159E242CD75C00D2644C /* XObjArray_tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ED324176C04005CDD5C /* XObjArray_tests.h */; };
9AF4159F242CD75C00D2644C /* Events.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3424176C04005CDD5C /* Events.h */; };
9AF415A0242CD75C00D2644C /* printlib-test-cpp_conf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF4155F242BABC700D2644C /* printlib-test-cpp_conf.h */; };
9AF415A1242CD75C00D2644C /* XStringWArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAC24176C04005CDD5C /* XStringWArray.h */; };
9AF415A1242CD75C00D2644C /* XStringArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAC24176C04005CDD5C /* XStringArray.h */; };
9AF415A3242CD75C00D2644C /* strcmp_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A28CD2D241BC0DF00F3D247 /* strcmp_test.h */; };
9AF415A4242CD75C00D2644C /* boot.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3824176C04005CDD5C /* boot.h */; };
9AF415A5242CD75C00D2644C /* ati.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F4624176C04005CDD5C /* ati.h */; };
@ -564,7 +559,7 @@
9AF415EE242CD75C00D2644C /* hda.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F3F24176C04005CDD5C /* hda.cpp */; };
9AF415EF242CD75C00D2644C /* egemb_icons_dark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F5E24176C04005CDD5C /* egemb_icons_dark.cpp */; };
9AF415F0242CD75C00D2644C /* scroll_images.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F6924176C04005CDD5C /* scroll_images.cpp */; };
9AF415F1242CD75C00D2644C /* XStringWArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FAF24176C04005CDD5C /* XStringWArray.cpp */; };
9AF415F1242CD75C00D2644C /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FAF24176C04005CDD5C /* XStringArray.cpp */; };
9AF415F2242CD75C00D2644C /* PlatformDriverOverride.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F2724176C04005CDD5C /* PlatformDriverOverride.cpp */; };
9AF415F3242CD75C00D2644C /* HdaCodecDump.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F1924176C04005CDD5C /* HdaCodecDump.cpp */; };
9AF415F4242CD75C00D2644C /* Nvram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F3124176C04005CDD5C /* Nvram.cpp */; };
@ -629,7 +624,7 @@
9AF4163C242CD75C00D2644C /* icns.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F9324176C04005CDD5C /* icns.cpp */; };
9AF4163D242CD75C00D2644C /* strcmp_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD2C241BC0DF00F3D247 /* strcmp_test.cpp */; };
9AF4163E242CD75C00D2644C /* nanosvgrast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F6E24176C04005CDD5C /* nanosvgrast.cpp */; };
9AF4163F242CD75C00D2644C /* XStringWArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringWArray_test.cpp */; };
9AF4163F242CD75C00D2644C /* XStringArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringArray_test.cpp */; };
9AF41640242CD75C00D2644C /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F9E24176C04005CDD5C /* main.cpp */; };
9AF41641242CD75C00D2644C /* nvidia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F5024176C04005CDD5C /* nvidia.cpp */; };
9AF41642242CD75C00D2644C /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CC91241AB33700F3D247 /* XString.cpp */; };
@ -656,7 +651,7 @@
9AF41664242CDA5800D2644C /* XTheme.h in Headers */ = {isa = PBXBuildFile; fileRef = A5E326302428F4EE002240E8 /* XTheme.h */; };
9AF41666242CDA5800D2644C /* nvidia.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3324176C04005CDD5C /* nvidia.h */; };
9AF41667242CDA5800D2644C /* operatorNewDelete.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FA324176C04005CDD5C /* operatorNewDelete.h */; };
9AF41669242CDA5800D2644C /* XStringWArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringWArray_test.h */; };
9AF41669242CDA5800D2644C /* XStringArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringArray_test.h */; };
9AF4166A242CDA5800D2644C /* syslinux_mbr.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F1424176C04005CDD5C /* syslinux_mbr.h */; };
9AF4166C242CDA5800D2644C /* lodepng.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F6024176C04005CDD5C /* lodepng.h */; };
9AF4166D242CDA5800D2644C /* loader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F8224176C04005CDD5C /* loader.h */; };
@ -669,7 +664,7 @@
9AF4167B242CDA5800D2644C /* XObjArray_tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ED324176C04005CDD5C /* XObjArray_tests.h */; };
9AF4167C242CDA5800D2644C /* Events.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3424176C04005CDD5C /* Events.h */; };
9AF4167D242CDA5800D2644C /* printlib-test-cpp_conf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF4155F242BABC700D2644C /* printlib-test-cpp_conf.h */; };
9AF4167E242CDA5800D2644C /* XStringWArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAC24176C04005CDD5C /* XStringWArray.h */; };
9AF4167E242CDA5800D2644C /* XStringArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FAC24176C04005CDD5C /* XStringArray.h */; };
9AF41680242CDA5800D2644C /* strcmp_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A28CD2D241BC0DF00F3D247 /* strcmp_test.h */; };
9AF41681242CDA5800D2644C /* boot.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F3824176C04005CDD5C /* boot.h */; };
9AF41682242CDA5800D2644C /* ati.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77F4624176C04005CDD5C /* ati.h */; };
@ -736,7 +731,7 @@
9AF416CB242CDA5800D2644C /* hda.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F3F24176C04005CDD5C /* hda.cpp */; };
9AF416CC242CDA5800D2644C /* egemb_icons_dark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F5E24176C04005CDD5C /* egemb_icons_dark.cpp */; };
9AF416CD242CDA5800D2644C /* scroll_images.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F6924176C04005CDD5C /* scroll_images.cpp */; };
9AF416CE242CDA5800D2644C /* XStringWArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FAF24176C04005CDD5C /* XStringWArray.cpp */; };
9AF416CE242CDA5800D2644C /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FAF24176C04005CDD5C /* XStringArray.cpp */; };
9AF416CF242CDA5800D2644C /* PlatformDriverOverride.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F2724176C04005CDD5C /* PlatformDriverOverride.cpp */; };
9AF416D0242CDA5800D2644C /* HdaCodecDump.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F1924176C04005CDD5C /* HdaCodecDump.cpp */; };
9AF416D1242CDA5800D2644C /* Nvram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F3124176C04005CDD5C /* Nvram.cpp */; };
@ -801,7 +796,7 @@
9AF41719242CDA5800D2644C /* icns.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F9324176C04005CDD5C /* icns.cpp */; };
9AF4171A242CDA5800D2644C /* strcmp_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD2C241BC0DF00F3D247 /* strcmp_test.cpp */; };
9AF4171B242CDA5800D2644C /* nanosvgrast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F6E24176C04005CDD5C /* nanosvgrast.cpp */; };
9AF4171C242CDA5800D2644C /* XStringWArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringWArray_test.cpp */; };
9AF4171C242CDA5800D2644C /* XStringArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringArray_test.cpp */; };
9AF4171D242CDA5800D2644C /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F9E24176C04005CDD5C /* main.cpp */; };
9AF4171E242CDA5800D2644C /* nvidia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77F5024176C04005CDD5C /* nvidia.cpp */; };
9AF4171F242CDA5800D2644C /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CC91241AB33700F3D247 /* XString.cpp */; };
@ -890,15 +885,13 @@
9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadOptions_test.h; sourceTree = "<group>"; };
9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadOptions_test.cpp; sourceTree = "<group>"; };
9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = "<group>"; };
9A9AEB91243F7B5600FBD7D8 /* XStringArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringArray.cpp; sourceTree = "<group>"; };
9A9AEB92243F7B5600FBD7D8 /* XStringArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringArray.h; sourceTree = "<group>"; };
9A9AEB93243F7B5600FBD7D8 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = "<group>"; };
9A9AEB98243F7B7900FBD7D8 /* printf_lite-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printf_lite-test.h"; sourceTree = "<group>"; };
9A9D3B2124221563006D8CD9 /* printf_lite-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "printf_lite-test.cpp"; sourceTree = "<group>"; };
9AC77EC424176BF2005CDD5C /* libCloverX64.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCloverX64.a; sourceTree = BUILT_PRODUCTS_DIR; };
9AC77ECC24176C04005CDD5C /* XStringWArray_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringWArray_test.h; sourceTree = "<group>"; };
9AC77ECC24176C04005CDD5C /* XStringArray_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringArray_test.h; sourceTree = "<group>"; };
9AC77ECD24176C04005CDD5C /* XArray_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XArray_tests.h; sourceTree = "<group>"; };
9AC77ECE24176C04005CDD5C /* XStringWArray_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringWArray_test.cpp; sourceTree = "<group>"; };
9AC77ECE24176C04005CDD5C /* XStringArray_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringArray_test.cpp; sourceTree = "<group>"; };
9AC77ED324176C04005CDD5C /* XObjArray_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XObjArray_tests.h; sourceTree = "<group>"; };
9AC77ED424176C04005CDD5C /* all_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = all_tests.cpp; sourceTree = "<group>"; };
9AC77ED524176C04005CDD5C /* XObjArray_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XObjArray_tests.cpp; sourceTree = "<group>"; };
@ -1044,8 +1037,8 @@
9AC77FA824176C04005CDD5C /* memory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory.h; sourceTree = "<group>"; };
9AC77FA924176C04005CDD5C /* abort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = abort.h; sourceTree = "<group>"; };
9AC77FAA24176C04005CDD5C /* remove_ref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = remove_ref.h; sourceTree = "<group>"; };
9AC77FAC24176C04005CDD5C /* XStringWArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringWArray.h; sourceTree = "<group>"; };
9AC77FAF24176C04005CDD5C /* XStringWArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringWArray.cpp; sourceTree = "<group>"; };
9AC77FAC24176C04005CDD5C /* XStringArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringArray.h; sourceTree = "<group>"; };
9AC77FAF24176C04005CDD5C /* XStringArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringArray.cpp; sourceTree = "<group>"; };
9AC77FB624176C04005CDD5C /* XArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XArray.h; sourceTree = "<group>"; };
9AC77FB724176C04005CDD5C /* XObjArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XObjArray.h; sourceTree = "<group>"; };
9AC7809924178F02005CDD5C /* menu_items.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = menu_items.cpp; sourceTree = "<group>"; };
@ -1202,8 +1195,8 @@
9AC77ED324176C04005CDD5C /* XObjArray_tests.h */,
9A28CC95241AB34800F3D247 /* XString_test.cpp */,
9A28CC96241AB34800F3D247 /* XString_test.h */,
9AC77ECE24176C04005CDD5C /* XStringWArray_test.cpp */,
9AC77ECC24176C04005CDD5C /* XStringWArray_test.h */,
9AC77ECE24176C04005CDD5C /* XStringArray_test.cpp */,
9AC77ECC24176C04005CDD5C /* XStringArray_test.h */,
);
path = cpp_unit_test;
sourceTree = "<group>";
@ -1456,10 +1449,8 @@
9A28CC91241AB33700F3D247 /* XString.cpp */,
9A28CC92241AB33700F3D247 /* XString.h */,
9A35A6172451FE1500CAFF76 /* XStringAbstract.h */,
9A9AEB91243F7B5600FBD7D8 /* XStringArray.cpp */,
9A9AEB92243F7B5600FBD7D8 /* XStringArray.h */,
9AC77FAF24176C04005CDD5C /* XStringWArray.cpp */,
9AC77FAC24176C04005CDD5C /* XStringWArray.h */,
9AC77FAF24176C04005CDD5C /* XStringArray.cpp */,
9AC77FAC24176C04005CDD5C /* XStringArray.h */,
);
path = cpp_foundation;
sourceTree = "<group>";
@ -1480,7 +1471,7 @@
9AC7801C24176C04005CDD5C /* nvidia.h in Headers */,
9AC7808524176C04005CDD5C /* operatorNewDelete.h in Headers */,
9AF41741242F15CC00D2644C /* BasicIO.h in Headers */,
9AC77FB924176C04005CDD5C /* XStringWArray_test.h in Headers */,
9AC77FB924176C04005CDD5C /* XStringArray_test.h in Headers */,
9AC77FFE24176C04005CDD5C /* syslinux_mbr.h in Headers */,
9AC7804724176C04005CDD5C /* lodepng.h in Headers */,
9AC7806824176C04005CDD5C /* loader.h in Headers */,
@ -1495,7 +1486,7 @@
9AC77FC024176C04005CDD5C /* XObjArray_tests.h in Headers */,
9AC7801D24176C04005CDD5C /* Events.h in Headers */,
9AF41562242BABC700D2644C /* printlib-test-cpp_conf.h in Headers */,
9AC7808D24176C04005CDD5C /* XStringWArray.h in Headers */,
9AC7808D24176C04005CDD5C /* XStringArray.h in Headers */,
9A105B7824483AE40006DE06 /* usbfix.h in Headers */,
9A28CD33241BC0DF00F3D247 /* strcmp_test.h in Headers */,
9AC7802124176C04005CDD5C /* boot.h in Headers */,
@ -1516,7 +1507,6 @@
9AC7808024176C04005CDD5C /* screen.h in Headers */,
9AF41563242BABC700D2644C /* printlib-test.h in Headers */,
9A105B5D24483AE40006DE06 /* FixBiosDsdt.h in Headers */,
9A9AEB96243F7B5600FBD7D8 /* XStringArray.h in Headers */,
9AD469522452B5A600D6D0DB /* Pci.h in Headers */,
9A105B6624483AE40006DE06 /* LegacyBoot.h in Headers */,
9AC7802224176C04005CDD5C /* DataHubCpu.h in Headers */,
@ -1613,7 +1603,7 @@
9ACFE65424309AF80071CC93 /* operatorNewDelete.h in Headers */,
9A105B3024464A830006DE06 /* BmLib.h in Headers */,
9ACFE65524309AF80071CC93 /* BasicIO.h in Headers */,
9ACFE65724309AF80071CC93 /* XStringWArray_test.h in Headers */,
9ACFE65724309AF80071CC93 /* XStringArray_test.h in Headers */,
9ACFE65824309AF80071CC93 /* syslinux_mbr.h in Headers */,
9ACFE65924309AF80071CC93 /* lodepng.h in Headers */,
9ACFE65A24309AF80071CC93 /* loader.h in Headers */,
@ -1627,7 +1617,7 @@
9ACFE66924309AF80071CC93 /* XObjArray_tests.h in Headers */,
9ACFE66A24309AF80071CC93 /* Events.h in Headers */,
9ACFE66B24309AF80071CC93 /* printlib-test-cpp_conf.h in Headers */,
9ACFE66C24309AF80071CC93 /* XStringWArray.h in Headers */,
9ACFE66C24309AF80071CC93 /* XStringArray.h in Headers */,
9ACFE66E24309AF80071CC93 /* strcmp_test.h in Headers */,
9ACFE66F24309AF80071CC93 /* boot.h in Headers */,
9ACFE67024309AF80071CC93 /* ati.h in Headers */,
@ -1709,7 +1699,7 @@
9AF41587242CD75C00D2644C /* XTheme.h in Headers */,
9AF41589242CD75C00D2644C /* nvidia.h in Headers */,
9AF4158A242CD75C00D2644C /* operatorNewDelete.h in Headers */,
9AF4158C242CD75C00D2644C /* XStringWArray_test.h in Headers */,
9AF4158C242CD75C00D2644C /* XStringArray_test.h in Headers */,
9AF4158D242CD75C00D2644C /* syslinux_mbr.h in Headers */,
9AF4158F242CD75C00D2644C /* lodepng.h in Headers */,
9AF41590242CD75C00D2644C /* loader.h in Headers */,
@ -1722,7 +1712,7 @@
9AF4159E242CD75C00D2644C /* XObjArray_tests.h in Headers */,
9AF4159F242CD75C00D2644C /* Events.h in Headers */,
9AF415A0242CD75C00D2644C /* printlib-test-cpp_conf.h in Headers */,
9AF415A1242CD75C00D2644C /* XStringWArray.h in Headers */,
9AF415A1242CD75C00D2644C /* XStringArray.h in Headers */,
9A09863C2438A15400826276 /* shared_with_menu.h in Headers */,
9A4185B72439F29D00BEAFB8 /* LoadOptions_test.h in Headers */,
9AF415A3242CD75C00D2644C /* strcmp_test.h in Headers */,
@ -1804,7 +1794,7 @@
9AF41664242CDA5800D2644C /* XTheme.h in Headers */,
9AF41666242CDA5800D2644C /* nvidia.h in Headers */,
9AF41667242CDA5800D2644C /* operatorNewDelete.h in Headers */,
9AF41669242CDA5800D2644C /* XStringWArray_test.h in Headers */,
9AF41669242CDA5800D2644C /* XStringArray_test.h in Headers */,
9AF4166A242CDA5800D2644C /* syslinux_mbr.h in Headers */,
9AF4166C242CDA5800D2644C /* lodepng.h in Headers */,
9AF4166D242CDA5800D2644C /* loader.h in Headers */,
@ -1817,7 +1807,7 @@
9AF4167B242CDA5800D2644C /* XObjArray_tests.h in Headers */,
9AF4167C242CDA5800D2644C /* Events.h in Headers */,
9AF4167D242CDA5800D2644C /* printlib-test-cpp_conf.h in Headers */,
9AF4167E242CDA5800D2644C /* XStringWArray.h in Headers */,
9AF4167E242CDA5800D2644C /* XStringArray.h in Headers */,
9A09863D2438A15400826276 /* shared_with_menu.h in Headers */,
9A4185B82439F29D00BEAFB8 /* LoadOptions_test.h in Headers */,
9AF41680242CDA5800D2644C /* strcmp_test.h in Headers */,
@ -2078,7 +2068,7 @@
9AC7802824176C04005CDD5C /* hda.cpp in Sources */,
9AC7804524176C04005CDD5C /* egemb_icons_dark.cpp in Sources */,
9AC7805024176C04005CDD5C /* scroll_images.cpp in Sources */,
9AC7809024176C04005CDD5C /* XStringWArray.cpp in Sources */,
9AC7809024176C04005CDD5C /* XStringArray.cpp in Sources */,
9AC7801024176C04005CDD5C /* PlatformDriverOverride.cpp in Sources */,
9AC7800224176C04005CDD5C /* HdaCodecDump.cpp in Sources */,
9AC7801A24176C04005CDD5C /* Nvram.cpp in Sources */,
@ -2101,7 +2091,6 @@
9AC7808424176C04005CDD5C /* globals_dtor.cpp in Sources */,
9AC7803024176C04005CDD5C /* DevicePath.cpp in Sources */,
9AC77FC324176C04005CDD5C /* XArray_tests.cpp in Sources */,
9A9AEB95243F7B5600FBD7D8 /* XStringArray.cpp in Sources */,
9AC7800A24176C04005CDD5C /* StateGenerator.cpp in Sources */,
9AC7805C24176C04005CDD5C /* XImage.cpp in Sources */,
9A014999244091B200B37399 /* printlib-test.cpp in Sources */,
@ -2156,7 +2145,7 @@
9AC7807624176C04005CDD5C /* icns.cpp in Sources */,
9A28CD32241BC0DF00F3D247 /* strcmp_test.cpp in Sources */,
9AC7805524176C04005CDD5C /* nanosvgrast.cpp in Sources */,
9AC77FBB24176C04005CDD5C /* XStringWArray_test.cpp in Sources */,
9AC77FBB24176C04005CDD5C /* XStringArray_test.cpp in Sources */,
9AC7808124176C04005CDD5C /* main.cpp in Sources */,
9AC7803924176C04005CDD5C /* nvidia.cpp in Sources */,
9A28CC93241AB33700F3D247 /* XString.cpp in Sources */,
@ -2191,7 +2180,7 @@
9ACFE6B824309AF80071CC93 /* hda.cpp in Sources */,
9ACFE6B924309AF80071CC93 /* egemb_icons_dark.cpp in Sources */,
9ACFE6BA24309AF80071CC93 /* scroll_images.cpp in Sources */,
9ACFE6BB24309AF80071CC93 /* XStringWArray.cpp in Sources */,
9ACFE6BB24309AF80071CC93 /* XStringArray.cpp in Sources */,
9ACFE6BC24309AF80071CC93 /* PlatformDriverOverride.cpp in Sources */,
9ACFE6BD24309AF80071CC93 /* HdaCodecDump.cpp in Sources */,
9ACFE6BE24309AF80071CC93 /* Nvram.cpp in Sources */,
@ -2244,7 +2233,6 @@
9ACFE6EE24309AF80071CC93 /* REFIT_MENU_SCREEN.cpp in Sources */,
9ACFE6EF24309AF80071CC93 /* LegacyBiosThunk.cpp in Sources */,
9A09863424389A6A00826276 /* menu.cpp in Sources */,
9A9AEB9F243F7B9200FBD7D8 /* XStringArray.cpp in Sources */,
9ACFE6F324309AF80071CC93 /* lockedgraphics.cpp in Sources */,
9A4185BD2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */,
9A4F68612449D4B5004B2F7E /* strlen.cpp in Sources */,
@ -2270,7 +2258,7 @@
9ACFE70624309AF80071CC93 /* icns.cpp in Sources */,
9ACFE70724309AF80071CC93 /* strcmp_test.cpp in Sources */,
9ACFE70824309AF80071CC93 /* nanosvgrast.cpp in Sources */,
9ACFE70924309AF80071CC93 /* XStringWArray_test.cpp in Sources */,
9ACFE70924309AF80071CC93 /* XStringArray_test.cpp in Sources */,
9ACFE70A24309AF80071CC93 /* main.cpp in Sources */,
9ACFE70B24309AF80071CC93 /* nvidia.cpp in Sources */,
9ACFE70C24309AF80071CC93 /* XString.cpp in Sources */,
@ -2305,7 +2293,7 @@
9AF415EE242CD75C00D2644C /* hda.cpp in Sources */,
9AF415EF242CD75C00D2644C /* egemb_icons_dark.cpp in Sources */,
9AF415F0242CD75C00D2644C /* scroll_images.cpp in Sources */,
9AF415F1242CD75C00D2644C /* XStringWArray.cpp in Sources */,
9AF415F1242CD75C00D2644C /* XStringArray.cpp in Sources */,
9AF415F2242CD75C00D2644C /* PlatformDriverOverride.cpp in Sources */,
9AF415F3242CD75C00D2644C /* HdaCodecDump.cpp in Sources */,
9AF415F4242CD75C00D2644C /* Nvram.cpp in Sources */,
@ -2358,7 +2346,6 @@
9AF41625242CD75C00D2644C /* LegacyBiosThunk.cpp in Sources */,
9A09863224389A6A00826276 /* menu.cpp in Sources */,
9AF41629242CD75C00D2644C /* lockedgraphics.cpp in Sources */,
9A9AEB9D243F7B9000FBD7D8 /* XStringArray.cpp in Sources */,
9AF4162A242CD75C00D2644C /* XString_test.cpp in Sources */,
9A4185BB2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */,
9A4F685B2449D4B4004B2F7E /* strlen.cpp in Sources */,
@ -2383,7 +2370,7 @@
9AF4163C242CD75C00D2644C /* icns.cpp in Sources */,
9AF4163D242CD75C00D2644C /* strcmp_test.cpp in Sources */,
9AF4163E242CD75C00D2644C /* nanosvgrast.cpp in Sources */,
9AF4163F242CD75C00D2644C /* XStringWArray_test.cpp in Sources */,
9AF4163F242CD75C00D2644C /* XStringArray_test.cpp in Sources */,
9AF41640242CD75C00D2644C /* main.cpp in Sources */,
9AF41641242CD75C00D2644C /* nvidia.cpp in Sources */,
9AF41642242CD75C00D2644C /* XString.cpp in Sources */,
@ -2419,7 +2406,7 @@
9AF416CB242CDA5800D2644C /* hda.cpp in Sources */,
9AF416CC242CDA5800D2644C /* egemb_icons_dark.cpp in Sources */,
9AF416CD242CDA5800D2644C /* scroll_images.cpp in Sources */,
9AF416CE242CDA5800D2644C /* XStringWArray.cpp in Sources */,
9AF416CE242CDA5800D2644C /* XStringArray.cpp in Sources */,
9AF416CF242CDA5800D2644C /* PlatformDriverOverride.cpp in Sources */,
9AF416D0242CDA5800D2644C /* HdaCodecDump.cpp in Sources */,
9AF416D1242CDA5800D2644C /* Nvram.cpp in Sources */,
@ -2472,7 +2459,6 @@
9AF41702242CDA5800D2644C /* LegacyBiosThunk.cpp in Sources */,
9A09863324389A6A00826276 /* menu.cpp in Sources */,
9AF41706242CDA5800D2644C /* lockedgraphics.cpp in Sources */,
9A9AEB9E243F7B9100FBD7D8 /* XStringArray.cpp in Sources */,
9AF41707242CDA5800D2644C /* XString_test.cpp in Sources */,
9A4185BC2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */,
9A4F685E2449D4B4004B2F7E /* strlen.cpp in Sources */,
@ -2497,7 +2483,7 @@
9AF41719242CDA5800D2644C /* icns.cpp in Sources */,
9AF4171A242CDA5800D2644C /* strcmp_test.cpp in Sources */,
9AF4171B242CDA5800D2644C /* nanosvgrast.cpp in Sources */,
9AF4171C242CDA5800D2644C /* XStringWArray_test.cpp in Sources */,
9AF4171C242CDA5800D2644C /* XStringArray_test.cpp in Sources */,
9AF4171D242CDA5800D2644C /* main.cpp in Sources */,
9AF4171E242CDA5800D2644C /* nvidia.cpp in Sources */,
9AF4171F242CDA5800D2644C /* XString.cpp in Sources */,

View File

@ -12,6 +12,7 @@
#define __XOBJARRAY_H__
#include <XToolsConf.h>
#include "XToolsCommon.h"
#if 1
@ -35,8 +36,8 @@ class XObjArrayNC
{
public:
XObjArrayEntry<TYPE> *_Data;
xsize _Len;
xsize m_allocatedSize;
size_t _Len;
size_t m_allocatedSize;
public:
void Init();
@ -58,16 +59,40 @@ class XObjArrayNC
bool NotNull() const { return size() > 0; }
bool IsNull() const { return size() == 0; }
const TYPE &ElementAt(xsize nIndex) const;
TYPE &ElementAt(xsize nIndex);
template<typename IntegralType, enable_if(is_integral(IntegralType))>
const TYPE &ElementAt(IntegralType nIndex) const
{
if (nIndex < 0) {
panic("XObjArrayNC::ElementAt() : i < 0. System halted\n");
}
if ( (unsigned_type(IntegralType))nIndex >= _Len ) {
panic("XObjArrayNC::ElementAt() -> operator [] - index (%zu) greater than length (%zu)\n", (size_t)nIndex, _Len);
}
return *((TYPE *)(_Data[nIndex].Object));
}
template<typename IntegralType, enable_if(is_integral(IntegralType))>
TYPE &ElementAt(IntegralType nIndex)
{
if (nIndex < 0) {
panic("XObjArrayNC::ElementAt() : i < 0. System halted\n");
}
if ( (unsigned_type(IntegralType))nIndex >= _Len ) {
panic("XObjArrayNC::ElementAt() const -> operator [] - index (%zu) greater than length (%zu)\n", (size_t)nIndex, _Len);
}
return *((TYPE *)(_Data[nIndex].Object));
}
// This was useful for realtime debugging with a debugger that do not recognise references. That was years and years ago. Probably not needed anymore.
#ifdef _DEBUG_iufasdfsfk
const TYPE *DbgAt(int i) const { if ( i >= 0 && (xsize)i < _Len ) return &ElementAt ((xsize) i); else return NULL; }
#endif
const TYPE &operator[](xsize nIndex) const { return ElementAt(nIndex); }
TYPE &operator[](xsize nIndex) { return ElementAt(nIndex); }
template<typename IntegralType, enable_if(is_integral(IntegralType))>
const TYPE &operator[](IntegralType nIndex) const { return ElementAt(nIndex); }
template<typename IntegralType, enable_if(is_integral(IntegralType))>
TYPE &operator[](IntegralType nIndex) { return ElementAt(nIndex); }
xsize AddReference(TYPE *newElement, bool FreeIt);
@ -163,7 +188,7 @@ const XObjArray<TYPE> &XObjArray<TYPE>::operator =(const XObjArray<TYPE> &anObjA
xsize ui;
XObjArrayNC<TYPE>::Empty();
CheckSize(anObjArray.length(), 0);
this->CheckSize(anObjArray.length(), 0);
for ( ui=0 ; ui<anObjArray.size() ; ui+=1 ) AddCopy(anObjArray.ElementAt(ui));
return *this;
}
@ -192,26 +217,6 @@ void XObjArrayNC<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
}
}
/* ElementAt() */
template<class TYPE>
TYPE &XObjArrayNC<TYPE>::ElementAt(xsize index)
{
if ( index >= _Len ) {
panic("XObjArray<TYPE>::ElementAt(xsize) -> operator [] - index (%zu) greater than length (%zu)\n", index, _Len);
}
return *((TYPE *)(_Data[index].Object));
}
/* ElementAt() */
template<class TYPE>
const TYPE &XObjArrayNC<TYPE>::ElementAt(xsize index) const
{
if ( index >= _Len ) {
panic("XObjArray<TYPE>::ElementAt(xsize) const -> operator [] - index (%zu) greater than length (%zu)\n", index, _Len);
}
return *((TYPE *)(_Data[index].Object));
}
///* Add() */
//template<class TYPE>
//TYPE &XObjArray<TYPE>::AddNew(bool FreeIt)

View File

@ -10,12 +10,13 @@
#define __XSTRINGABSTRACT_H__
#include <XToolsConf.h>
#include "XToolsCommon.h"
#include "unicode_conversions.h"
#ifndef DEBUG_ALL
#define DEBUG_XStringAbstract 0
#else
#define DEBUG_TEXT DEBUG_ALL
#define DEBUG_XStringAbstract DEBUG_ALL
#endif
#if DEBUG_XStringAbstract == 0
@ -35,90 +36,6 @@
#endif
struct XStringAbstract__false_type {
static constexpr bool value = false;
bool v() const { return false; }
};
struct XStringAbstract__true_type {
static constexpr bool value = true;
bool v() const { return true; }
};
/* make unsigned */
template <class _Tp>
struct XStringAbstract__make_unsigned {};
template <> struct XStringAbstract__make_unsigned< char> {typedef unsigned char type;};
template <> struct XStringAbstract__make_unsigned< signed char> {typedef unsigned char type;};
template <> struct XStringAbstract__make_unsigned<unsigned char> {typedef unsigned char type;};
template <> struct XStringAbstract__make_unsigned< char16_t> {typedef char16_t type;};
template <> struct XStringAbstract__make_unsigned< char32_t> {typedef char32_t type;};
template <> struct XStringAbstract__make_unsigned< wchar_t> {typedef wchar_t type;};
template <> struct XStringAbstract__make_unsigned< signed short> {typedef unsigned short type;};
template <> struct XStringAbstract__make_unsigned<unsigned short> {typedef unsigned short type;};
template <> struct XStringAbstract__make_unsigned< signed int> {typedef unsigned int type;};
template <> struct XStringAbstract__make_unsigned<unsigned int> {typedef unsigned int type;};
template <> struct XStringAbstract__make_unsigned< signed long> {typedef unsigned long type;};
template <> struct XStringAbstract__make_unsigned<unsigned long> {typedef unsigned long type;};
template <> struct XStringAbstract__make_unsigned< signed long long> {typedef unsigned long long type;};
template <> struct XStringAbstract__make_unsigned<unsigned long long> {typedef unsigned long long type;};
#define unsigned_type(x) typename XStringAbstract__make_unsigned<x>::type
/* enable_if */
template <bool, typename T = void>
struct XStringAbstract__enable_if_t
{};
template <typename T>
struct XStringAbstract__enable_if_t<true, T> {
typedef T type;
};
//#define enable_if(x) XStringAbstract__enable_if_t(x, void)::type
#define enable_if(x) typename enable_if_type = typename XStringAbstract__enable_if_t<x>::type
//
//template< bool B, class T = void >
//using XStringAbstract__enable_if_t = typename XStringAbstract__enable_if<B,T>::type;
// is_integral
template <class _Tp> struct XStringAbstract__is_integral_st : public XStringAbstract__false_type {};
template <> struct XStringAbstract__is_integral_st<bool> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<signed char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<wchar_t> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<short> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned short> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<int> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned int> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<long> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned long> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<long long> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned long long> : public XStringAbstract__true_type {};
#define is_integral(x) XStringAbstract__is_integral_st<x>::value
// is_char
template <class _Tp> struct XStringAbstract__is_char_st : public XStringAbstract__false_type {};
template <> struct XStringAbstract__is_char_st<char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<char[]> : public XStringAbstract__true_type {};
template <size_t _Np> struct XStringAbstract__is_char_st<char[_Np]> : public XStringAbstract__true_type {};
//template <> struct XStringAbstract__is_char_st<signed char> : public XStringAbstract__true_type {};
//template <> struct XStringAbstract__is_char_st<unsigned char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<char16_t> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<char16_t[]> : public XStringAbstract__true_type {};
template <size_t _Np> struct XStringAbstract__is_char_st<char16_t[_Np]> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<char32_t> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<char32_t[]> : public XStringAbstract__true_type {};
template <size_t _Np> struct XStringAbstract__is_char_st<char32_t[_Np]> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<wchar_t> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<wchar_t[]> : public XStringAbstract__true_type {};
template <size_t _Np> struct XStringAbstract__is_char_st<wchar_t[_Np]> : public XStringAbstract__true_type {};
#define is_char(x) XStringAbstract__is_char_st<x>::value
@ -126,6 +43,31 @@ template <size_t _Np> struct XStringAbstract__is_char_st<wchar_t[_Np]>
#define asciiToLower(ch) (((ch >= L'A') && (ch <= L'Z')) ? ((ch - L'A') + L'a') : ch)
#define asciiToUpper(ch) (((ch >= L'a') && (ch <= L'z')) ? ((ch - L'a') + L'A') : ch)
template<typename S, typename O>
int XStringAbstract__startWith(const S* src, const O* other, bool ignoreCase)
{
size_t nb = 0;
const S* src2 = src;
const O* other2 = other;
char32_t src_char32;
char32_t other_char32;
other2 = get_char32_from_string(other2, &other_char32);
if ( !other_char32 ) return true; // startWith with empty string is considered true
src2 = get_char32_from_string(src2, &src_char32);
while ( other_char32 ) {
if ( ignoreCase ) {
src_char32 = asciiToLower(src_char32);
other_char32 = asciiToLower(other_char32);
}
if ( src_char32 != other_char32 ) return false;
src2 = get_char32_from_string(src2, &src_char32);
other2 = get_char32_from_string(other2, &other_char32);
nb += 1;
};
return src_char32 != 0;
}
template<typename S, typename O>
int XStringAbstract__compare(const S* src, const O* other, bool ignoreCase)
{
@ -335,6 +277,7 @@ public:
size_t length() const { return length_of_utf_string(m_data); }
// size_t sizeZZ() const { return size_of_utf_string(m_data); }
size_t sizeInBytes() const { return size_of_utf_string(m_data)*sizeof(T); }
size_t sizeInBytesIncludingTerminator() const { return (size_of_utf_string(m_data)+1)*sizeof(T); } // usefull for unit tests
size_t allocatedSize() const { return m_allocatedSize; }
@ -369,6 +312,7 @@ public:
do {
p = get_char32_from_string(p, &char32);
if (!char32) {
if ( (unsigned_type(IntegralType))i == nb ) return 0; // no panic if we want to access the null terminator
panic("XStringAbstract::char32At(size_t i) : i >= length(). System halted\n");
}
nb += 1;
@ -392,23 +336,20 @@ public:
char32_t lastChar() const { if ( length() > 0 ) return char32At(length()-1); else return 0; }
//--------------------------------------------------------------------- strcat, strcpy, operator =
/* strncpy */
template<typename O>
void strncpy(const O* other, size_t other_len)
/* strcpy char */
template<typename O, enable_if(is_char(O))>
void strcpy(O otherChar)
{
if ( other && *other && other_len > 0 ) {
size_t newSize = utf_size_of_utf_string_len(m_data, other, other_len);
if ( otherChar != 0) {
size_t newSize = utf_size_of_utf_string_len(m_data, &otherChar, 1);
CheckSize(newSize+1, 0);
utf_string_from_utf_string_len(m_data, m_allocatedSize, other, other_len);
utf_string_from_utf_string_len(m_data, m_allocatedSize, &otherChar, 1);
m_data[newSize] = 0;
}else{
setEmpty();
}
}
// Old name. TODO remove
template<typename O>
void StrnCpy(const O* other, size_t other_len) { strncpy(other, other_len); }
/* strcpy */
template<typename O>
void strcpy(const O* other)
@ -422,15 +363,29 @@ public:
setEmpty();
}
}
/* strncat */
/* strncpy */
template<typename O>
void strncat(const O* other, size_t other_len)
void strncpy(const O* other, size_t other_len)
{
if ( other && *other && other_len > 0 ) {
size_t currentSize = size_of_utf_string(m_data);
size_t newSize = currentSize + utf_size_of_utf_string_len(m_data, other, other_len);
size_t newSize = utf_size_of_utf_string_len(m_data, other, other_len);
CheckSize(newSize+1, 0);
utf_string_from_utf_string_len(m_data+currentSize, m_allocatedSize, other, other_len);
utf_string_from_utf_string_len(m_data, m_allocatedSize, other, other_len);
m_data[newSize] = 0;
}else{
setEmpty();
}
}
/* strcat char */
template<typename O, enable_if(is_char(O))>
void strcat(O otherChar)
{
if ( otherChar ) {
size_t currentSize = size_of_utf_string(m_data);
size_t newSize = currentSize + utf_size_of_utf_string_len(m_data, &otherChar, 1);
CheckSize(newSize+1, 0);
utf_string_from_utf_string_len(m_data+currentSize, m_allocatedSize, &otherChar, 1);
m_data[newSize] = 0;
}else{
// nothing to do
@ -450,6 +405,20 @@ public:
// nothing to do
}
}
/* strncat */
template<typename O>
void strncat(const O* other, size_t other_len)
{
if ( other && *other && other_len > 0 ) {
size_t currentSize = size_of_utf_string(m_data);
size_t newSize = currentSize + utf_size_of_utf_string_len(m_data, other, other_len);
CheckSize(newSize+1, 0);
utf_string_from_utf_string_len(m_data+currentSize, m_allocatedSize, other, other_len);
m_data[newSize] = 0;
}else{
// nothing to do
}
}
/* takeValueFrom */
template<typename O, class OtherXStringClass>
ThisXStringClass& takeValueFrom(const XStringAbstract<O, OtherXStringClass>& S) { strcpy(S.s()); return *((ThisXStringClass*)this); }
@ -479,19 +448,25 @@ public:
/* += */
template<typename O, class OtherXStringClass>
ThisXStringClass& operator += (const XStringAbstract<O, OtherXStringClass>& S) { strcat(S.s()); return *((ThisXStringClass*)this); }
template<typename O, enable_if(is_char(O))>
ThisXStringClass& operator += (O S) { strcat(S); return *((ThisXStringClass*)this); }
template<typename O>
ThisXStringClass& operator += (const O* S) { strcat(S); return *((ThisXStringClass*)this); }
template<typename O, class OtherXStringClass>
ThisXStringClass operator + (const XStringAbstract<O, OtherXStringClass>& p2) const { XStringAbstract s; s=*this; s+=p2; return s; }
template<typename O, enable_if(is_char(O))>
ThisXStringClass operator + (O p1) const { XStringAbstract s; s=*this; s.strcat(p1); return s; }
template<typename O>
ThisXStringClass operator + (const O* p2) const { XStringAbstract s; s=*this; s+=p2; return s; }
template<typename O, enable_if(is_char(O))>
friend ThisXStringClass operator + (O p1, const ThisXStringClass& p2) { XStringAbstract s; s.strcat(p1); s.strcat(p2.s()); return s; }
template<typename O>
friend ThisXStringClass operator + (const O *p1, const ThisXStringClass& p2) { XStringAbstract s; s.strcat(p1); s.strcat(p2.s()); return s; }
//--------------------------------------------------------------------- indexOf, rindexOf
//--------------------------------------------------------------------- indexOf, rindexOf, contains, subString
/* indexOf */
size_t indexOf(char32_t char32Searched, size_t Pos = 0) const
@ -536,8 +511,43 @@ public:
template<typename O, class OtherXStringClass>
size_t rindexOfIC(const XStringAbstract<O, OtherXStringClass>& S, size_t Pos = MAX_XSIZE-1) const { return rindexOf(S.s(), Pos); }
template<typename O, class OtherXStringClass>
bool contains(const XStringAbstract<O, OtherXStringClass>& S) const { return indexOf(S) != MAX_XSIZE; }
template<typename O>
bool contains(const O* S) const { return indexOf(S) != MAX_XSIZE; }
template<typename O, class OtherXStringClass>
size_t containsIC(const XStringAbstract<O, OtherXStringClass>& S) const { return indexOfIC(S) != MAX_XSIZE; }
template<typename O>
size_t containsIC(const O* S) const { return indexOfIC(S) != MAX_XSIZE; }
//---------------------------------------------------------------------
ThisXStringClass subString(size_t pos, size_t count) const
{
if ( pos > length() ) return ThisXStringClass();
if ( count > length()-pos ) count = length()-pos;
ThisXStringClass ret;
const T* src = m_data;
char32_t char32 = 1;
while ( char32 && pos > 0 ) {
src = get_char32_from_string(src, &char32);
pos -= 1;
};
ret.strncat(src, count);
return ret;
}
template<typename O, class OtherXStringClass>
bool startWith(const XStringAbstract<O, OtherXStringClass>& otherS) const { return XStringAbstract__startWith(m_data, otherS.m_data, false); }
template<typename O>
bool startWith(const O* other) const { return XStringAbstract__startWith(m_data, other, false); }
template<typename O, class OtherXStringClass>
bool startWithIC(const XStringAbstract<O, OtherXStringClass>& otherS) const { return XStringAbstract__startWith(m_data, otherS.m_data, true); }
template<typename O>
bool startWithIC(const O* other) const { return XStringAbstract__startWith(m_data, other, true); }
//--------------------------------------------------------------------- String modification
void lowerAscii()
{
@ -593,34 +603,6 @@ public:
// }
//}
ThisXStringClass subString(size_t pos, size_t count) const
{
if ( pos > length() ) return ThisXStringClass();
if ( count > length()-pos ) count = length()-pos;
ThisXStringClass ret;
const T* src = m_data;
char32_t char32 = 1;
while ( char32 && pos > 0 ) {
src = get_char32_from_string(src, &char32);
pos -= 1;
};
ret.strncat(src, count);
return ret;
}
// todo rename to contains
template<typename O, class OtherXStringClass>
bool contains(const XStringAbstract<O, OtherXStringClass>& S) const { return indexOf(S) != MAX_XSIZE; }
template<typename O>
bool contains(const O* S) const { return indexOf(S) != MAX_XSIZE; }
template<typename O, class OtherXStringClass>
size_t containsIC(const XStringAbstract<O, OtherXStringClass>& S) const { return indexOfIC(S) != MAX_XSIZE; }
template<typename O>
size_t containsIC(const O* S) const { return indexOfIC(S) != MAX_XSIZE; }
// void ToLower(bool FirstCharIsCap = false);
// bool IsLetters() const;
// bool IsLettersNoAccent() const;
@ -765,46 +747,6 @@ T XStringAbstract<T, ThisXStringClass>::nullChar = 0;
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//
//template<class T, class SubType, size_t growBy>
//void XStringAbstract<T>::RemoveLastEspCtrl()
//{
// T *p;
//
// if ( size() > 0 ) {
// p = s() + size() - 1;
// #if __WCHAR_MIN__ < 0
// if ( *p >= 0 && *p <= ' ' ) {
// #else
// if ( *p <= ' ' ) {
// #endif
// p -= 1;
// #if __WCHAR_MIN__ < 0
// while ( p>data() && *p >= 0 && *p <= ' ' ) p -= 1;
// #else
// while ( p>data() && *p <= ' ' ) p -= 1;
// #endif
// if ( p>data() ) {
// setSize( (size_t)(p-data())+1);
// }else{
// #if __WCHAR_MIN__ < 0
// if ( *p >= 0 && *p <= ' ' ) setSize(0);
// #else
// if ( *p <= ' ' ) setSize(0);
// #endif
// else setSize(1);
// }
// }
// }
//}
@ -814,10 +756,6 @@ T XStringAbstract<T, ThisXStringClass>::nullChar = 0;
#undef DBG_XSTRING
#undef asciiToLower
#undef unsigned_type
#undef is_integral
#undef is_char
#undef enable_if

View File

@ -9,131 +9,4 @@
const XStringArray NullXStringArray;
XStringArray::XStringArray() : XStringArraySuper()
{
}
//-------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------
void XStringArray::AddStrings(const wchar_t *Val1, ...)
{
va_list va;
const wchar_t *p;
{
XString* newS = new XString;
newS->takeValueFrom(Val1);
AddReference(newS, true);
}
va_start(va, Val1);
p = VA_ARG(va, const wchar_t *);
while ( p != nullptr ) {
XString* newS = new XString;
newS->takeValueFrom(Val1);
AddReference(newS, true);
p = VA_ARG(va, const wchar_t *);
}
va_end(va);
}
XString XStringArray::ConcatAll(const XString& Separator, const XString& Prefix, const XString& Suffix) const
{
xsize i;
XString s;
if ( size() > 0 ) {
s = Prefix;
s += ElementAt(0);
for ( i=1 ; i<size() ; i+=1 ) {
s += Separator;
s += ElementAt(i);
}
s += Suffix;
}
return s;
}
bool XStringArray::Equal(const XStringArray &aStrings) const
{
xsize ui;
if ( size() != aStrings.size() ) return false;
for ( ui=0 ; ui<size() ; ui+=1 ) {
if ( ElementAt(ui) != aStrings[ui] ) return false;
}
return true;
}
bool XStringArray::Same(const XStringArray &aStrings) const
{
xsize i;
for ( i=0 ; i<size() ; i+=1 ) {
if ( !aStrings.Contains(ElementAt(i)) ) return false;
}
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
if ( !Contains(aStrings.ElementAt(i)) ) return false;
}
return true;
}
bool XStringArray::Contains(const XString &S) const
{
xsize i;
for ( i=0 ; i<size() ; i+=1 ) {
if ( ElementAt(i) == S ) return true;
}
return false;
}
//-------------------------------------------------------------------------------------------------
// Add
//-------------------------------------------------------------------------------------------------
void XStringArray::Add(const XStringArray &aStrings)
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
AddCopy(aStrings[i]);
}
}
void XStringArray::AddID(const XString &aString)
{
if ( !Contains(aString) ) AddCopy(aString);
}
void XStringArray::AddID(const XStringArray &aStrings)
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
if ( !Contains(aStrings[i]) ) AddCopy(aStrings[i]);
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Divers
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
XStringArray Split(const XString &S, const XString &Separator)
{
XStringArray Ss;
size_t idxB, idxE;
idxB = 0;
idxE = S.indexOf(Separator, idxB);
while ( idxE != MAX_XSIZE ) {
Ss.AddCopy(S.subString(idxB, idxE-idxB));
idxB = idxE + Separator.length();
idxE = S.indexOf(Separator, idxB);
}
if ( idxB < S.length() ) Ss.AddCopy(S.subString(idxB, S.length()-idxB));
return Ss;
}
const XStringWArray NullXStringWArray;

View File

@ -10,45 +10,260 @@
#define __XSTRINGARRAY_H__
#include <XToolsConf.h>
#include "XStringWArray.h"
#include "XToolsCommon.h"
#include "XObjArray.h"
#include "XString.h"
#define XStringArraySuper XObjArray<XString>
class XStringArray : public XStringArraySuper
#define XStringArraySuper XObjArray<XStringClass>
template<class XStringClass_>
class XStringArray_/* : public XStringArraySuper*/
{
protected:
XObjArray<XStringClass_> array;
public:
typedef XStringClass_ XStringClass;
XStringArray();
XStringArray_() {};
size_t size() const { return array.size(); }
void setEmpty() { array.Empty(); }
bool isEmpty() const { return this->size() == 0 ; }
bool notEmpty() const { return this->size() > 0 ; }
// #define enable_if XStringAbstract__enable_if_t
/* [] */
template<typename IntegralType, enable_if(is_integral(IntegralType))>
const XStringClass& operator [](IntegralType i) const { return array[i]; }
void SetNull() { Empty(); }
bool IsNull() const { return size() == 0 ; }
bool NotNull() const { return size() > 0 ; }
XStringClass ConcatAll(const XStringClass& Separator = ", "_XS, const XStringClass& Prefix = NullXString, const XStringClass& Suffix = NullXString) const
{
xsize i;
XString s;
XString ConcatAll(const XString& Separator = ", "_XS, const XString& Prefix = NullXString, const XString& Suffix = NullXString) const;
if ( array.size() > 0 ) {
s = Prefix;
s += array.ElementAt(0);
for ( i=1 ; i<array.size() ; i+=1 ) {
s += Separator;
s += array.ElementAt(i);
}
s += Suffix;
}
return s;
}
bool Equal(const XStringArray &aStrings) const;
bool operator ==(const XStringArray &aXStrings) const { return Equal(aXStrings); }
bool operator !=(const XStringArray& aXStrings) const { return !Equal(aXStrings); }
bool Contains(const XString &S) const;
bool Same(const XStringArray &aStrings) const;
template<class OtherXStringArrayClass>
bool Equal(const OtherXStringArrayClass &aStrings) const
{
xsize ui;
if ( array.size() != aStrings.size() ) return false;
for ( ui=0 ; ui<array.size() ; ui+=1 ) {
if ( array.ElementAt(ui) != aStrings[ui] ) return false;
}
return true;
}
template<class OtherXStringArrayClass>
bool operator ==(const OtherXStringArrayClass &aXStrings) const { return Equal(aXStrings); }
template<class OtherXStringArrayClass>
bool operator !=(const OtherXStringArrayClass& aXStrings) const { return !Equal(aXStrings); }
template<class OtherXStringClass>
bool contains(const OtherXStringClass &S) const
{
xsize i;
for ( i=0 ; i<array.size() ; i+=1 ) {
if ( array.ElementAt(i) == S ) return true;
}
return false;
}
template<class OtherXStringClass>
bool containsIC(const OtherXStringClass &S) const
{
xsize i;
for ( i=0 ; i<XStringArraySuper::size() ; i+=1 ) {
if ( this->ElementAt(i).EqualIC(S) ) return true;
}
return false;
}
template<class OtherXStringClass>
bool ContainsStartWithIC(const OtherXStringClass &S) const
{
xsize i;
for ( i=0 ; i<XStringArraySuper::size() ; i+=1 ) {
if ( this->ElementAt(i).startWith(S) ) return true;
}
return false;
}
template<class OtherXStringArrayClass>
bool Same(const OtherXStringArrayClass &aStrings) const
{
xsize i;
for ( i=0 ; i<this->size() ; i+=1 ) {
if ( !aStrings.contains(array.ElementAt(i)) ) return false;
}
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
if ( !contains(aStrings[i]) ) return false;
}
return true;
}
// Add
void AddStrings(const wchar_t *Val1, ...);
template<typename CharType>
void AddStrings(const CharType* Val1, ...)
{
va_list va;
const wchar_t *p;
void AddNoNull(const XString &aString) { if ( !aString.isEmpty() ) AddCopy(aString); }
void AddEvenNull(const XString &aString) { AddCopy(aString); }
{
XStringClass* newS = new XStringClass;
newS->takeValueFrom(Val1);
XStringArraySuper::AddReference(newS, true);
}
va_start(va, Val1);
p = VA_ARG(va, const CharType*);
while ( p != nullptr ) {
XStringClass* newS = new XStringClass;
newS->takeValueFrom(Val1);
XStringArraySuper::AddReference(newS, true);
p = VA_ARG(va, const CharType*);
}
va_end(va);
}
void Add(const XString &aString) { AddCopy(aString); }
void Add(const XStringArray &aStrings);
void AddNoNull(const XStringClass &aString) { if ( !aString.isEmpty() ) array.AddCopy(aString); }
void AddEvenNull(const XStringClass &aString) { array.AddCopy(aString); }
void Add(const XStringClass &aString) { array.AddCopy(aString); }
void AddReference(XStringClass *newElement, bool FreeIt) { array.AddReference(newElement, FreeIt); }
template<class OtherXStringClass>
void Add(const XStringArray_<OtherXStringClass> &aStrings)
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
AddCopy(aStrings[i]);
}
}
void AddID(const XStringClass &aString) /* ignore Duplicate */
{
if ( !contains(aString) ) array.AddCopy(aString);
}
void AddID(const XStringArray_ &aStrings) /* ignore Duplicate */
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
if ( !Contains(aStrings[i]) ) AddCopy(aStrings[i]);
}
}
void remove(const XStringClass &aString)
{
if ( array.size() > 0 )
{
size_t i = array.size();
do {
i--;
if ( array[i] == aString ) {
array.RemoveAtIndex(i);
break;
}
} while ( i > 0 );
}
}
void removeIC(const XStringClass &aString)
{
if ( array.size() > 0 )
{
size_t i = array.size();
do {
i--;
if ( array[i].equalIC(aString) ) {
array.RemoveAtIndex(i);
break;
}
} while ( i > 0 );
}
}
void AddID(const XString &aString); /* ignore Duplicate */
void AddID(const XStringArray &aStrings); /* ignore Duplicate */
};
class XStringArray : public XStringArray_<XString>
{
};
extern const XStringArray NullXStringArray;
XStringArray Split(const XString &S, const XString &Separator = ", "_XS);
class XString16Array : public XStringArray_<XString16>
{
};
extern const XString16Array NullXString16Array;
class XString32Array : public XStringArray_<XString32>
{
};
extern const XString32Array NullXString32Array;
class XStringWArray : public XStringArray_<XStringW>
{
};
extern const XStringWArray NullXStringWArray;
//
//template<class XStringArrayClass, class XStringClass1, enable_if(!is_char(XStringClass1) && !is_char_ptr(XStringClass1))>
//XStringArrayClass Split(const XStringClass1& S)
//{
// return Split<XStringArrayClass>(S, ", "_XS);
//};
template<class XStringArrayClass, class XStringClass1, class XStringClass2, enable_if(!is_char(XStringClass1) && !is_char_ptr(XStringClass1) && !is_char(XStringClass2))>
XStringArrayClass Split(const XStringClass1& S, const XStringClass2& Separator)
{
XStringArrayClass Ss;
size_t idxB, idxE;
idxB = 0;
idxE = S.indexOf(Separator, idxB);
while ( idxE != MAX_XSIZE ) {
Ss.Add(S.subString(idxB, idxE-idxB));
idxB = idxE + Separator.length();
idxE = S.indexOf(Separator, idxB);
}
if ( idxB < S.length() ) Ss.Add(S.subString(idxB, S.length()-idxB));
return Ss;
};
template<class XStringArrayClass, class XStringClass1, enable_if(!is_char(XStringClass1) && !is_char_ptr(XStringClass1))>
XStringArrayClass Split(const XStringClass1& S)
{
return Split<XStringArrayClass>(S, ", "_XS);
};
template<class XStringArrayClass, typename CharType1, typename CharType2, enable_if(is_char(CharType1) && is_char(CharType2))>
XStringArrayClass Split(const CharType1* S, const CharType2* Separator)
{
// TODO : Allocating temporary strings could be avoided by using low level function from unicode_conversions
typename XStringArrayClass::XStringClass SS;
SS.takeValueFrom(S);
typename XStringArrayClass::XStringClass XSeparator;
SS.takeValueFrom(Separator);
return Split<XStringArrayClass>(SS, XSeparator);
};
#endif

View File

@ -1,145 +0,0 @@
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//
// STRINGS
//
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#if !defined(__XSTRINGWS_CPP__)
#define __XSTRINGWS_CPP__
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "XStringWArray.h"
const XStringWArray NullXStrings;
XStringWArray::XStringWArray() : XStringWArraySuper()
{
}
//-------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------
void XStringWArray::AddStrings(const wchar_t *Val1, ...)
{
va_list va;
const wchar_t *p;
{
XStringW* newS = new XStringW;
newS->takeValueFrom(Val1);
AddReference(newS, true);
}
va_start(va, Val1);
p = VA_ARG(va, const wchar_t *);
while ( p != nullptr ) {
XStringW* newS = new XStringW;
newS->takeValueFrom(Val1);
AddReference(newS, true);
p = VA_ARG(va, const wchar_t *);
}
va_end(va);
}
XStringW XStringWArray::ConcatAll(const XStringW& Separator, const XStringW& Prefix, const XStringW& Suffix) const
{
xsize i;
XStringW s;
if ( size() > 0 ) {
s = Prefix;
s += ElementAt(0);
for ( i=1 ; i<size() ; i+=1 ) {
s += Separator;
s += ElementAt(i);
}
s += Suffix;
}
return s;
}
bool XStringWArray::Equal(const XStringWArray &aStrings) const
{
xsize ui;
if ( size() != aStrings.size() ) return false;
for ( ui=0 ; ui<size() ; ui+=1 ) {
if ( ElementAt(ui) != aStrings[ui] ) return false;
}
return true;
}
bool XStringWArray::Same(const XStringWArray &aStrings) const
{
xsize i;
for ( i=0 ; i<size() ; i+=1 ) {
if ( !aStrings.Contains(ElementAt(i)) ) return false;
}
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
if ( !Contains(aStrings.ElementAt(i)) ) return false;
}
return true;
}
bool XStringWArray::Contains(const XStringW &S) const
{
xsize i;
for ( i=0 ; i<size() ; i+=1 ) {
if ( ElementAt(i) == S ) return true;
}
return false;
}
//-------------------------------------------------------------------------------------------------
// Add
//-------------------------------------------------------------------------------------------------
void XStringWArray::Add(const XStringWArray &aStrings)
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
AddCopy(aStrings[i]);
}
}
void XStringWArray::AddID(const XStringW &aString)
{
if ( !Contains(aString) ) AddCopy(aString);
}
void XStringWArray::AddID(const XStringWArray &aStrings)
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
if ( !Contains(aStrings[i]) ) AddCopy(aStrings[i]);
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Divers
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
XStringWArray Split(const XStringW &S, const XStringW &Separator)
{
XStringWArray Ss;
xsize idxB, idxE;
idxB = 0;
idxE = S.indexOf(Separator, idxB);
while ( idxE != MAX_XSIZE ) {
Ss.AddCopy(S.subString(idxB, idxE-idxB));
idxB = idxE + Separator.length();
idxE = S.indexOf(Separator, idxB);
}
if ( idxB < S.length() ) Ss.AddCopy(S.subString(idxB, S.length()-idxB));
return Ss;
}
#endif

View File

@ -1,54 +0,0 @@
//*************************************************************************************************
//*************************************************************************************************
//
// STRINGS
//
//*************************************************************************************************
//*************************************************************************************************
#if !defined(__XSTRINGWARRAY_H__)
#define __XSTRINGWARRAY_H__
#include <XToolsConf.h>
#include "XObjArray.h"
#include "XString.h"
#define XStringWArraySuper XObjArray<XStringW>
class XStringWArray : public XStringWArraySuper
{
public:
XStringWArray();
void SetNull() { Empty(); }
bool IsNull() const { return size() == 0 ; }
bool NotNull() const { return size() > 0 ; }
XStringW ConcatAll(const XStringW& Separator = L", "_XSW, const XStringW& Prefix = NullXStringW, const XStringW& Suffix = NullXStringW) const;
bool Equal(const XStringWArray &aStrings) const;
bool operator ==(const XStringWArray &aXStrings) const { return Equal(aXStrings); }
bool operator !=(const XStringWArray& aXStrings) const { return !Equal(aXStrings); }
bool Contains(const XStringW &S) const;
bool Same(const XStringWArray &aStrings) const;
// Add
void AddStrings(const wchar_t *Val1, ...);
void AddNoNull(const XStringW &aString) { if ( !aString.isEmpty() ) AddCopy(aString); }
void AddEvenNull(const XStringW &aString) { AddCopy(aString); }
void Add(const XStringW &aString) { AddCopy(aString); }
void Add(const XStringWArray &aStrings);
void AddID(const XStringW &aString); /* ignore Duplicate */
void AddID(const XStringWArray &aStrings); /* ignore Duplicate */
};
extern const XStringWArray NullXStringws;
XStringWArray Split(const XStringW &S, const XStringW &Separator = L", "_XSW);
#endif

View File

@ -0,0 +1,137 @@
//
// XToolsCommon.h
// cpp_tests
//
// Created by jief on 25.04.20.
// Copyright © 2020 JF Knudsen. All rights reserved.
//
#ifndef XToolsCommon_h
#define XToolsCommon_h
struct XStringAbstract__false_type {
static constexpr bool value = false;
bool v() const { return false; }
};
struct XStringAbstract__true_type {
static constexpr bool value = true;
bool v() const { return true; }
};
/* make unsigned */
template <class _Tp>
struct XStringAbstract__make_unsigned {};
template <> struct XStringAbstract__make_unsigned< char> {typedef unsigned char type;};
template <> struct XStringAbstract__make_unsigned< signed char> {typedef unsigned char type;};
template <> struct XStringAbstract__make_unsigned<unsigned char> {typedef unsigned char type;};
template <> struct XStringAbstract__make_unsigned< char16_t> {typedef char16_t type;};
template <> struct XStringAbstract__make_unsigned< char32_t> {typedef char32_t type;};
template <> struct XStringAbstract__make_unsigned< wchar_t> {typedef wchar_t type;};
template <> struct XStringAbstract__make_unsigned< signed short> {typedef unsigned short type;};
template <> struct XStringAbstract__make_unsigned<unsigned short> {typedef unsigned short type;};
template <> struct XStringAbstract__make_unsigned< signed int> {typedef unsigned int type;};
template <> struct XStringAbstract__make_unsigned<unsigned int> {typedef unsigned int type;};
template <> struct XStringAbstract__make_unsigned< signed long> {typedef unsigned long type;};
template <> struct XStringAbstract__make_unsigned<unsigned long> {typedef unsigned long type;};
template <> struct XStringAbstract__make_unsigned< signed long long> {typedef unsigned long long type;};
template <> struct XStringAbstract__make_unsigned<unsigned long long> {typedef unsigned long long type;};
#define unsigned_type(x) typename XStringAbstract__make_unsigned<x>::type
/* enable_if */
template <bool, typename T = void>
struct XStringAbstract__enable_if_t
{};
template <typename T>
struct XStringAbstract__enable_if_t<true, T> {
typedef T type;
};
//#define enable_if(x) XStringAbstract__enable_if_t(x, void)::type
#define enable_if(x) typename enable_if_type = typename XStringAbstract__enable_if_t<x>::type
//
//template< bool B, class T = void >
//using XStringAbstract__enable_if_t = typename XStringAbstract__enable_if<B,T>::type;
// is_integral
template <class _Tp> struct XStringAbstract__is_integral_st : public XStringAbstract__false_type {};
template <> struct XStringAbstract__is_integral_st<bool> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<signed char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<wchar_t> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<short> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned short> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<int> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned int> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<long> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned long> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<long long> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_integral_st<unsigned long long> : public XStringAbstract__true_type {};
#define is_integral(x) XStringAbstract__is_integral_st<x>::value
// is_char
template <class _Tp> struct XStringAbstract__is_char_st : public XStringAbstract__false_type {};
template <> struct XStringAbstract__is_char_st<char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<signed char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<unsigned char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<char16_t> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<char32_t> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_st<wchar_t> : public XStringAbstract__true_type {};
#define is_char(x) XStringAbstract__is_char_st<x>::value
//
//// STRUCT TEMPLATE remove_reference
//template<class _Ty>
// struct remove_ref
// { // remove reference
// using type = _Ty;
// };
//
//template<class _Ty>
// struct remove_ref<_Ty&>
// { // remove reference
// using type = _Ty;
// };
// STRUCT TEMPLATE remove_const
template<class _Ty>
struct remove_const
{ // remove const
using type = _Ty;
};
template<class _Ty>
struct remove_const<const _Ty>
{ // remove const
using type = _Ty;
};
// is_char_ptr
template <class _Tp> struct XStringAbstract__is_char_ptr_st : public XStringAbstract__false_type {};
template <> struct XStringAbstract__is_char_ptr_st<char*> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_ptr_st<char[]> : public XStringAbstract__true_type {};
template <size_t _Np> struct XStringAbstract__is_char_ptr_st<char[_Np]> : public XStringAbstract__true_type {};
//template <> struct XStringAbstract__is_char_ptr_st<signed char> : public XStringAbstract__true_type {};
//template <> struct XStringAbstract__is_char_ptr_st<unsigned char> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_ptr_st<char16_t*> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_ptr_st<char16_t[]> : public XStringAbstract__true_type {};
template <size_t _Np> struct XStringAbstract__is_char_ptr_st<char16_t[_Np]> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_ptr_st<char32_t*> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_ptr_st<char32_t[]> : public XStringAbstract__true_type {};
template <size_t _Np> struct XStringAbstract__is_char_ptr_st<char32_t[_Np]> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_ptr_st<wchar_t*> : public XStringAbstract__true_type {};
template <> struct XStringAbstract__is_char_ptr_st<wchar_t[]> : public XStringAbstract__true_type {};
template <size_t _Np> struct XStringAbstract__is_char_ptr_st<wchar_t[_Np]> : public XStringAbstract__true_type {};
#define is_char_ptr(x) XStringAbstract__is_char_ptr_st<typename remove_const<x>::type>::value
#endif /* XToolsCommon_h */

View File

@ -269,22 +269,6 @@ const char* get_char32_from_utf8_string(const char* s, char32_t* char32)
return s;
}
/*
* get nth char32 of an utf8 string
* Return value : pointer to the end of string or at the error
*/
char32_t get_char32_from_utf8_string_at_pos(const char* s, size_t pos)
{
if ( !s ) return 0;
char32_t char32;
s = get_char32_from_utf8_string(s, &char32);
while ( char32 && pos > 0 ) {
s = get_char32_from_utf8_string(s, &char32);
pos--;
}
return char32;
}
/************************************************************* utf8 - char32 *********************************************************/
@ -412,6 +396,22 @@ size_t utf8_string_from_utf32_string_len(char* dst, size_t dst_max_size, const c
return (size_t)(p-dst);
}
/*
* get nth char32 of an utf8 string
* Return value : pointer to the end of string or at the error
*/
char32_t get_char32_from_utf8_string_at_pos(const char* s, size_t pos)
{
if ( !s ) return 0;
char32_t char32;
s = get_char32_from_utf8_string(s, &char32);
while ( char32 && pos > 0 ) {
s = get_char32_from_utf8_string(s, &char32);
pos--;
}
return char32;
}
/************************************************************* utf8 - char16 *********************************************************/
@ -761,6 +761,22 @@ size_t utf32_string_from_utf16_string_len(char32_t* dst, size_t dst_max_size, co
}
/*
* get nth char32 of an utf16 string
* Return value : pointer to the end of string or at the error
*/
char32_t get_char32_from_utf16_string_at_pos(const char16_t* s, size_t pos)
{
if ( !s ) return 0;
char32_t char32;
s = get_char32_from_utf16_string(s, &char32);
while ( char32 && pos > 0 ) {
s = get_char32_from_utf16_string(s, &char32);
pos--;
}
return char32;
}
/************************************************************* utf8 - wchar_t *********************************************************/
@ -972,6 +988,19 @@ size_t wchar_string_from_utf32_string(wchar_t* dst, size_t dst_max_size, const c
/*
* get nth char32 of an utf16 string
* Return value : pointer to the end of string or at the error
*/
char32_t get_char32_from_wchar_string_at_pos(const char16_t* s, size_t pos)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return get_char32_from_utf16_string_at_pos((char16_t*)s, pos);
#else
return get_char32_from_utf32_string_at_pos((char32_t*)s, pos);
#endif
}
@ -1194,6 +1223,20 @@ size_t wchar_string_from_wchar_string_len(wchar_t* dst, size_t dst_max_size, con
}
/*
* get nth char32 of an utf32 string
* Return value : pointer to the end of string or at the error
*/
char32_t get_char32_from_utf32_string_at_pos(const char32_t* s, size_t pos)
{
if ( !s ) return 0;
while ( *s && pos > 0 ) {
s++;
pos--;
}
return *s;
}
/****** convenience *****/
size_t length_of_wchar_string(const wchar_t* s)

View File

@ -108,6 +108,8 @@ size_t utf32_string_from_utf8_string_len(char32_t* dst, size_t dst_max_size, con
size_t utf8_string_from_utf32_string(char* dst, size_t dst_max_size, const char32_t *s);
size_t utf8_string_from_utf32_string_len(char* dst, size_t dst_max_size, const char32_t *s, size_t len);
char32_t get_char32_from_utf8_string_at_pos(const char* s, size_t pos);
/****** utf8 - utf16 *****/
@ -148,6 +150,13 @@ size_t utf32_string_from_utf16_string(char32_t* dst, size_t dst_max_size, const
size_t utf32_string_from_utf16_string_len(char32_t* dst, size_t dst_max_size, const char16_t *s, size_t len);
/*
* get nth char32 of an utf16 string
* Return value : pointer to the end of string or at the error
*/
char32_t get_char32_from_utf16_string_at_pos(const char16_t* s, size_t pos);
/****** utf8 - wchar_t *****/
size_t utf8_size_of_wchar_string(const wchar_t* s);
@ -184,6 +193,8 @@ size_t utf32_string_from_wchar_string_len(char32_t* dst, size_t dst_max_size, co
size_t wchar_string_from_utf32_string(wchar_t* dst, size_t dst_max_size, const char32_t* s);
size_t wchar_string_from_utf32_string_len(wchar_t* dst, size_t dst_max_size, const char32_t* s, size_t len);
char32_t get_char32_from_wchar_string_at_pos(const char16_t* s, size_t pos);
/****** no conversion *****/
@ -205,6 +216,8 @@ size_t utf32_string_from_utf32_string_len(char32_t* dst, size_t dst_max_size, c
size_t wchar_string_from_wchar_string(wchar_t* dst, size_t dst_max_size, const wchar_t *s);
size_t wchar_string_from_wchar_string_len(wchar_t* dst, size_t dst_max_size, const wchar_t *s, size_t len);
char32_t get_char32_from_utf32_string_at_pos(const char32_t* s, size_t pos);
/****** convenience *****/
inline size_t length_of_utf8_string(const char* s) {return utf32_size_of_utf8_string(s); }
@ -220,6 +233,13 @@ inline const char16_t* get_char32_from_string(const char16_t* s, char32_t* char3
inline const char32_t* get_char32_from_string(const char32_t* s, char32_t* char32) { *char32 = *s; return s+1; }
inline const wchar_t* get_char32_from_string(const wchar_t* s, char32_t* char32) { return (wchar_t*)get_char32_from_string((wchar_cast*)s, char32); }
inline char32_t get_char32_from_utf_string_at_pos(const char* s, size_t pos) { return get_char32_from_utf8_string_at_pos(s, pos); }
inline char32_t get_char32_from_utf_string_at_pos(const char16_t* s, size_t pos) { return get_char32_from_utf16_string_at_pos(s, pos); }
inline char32_t get_char32_from_utf_string_at_pos(const char32_t* s, size_t pos) { return get_char32_from_utf32_string_at_pos(s, pos); }
inline char32_t get_char32_from_utf_string_at_pos(const wchar_t* s, size_t pos) { return get_char32_from_utf_string_at_pos((wchar_cast*)s, pos); }
inline char* store_utf_from_char32(char* dst, size_t* dst_max_size, char32_t utf32_char) { return get_utf8_from_char32(dst, dst_max_size, utf32_char); }
inline char16_t* store_utf_from_char32(char16_t* dst, size_t* dst_max_size, char32_t utf32_char) { return get_utf16_from_char32(dst, dst_max_size, utf32_char); }
inline char32_t* store_utf_from_char32(char32_t* dst, size_t* dst_max_size, char32_t utf32_char) { return get_utf32_from_char32(dst, dst_max_size, utf32_char); }

View File

@ -85,21 +85,22 @@ CHAR16 *Old1_RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *Loa
//
//static XString AddLoadOption(IN CONST XString& LoadOptions, IN CONST XString& LoadOption)
//{
// // LoadOptions assumed out
// // If either option strings are null nothing to do
// if (LoadOptions.isEmpty())
// if (LoadOptions.isEmpty()) //initially empty so return new option even if empty
// {
// // return LoadOption as nothing to add
// // return LoadOption
// return LoadOption;
// }
// // If there is no option or it is already present duplicate original
// else {
// if ( LoadOptions.contains(LoadOption) ) return LoadOptions;
// if ( LoadOptions.contains(LoadOption) ) return LoadOptions; //good
// // Otherwise add option
// return SPrintf("%s %s", LoadOptions.c_str(), LoadOption.c_str()); //LoadOptions + LoadOption
//// return SPrintf("%s %s", LoadOptions.c_str(), LoadOption.c_str()); //LoadOptions + LoadOption
// return LoadOptions + " "_XS + LoadOption; //why not?
// }
//}
//
@ -146,25 +147,22 @@ CHAR16 *Old1_RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *Loa
// XString NewLoadOptions;
// if (Offset == 0) {
// // Simple case - we just need substring after OptionLength position
// NewLoadOptions = LoadOptions.SubString(OptionLength, MAX_XSIZE);
// NewLoadOptions = LoadOptions.subString(OptionLength, MAX_XSIZE);
// } else {
// // Copy preceeding substring
// NewLoadOptions = LoadOptions.SubString(0, Offset);
// NewLoadOptions = LoadOptions.subString(0, Offset);
//// CopyMem(NewLoadOptions, LoadOptions, Offset * sizeof(CHAR16));
// if ((Offset + OptionLength) < Length) {
// // Copy following substring, but include one space also
// OptionLength--;
// NewLoadOptions += LoadOptions.SubString(Offset + OptionLength, MAX_XSIZE);
// NewLoadOptions += LoadOptions.subString(Offset + OptionLength, MAX_XSIZE);
//// CopyMem(NewLoadOptions + Offset, LoadOptions + Offset + OptionLength, (Length - OptionLength - Offset) * sizeof(CHAR16));
// }
// }
// return NewLoadOptions;
//}
//
//
@ -201,14 +199,14 @@ int BootOptions_tests()
// LoadOptions = AddLoadOption(LoadOptions, "opt2"_XS);
// LoadOptions = AddLoadOption(LoadOptions, "opt3"_XS);
//
// if ( LoadOptions != "opt1 opt2 opt3"_XS ) return 1;
// if ( LoadOptions != "opt1 opt2 opt3"_XS ) return 10;
//
// XString LoadOptions1 = RemoveLoadOption(LoadOptions, "opt1"_XS);
// if ( LoadOptions1 != "opt2 opt3"_XS ) return 1;
// if ( LoadOptions1 != "opt2 opt3"_XS ) return 11;
// XString LoadOptions2 = RemoveLoadOption(LoadOptions, "opt2"_XS);
// if ( LoadOptions2 != "opt1 opt3"_XS ) return 1;
// if ( LoadOptions2 != "opt1 opt3"_XS ) return 12;
// XString LoadOptions3 = RemoveLoadOption(LoadOptions, "opt3"_XS);
// if ( LoadOptions3 != "opt1 opt2"_XS ) return 1;
// if ( LoadOptions3 != "opt1 opt2"_XS ) return 13;
// }
{
XStringArray LoadOptions;
@ -220,13 +218,13 @@ int BootOptions_tests()
if ( LoadOptions.ConcatAll(" "_XS) != "opt1 opt2 opt3"_XS ) return 30;
XStringArray LoadOptions1 = LoadOptions;
LoadOptions1.Remove("opt1"_XS);
LoadOptions1.remove("opt1"_XS);
if ( LoadOptions1.ConcatAll(" "_XS) != "opt2 opt3"_XS ) return 31;
XStringArray LoadOptions2 = LoadOptions;
LoadOptions2.Remove("opt2"_XS);
LoadOptions2.remove("opt2"_XS);
if ( LoadOptions2.ConcatAll(" "_XS) != "opt1 opt3"_XS ) return 32;
XStringArray LoadOptions3 = LoadOptions;
LoadOptions3.Remove("opt3"_XS);
LoadOptions3.remove("opt3"_XS);
if ( LoadOptions3.ConcatAll(" "_XS) != "opt1 opt2"_XS ) return 33;
}

View File

@ -1,7 +1,7 @@
#include <Platform.h>
#include "../cpp_foundation/XStringWArray.h"
#include "../cpp_foundation/XStringArray.h"
int XStringWArray_tests()
int XStringArray_tests()
{
#ifdef JIEF_DEBUG
@ -10,16 +10,16 @@ int XStringWArray_tests()
XStringWArray array1;
if ( !array1.IsNull() ) return 1;
if ( !array1.isEmpty() ) return 1;
array1.Add(L"1"_XSW);
if ( array1.IsNull() ) return 2;
if ( array1.isEmpty() ) return 2;
array1.Add(L"2"_XSW);
if ( array1[0] != L"1"_XSW ) return 3;
if ( array1[1] != L"2"_XSW ) return 4;
if ( !array1.Contains(L"2"_XSW) ) return 5;
if ( !array1.contains(L"2"_XSW) ) return 5;
// Test == and !=
{
@ -39,8 +39,16 @@ int XStringWArray_tests()
// Split doesn't handle prefix and suffix yet.
c = array1.ConcatAll(L", "_XSW);
XStringWArray array1bis = Split(c);
XStringWArray array1bis = Split<XStringWArray>(c);
if ( array1 != array1bis ) return 20;
XStringWArray array2bis = Split<XStringWArray>(c);
if ( array1 != array2bis ) return 20;
XStringArray array3bis = Split<XStringArray>(c);
if ( array1 != array3bis ) return 20;
char* c2;// = "a, b, c";
XStringArray array4 = Split<XStringArray>(c2, " ");
}
XStringWArray array2;

View File

@ -0,0 +1,2 @@
int XStringArray_tests();

View File

@ -1,2 +0,0 @@
int XStringWArray_tests();

View File

@ -163,6 +163,8 @@ struct TestString : public AbstractTestString
const CharType* cha;
TestString(size_t _size, const CharType* _cha, size_t _utf32_length, const char32_t* _utf32) : AbstractTestString(_size, _utf32_length, _utf32), cha(_cha) {
}
size_t getSizeInBytes() const { return size*sizeof(CharType); }
size_t getSizeInBytesIncludingTerminator() const { return (size+1)*sizeof(CharType); }
};
@ -484,98 +486,106 @@ SimpleString testDefaultCtor_()
testDefaultCtor_<XStringClass>();
/***************************** takeValueFrom(char type) *****************************/
/***************************** Assignement : ctor, strcpy, takeValueFrom *****************************/
#define CHECK_XSTRING_EQUAL_TESTSTRING(xstr, expectedResult) \
/* We don't use XString::operator == to check xstr == xstr because operator == is not tested yet. */ \
CHECK_RESULT(xstr.sizeInBytes() == expectedResult.getSizeInBytes(), \
ssprintf("xstr.sizeInBytes() == expectedResult.getSizeInBytes() (%zu)", expectedResult.getSizeInBytes()), \
ssprintf("xstr.sizeInBytes() != expectedResult.getSizeInBytes() (%zu!=%zu)", xstr.sizeInBytes(), expectedResult.getSizeInBytes()) \
); \
CHECK_RESULT(memcmp(xstr.s(), expectedResult.cha, expectedResult.getSizeInBytesIncludingTerminator()) == 0, \
ssprintf("memcmp(xstr.s(), expectedResult.cha, expectedResult.getSizeInBytesIncludingTerminator()) == 0"), \
ssprintf("memcmp(xstr.s(), expectedResult.cha, expectedResult.getSizeInBytesIncludingTerminator()) != 0") \
); \
template<class XStringClass, class TestStringSrc, class TestStringExpectedResult>
SimpleString testTakeValueFrom_(const TestStringSrc& src, const TestStringExpectedResult& expectedResult)
{
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::testTakeValueFrom(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<TestStringSrc>::prefix, SimpleString(src.cha).c_str()));
XStringClass xstr;
xstr.takeValueFrom(src.cha);
typedef typename XStringClassInfo<XStringClass>::ch_t ch_t;
ch_t c; (void)c; // dummy for call utf function
size_t expectedSize = expectedResult.size*sizeof(expectedResult.cha[0]);
CHECK_RESULT(xstr.sizeInBytes() == expectedSize,
ssprintf("xstr.sizeInBytes() == expectedSize (%zu)", expectedSize),
ssprintf("xstr.sizeInBytes() != expectedSize (%zu!=%zu)", xstr.sizeInBytes(), expectedSize)
);
CHECK_RESULT(memcmp(xstr.s(), expectedResult.cha, expectedSize) == 0,
ssprintf("memcmp(xstr.s(), expectedResult.cha, expectedSize) == 0"),
ssprintf("memcmp(xstr.s(), expectedResult.cha, expectedSize) != 0")
);
// takeValueFrom(native char type)
{
XStringClass xstr;
xstr.takeValueFrom(src.cha);
CHECK_XSTRING_EQUAL_TESTSTRING(xstr, expectedResult);
}
// strcpy(native char type)
{
XStringClass xstr;
xstr.takeValueFrom("blabla");
xstr.strcpy(src.cha);
CHECK_XSTRING_EQUAL_TESTSTRING(xstr, expectedResult);
}
// strcpy one native char
{
if ( src.utf32_length > 0 )
{
XStringClass xstr;
for ( size_t pos = 0 ; pos < src.utf32_length - 1 ; pos++ )
{
char32_t char32 = get_char32_from_utf_string_at_pos(src.cha, pos);
xstr.takeValueFrom("foobar");
xstr.strcpy(char32);
//printf("%s\n", SimpleString(xstr.s()).c_str());
size_t expectedSize = utf_size_of_utf_string_len(&c, &char32, 1) * sizeof(c);
CHECK_RESULT(xstr.sizeInBytes() == expectedSize,
ssprintf("xstr.sizeInBytes() == expectedSize (%zu)", expectedSize),
ssprintf("xstr.sizeInBytes() != expectedSize (%zu!=%zu)", xstr.sizeInBytes(), expectedSize)
);
ch_t buf[8];
utf_string_from_utf_string_len(buf, sizeof(buf)/sizeof(buf[0]), &char32, 1);
size_t expectedSizeIncludingTerminator = expectedSize+sizeof(buf[0]);
CHECK_RESULT(memcmp(xstr.s(), buf, expectedSizeIncludingTerminator) == 0, // +1 char
ssprintf("memcmp(xstr.s(), buf, expectedSizeIncludingTerminator) == 0"),
ssprintf("memcmp(xstr.s(), buf, expectedSizeIncludingTerminator) != 0")
);
//xstr.takeValueFrom("foobar");
//xstr.strcpy(src.cha[0]);
}
}
}
typename XStringClassInfo<TestStringSrc>::xs_t srcXString;
srcXString.takeValueFrom(src.cha);
// takeValueFrom(XString)
{
XStringClass xstr;
xstr.takeValueFrom(srcXString);
CHECK_XSTRING_EQUAL_TESTSTRING(xstr, expectedResult);
}
// ctor XString
{
XStringClass xstr(srcXString);
CHECK_XSTRING_EQUAL_TESTSTRING(xstr, expectedResult);
}
// = XString
{
XStringClass xstr;
xstr = srcXString;
CHECK_XSTRING_EQUAL_TESTSTRING(xstr, expectedResult);
}
// TODO test ctor with litteral
// XStringClass xstr2;
// xstr2 = src.cha;
// XStringClass xstr;
// xstr = src.cha;
return SimpleString();
}
#define testTakeValueFrom(XStringClass, classEncoding, encoding1) \
printf("Test %s::testTakeValueFrom(%s)\n", STRINGIFY(XStringClass), STRINGIFY(encoding1)); \
printf("Test %s::testTakeValueFrom, strcpy(%s)\n", STRINGIFY(XStringClass), STRINGIFY(encoding1)); \
for ( size_t i = 0 ; i < nbTestStringMultiCoded ; i++ ) { \
testTakeValueFrom_<XStringClass>(testStringMultiCodedArray[i].encoding1, testStringMultiCodedArray[i].classEncoding); \
} \
/***************************** takeValueFrom(XString), ctor(XString), operator =(XString) *****************************/
template<class XStringClass, class TestStringSrc, class TestStringExpectedResult>
SimpleString testTakeValueFromXString_(const TestStringSrc& src, const TestStringExpectedResult& expectedResult)
{
// TODO test ctor with litteral
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::testTakeValueFrom(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<TestStringSrc>::prefix, SimpleString(src.cha).c_str()));
typename XStringClassInfo<TestStringSrc>::xs_t srcXString;
srcXString.takeValueFrom(src.cha);
XStringClass xstr;
xstr.takeValueFrom(srcXString);
size_t expectedSize = expectedResult.size*sizeof(expectedResult.cha[0]);
CHECK_RESULT(xstr.sizeInBytes() == expectedSize,
ssprintf("xstr.sizeInBytes() == expectedSize (%zu)", expectedSize),
ssprintf("xstr.sizeInBytes() != expectedSize (%zu!=%zu)", xstr.sizeInBytes(), expectedSize)
);
CHECK_RESULT(memcmp(xstr.s(), expectedResult.cha, expectedSize+sizeof(expectedResult.cha[0])) == 0,
ssprintf("memcmp(xstr.s(), expectedResult.cha, expectedResult.size) == 0"),
ssprintf("memcmp(xstr.s(), expectedResult.cha, expectedResult.size) != 0")
);
{
XStringClass xstr2(srcXString);
// We don't use operator == to check xstr == xstr2 because operator == is not tested yet.
CHECK_RESULT(xstr2.sizeInBytes() == xstr.sizeInBytes(),
ssprintf("xstr2.sizeInBytes() == xstr.sizeInBytes() (%zu)", xstr.sizeInBytes()),
ssprintf("xstr2.sizeInBytes() != xstr.sizeInBytes() (%zu!=%zu)", xstr2.sizeInBytes(), xstr.sizeInBytes())
);
CHECK_RESULT(memcmp(xstr2.s(), xstr.s(), xstr.sizeInBytes()+sizeof(xstr.s()[0])) == 0,
ssprintf("memcmp(xstr2.s(), xstr.s(), xstr.sizeInBytes()) == 0"),
ssprintf("memcmp(xstr2.s(), xstr.s(), xstr.sizeInBytes()) != 0")
);
}
{
XStringClass xstr2;
xstr2 = srcXString;
// We don't use operator == to check xstr == xstr2 because operator == is not tested yet.
CHECK_RESULT(xstr2.sizeInBytes() == xstr.sizeInBytes(),
ssprintf("xstr2.sizeInBytes() == xstr.sizeInBytes() (%zu)", xstr.sizeInBytes()),
ssprintf("xstr2.sizeInBytes() != xstr.sizeInBytes() (%zu!=%zu)", xstr2.sizeInBytes(), xstr.sizeInBytes())
);
CHECK_RESULT(memcmp(xstr2.s(), xstr.s(), xstr.sizeInBytes()+sizeof(xstr.s()[0])) == 0,
ssprintf("memcmp(xstr2.s(), xstr.s(), xstr.sizeInBytes()) == 0"),
ssprintf("memcmp(xstr2.s(), xstr.s(), xstr.sizeInBytes()) != 0")
);
}
return SimpleString();
}
#define testTakeValueFromXString(XStringClass, classEncoding, encoding1) \
printf("Test %s::testTakeValueFromXString(%s)\n", STRINGIFY(XStringClass), STRINGIFY(encoding1)); \
for ( size_t i = 0 ; i < nbTestStringMultiCoded ; i++ ) { \
testTakeValueFromXString_<XStringClass>(testStringMultiCodedArray[i].encoding1, testStringMultiCodedArray[i].classEncoding); \
} \
/***************************** Default isEmpty, SetEmpty *****************************/
template<class XStringClass>
@ -663,36 +673,6 @@ SimpleString testdataSized_()
/***************************** strcpy *****************************/
template<class XStringClass, class TestStringSameAsClass, class TestStringSrc>
SimpleString teststrcpy_(const TestStringSameAsClass& encodedSameAsClass, const TestStringSrc& src)
{
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::strcpy(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<TestStringSrc>::prefix, SimpleString(src.cha).c_str()));
XStringClass xstr;
xstr.takeValueFrom("foobar");
xstr.strcpy(src.cha);
size_t expectedSize = encodedSameAsClass.size*sizeof(encodedSameAsClass.cha[0]);
CHECK_RESULT(xstr.sizeInBytes() == expectedSize,
ssprintf("xstr.sizeInBytes() == dst.size (%zu)", expectedSize),
ssprintf("xstr.sizeInBytes() != dst.size (%zu!=%zu)", xstr.sizeInBytes(), expectedSize)
);
CHECK_RESULT(memcmp(xstr.s(), encodedSameAsClass.cha, expectedSize+sizeof(encodedSameAsClass.cha[0])) == 0,
ssprintf("memcmp(xstr.s(), dst.cha, dst.size) == 0"),
ssprintf("memcmp(xstr.s(), dst.cha, dst.size) != 0")
);
return SimpleString();
}
#define teststrcpy(XStringClass, classEncoding, encoding1) \
printf("Test %s::teststrcpy(%s)\n", STRINGIFY(XStringClass), STRINGIFY(encoding1)); \
for ( size_t i = 0 ; i < nbTestStringMultiCoded ; i++ ) { \
teststrcpy_<XStringClass>(testStringMultiCodedArray[i].classEncoding, testStringMultiCodedArray[i].encoding1); \
} \
/***************************** strncpy *****************************/
template<class XStringClass, class TestStringSameAsClass, class TestStringSrc>
SimpleString teststrncpy_(const TestStringSameAsClass& encodedSameAsClass, const TestStringSrc& src)
@ -705,13 +685,15 @@ SimpleString teststrncpy_(const TestStringSameAsClass& encodedSameAsClass, const
xstr.takeValueFrom("foobar");
xstr.strncpy(src.cha, i);
CHECK_RESULT((length_of_utf_string(encodedSameAsClass.cha) >= i && xstr.length() == i) || (xstr.length() == length_of_utf_string(encodedSameAsClass.cha)),
ssprintf("xstr.sizeInBytes() == dst.size (%zu)", xstr.sizeInBytes()),
ssprintf("xstr.sizeInBytes() != dst.size (%zu!=%zu)", xstr.sizeInBytes(), encodedSameAsClass.size)
size_t expectedLength = length_of_utf_string(encodedSameAsClass.cha);
if ( expectedLength > i ) expectedLength = i;
CHECK_RESULT(xstr.length() == expectedLength,
ssprintf("xstr.length() == expectedLength (%zu)", expectedLength),
ssprintf("xstr.length() != expectedLength (%zu!=%zu)", xstr.length(), expectedLength)
);
CHECK_RESULT(memcmp(xstr.s(), encodedSameAsClass.cha, xstr.sizeInBytes()) == 0,
ssprintf("memcmp(xstr.s(), dst.cha, dst.size) == 0"),
ssprintf("memcmp(xstr.s(), dst.cha, dst.size) != 0")
CHECK_RESULT(memcmp(xstr.s(), encodedSameAsClass.cha, xstr.sizeInBytes()) == 0, // cannot include terminator as xstr is a substring of encodedSameAsClass. But length() test shows that xstr is really a substring.
ssprintf("memcmp(xstr.s(), encodedSameAsClass.cha, xstr.sizeInBytes()) == 0"),
ssprintf("memcmp(xstr.s(), encodedSameAsClass.cha, xstr.sizeInBytes()) != 0")
);
}
return SimpleString();
@ -747,10 +729,10 @@ static void teststrcatCheckResult(size_t expectedLength, size_t expectedSize, ch
);
}
template<class XStringClass, class InitialValue, class ValueToCat>
SimpleString teststrcat_(const InitialValue& initialValue, const ValueToCat& valueToCat)
template<class XStringClass, class InitialValue, typename TestStringCharType>
SimpleString teststrcat_(const InitialValue& initialValue, const TestString<TestStringCharType>& valueToCat)
{
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::strcpy(%s\"%s\") strcat(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str(), XStringClassInfo<ValueToCat>::prefix, SimpleString(valueToCat.cha).c_str()));
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::strcpy(%s\"%s\") strcat(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str(), XStringClassInfo<TestStringCharType>::prefix, SimpleString(valueToCat.cha).c_str()));
typedef typename XStringClassInfo<XStringClass>::ch_t ch_t;
ch_t c; // dummy for call utf function
@ -761,14 +743,31 @@ SimpleString teststrcat_(const InitialValue& initialValue, const ValueToCat& val
utf_string_from_utf_string(expectedString, expectedSize*sizeof(ch_t) + 1, initialValue.cha);
utf_string_from_utf_string(expectedString + size_of_utf_string(expectedString), expectedSize*sizeof(ch_t) + 1 - size_of_utf_string(expectedString), valueToCat.cha);
// strcat native type
// strcat(native char)
{
XStringClass xstr;
xstr.takeValueFrom(initialValue.cha);
for ( size_t i = 0 ; i < valueToCat.utf32_length ; i++) xstr.strcat(valueToCat.utf32[i]);
teststrcatCheckResult(expectedLength, expectedSize, expectedString, xstr);
}
// += native char
{
XStringClass xstr;
xstr.takeValueFrom(initialValue.cha);
for ( size_t i = 0 ; i < valueToCat.utf32_length ; i++) xstr += valueToCat.utf32[i];
teststrcatCheckResult(expectedLength, expectedSize, expectedString, xstr);
}
// strcat(native char*)
{
XStringClass xstr;
xstr.takeValueFrom(initialValue.cha);
xstr.strcat(valueToCat.cha);
teststrcatCheckResult(expectedLength, expectedSize, expectedString, xstr);
}
// += native type
// += native char*
{
XStringClass xstr;
xstr.takeValueFrom(initialValue.cha);
@ -777,14 +776,14 @@ SimpleString teststrcat_(const InitialValue& initialValue, const ValueToCat& val
}
// strcat XString
{
typename XStringClassInfo<ValueToCat>::xs_t valueToCatXString;
typename XStringClassInfo<TestStringCharType>::xs_t valueToCatXString;
valueToCatXString.takeValueFrom(valueToCat.cha);
XStringClass xstr;
xstr.takeValueFrom(initialValue.cha);
xstr += valueToCatXString;
teststrcatCheckResult(expectedLength, expectedSize, expectedString, xstr);
}
// XString + native type
// XString + native char*
{
XStringClass xinitialValue;
xinitialValue.takeValueFrom(initialValue.cha);
@ -796,15 +795,15 @@ SimpleString teststrcat_(const InitialValue& initialValue, const ValueToCat& val
{
XStringClass xinitialValue;
xinitialValue.takeValueFrom(initialValue.cha);
typename XStringClassInfo<ValueToCat>::xs_t valueToCatXString;
typename XStringClassInfo<TestStringCharType>::xs_t valueToCatXString;
valueToCatXString.takeValueFrom(valueToCat.cha);
XStringClass xstr;
xstr = xinitialValue + valueToCatXString;
teststrcatCheckResult(expectedLength, expectedSize, expectedString, xstr);
}
// native type + XString
// native char* + XString
{
typename XStringClassInfo<ValueToCat>::xs_t valueToCatXString;
typename XStringClassInfo<TestStringCharType>::xs_t valueToCatXString;
valueToCatXString.takeValueFrom(valueToCat.cha);
XStringClass xstr;
xstr = initialValue.cha + valueToCatXString;
@ -888,7 +887,7 @@ SimpleString teststrncat_(const InitialValue& initialValue, const ValueToCat& va
template<class XStringClass, class InitialValue>
SimpleString testSubString_(const InitialValue& initialValue)
{
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::subString(%s\"%s\"", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str()));
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::subString(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str()));
typedef typename XStringClassInfo<XStringClass>::ch_t ch_t;
ch_t c; // dummy for call utf function
@ -1322,7 +1321,7 @@ SimpleString testindexOf_(const InitialValue& initialValue)
template<class XStringClass, class InitialValue>
SimpleString testlastChar_(const InitialValue& initialValue)
{
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::lastChar(%s\"%s\"", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str()));
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::lastChar(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str()));
// typedef typename XStringClassInfo<XStringClass>::ch_t ch_t;
// ch_t c; // dummy for call utf function
@ -1355,7 +1354,7 @@ SimpleString testlastChar_(const InitialValue& initialValue)
template<class XStringClass, class InitialValue, class ExpectedValue>
SimpleString testtrim_(const InitialValue& initialValue, const ExpectedValue& expectedValue)
{
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::trim(%s\"%s\"", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str()));
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::trim(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str()));
// typedef typename XStringClassInfo<XStringClass>::ch_t ch_t;
// ch_t c; // dummy for call utf function
@ -1385,6 +1384,58 @@ SimpleString testtrim_(const InitialValue& initialValue, const ExpectedValue& ex
} \
/***************************** startWith *****************************/
template<class XStringClass, class InitialValue>
SimpleString teststartWith_(const InitialValue& initialValue)
{
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::startWith(%s\"%s\")", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str()));
// typedef typename XStringClassInfo<XStringClass>::ch_t ch_t;
// ch_t c; // dummy for call utf function
XStringClass initialString;
initialString.takeValueFrom(initialValue.cha);
char32_t expectedChar = 0;
if ( initialValue.utf32_length > 0) expectedChar = initialValue.utf32[initialValue.utf32_length-1];
for ( size_t count = 0 ; count < initialValue.utf32_length+3 ; count+=1 )
{
XStringClass subStr = initialString.subString(0, count);
bool expectedResult = true;
if ( subStr.length() > 0 && count >= initialValue.utf32_length ) expectedResult = false;
CHECK_RESULT(initialString.startWith(subStr) == expectedResult,
ssprintf("\"%s\".startWith(\"%s\") == %d", SimpleString(initialString.s()).c_str(), SimpleString(subStr.s()).c_str(), expectedResult),
ssprintf("\"%s\".startWith(\"%s\") != %d", SimpleString(initialString.s()).c_str(), SimpleString(subStr.s()).c_str(), expectedResult)
);
//initialString.startWith(subStr);
subStr = initialString.subString(0, count-1) + ((char32_t)(initialValue.utf32[count-1]+1));
expectedResult = false;
CHECK_RESULT(initialString.startWith(subStr) == expectedResult,
ssprintf("\"%s\".startWith(\"%s\") == %d", SimpleString(initialString.s()).c_str(), SimpleString(subStr.s()).c_str(), expectedResult),
ssprintf("\"%s\".startWith(\"%s\") != %d", SimpleString(initialString.s()).c_str(), SimpleString(subStr.s()).c_str(), expectedResult)
);
//subStr = initialString.subString(0, count-1);
//subStr = subStr + ((char32_t)(initialValue.utf32[count-1]+1));
//initialString.startWith(subStr);
}
//str.takeValueFrom(initialValue.cha);
//str.startWith();
return SimpleString();
}
#define teststartWith(XStringClass, classEncoding) \
printf("Test %s::teststartWith\n", STRINGIFY(XStringClass)); \
for ( size_t i = 0 ; i < nbTestStringMultiCoded ; i++ ) { \
teststartWith_<XStringClass>(testStringMultiCodedArray[i].classEncoding); \
} \
/***************************** *****************************/
#undef realloc
@ -1482,14 +1533,12 @@ size_t utf32_size = sizeof(U"ギ") - 1; (void)utf32_size; // this char is 6 b
// TEST_ALL_CLASSES(testDefaultCtor, __TEST0);
// TEST_ALL_CLASSES(testEmpty, __TEST0);
// TEST_ALL_CLASSES(testTakeValueFrom, TEST_ALL_UTF);
// TEST_ALL_CLASSES(testTakeValueFromXString, TEST_ALL_UTF);
TEST_ALL_CLASSES(testTakeValueFrom, TEST_ALL_UTF);
// TEST_ALL_CLASSES(testchar32At, TEST_ALL_INTEGRAL);
// TEST_ALL_CLASSES(testdataSized, TEST_ALL_INTEGRAL);
//
// TEST_ALL_CLASSES(teststrcpy, TEST_ALL_UTF);
// TEST_ALL_CLASSES(teststrncpy, TEST_ALL_UTF); // 26944 tests
// TEST_ALL_CLASSES(teststrcat, TEST_ALL_UTF_ALL_UTF);
TEST_ALL_CLASSES(teststrncpy, TEST_ALL_UTF); // 26944 tests
TEST_ALL_CLASSES(teststrcat, TEST_ALL_UTF_ALL_UTF);
// TEST_ALL_CLASSES(teststrncat, TEST_ALL_UTF_ALL_UTF); // 2101632 tests
//
// TEST_ALL_CLASSES(testSubString, __TEST0);
@ -1498,6 +1547,7 @@ size_t utf32_size = sizeof(U"ギ") - 1; (void)utf32_size; // this char is 6 b
//
// TEST_ALL_CLASSES(testlastChar, __TEST0);
TEST_ALL_CLASSES(testtrim, __TEST0);
TEST_ALL_CLASSES(teststartWith, __TEST0);

View File

@ -6,7 +6,7 @@
#include "XArray_tests.h"
#include "XObjArray_tests.h"
#include "XStringWArray_test.h"
#include "XStringArray_test.h"
#include "XString_test.h"
#include "strcmp_test.h"
#include "strncmp_test.h"
@ -91,7 +91,7 @@ bool all_tests()
printf("XObjArray_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = XStringWArray_tests();
ret = XStringArray_tests();
if ( ret != 0 ) {
printf("XStringWArray_tests() failed at test %d\n", ret);
all_ok = false;

View File

@ -271,7 +271,7 @@ STATIC void CreateInfoLines(IN CONST XStringW& Message, OUT XStringWArray* Infor
if (Message.isEmpty()) {
return;
}
Information->Empty();
Information->setEmpty();
//TODO will fill later
}
@ -328,7 +328,7 @@ VOID AlertMessage(IN XStringW& Title, IN CONST XStringW& Message)
CreateInfoLines(Message, &AlertMessageMenu.InfoLines);
AlertMessageMenu.Title = Title;
AlertMessageMenu.RunMenu(NULL);
AlertMessageMenu.InfoLines.Empty();
AlertMessageMenu.InfoLines.setEmpty();
}
#define TAG_YES 1
@ -357,7 +357,7 @@ BOOLEAN YesNoMessage(IN XStringW& Title, IN CONST XStringW& Message)
MenuExit = MENU_EXIT_ENTER;
}
} while (MenuExit != MENU_EXIT_ENTER);
YesNoMessageMenu.InfoLines.Empty();
YesNoMessageMenu.InfoLines.setEmpty();
return Result;
}
// Ask user for file path from directory menu

View File

@ -474,7 +474,7 @@ VOID REFIT_MENU_SCREEN::FreeMenu()
}
Entries.Empty();
}
InfoLines.Empty();
InfoLines.setEmpty();
}
INTN REFIT_MENU_SCREEN::FindMenuShortcutEntry(IN CHAR16 Shortcut)
@ -1422,15 +1422,15 @@ VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN
XStringW BCSTextX;
if (StrLen(Text) <= MaxTextLen) { // if the text exceeds the given limit
BCSTextX.StrnCpy(Text, MaxTextLen);
BCSTextX.strncpy(Text, MaxTextLen);
} else {
BCSTextX.StrnCpy(Text, MaxTextLen - 2); // EllipsisLen=2
BCSTextX.strncpy(Text, MaxTextLen - 2); // EllipsisLen=2
BCSTextX += L"..";
}
DrawTextXY(BCSTextX, XPos, YPos, XAlign);
}
VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN UINTN Cursor)
VOID REFIT_MENU_SCREEN::DrawMenuText(IN const XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN UINTN Cursor)
{
XImage TextBufferX(UGAWidth-XPos, ThemeX.TextHeight);
XImage SelectionBar(UGAWidth-XPos, ThemeX.TextHeight);

View File

@ -41,7 +41,7 @@
#include "../cpp_foundation/XObjArray.h"
#include "../cpp_foundation/XString.h"
#include "../cpp_foundation/XStringWArray.h"
#include "../cpp_foundation/XStringArray.h"
#include "../libeg/XPointer.h"
#include "../libeg/XCinema.h"
#include "menu_items/menu_items.h"
@ -194,7 +194,7 @@ public:
INTN DrawTextXY(IN CONST XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
void EraseTextXY();
VOID DrawTextCorner(UINTN TextC, UINT8 Align);
VOID DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN UINTN Cursor);
VOID DrawMenuText(IN const XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN UINTN Cursor);
VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
VOID CountItems();
VOID InitAnime();

View File

@ -41,7 +41,7 @@
#ifdef __cplusplus
#include "../../cpp_foundation/XObjArray.h"
#include "../../cpp_foundation/XString.h"
#include "../../cpp_foundation/XStringWArray.h"
#include "../../cpp_foundation/XStringArray.h"
#include "../../libeg/XPointer.h"
#endif

View File

@ -40,7 +40,7 @@
#include "../../refit/lib.h"
#ifdef __cplusplus
#include "../../cpp_foundation/XObjArray.h"
#include "../../cpp_foundation/XStringWArray.h"
#include "../../cpp_foundation/XStringArray.h"
#include "../../cpp_foundation/XString.h"
#include "../../libeg/XPointer.h"
#endif

View File

@ -247,8 +247,7 @@
cpp_foundation/XString.h
cpp_foundation/XStringArray.cpp
cpp_foundation/XStringArray.h
cpp_foundation/XStringWArray.cpp
cpp_foundation/XStringWArray.h
cpp_foundation/XStringArray.cpp
# cpp_foundation/XUINTN.cpp
# cpp_foundation/XUINTN.h
cpp_unit_test/all_tests.h
@ -274,8 +273,8 @@
cpp_unit_test/XObjArray_tests.h
cpp_unit_test/XString_test.cpp
cpp_unit_test/XString_test.h
cpp_unit_test/XStringWArray_test.cpp
cpp_unit_test/XStringWArray_test.h
cpp_unit_test/XStringArray_test.cpp
cpp_unit_test/XStringArray_test.h
# cpp_unit_test/XUINTN_test.cpp
# cpp_unit_test/XUINTN_test.h

View File

@ -61,7 +61,6 @@
#ifdef __cplusplus
#include "../cpp_foundation/XObjArray.h"
#include "../cpp_foundation/XString.h"
#include "../cpp_foundation/XStringWArray.h"
#include "../libeg/XTheme.h"
extern XTheme ThemeX; //global variable defined in lib.cpp