2
0

jsstringh.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2005 by Florian Klaempfl,
  4. member of the Free Pascal development team.
  5. This file implements support routines for Shortstrings with FPC/JVM
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. type
  13. TAnsiCharArray = array of ansichar;
  14. ShortstringClass = class sealed (JLObject,JLCloneable)
  15. public
  16. { "length byte" }
  17. curlen: byte;
  18. { length is always the maximum length of the string (so that even reads
  19. past the current length of the shortstring work, just like in regular
  20. shortstrings }
  21. fdata: TAnsiCharArray;
  22. public
  23. constructor Create(const arr: array of ansichar; maxlen: byte);overload;
  24. constructor Create(const arr: array of unicodechar; maxlen: byte);overload;
  25. constructor Create(const u: unicodestring; maxlen: byte);overload;
  26. constructor Create(const a: ansistring; maxlen: byte);overload;
  27. constructor Create(const s: shortstring; maxlen: byte);overload;
  28. constructor Create(ch: ansichar; maxlen: byte);overload;
  29. constructor Create(ch: unicodechar; maxlen: byte);overload;
  30. class function CreateEmpty(maxlen: byte): ShortstringClass; static;
  31. class function CreateFromLiteralStringBytes(const u: unicodestring): shortstring; static;
  32. procedure FpcDeepCopy(dest: ShortstringClass);
  33. procedure copyFromAnsiCharArray(const arr: array of ansichar; maxlen: byte);
  34. procedure setChar(index: jint; char: ansichar);
  35. function charAt(index: jint): ansichar;
  36. function toUnicodeString: unicodestring;
  37. function toAnsistring: ansistring;
  38. function toString: JLString; override;
  39. function clone: JLObject; override;
  40. // function concat(const a: shortstring): shortstring;
  41. // function concatmultiple(const arr: array of shortstring): shortstring;
  42. function length: jint;
  43. end;
  44. AnsiCharArrayClass = class sealed (JLObject)
  45. class function CreateFromLiteralStringBytes(const u: unicodestring): TAnsiCharArray; static;
  46. end;