mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-06 15:48:47 +00:00
[base] remove the wrapper FindLastSubstring
This commit is contained in:
+11
-8
@@ -1,26 +1,32 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Basic Unicode string types.
|
//~ Basic Unicode string types.
|
||||||
|
|
||||||
|
@doc("A pointer and size representing a UTF-8 string. Also used for any range of untyped data range.")
|
||||||
|
@see(MD_String8List)
|
||||||
@struct MD_String8: {
|
@struct MD_String8: {
|
||||||
str: *MD_u8,
|
str: *MD_u8,
|
||||||
size: MD_u64,
|
size: MD_u64,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@doc("A pointer and size representing a UTF-16 string.")
|
||||||
@struct MD_String16: {
|
@struct MD_String16: {
|
||||||
str: *MD_u16,
|
str: *MD_u16,
|
||||||
size: MD_u64,
|
size: MD_u64,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@doc("A pointer and size representing a UTF-32 string.")
|
||||||
@struct MD_String32: {
|
@struct MD_String32: {
|
||||||
str: *MD_u32,
|
str: *MD_u32,
|
||||||
size: MD_u64,
|
size: MD_u64,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@doc("A node in an MD_String8List")
|
||||||
@struct MD_String8Node: {
|
@struct MD_String8Node: {
|
||||||
next: MD_String8Node,
|
next: *MD_String8Node,
|
||||||
string: MD_String8,
|
string: MD_String8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@doc("A list of multiple possibly discontiguous strings (in MD_String8). Stored as a singly linked list.")
|
||||||
@struct MD_String8List: {
|
@struct MD_String8List: {
|
||||||
node_count: MD_u64,
|
node_count: MD_u64,
|
||||||
total_size: MD_u64,
|
total_size: MD_u64,
|
||||||
@@ -28,11 +34,15 @@
|
|||||||
last: *MD_String8Node,
|
last: *MD_String8Node,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@doc("Controls matching rules in routines that perform string matching.")
|
||||||
@prefix(MD_StringMatchFlag)
|
@prefix(MD_StringMatchFlag)
|
||||||
@base_type(MD_u32)
|
@base_type(MD_u32)
|
||||||
@flags MD_StringMatchFlags: {
|
@flags MD_StringMatchFlags: {
|
||||||
|
@doc("Consider lower case letters equivalent to upper case equivalents in the ASCII range.")
|
||||||
CaseInsensitive,
|
CaseInsensitive,
|
||||||
|
@doc("Do not require the strings to be the same length. If one of the strings is a prefix of another, the two strings will count as a match.")
|
||||||
RightSideSloppy,
|
RightSideSloppy,
|
||||||
|
@doc("On string ")
|
||||||
FindLast,
|
FindLast,
|
||||||
SlashInsensitive,
|
SlashInsensitive,
|
||||||
};
|
};
|
||||||
@@ -482,13 +492,6 @@
|
|||||||
return: MD_u64,
|
return: MD_u64,
|
||||||
};
|
};
|
||||||
|
|
||||||
@func MD_FindLastSubstring: {
|
|
||||||
str: MD_String8,
|
|
||||||
substring: MD_String8,
|
|
||||||
flags: MD_StringMatchFlags,
|
|
||||||
return: MD_u64,
|
|
||||||
};
|
|
||||||
|
|
||||||
@func MD_ChopExtension: {
|
@func MD_ChopExtension: {
|
||||||
string: MD_String8,
|
string: MD_String8,
|
||||||
return: MD_String8,
|
return: MD_String8,
|
||||||
|
|||||||
@@ -657,7 +657,6 @@ MD_FUNCTION MD_String8 MD_StringSuffix(MD_String8 str, MD_u64 size);
|
|||||||
MD_FUNCTION MD_b32 MD_StringMatch(MD_String8 a, MD_String8 b, MD_StringMatchFlags flags);
|
MD_FUNCTION MD_b32 MD_StringMatch(MD_String8 a, MD_String8 b, MD_StringMatchFlags flags);
|
||||||
MD_FUNCTION MD_u64 MD_FindSubstring(MD_String8 str, MD_String8 substring,
|
MD_FUNCTION MD_u64 MD_FindSubstring(MD_String8 str, MD_String8 substring,
|
||||||
MD_u64 start_pos, MD_StringMatchFlags flags);
|
MD_u64 start_pos, MD_StringMatchFlags flags);
|
||||||
MD_FUNCTION MD_u64 MD_FindLastSubstring(MD_String8 str, MD_String8 substring, MD_StringMatchFlags flags);
|
|
||||||
|
|
||||||
MD_FUNCTION MD_String8 MD_ChopExtension(MD_String8 string);
|
MD_FUNCTION MD_String8 MD_ChopExtension(MD_String8 string);
|
||||||
MD_FUNCTION MD_String8 MD_SkipFolder(MD_String8 string);
|
MD_FUNCTION MD_String8 MD_SkipFolder(MD_String8 string);
|
||||||
|
|||||||
+8
-10
@@ -259,16 +259,10 @@ MD_FindSubstring(MD_String8 str, MD_String8 substring, MD_u64 start_pos, MD_Stri
|
|||||||
return found_idx;
|
return found_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
MD_FUNCTION_IMPL MD_u64
|
|
||||||
MD_FindLastSubstring(MD_String8 str, MD_String8 substring, MD_StringMatchFlags flags)
|
|
||||||
{
|
|
||||||
return MD_FindSubstring(str, substring, 0, flags | MD_StringMatchFlag_FindLast);
|
|
||||||
}
|
|
||||||
|
|
||||||
MD_FUNCTION_IMPL MD_String8
|
MD_FUNCTION_IMPL MD_String8
|
||||||
MD_ChopExtension(MD_String8 string)
|
MD_ChopExtension(MD_String8 string)
|
||||||
{
|
{
|
||||||
MD_u64 period_pos = MD_FindLastSubstring(string, MD_S8Lit("."), 0);
|
MD_u64 period_pos = MD_FindSubstring(string, MD_S8Lit("."), 0, MD_StringMatchFlag_FindLast);
|
||||||
if(period_pos < string.size)
|
if(period_pos < string.size)
|
||||||
{
|
{
|
||||||
string.size = period_pos;
|
string.size = period_pos;
|
||||||
@@ -279,7 +273,9 @@ MD_ChopExtension(MD_String8 string)
|
|||||||
MD_FUNCTION_IMPL MD_String8
|
MD_FUNCTION_IMPL MD_String8
|
||||||
MD_SkipFolder(MD_String8 string)
|
MD_SkipFolder(MD_String8 string)
|
||||||
{
|
{
|
||||||
MD_u64 slash_pos = MD_FindLastSubstring(string, MD_S8Lit("/"), MD_StringMatchFlag_SlashInsensitive);
|
MD_u64 slash_pos = MD_FindSubstring(string, MD_S8Lit("/"), 0,
|
||||||
|
MD_StringMatchFlag_SlashInsensitive|
|
||||||
|
MD_StringMatchFlag_FindLast);
|
||||||
if(slash_pos < string.size)
|
if(slash_pos < string.size)
|
||||||
{
|
{
|
||||||
string.str += slash_pos+1;
|
string.str += slash_pos+1;
|
||||||
@@ -291,7 +287,7 @@ MD_SkipFolder(MD_String8 string)
|
|||||||
MD_FUNCTION_IMPL MD_String8
|
MD_FUNCTION_IMPL MD_String8
|
||||||
MD_ExtensionFromPath(MD_String8 string)
|
MD_ExtensionFromPath(MD_String8 string)
|
||||||
{
|
{
|
||||||
MD_u64 period_pos = MD_FindLastSubstring(string, MD_S8Lit("."), 0);
|
MD_u64 period_pos = MD_FindSubstring(string, MD_S8Lit("."), 0, MD_StringMatchFlag_FindLast);
|
||||||
if(period_pos < string.size)
|
if(period_pos < string.size)
|
||||||
{
|
{
|
||||||
string.str += period_pos+1;
|
string.str += period_pos+1;
|
||||||
@@ -303,7 +299,9 @@ MD_ExtensionFromPath(MD_String8 string)
|
|||||||
MD_FUNCTION_IMPL MD_String8
|
MD_FUNCTION_IMPL MD_String8
|
||||||
MD_FolderFromPath(MD_String8 string)
|
MD_FolderFromPath(MD_String8 string)
|
||||||
{
|
{
|
||||||
MD_u64 slash_pos = MD_FindLastSubstring(string, MD_S8Lit("/"), MD_StringMatchFlag_SlashInsensitive);
|
MD_u64 slash_pos = MD_FindSubstring(string, MD_S8Lit("/"), 0,
|
||||||
|
MD_StringMatchFlag_SlashInsensitive|
|
||||||
|
MD_StringMatchFlag_FindLast);
|
||||||
if(slash_pos < string.size)
|
if(slash_pos < string.size)
|
||||||
{
|
{
|
||||||
string.size = slash_pos;
|
string.size = slash_pos;
|
||||||
|
|||||||
Reference in New Issue
Block a user