About Store Forum Documentation Contact



Post Reply 
Str Compare Function
Author Message
fatcoder Offline
Member

Post: #1
Str Compare Function
Are you able to add the following to String Functions.h?

Code:
Int Compare(C Str &a, C Str &b, Bool case_sensitive=false);

I find myself always having to write a wrapper function and pass the strings to one of the CChar compare functions.
02-19-2014 12:41 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Str Compare Function
You don't need that since Str is autocasted to CChar*, for which there's already a function
02-19-2014 11:04 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #3
RE: Str Compare Function
Yep, understand. However, try adding in a Map that uses Str as the key, then use Compare in the constructor to init the Map and you'll see what I mean. Also, some other third party libraries I'm integrating with don't like the CChar Compare functions, so I have to wrap them to pass a Str.

I see there is a ComparePath that takes in Str, but it would be an issue if a / was used in normal text for example.
02-20-2014 12:40 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Str Compare Function
If you want to use this for Map, then you can't go with what you've specified (because that func has extra param), you'd need something like this, which will be added in next release:
Code:
inline Int CompareCI(C Str  &a, C Str  &b) {return Compare(a, b, false);} // compare texts Case-Insensitive, you can use this function directly to other parts of the engine which require comparison functions in this format
inline Int CompareCI(C Str8 &a, C Str8 &b) {return Compare(a, b, false);} // compare texts Case-Insensitive, you can use this function directly to other parts of the engine which require comparison functions in this format
inline Int CompareCS(C Str  &a, C Str  &b) {return Compare(a, b, true );} // compare texts Case-  Sensitive, you can use this function directly to other parts of the engine which require comparison functions in this format
inline Int CompareCS(C Str8 &a, C Str8 &b) {return Compare(a, b, true );} // compare texts Case-  Sensitive, you can use this function directly to other parts of the engine which require comparison functions in this format
02-20-2014 02:17 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #5
RE: Str Compare Function
Thank you. This will work perfect! I can remove wrapper code I've been using from all over the place. lol
02-20-2014 09:35 PM
Find all posts by this user Quote this message in a reply
Post Reply