sysstrh.inc 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. {
  2. *********************************************************************
  3. $Id$
  4. Copyright (C) 1997, 1998 Gertjan Schouten
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. *********************************************************************
  17. System Utilities For Free Pascal
  18. }
  19. {==============================================================================}
  20. { standard functions }
  21. {==============================================================================}
  22. type
  23. PString = ^String;
  24. { For FloatToText }
  25. TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency);
  26. TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
  27. const
  28. { For floattodatetime }
  29. MinDateTime: TDateTime = -657434.0; { 01/01/0100 12:00:00.000 AM }
  30. MaxDateTime: TDateTime = 2958465.99999; { 12/31/9999 11:59:59.999 PM }
  31. function NewStr(const S: string): PString;
  32. procedure DisposeStr(S: PString);
  33. procedure AssignStr(var P: PString; const S: string);
  34. procedure AppendStr(var Dest: String; const S: string);
  35. function UpperCase(const s: string): string;
  36. function LowerCase(const s: string): string; overload;
  37. function CompareStr(const S1, S2: string): Integer;
  38. function CompareMemRange(P1, P2: Pointer; Length: cardinal): integer;
  39. function CompareMem(P1, P2: Pointer; Length: cardinal): Boolean;
  40. function CompareText(const S1, S2: string): integer;
  41. function AnsiUpperCase(const s: string): string;
  42. function AnsiLowerCase(const s: string): string;
  43. function AnsiCompareStr(const S1, S2: string): integer;
  44. function AnsiCompareText(const S1, S2: string): integer;
  45. function AnsiStrComp(S1, S2: PChar): integer;
  46. function AnsiStrIComp(S1, S2: PChar): integer;
  47. function AnsiStrLComp(S1, S2: PChar; MaxLen: cardinal): integer;
  48. function AnsiStrLIComp(S1, S2: PChar; MaxLen: cardinal): integer;
  49. function AnsiStrLower(Str: PChar): PChar;
  50. function AnsiStrUpper(Str: PChar): PChar;
  51. function AnsiLastChar(const S: string): PChar;
  52. function AnsiStrLastChar(Str: PChar): PChar;
  53. function Trim(const S: string): string;
  54. function TrimLeft(const S: string): string;
  55. function TrimRight(const S: string): string;
  56. function QuotedStr(const S: string): string;
  57. function AnsiQuotedStr(const S: string; Quote: char): string;
  58. function AnsiExtractQuotedStr(Const Src: PChar; Quote: Char): string;
  59. function AdjustLineBreaks(const S: string): string;
  60. function IsValidIdent(const Ident: string): boolean;
  61. function IntToStr(Value: integer): string;
  62. function IntToStr(Value: Int64): string;
  63. function IntToStr(Value: QWord): string;
  64. function IntToHex(Value: integer; Digits: integer): string;
  65. function IntToHex(Value: Int64; Digits: integer): string;
  66. function StrToInt(const s: string): integer;
  67. function StrToInt64(const s: string): int64;
  68. function StrToIntDef(const S: string; Default: integer): integer;
  69. function StrToInt64Def(const S: string; Default: int64): int64;
  70. function LoadStr(Ident: integer): string;
  71. // function FmtLoadStr(Ident: integer; const Args: array of const): string;
  72. Function Format (Const Fmt : String; const Args : Array of const) : String;
  73. Function FormatBuf (Var Buffer; BufLen : Cardinal; Const Fmt; fmtLen : Cardinal; Const Args : Array of const) : Cardinal;
  74. Function StrFmt(Buffer,Fmt : PChar; Const args: Array of const) : Pchar;
  75. Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Array of const) : Pchar;
  76. Procedure FmtStr(Var Res: String; Const Fmt : String; Const args: Array of const);
  77. Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
  78. Function FloatToStr(Value: Extended): String;
  79. Function StrToFloat(Value : String) : Extended;
  80. Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
  81. Function FloatToDateTime (Const Value : Extended) : TDateTime;
  82. Function FloattoCurr (Const Value : Extended) : Currency;
  83. Function CurrToStr(Value: Currency): string;
  84. function StrToCurr(const S: string): Currency;
  85. function StrToBool(const S: string): Boolean;
  86. function BoolToStr(B: Boolean): string;
  87. function LastDelimiter(const Delimiters, S: string): Integer;
  88. function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;
  89. {==============================================================================}
  90. { extra functions }
  91. {==============================================================================}
  92. function LeftStr(const S: string; Count: integer): string;
  93. function RightStr(const S: string; Count: integer): string;
  94. function BCDToInt(Value: integer): integer;
  95. {
  96. $Log$
  97. Revision 1.11 2002-01-24 18:33:58 peter
  98. * overload for lowercase()
  99. Revision 1.10 2002/01/24 12:33:54 jonas
  100. * adapted ranges of native types to int64 (e.g. high cardinal is no
  101. longer longint($ffffffff), but just $fffffff in psystem)
  102. * small additional fix in 64bit rangecheck code generation for 32 bit
  103. processors
  104. * adaption of ranges required the matching talgorithm used for selecting
  105. which overloaded procedure to call to be adapted. It should now always
  106. select the closest match for ordinal parameters.
  107. + inttostr(qword) in sysstr.inc/sysstrh.inc
  108. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  109. fixes were required to be able to add them)
  110. * is_in_limit() moved from ncal to types unit, should always be used
  111. instead of direct comparisons of low/high values of orddefs because
  112. qword is a special case
  113. Revision 1.9 2001/09/20 14:42:34 michael
  114. + Implemented missing StringReplace function
  115. Revision 1.6 2000/12/09 10:39:50 florian
  116. * fixed merging problem
  117. Revision 1.1.2.3 2001/09/20 14:35:34 michael
  118. Implemented missing StringReplace function
  119. Revision 1.1.2.2 2000/12/07 21:48:58 michael
  120. + Added LastDelimiter function
  121. Revision 1.1.2.1 2000/08/09 19:31:03 peter
  122. * int64 updates from Marco
  123. Revision 1.5 2000/12/07 21:58:30 michael
  124. + Merged lastdelimiter from fixbranch
  125. Revision 1.4 2000/08/13 17:55:38 michael
  126. + Added some missing functions needed for variant support
  127. Revision 1.3 2000/08/09 07:48:05 marco
  128. * Uncommented some int64 functions, now that int64 support is ok
  129. Revision 1.2 2000/07/13 11:33:51 michael
  130. + removed logs
  131. }