The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information.... |
Home BasePack Stringl Interface of SDL_StringL | |
Interface of SDL_StringL |
|
const MaxGrepTokens = 64; MAXTOKENS = 1000; WordSeps : set of char = [#00,' ','-',#13, #10,'.',',','/','\', '#', '"', '''', ':','+','%','*','(',')',';','=','{','}','[',']', '{', '}', '<', '>']; {$IFDEF PAIDVERS} SDLVersionInfo = 'stringl_r1200_full'; IsLightEd = false; {$ELSE} SDLVersionInfo = 'stringl_r1200_lighted'; IsLightEd = true; {$ENDIF} Release = 1200; type ESDLStringlError = class(ESDLError); { exception type to indicate errors } TCharArr256 = array[0..255] of char; TOpenStringArray = array of string; TQuotedStrState = (vsStart, vs1stQuote, vsQuote, vsNormal, vsEnd); TGrepTokenAct = (taNormal, { normal character to be matched } taAnyByte, { '.' - skip this character } taEol, { '$' - end of line } taBol, { '^' - beginning of line } taSet, { '[]' - set of characters } taMult0, { '*' - multiplier, including 0: any number of this character allowed } taMult1, { '+' - multiplier, excluding 0: at least 1 occurrence of this character required } taOpti); { '?' - this character can occur optionally } TGrepToken = record Action : TGrepTokenAct; NumChars : integer; Params : TCharArr256; ValidFrom: integer; end; { List of actions and their parameters: Action NumChars Params ---------------------------------------------------- taNormal #chars list of NumChars characters taAnybyte -- -- taEol -- -- taBol -- -- taSet -- set of characters (boolean array: TRUE for members of set) taMult0 #chars #chars > 0: list of NumChars to be matched #chars = 0: anychar to be matched #chars < 0: set to be matched taMult1 #chars #chars > 0: list of NumChars to be matched #chars = 0: anychar to be matched #chars < 0: set to be matched taOpti #chars #chars > 0: list of NumChars to be matched #chars = 0: anychar to be matched #chars < 0: set to be matched } TRegExp = array[1..MaxGrepTokens] of TGrepToken; TGrep = class (TComponent) private FLengRegExp : integer; { no. of tokens in reg. expr. } FStopOnError : boolean; { TRUE: raise exception on error } FregExp : TRegExp; { regular expression tokens } FRegExpStr : string; { original reg.exp. string } FIgnoreCase : boolean; { TRUE: ignore case during search } FError : integer; { error number - see SetRegExp } FMatchEndPos : integer; { last matched position in search string } FMatchStartPos: integer; { first matched position in search string } FSrcStartPos : integer; { starting pos. where to start matching } function CompileRegExp (regexp: string): integer; procedure SetRegExp (regexp: string); procedure SetIgnoreCase (ic: boolean); function GetRegExpToken (regix: integer): TGrepToken; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure PrintRegExp (FName: string); function MatchString (Instring: string; var MatchPos: integer): boolean; property RegExpToken [regix: integer]: TGrepToken read GetRegExpToken; property MatchEndPos: integer read FMatchEndPos; property MatchStartPos: integer read FMatchStartPos; property NrOfRegExpTokens: integer read FLengRegExp; property LastError: integer read FError; published property IgnoreCase: boolean read FIgnoreCase write SetIgnoreCase; property RegExp: string read FRegExpStr write SetRegExp; property SearchStartPos: integer read FSrcStartPos write FSrcStartPos; property StopOnError: boolean read FStopOnError write FStopOnError; end; {procedures and functions} function AbbrevString (Instring : string; { string to be abbreviated } width : integer) { maximum width } : string; { abbreviated string } function AutoFormatData (data : double; { value to be converted to a string } SigDig : integer) { number of significant digits } : string; overload; { resulting string representation } function AutoFormatData (data : double; { value to be converted to a string } SigDig : integer; { number of significant digits } UseComma : boolean) { TRUE: comma is used as dec. sep. } : string; overload; { resulting string representation } function BinString (ABool : boolean; { boolean value to control result } TrueString : string; { string to be returned for ABool = TRUE } FalseString : string) { string to be returned for ABool = FALSE } : string; { selected string } function BoolToStr (ABool : boolean; { input variable } Format : integer) { format of output } : string; { formatted string } function CapitalizeString (Instring : string) { string to be capitalized } : string; { capitalized string } function ChangeCase (const InString : string) { string to be converted } : string; { string with switched cases } function CenterString (Instring : string; { string to center } Width : byte) { width of result } : string; { centered string } function ConvertVariant (const val : variant) { variant value to be converted } : string; { value converted to a string } function ConvertToTabs (Instring : string; { string to be converted } ConvColonSpace : boolean; { TRUE convert ': ' } ConvSpacePlusMinus : boolean) { TRUE: convert ' +/-' } : string; { all multi-spaces are converted to tabs } function CountCharInString (cc : char; { character to be counted } Instring : string; { string to be analyzed } CaseSensitive : boolean) { TRUE: search is case sensitive } : integer; { count of cc in InString } function CountControlChars (InString : string) { string to be analyzed } : integer; { control char count of string } function CountStringInString (SearchStr : string; { string to be counted } Instring : string; { string to be analyzed } CaseSensitive : boolean) { TRUE: search is case sensitive } : integer; { count of cc in InString } function CountWords (InString : string) { string to be analyzed } : integer; { word count of string } function CreateParList (ParArray : TDoubleArray; { array of parameters to be listed } FinalComma : boolean; { TRUE: append a comma to string } MaxElems : integer; { maximum number of elements to be included } SigDig : integer; { number of significant digits } EnclosingBrackets : boolean) { put parameter list in brackets } : string; overload; { resulting list of numbers } function CreateParList (ParArray : TIntArray; { array of parameters to be listed } FinalComma : boolean; { TRUE: append a comma to string } MaxElems : integer; { maximum number of elements to be included } EnclosingBrackets : boolean) { put parameter list in brackets } : string; overload; { resulting list of numbers } function CreateParList (ParArray : array of integer; { array of parameters to be listed } FinalComma : boolean; { TRUE: append a comma to string } MaxElems : integer; { maximum number of elements to be included } EnclosingBrackets : boolean) { put parameter list in brackets } : string; overload; { resulting list of numbers } function CreateParList (ParArray : array of TColor; { array of parameters to be listed } FinalComma : boolean; { TRUE: append a comma to string } MaxElems : integer; { maximum number of elements to be included } EnclosingBrackets : boolean; { put parameter list in brackets } ResolveColorNames : boolean) { TRUE: convert to color names where possible } : string; overload; { resulting list of colors } function CreateParList (ParArray : array of boolean; { array of parameters to be listed } FinalComma : boolean; { TRUE: append a comma to string } MaxElems : integer; { maximum number of elements to be included } EnclosingBrackets : boolean) { put parameter list in brackets } : string; overload; { resulting list of numbers } function CreateParList (ParArray : array of double; { array of parameters to be listed } FinalComma : boolean; { TRUE: append a comma to string } MaxElems : integer; { maximum number of elements to be included } SigDig : integer; { number of significant digits } EnclosingBrackets : boolean) { put parameter list in brackets } : string; overload; { resulting list of numbers } function DeScramble (Instring : string) { string to be scrambled } : string; { scrambled string } function DetectCSVDelimiter (InString : string) { string to be analysed } : TCSVDelimiters; { detected CSV delimiter } function DetectNextTagInString (const InString : string; { string to be analysed } var StartIdx, { index of first character of tag } StopIdx : integer; { index of last character of tag } const TagList : array of string; { list of XML tags } var Attrib : string; { associated attributes } var IsClosingTag : boolean) { TRUE if tag is a closing tag } : integer; { index of tag } function EnsureLeadingChar (cc : char; { character to be forced } instring : string) { string to be processed } : string; function EnsureTrailingBkSlash (instring : string) { string to be processed } : string; function EnsureTrailingChar (cc : char; { character to be forced } instring : string) { string to be processed } : string; {$IFNDEF DOTNET} function EqualAnsiStrings (const String1, { string to compare } String2 : string) { string to compare } : boolean; { TRUE if strings are equal } {$ENDIF} function ExpandDiphthongs (line : string) { any string } : string; { diphthongs --> vowels } function ExtractParam (ParamId : string; { name of parameter to be extracted } StartPos : integer; { position where to start the search } AssignChar : char; { assignment character } Terminator : char; { terminating character } InString : string) { string to be analyzed } : string; { value of the parameter } {$IFNDEF DOTNET} function ExtractAfterTrigger (InString, { string to be analysed } Trigger : string; { substring to be searched } StripBlanks : boolean) { TRUE: remove leading and trailing blanks } : string; { substring after the trigger string } function ExtractBeforeTrigger (InString, { string to be analysed } Trigger : string; { substring to be searched } StripBlanks : boolean) { TRUE: remove leading and trailing blanks } : string; { substring before the trigger string } function ExtractSubString (const Instring : string; { source string } const occ : integer; { occurrence counter } const Separator : string) { separating string } : string; { extracted substring } function ExtractWordFromString (const InString : string; const Pos : integer; var FirstIdx, LastIdx : integer) : string; overload; function ExtractWordFromString (const InString : string; const Pos : integer) : string; overload; {$ENDIF} function FindFirstNonBlank (const InString : string) { string to be searched } : integer; { position of first non blank char } function FindFirstDigit (const InString : string) { string to be searched } : integer; { position of first digit in the string } function FormatData (data : double; { data to be formatted } NumWidth : integer; { width of resulting string } NDecP : integer) { number of decimal places } : string; { resulting string } procedure InitScramble (Key : longint); { key for scrambling } function IntToStrGrouped (inum : int64; { integer to be converted } spacer : char) { character used for spacing } : string; { grouped numeric string } function IsAbbreviation (InString : string) { word to be tested } : boolean; { TRUE if Instring is an abbreviation} function IsAllDec (InString : string) { string to be tested } : boolean; { TRUE if Instring is consists of dec. digits } function IsAllHex (InString : string) { string to be tested } : boolean; { TRUE if Instring is consists of hex. digits } function IsDigit (c : char) : boolean; function IsDigitLetter (c : char) : boolean; function IsHexChar (c : char) : boolean; function IsLetter (c : char) : boolean; function IsUmlaut (c : char) : boolean; function LeftString (Instring : string; { input string } Width : byte) { width of result } : string; { left adjusted string } function MultiChar (cc : char; { character } RepCnt : integer) { number of repetitions } : string; { string with RepCnt chars } function NumberedPos (SubStr, { sub string to be searched for } MainStr : string; { string to be searched in } StartIx, { index of MainStr where to start search } Count : integer; { count of occurrence when to stop search } IgnoreCase : boolean) { TRUE: ignore case of SubStr and MainStr } : integer; function NumberedPosBw (SubStr, { sub string to be searched for } MainStr : string; { string to be searched in } StartIx, { index of MainStr where to start search } Count : integer; { count of occurrence when to stop search } IgnoreCase : boolean) { TRUE: ignore case of SubStr and MainStr } : integer; {$IFNDEF DOTNET} {$IFDEF MSWINDOWS} {$IFNDEF GE_LEV13} function OEMString (Instring : ShortString) { input string with ANSI character set } : ShortString; { output string with IBM character set } {$ENDIF} {$ENDIF} {$ENDIF} function ParseQuotedName (cc : char; { next character to be parsed } QuoteChar : char; { character to be used as quote } var CurrentName : string; { name built up so far } var State : TQuotedStrState) { state of finite state machine } : boolean; { TRUE if CurrentName is completed } function PosLast (SubStr : string; { substring to be searched for } Instring : string) { string to be searched in } : integer; { index where substring starts } function ProcessHexChars (InString : string) { string to be processed } : string; { all \#xx replaced by actual characters } function ReadLnString (Instring : string; { string to be read } var StartPos : integer; { starting/ending position } var eos : boolean; { TRUE: end of string encountered } EOLMode : integer) { mode of end-of-line recognition } : string; { partial string read from Instring } function ReadNextTagInString (const InString : string; { string to be scanned } var StartAt : integer; { position to start scanning } const TagList : array of string; { list of XML tags } var Attrib, { associated attributes } Contents : string) { contents of tag } : integer; { index of tag } function ReduceStringToFN83CompliantChars (InString : string) { string to be processed } : string;{ string containing only Win 8.3 compliant chars } function ReduceStringToAZ09 (InString : string) { string to be processed } : string; { string containing only a..z and 0..9 } function RemoveCharInString (Instring : string; { string to be processed } CharToRemove : char) { character to be removed from string } : string; { resulting string } function RemoveMultiChars (Instring : string; { string to be processed } CharToRemove : char) { character to be reduced } : string; { resulting string } function RemoveControlChars (Instring : string) { input string } : string; { no control characters } function ReplaceCharInString (Instring : string; { string to be processed } OldChar : char; { old character } NewChar : char) { new character } : string; { resulting string } function ReplaceControlChars (Instring : string; { input string } ReplacementChar : char) { replacement character } : string; { no control characters } function ReplaceStringInString (Instring : string; { string to be processed } OldStr : string; { substring to be replaced } NewStr : string; { new substring } IgnoreCase : boolean) { ignore case in search if TRUE } : string; { resulting string } function ReverseString (InString : string) { string to be processed } : string; { string with reversed order of characters } function RightString (Instring : string; { input string } Width : byte) { width of result } : string; { right aligned string } function ScanStringForXMLTag (InString : string; { string to be scanned } StartIx : integer; { index where to start scan } XMLTag : string; { XML tag to be searched } var Attrib, { attribute of XML tag } Contents : string) { contents of XML tag } : integer; { error code } function Scramble (Instring : string) { string to be scrambled } : string; { scrambled string } function SigDigStr (data : double; { data to be formatted } Width : integer; { width of resulting string } NSigDig : integer) { number of significant digits } : string; overload; { resulting string } function SigDigStr (data : double; { data to be formatted } Width : integer; { width of resulting string } NSigDig : integer; { number of significant digits } NoBlanks : boolean) { TRUE: no leading blanks } : string; overload; { resulting string } function SortableNumericString (Instring : string; { numeric string to be aligned } DecSep : char; { decimal separator } DecPPos : integer) { intended postion of the decimal point } : string; { adjusted string with leading blanks } function SortStringList (SL : TStringList; Trigger : string; TrgCnt : integer; SortPos : integer; IgnoreCase, SortByNumValue : boolean) : integer; procedure SplitString (InString, { string to be split } Delimiter : string; { substring which serves as a delimiter } StripBlanks : boolean; { TRUE: remove leading and trailing blanks } var Str1, Str2 : string); { left and right part of the string } function StringContains (Instring : string; { string to be checked } CharList : string) { list of characters to be tested } : boolean;{TRUE if any character of CharList is contained } function StringContainsOtherThan (Instring : string; { string to be checked } CharList : string) { list of characters to be tested } : boolean; {TRUE if InString contains other characters } function StringIx (InString : string; { string to matched } SArray : array of string) { string array of valid keywords } : integer; overload; { index of matched keyword } function StringIx (InString : string; { string to matched } CaseSensitive : boolean; { TRUE: comparison is case sensitive } SArray : array of string) { string array of valid keywords } : integer; overload; { index of matched keyword } function StripLeadingBlanks (Instring : string) { input string } : string; { string without leading blanks } function StripLeadingChars (cc : char; { character to be stripped off } Instring : string) { input string } : string; { string without leading cc(s) } function StripLTBlanks (Instring : string) { input string } : string; { string without leading/trailing blanks } function StripTrailingBlanks (Instring : string) { input string } : string; { string without trailing blanks } function StripTrailingChars (cc : char; { character to be stripped off } Instring : string) { input string } : string; { string without trailing cc(s) } function strff (r : extended; { number to convert } FieldWidth : integer; { width of output field } DecP : integer) { number of dec. places } : string; { formatted string } function strffForcePlus (r : extended; { number to convert } FieldWidth : integer; { width of output field } DecP : integer) { number of dec. places } : string; { formatted string } function StrToTriState (value : string) { string to be converted } : TTriState; function TestAllChar (Instr : string; { string to be tested } cc : char) { character to be searched } : boolean; { TRUE, if string=all cc } procedure TextLineCoords (const InString : string; { string to be analyzed } const Pos : integer; { string position } var X, Y : integer); { column and row in text } function TimeString (Time : double; { time in sec } Fmt : byte) { format specification } : string; { time string } function Tokenize (Instring : string; { string to be analyzed } const Separator : string; { separating string } var Tokens : TOpenStringArray) { token found } : integer; overload; { number of tokens found } {$IFDEF GE_LEV18} function Tokenize (Instring : string; { string to be analyzed } const Separator : string; { separating string } const EscapeChar : char; var Tokens : TOpenStringArray) { token found } : integer; overload; { number of tokens found } {$ENDIF} function TriStateToStr (value : TTriState; { tri-state value to be converted } Format : integer) { format of output } : string; function UUDecodeStr (Instring : string) { string to be UU decoded } : string; { UU encoded string } function UUEncodeStr (Instring : string) { string to be UU encoded } : string; { UU encoded string } {$IFNDEF DOTNET} {$IFDEF MSWINDOWS} {$IFNDEF GE_LEV13} function WinAnsiString (Instring : ShortString) { input string with IBM character set } : ShortString; { output string with ANSI character set } {$ENDIF} {$ENDIF} {$ENDIF}
|