PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

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