Changeset 139 for trunk/NewView/StringUtilsUnit.pas
- Timestamp:
- Apr 30, 2007, 9:00:32 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/StringUtilsUnit.pas
r123 r139 18 18 StrLF = CharLF; 19 19 StrCRLF = StrCR + StrLF; 20 StrSingleQuote = '''';21 StrDoubleQuote = '"';20 StrSingleQuote = CharSingleQuote; 21 StrDoubleQuote = CharDoubleQuote; 22 22 23 23 … … 37 37 end; 38 38 39 // prefi ces all occurences of one of the chars in aStringWithChars with anEscape char39 // prefixes all occurences of one of the chars in aStringWithChars with anEscape char 40 40 // if the escapeChar itself is found, then it is doubled 41 41 Function StrEscapeAllCharsBy(const aReceiver: String; const aSetOfChars: TSetOfChars; const anEscapeChar: char): String; … … 94 94 Function StrEndsWithIgnoringCase(const aReceiver: String; const anEndString: String): Boolean; 95 95 96 // Returns true if aReceiver is only spaces (or empty) 97 Function StrIsEmptyOrSpaces(const aReceiver: String) : Boolean; 98 96 99 // returns true if the Strings are the same 97 100 // this is case INsensitive … … 105 108 Function BoolToStr(const aBoolean : boolean ): string; 106 109 110 // Returns aString enclosed in single quotes 111 Function StrInSingleQuotes(const aString : String) : String; 112 107 113 // Returns aString enclosed in double quotes 108 114 Function StrInDoubleQuotes(const aString : String) : String; … … 117 123 Function CaseInsensitivePos(const aPart: String; const aString: String ): longint; 118 124 125 // Finds the last position of aChar within aString. Returns zero if no match 126 Function LastPosOfChar(const aChar: char; const aString: String): longint; 127 119 128 120 129 // -------------------- … … 122 131 // -------------------- 123 132 124 133 125 134 // removes all occurences of char from aSetOfChars from the beginning 126 135 // of a String. … … 139 148 140 149 150 // -------------------- 151 // ---- Misc TODO ---- 152 // -------------------- 153 154 Procedure GetMemString(const aPointer : pointer; var aString: string; const aSize: byte); 155 156 Procedure FreePString(var aPString: PString ); 157 158 Function NewPString(const aString : String) : PString; 141 159 142 160 … … 145 163 uses 146 164 SysUtils, 147 DebugUnit; 165 DebugUnit, 166 ACLUtility; // TODO 148 167 149 168 constructor TSerializableStringList.Create; … … 568 587 569 588 589 Function StrIsEmptyOrSpaces(const aReceiver: String) : Boolean; 590 Begin 591 Asm 592 MOV ESI, aReceiver // get address of aReceiver into ESI 593 MOV CL,[ESI] // get length of s 594 MOVZX ECX, CL // widen CL 595 INC ECX 596 597 !IsSpacesLoop: 598 INC ESI // move to next char 599 DEC ECX 600 JE !IsSpacesTrue 601 602 MOV AL,[ESI] // load character 603 CMP AL,32 // is it a space? 604 JE !IsSpacesLoop // yes, go to next 605 606 // no, return false 607 MOV EAX, 0 608 JMP !IsSpacesDone 609 610 !IsSpacesTrue: 611 MOV EAX, 1 612 613 !IsSpacesDone: 614 LEAVE 615 RETN32 4 616 End; 617 End; 618 619 570 620 Function StrEqualIgnoringCase(const aReceiver: String; const aSecondString: String): Boolean; 571 621 begin … … 618 668 619 669 670 Function StrInSingleQuotes(const aString : String) : String; 671 begin 672 Result := StrSingleQuote + aString + StrSingleQuote; 673 end; 674 675 620 676 Function StrInDoubleQuotes(const aString : String) : String; 621 677 begin … … 866 922 867 923 924 Function LastPosOfChar(const aChar: char; const aString: String): longint; 925 Var 926 tmpPos : longint; 927 begin 928 tmpPos := Length(aString); 929 while tmpPos > 0 do 930 begin 931 if aString[tmpPos] = aChar then 932 begin 933 Result := tmpPos; 934 exit; 935 end; 936 dec(tmpPos); 937 end; 938 Result := 0; 939 end; 940 868 941 // -------------------- 869 942 // ---- AnsiString ---- … … 994 1067 995 1068 1069 // -------------------- 1070 // ---- Misc TODO ---- 1071 // -------------------- 1072 1073 Procedure GetMemString(const aPointer : pointer; var aString: string; const aSize: byte); 1074 begin 1075 aString[0] := char(aSize); 1076 MemCopy(aPointer, Addr(aString[1]), aSize); 1077 end; 1078 1079 1080 Procedure FreePString(var aPString : PString ); 1081 begin 1082 if aPString = nil then 1083 begin 1084 exit; 1085 end; 1086 1087 FreeMem(aPString, Length(aPString^) + 1); 1088 aPString := nil; 1089 end; 1090 1091 1092 Function NewPString(const aString : String) : PString; 1093 begin 1094 GetMem(Result, Length(aString) + 1); 1095 Result^ := aString; 1096 end; 1097 996 1098 END.
Note:
See TracChangeset
for help on using the changeset viewer.