/components/jcf2/ReadWrite/StringsReader.pas

http://github.com/graemeg/lazarus · Pascal · 84 lines · 33 code · 19 blank · 32 comment · 1 complexity · 8a5a896ba8f59c22861570012de2f295 MD5 · raw file

  1. unit StringsReader;
  2. {
  3. AFS 1 Jan 2003
  4. Attach the formatter to TStrings
  5. }
  6. {(*}
  7. (*------------------------------------------------------------------------------
  8. Delphi Code formatter source code
  9. The Original Code is StringsReader, released May 2003.
  10. The Initial Developer of the Original Code is Anthony Steele.
  11. Portions created by Anthony Steele are Copyright (C) 1999-2000 Anthony Steele.
  12. All Rights Reserved.
  13. Contributor(s): Anthony Steele.
  14. The contents of this file are subject to the Mozilla Public License Version 1.1
  15. (the "License"). you may not use this file except in compliance with the License.
  16. You may obtain a copy of the License at http://www.mozilla.org/NPL/
  17. Software distributed under the License is distributed on an "AS IS" basis,
  18. WITHOUT WARRANTY OF ANY KIND, either express or implied.
  19. See the License for the specific language governing rights and limitations
  20. under the License.
  21. Alternatively, the contents of this file may be used under the terms of
  22. the GNU General Public License Version 2 or later (the "GPL")
  23. See http://www.gnu.org/licenses/gpl.html
  24. ------------------------------------------------------------------------------*)
  25. {*)}
  26. {$I JcfGlobal.inc}
  27. interface
  28. uses
  29. { delphi }Classes,
  30. { local }CodeReader;
  31. type
  32. TStringsReader = class(TCodeReader)
  33. private
  34. { property implementation }
  35. FcInputStrings: TStrings;
  36. protected
  37. procedure ReadFromSource; override;
  38. public
  39. procedure Clear; override;
  40. property InputStrings: TStrings Read FcInputStrings Write FcInputStrings;
  41. end;
  42. implementation
  43. { TSTringsReader }
  44. procedure TStringsReader.Clear;
  45. begin
  46. inherited;
  47. FcInputStrings := nil;
  48. end;
  49. procedure TStringsReader.ReadFromSource;
  50. begin
  51. if fbHasRead then
  52. exit;
  53. // Open the file
  54. Assert((FcInputStrings <> nil), 'No source strings');
  55. fsSource := FcInputStrings.Text;
  56. fiSourceLength := Length(fsSource);
  57. fiReadIndex := 1;
  58. fiBufferLength := 1;
  59. fbHasRead := True;
  60. end;
  61. end.