OSDN Git Service

・板一覧更新の処理メッセージを追加
[gikonavigoeson/gikonavi.git] / AbonInfo.pas
1 unit AbonInfo;
2
3 interface
4
5 uses
6   SysUtils;
7
8 type
9   TAbonType = (atStandard, stTransparent);
10   TCompType = (ctStandard, ctRegexp);
11   TTargetType = (ttAll, ttThread, ttBoard);
12
13   TLineInfo = class(TObject)
14   public
15     AbonType:   TAbonType;
16     CompType:   TCompType;
17     TargetType: TTargetType;
18     TargetBoard: String;
19     TargetThread: String;
20         constructor Create;
21     function ToString: String;
22     procedure Clear;
23     procedure Copy(const Src: TLineInfo);
24   end;
25
26   TAbonThread = class(TObject)
27   public
28     Is2ch:  Boolean;
29     Board:  String;
30     Thread: String;
31         constructor Create;
32     procedure Clear;
33     function IsTarget(Chk: String): Boolean;
34   end;
35
36 const
37     DEF_REGEXP:  String = '{{REGEXP}}';
38     DEF_THREAD:  String = '{{THREAD:';
39     DEF_BOARD:   String = '{{BOARD:';
40     DEF_END:     String = '}}';
41
42 implementation
43
44 constructor TAbonThread.Create;
45 begin
46     Is2ch := False;
47 end;
48
49 procedure TAbonThread.Clear;
50 begin
51     Is2ch  := False;
52     Board  := '';
53     Thread := '';
54 end;
55
56 function TAbonThread.IsTarget(Chk: String): Boolean;
57 var
58     Target: String;
59     EndPos: Integer;
60     CopyLen: Integer;
61     DefLen: Integer;
62 begin
63     EndPos := AnsiPos(DEF_END, Chk);
64     if (EndPos < 1) then begin
65         Result := True;     // \8ew\92è\8c`\8e®\82Æ\88á\82¤\82Ì\82Å\91Î\8fÛ
66     end
67     else if (AnsiPos(DEF_BOARD, Chk) = 1) then begin
68         if (Is2ch = False) then begin
69             Result := False;     // 2ch\82Å\82È\82¢
70         end else begin
71             DefLen := Length(DEF_BOARD);
72             CopyLen := EndPos - DefLen - 1;
73             Target := Copy(Chk, DefLen + 1, CopyLen);
74             if (Target = Board) then
75                 Result := True      // \91Î\8fÛ\82Ì\94Â
76             else
77                 Result := False;    // \91Î\8fÛ\82Ì\94Â\82Å\82Í\82È\82¢
78         end;
79     end
80     else if (AnsiPos(DEF_THREAD, Chk) = 1) then begin
81         if (Is2ch = False) then begin
82             Result := False;     // 2ch\82Å\82È\82¢
83         end else begin
84             DefLen := Length(DEF_THREAD);
85             CopyLen := EndPos - DefLen - 1;
86             Target := Copy(Chk, DefLen + 1, CopyLen);
87             if (Target = Board + '/' + Thread) then
88                 Result := True      // \91Î\8fÛ\82Ì\83X\83\8c
89             else
90                 Result := False;    // \91Î\8fÛ\82Ì\83X\83\8c\82Å\82Í\82È\82¢
91         end;
92     end
93     else begin
94         Result := True;     // \8ew\92è\8c`\8e®\82Æ\88á\82¤\82Ì\82Å\91Î\8fÛ
95     end;
96 end;
97
98 constructor TLineInfo.Create;
99 begin
100     AbonType := atStandard;
101     CompType := ctStandard;
102     TargetType := ttAll;
103 end;
104
105 function TLineInfo.ToString: String;
106 var
107     dst: String;
108 begin
109     case AbonType of
110         atStandard:    dst := '\92Ê\8fí\82 \82Ú\81[\82ñ\81E';
111         stTransparent: dst := '\93§\96¾\82 \82Ú\81[\82ñ\81E';
112         else           dst := '\81E';
113     end;
114     case CompType of
115         ctStandard:    dst := dst + '\92Ê\8fí\94ä\8ar\81E';
116         ctRegexp:      dst := dst + '\90³\8bK\95\\8c»\81E';
117         else           dst := dst + '\81E';
118     end;
119     case TargetType of
120         ttAll:         dst := dst + '\91S\83X\83\8c\91Î\8fÛ';
121         ttThread:      dst := dst + '\83X\83\8c\8ew\92è';
122         ttBoard:       dst := dst + '\94Â\8ew\92è';
123     end;
124     Result := dst;
125 end;
126
127 procedure TLineInfo.Clear;
128 begin
129     AbonType     := atStandard;
130     CompType     := ctStandard;
131     TargetType   := ttAll;
132     TargetBoard  := '';
133     TargetThread := '';
134 end;
135
136 procedure TLineInfo.Copy(const Src: TLineInfo);
137 begin
138     AbonType     := Src.AbonType;
139     CompType     := Src.CompType;
140     TargetType   := Src.TargetType;
141     TargetBoard  := Src.TargetBoard;
142     TargetThread := Src.TargetThread;
143 end;
144
145 end.