jedidotnet-commits Mailing List for JEDI.NET (Page 7)
Status: Pre-Alpha
Brought to you by:
jedi_mbe
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(81) |
Jul
(7) |
Aug
(8) |
Sep
(2) |
Oct
|
Nov
(47) |
Dec
(30) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(32) |
Feb
|
Mar
(86) |
Apr
|
May
(1) |
Jun
(24) |
Jul
(4) |
Aug
(5) |
Sep
(4) |
Oct
|
Nov
|
Dec
(9) |
From: Marcel B. <jed...@us...> - 2005-01-22 17:59:58
|
Update of /cvsroot/jedidotnet/nunit/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25409/nunit/resources Added Files: Jedi.IO.IniFiles.resx Removed Files: Jedi.System.IniFiles.resx Log Message: * Renamed Jedi.System.IniFiles to Jedi.IO.IniFiles * Added Jedi.IO.IniFIles to Jedi.IO package * Renamed classes from *ConfigFile* to *IniFile* * renamed classes from InMemory* to Memory* --- Jedi.System.IniFiles.resx DELETED --- --- NEW FILE: Jedi.IO.IniFiles.resx --- <?xml version="1.0" encoding="utf-8" ?> <root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="ResMimeType"> <value>text/microsoft-resx</value> </resheader> <resheader name="Version"> <value>1.0.0.0</value> </resheader> <resheader name="Reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="Writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="initest"> <value>MyTestString=Abcdef ghij klmnop; 1+1=2 #a comment, or maybe not, depending on settings [Basics] UseKeyMapper=1 AutoWriteSettings=1 TestString=Just another test. EmptyString= [TempList] Count=3 Item1=Abc Item2=Def Item3=Ghi </value> </data> </root> |
From: Marcel B. <jed...@us...> - 2005-01-22 17:59:24
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25290/main/run Added Files: Jedi.IO.IniFiles.pas Removed Files: Jedi.System.IniFiles.pas Log Message: * Renamed Jedi.System.IniFiles to Jedi.IO.IniFiles * Added Jedi.IO.IniFIles to Jedi.IO package * Renamed classes from *ConfigFile* to *IniFile* * renamed classes from InMemory* to Memory* --- Jedi.System.IniFiles.pas DELETED --- --- NEW FILE: Jedi.IO.IniFiles.pas --- {--------------------------------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.System.IniFiles.pas, released on 2004-12-24. The Initial Developer of the Original Code is Marcel Bestebroer Portions created by Marcel Bestebroer are Copyright (C) 2004 Marcel Bestebroer All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the JEDI.NET home page, located at http://sf.net/projects/jedidotnet [...2023 lines suppressed...] SaveImpl(Writer, True, #0); end; procedure MemoryIniFile.Save(writer: TextWriter; commentChar: Char); begin SaveImpl(Writer, True, commentChar); end; procedure MemoryIniFile.Save(writer: TextWriter; emptyLineBetweenSections: Boolean); begin SaveImpl(writer, emptyLineBetweenSections, #0); end; procedure MemoryIniFile.Save(writer: TextWriter; commentChar: Char; emptyLineBetweenSections: Boolean); begin SaveImpl(writer, emptyLineBetweenSections, commentChar); end; {$ENDREGION} end. |
From: Marcel B. <jed...@us...> - 2005-01-22 17:59:24
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25290/main/assemblies Modified Files: Jedi.IO.bdsproj Jedi.IO.dpk Log Message: * Renamed Jedi.System.IniFiles to Jedi.IO.IniFiles * Added Jedi.IO.IniFIles to Jedi.IO package * Renamed classes from *ConfigFile* to *IniFile* * renamed classes from InMemory* to Memory* Index: Jedi.IO.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.IO.bdsproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Jedi.IO.bdsproj 22 Jan 2005 15:27:54 -0000 1.3 --- Jedi.IO.bdsproj 22 Jan 2005 17:59:14 -0000 1.4 *************** *** 175,178 **** --- 175,179 ---- <File FileName="..\run\Jedi.IO.Paths.pas" ContainerId="" ModuleName="Jedi.IO.Paths"/> <File FileName="..\run\Jedi.IO.FileOfRec.pas" ContainerId="" ModuleName="Jedi.IO.FileOfRec"/> + <File FileName="..\run\Jedi.IO.IniFiles.pas" ContainerId="" ModuleName="Jedi.IO.IniFiles"/> </FileList> </DelphiDotNet.Personality> Index: Jedi.IO.dpk =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.IO.dpk,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.IO.dpk 5 Dec 2004 15:04:01 -0000 1.2 --- Jedi.IO.dpk 22 Jan 2005 17:59:14 -0000 1.3 *************** *** 31,35 **** contains Jedi.IO.Paths in '..\run\Jedi.IO.Paths.pas', ! Jedi.IO.FileOfRec in '..\run\Jedi.IO.FileOfRec.pas'; [assembly: AssemblyTitle('Jedi.IO')] --- 31,36 ---- contains Jedi.IO.Paths in '..\run\Jedi.IO.Paths.pas', ! Jedi.IO.FileOfRec in '..\run\Jedi.IO.FileOfRec.pas', ! Jedi.IO.IniFiles in '..\run\Jedi.IO.IniFiles.pas'; [assembly: AssemblyTitle('Jedi.IO')] |
From: Marcel B. <jed...@us...> - 2005-01-22 15:31:50
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20006/nunit Modified Files: Nunit.Jedi.System.bdsproj Nunit.Jedi.System.dpk Log Message: Removed IniFiles related resources Index: Nunit.Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.dpk,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Nunit.Jedi.System.dpk 22 Jan 2005 15:12:36 -0000 1.4 --- Nunit.Jedi.System.dpk 22 Jan 2005 15:31:41 -0000 1.5 *************** *** 24,29 **** {$IMAGEBASE $400000} {$IMPLICITBUILD OFF} - {$R 'resources\Jedi.System.IniFiles.resources' 'resources\Jedi.System.IniFiles.resx'} - {%File '..\docs\Jedi.System.IniFiles.xml'} requires --- 24,27 ---- Index: Nunit.Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.bdsproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Nunit.Jedi.System.bdsproj 22 Jan 2005 15:12:36 -0000 1.4 --- Nunit.Jedi.System.bdsproj 22 Jan 2005 15:31:41 -0000 1.5 *************** *** 120,124 **** <Directories Name="PackageDLLOutputDir" Type="String">bin</Directories> <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> ! <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin;resources</Directories> <Directories Name="Packages" Type="String">System.XML.dll;System.Data.dll;Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> --- 120,124 ---- <Directories Name="PackageDLLOutputDir" Type="String">bin</Directories> <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> ! <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin</Directories> <Directories Name="Packages" Type="String">System.XML.dll;System.Data.dll;Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> *************** *** 171,175 **** </VersionInfoKeys> <FileList> - <File FileName="resources\Jedi.System.IniFiles.resx" ContainerId="ResXCompiler" ModuleName="Jedi.System.IniFiles"/> <File FileName="..\docs\Jedi.System.IniFiles.xml" ContainerId="File" ModuleName="Jedi.System.IniFiles"/> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> --- 171,174 ---- |
From: Marcel B. <jed...@us...> - 2005-01-22 15:29:32
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19344/main/run Modified Files: Jedi.System.Strings.pas Log Message: Corrected SourceInfo attribute Index: Jedi.System.Strings.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.System.Strings.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Jedi.System.Strings.pas 22 Jan 2005 15:04:39 -0000 1.3 --- Jedi.System.Strings.pas 22 Jan 2005 15:29:23 -0000 1.4 *************** *** 35,39 **** {$REGION 'Enumerations'} type ! [Flags, CVSSourceInfo('$Header$')] ExtractQuotedStringFlags = (Default = 0, IgnoreGarbage = 1, EndQuoteMandetory = 2); {$ENDREGION} --- 35,39 ---- {$REGION 'Enumerations'} type ! [Flags, JediSourceInfo('$Header$')] ExtractQuotedStringFlags = (Default = 0, IgnoreGarbage = 1, EndQuoteMandetory = 2); {$ENDREGION} *************** *** 41,45 **** {$REGION 'String utilities class'} type ! [CVSSourceInfo('$Header$')] StringUtils = class {$REGION 'TabSet class'} --- 41,45 ---- {$REGION 'String utilities class'} type ! [JediSourceInfo('$Header$')] StringUtils = class {$REGION 'TabSet class'} |
From: Marcel B. <jed...@us...> - 2005-01-22 15:28:53
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19189/main/run Modified Files: Jedi.Drawing.Colors.pas Jedi.IO.FileOfRec.pas Jedi.IO.Paths.pas Log Message: Added SourceInfo attributes Index: Jedi.IO.Paths.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.IO.Paths.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.IO.Paths.pas 5 Dec 2004 13:19:48 -0000 1.1 --- Jedi.IO.Paths.pas 22 Jan 2005 15:28:45 -0000 1.2 *************** *** 26,37 **** --- 26,42 ---- interface + uses + Jedi.System; + {$REGION 'Path manipulations'} type CharArray = array of Char; + [JediSourceInfo('$Header$')] Path = class {$REGION 'PathConfig'} public type + [JediSourceInfo('$Header$')] PathConfig = class strict private *************** *** 76,79 **** --- 81,85 ---- end; + [JediSourceInfo('$Header$')] PathException = class (SystemException) end; *************** *** 86,91 **** System.Collections, System.IO, ! System.Text, ! Jedi.System; {$ENDREGION} --- 92,96 ---- System.Collections, System.IO, ! System.Text; {$ENDREGION} Index: Jedi.IO.FileOfRec.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.IO.FileOfRec.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.IO.FileOfRec.pas 10 Dec 2004 11:58:23 -0000 1.2 --- Jedi.IO.FileOfRec.pas 22 Jan 2005 15:28:45 -0000 1.3 *************** *** 29,33 **** uses System.IO, ! System.Reflection; {$ENDREGION} --- 29,34 ---- uses System.IO, ! System.Reflection, ! Jedi.System; {$ENDREGION} *************** *** 40,43 **** --- 41,45 ---- /// </summary> + [JediSourceInfo('$Header$')] StoredExtended = record private *************** *** 73,76 **** --- 75,79 ---- {$REGION 'FileOfRecord = class(System.Object)'} + [JediSourceInfo('$Header$')] EFileOfRecordError = class(Exception); /// <summary> *************** *** 81,84 **** --- 84,88 ---- /// type must be changed into StoredExtended. /// </limitation> + [JediSourceInfo('$Header$')] FileOfRecord = class(System.Object) strict private Index: Jedi.Drawing.Colors.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.Drawing.Colors.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.Drawing.Colors.pas 5 Dec 2004 13:19:48 -0000 1.1 --- Jedi.Drawing.Colors.pas 22 Jan 2005 15:28:45 -0000 1.2 *************** *** 28,36 **** {$REGION 'interface uses'} uses ! System.Drawing; {$ENDREGION} {$REGION 'Color related'} type ColorUtils = class sealed (System.Object) public --- 28,38 ---- {$REGION 'interface uses'} uses ! System.Drawing, ! Jedi.System.SourceVersioning; {$ENDREGION} {$REGION 'Color related'} type + [JediSourceInfo('$Header$')] ColorUtils = class sealed (System.Object) public |
From: Marcel B. <jed...@us...> - 2005-01-22 15:28:03
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18986/main/assemblies Modified Files: Jedi.Drawing.bdsproj Jedi.Drawing.dpk Jedi.IO.bdsproj Log Message: Added SourceInfo attributes Index: Jedi.Drawing.dpk =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.Drawing.dpk,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Jedi.Drawing.dpk 5 Dec 2004 13:19:48 -0000 1.3 --- Jedi.Drawing.dpk 22 Jan 2005 15:27:54 -0000 1.4 *************** *** 27,31 **** requires Borland.Delphi, ! System.Drawing; contains --- 27,32 ---- requires Borland.Delphi, ! System.Drawing, ! Jedi.System; contains Index: Jedi.Drawing.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.Drawing.bdsproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Jedi.Drawing.bdsproj 5 Dec 2004 13:19:47 -0000 1.5 --- Jedi.Drawing.bdsproj 22 Jan 2005 15:27:54 -0000 1.6 *************** *** 172,176 **** <FileList> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="Borland.Delphi" Version="9.0.1761.24408" LinkUnits="False"/> ! <File FileName="System.Drawing.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Drawing" AssemblyName="System.Drawing" Version="1.0.5000.0" LinkUnits="False"/> <File FileName="..\run\Jedi.Drawing.Colors.pas" ContainerId="" ModuleName="Jedi.Drawing.Colors"/> </FileList> --- 172,177 ---- <FileList> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="Borland.Delphi" Version="9.0.1761.24408" LinkUnits="False"/> ! <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Drawing.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Drawing" AssemblyName="System.Drawing" Version="1.0.5000.0" LinkUnits="False"/> ! <File FileName="..\bin\Jedi.System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.System" AssemblyName="Jedi.System" Version="1.0.0.0" LinkUnits="False"/> <File FileName="..\run\Jedi.Drawing.Colors.pas" ContainerId="" ModuleName="Jedi.Drawing.Colors"/> </FileList> Index: Jedi.IO.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.IO.bdsproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.IO.bdsproj 5 Dec 2004 15:04:01 -0000 1.2 --- Jedi.IO.bdsproj 22 Jan 2005 15:27:54 -0000 1.3 *************** *** 45,51 **** <Compiler Name="ShowHints">True</Compiler> <Compiler Name="ShowWarnings">True</Compiler> ! <Compiler Name="UnitAliases">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.Strings;Jedi.Collections=Jedi.Collections.InlineEditable</Compiler> <Compiler Name="NamespacePrefix"></Compiler> ! <Compiler Name="GenerateDocumentation">False</Compiler> <Compiler Name="DefaultNamespace"></Compiler> <Compiler Name="SymbolDeprecated">True</Compiler> --- 45,51 ---- <Compiler Name="ShowHints">True</Compiler> <Compiler Name="ShowWarnings">True</Compiler> ! <Compiler Name="UnitAliases">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.Strings, Jedi.System.SourceVersioning;Jedi.Collections=Jedi.Collections.InlineEditable</Compiler> <Compiler Name="NamespacePrefix"></Compiler> ! <Compiler Name="GenerateDocumentation">True</Compiler> <Compiler Name="DefaultNamespace"></Compiler> <Compiler Name="SymbolDeprecated">True</Compiler> *************** *** 170,178 **** <VersionInfoKeys Name="Comments"></VersionInfoKeys> </VersionInfoKeys> - - - - - <FileList> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> --- 170,173 ---- |
From: Marcel B. <jed...@us...> - 2005-01-22 15:13:02
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14975/nunit/source Modified Files: Jedi.System.Strings.NUnit.pas Added Files: Jedi.System.SourceVersioning.NUnit.pas Log Message: * Added Jedi.System.SourceVersioning test-sets * Update Jedi.System.Strings test-sets to include escaped-string tests. --- NEW FILE: Jedi.System.SourceVersioning.NUnit.pas --- unit Jedi.System.SourceVersioning.NUnit; interface {$REGION 'interface uses'} uses Jedi.System.SourceVersioning, NUnit.Framework; {$ENDREGION} {$REGION 'Attribute test-set'} type [TestFixture] Attributes = class {$REGION 'Constructor'} strict private class constructor Create; {$ENDREGION} {$REGION 'BaseAttribute test cases'} strict protected const BaseTest1SourceIn = 'dummy/TestFile.cs'; const BaseTest1Revision = '1.0.3'; const BaseTest1Date: DateTime = DateTime.Create(2003, 3, 16, 19, 12, 34, 0); const BaseTest2SourceIn = 'dummy\TestFile2.vb'; const BaseTest2Revision = '1.1'; const BaseTest2Date: DateTime = DateTime.Create(2003, 11, 23, 23, 45, 12, 0); class var BaseTest1SourceOut: string; class var BaseTest2SourceOut: string; {$ENDREGION} {$REGION 'CVSBasedAttribute test cases'} strict protected const CVSBasedTest1SourceBase = 'TestFile3.pas'; const CVSBasedTest1SourceIn = '$' + 'RCSfile: ' + CVSBasedTest1SourceBase + ',v $'; const CVSBasedTest1RevisionIn = '$' + 'Revision: 1.19 $'; const CVSBasedTest1RevisionOut: Revision = 1.19; const CVSBasedTest1DateIn = '$' + 'Date: 2004/10/23 10:04:23 $'; const CVSBasedTest1DateOut: DateTime = DateTime.Create(2004, 10, 23, 10, 4, 23, 0); const CVSBasedTest2SourceBase = '/cvsroot/dir1/dir2/dir3/dir4/TestFile4.inc'; const CVSBasedTest2SourceIn = '$' + 'Source: ' + CVSBasedTest2SourceBase + ',v $'; const CVSBasedTest2RevisionIn = '$' + 'Revision: 1.1.3.1 $'; const CVSBasedTest2RevisionOut: Revision = '1.1.3.1'; const CVSBasedTest2DateIn = '$' + 'Date: 2002/01/01 00:01:03 $'; const CVSBasedTest2DateOut: DateTime = DateTime.Create(2002, 1, 1, 0, 1, 3, 0); const CVSBasedTest3Id = '$' + 'Id: ' + CVSBasedTest1SourceBase + ',v 1.19 2004/10/23 10:04:23 dummy_user Exp $'; const CVSBasedTest4Id = '$' + 'Header: ' + CVSBasedTest2SourceBase + ',v 1.1.3.1 2002/01/01 00:01:03 ' + 'dummy_user Exp $'; class var CVSBasedTest1SourceOut: string; class var CVSBasedTest2SourceOut: string; class var CVSBasedTest2SourceOut1: string; class var CVSBasedTest2SourceOut2: string; class var CVSBasedTest2SourceOut3: string; {$ENDREGION} {$REGION 'JediBasedAttribute test cases'} strict protected const JediCommonRoot = '/cvsroot/jedidotnet/'; const JediTestSourcePath = 'main/run/'; const JediTestSourceFile = 'Jedi.System.SourceVersioning.pas'; const JediTestRevisionIn = '$' + 'Revision: 1.0 $'; const JediTestRevisionOut: Revision = '1.0'; const JediTestDateIn = '$' + 'Date: 2005/01/01 04:56:58 $'; const JediTestDateOut: DateTime = DateTime.Create(2005, 1, 1, 4, 56, 58); const JediBasedTest1Id = '$' + 'Id: ' + JediTestSourceFile + ',v 1.0 2005/01/01 04:56:58 dummy_user Exp $'; const JediBasedTest2Id = '$' + 'Header: ' + JediCommonRoot + JediTestSourcePath + JediTestSourceFile + ',v 1.0 2005/01/01 04:56:58 dummy_user Exp $'; const JediBasedTest3SourceIn = '$' + 'RCSFile: ' + JediTestSourceFile + ',v $'; const JediBasedTest4SourceIn = '$' + 'Source: ' + JediCommonRoot + JediTestSourcePath + JediTestSourceFile + ',v$'; class var JediBasedTest2SourceOut: string; {$ENDREGION} {$REGION 'Tests'} public [Test] procedure BaseAttribute; [Test] procedure CVSBasedAttribute; [Test] procedure JediBasedAttribute; {$ENDREGION} end; {$ENDREGION} {$REGION 'Revision test-set'} type [TestFixture] RevisionStruct = class {$REGION 'Tests'} public [Test] procedure Conversions; [Test] procedure Comparisons; {$ENDREGION} end; {$ENDREGION} {$REGION 'SourceInfo test-set'} type [TestFixture] [SourceInfoAttribute('nunit\source\Jedi.System.SourceVersioning.NUnit.pas', '1.0.1', '2005/01/22 14:08:10')] SourceInfoClass = class public {$REGION 'Tests'} [Test] procedure AtLeast; [Test] procedure Retrieval; {$ENDREGION} end; {$ENDREGION} implementation {$REGION 'implementtion uses'} uses System.IO; {$ENDREGION} {$REGION 'Attributes'} class constructor Attributes.Create; begin BaseTest1SourceOut := BaseTest1SourceIn.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); BaseTest2SourceOut := BaseTest2SourceIn.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); CVSBasedTest1SourceOut := CVSBasedTest1SourceBase.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); CVSBasedTest2SourceOut := CVSBasedTest2SourceBase.SubString(1).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); CVSBasedTest2SourceOut1 := CVSBasedTest2SourceOut.Substring(CVSBasedTest2SourceOut.IndexOf(Path.DirectorySeparatorChar) + 1); CVSBasedTest2SourceOut2 := CVSBasedTest2SourceOut1.Substring(CVSBasedTest2SourceOut1.IndexOf(Path.DirectorySeparatorChar) + 1); CVSBasedTest2SourceOut3 := CVSBasedTest2SourceOut2.Substring(CVSBasedTest2SourceOut2.IndexOf(Path.DirectorySeparatorChar) + 1); JediBasedTest2SourceOut := JediTestSourcePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar) + JediTestSourceFile; end; procedure Attributes.BaseAttribute; var attr: SourceInfoAttribute; begin attr := SourceInfoAttribute.Create(BaseTest1SourceIn, BaseTest1Revision, BaseTest1Date); Assert.AreEqual(BaseTest1SourceOut, attr.SourceFile, 'Test1.SourceFile'); Assert.AreEqual(Revision(BaseTest1Revision), attr.Revision, 'Test1.Revision'); Assert.AreEqual(BaseTest1Date, attr.Date, 'Test1.Date'); attr := SourceInfoAttribute.Create(BaseTest2SourceIn, BaseTest2Revision, BaseTest2Date); Assert.AreEqual(BaseTest2SourceOut, attr.SourceFile, 'Test2.SourceFile'); Assert.AreEqual(Revision(BaseTest2Revision), attr.Revision, 'Test2.Revision'); Assert.AreEqual(BaseTest2Date, attr.Date, 'Test2.Date'); end; procedure Attributes.CVSBasedAttribute; var attr: SourceInfoAttribute; begin attr := CVSSourceInfoAttribute.Create(CVSBasedTest1SourceIn, CVSBasedTest1RevisionIn, CVSBasedTest1DateIn); Assert.AreEqual(CVSBasedTest1SourceOut, attr.SourceFile, 'Test1.SourceFile'); Assert.AreEqual(CVSBasedTest1RevisionOut, attr.Revision, 'Test1.Revision'); Assert.AreEqual(CVSBasedTest1DateOut, attr.Date, 'Test1.Date'); attr := CVSSourceInfoAttribute.Create(CVSBasedTest2SourceIn, CVSBasedTest2RevisionIn, CVSBasedTest2DateIn); Assert.AreEqual(CVSBasedTest2SourceOut, attr.SourceFile, 'Test2.SourceFile'); Assert.AreEqual(CVSBasedTest2RevisionOut, attr.Revision, 'Test2.Revision'); Assert.AreEqual(CVSBasedTest2DateOut, attr.Date, 'Test2.Date'); attr := CVSSourceInfoAttribute.Create(CVSBasedTest2SourceIn, CVSBasedTest2RevisionIn, CVSBasedTest2DateIn, 1); Assert.AreEqual(CVSBasedTest2SourceOut1, attr.SourceFile, 'Test2.SourceFile (ignore 1)'); attr := CVSSourceInfoAttribute.Create(CVSBasedTest2SourceIn, CVSBasedTest2RevisionIn, CVSBasedTest2DateIn, 2); Assert.AreEqual(CVSBasedTest2SourceOut2, attr.SourceFile, 'Test2.SourceFile (ignore 2)'); attr := CVSSourceInfoAttribute.Create(CVSBasedTest2SourceIn, CVSBasedTest2RevisionIn, CVSBasedTest2DateIn, 3); Assert.AreEqual(CVSBasedTest2SourceOut3, attr.SourceFile, 'Test2.SourceFile (ignore 3)'); attr := CVSSourceInfoAttribute.Create(CVSBasedTest3Id); Assert.AreEqual(CVSBasedTest1SourceOut, attr.SourceFile, 'Test3.SourceFile'); Assert.AreEqual(CVSBasedTest1RevisionOut, attr.Revision, 'Test3.Revision'); Assert.AreEqual(CVSBasedTest1DateOut, attr.Date, 'Test3.Date'); attr := CVSSourceInfoAttribute.Create(CVSBasedTest4Id); Assert.AreEqual(CVSBasedTest2SourceOut, attr.SourceFile, 'Test4.SourceFile'); Assert.AreEqual(CVSBasedTest2RevisionOut, attr.Revision, 'Test4.Revision'); Assert.AreEqual(CVSBasedTest2DateOut, attr.Date, 'Test4.Date'); attr := CVSSourceInfoAttribute.Create(CVSBasedTest4Id, 2); Assert.AreEqual(CVSBasedTest2SourceOut2, attr.SourceFile, 'Test4.SourceFile (ignore 2)'); end; procedure Attributes.JediBasedAttribute; var attr: SourceInfoAttribute; begin attr := JediSourceInfoAttribute.Create(JediBasedTest1Id); Assert.AreEqual(JediTestSourceFile, attr.SourceFile, 'Test1.SourceFile'); Assert.AreEqual(JediTestRevisionOut, attr.Revision, 'Test1.Revision'); Assert.AreEqual(JediTestDateOut, attr.Date, 'Test1.Date'); attr := JediSourceInfoAttribute.Create(JediBasedTest2Id); Assert.AreEqual(JediBasedTest2SourceOut, attr.SourceFile, 'Test2.SourceFile'); Assert.AreEqual(JediTestRevisionOut, attr.Revision, 'Test2.Revision'); Assert.AreEqual(JediTestDateOut, attr.Date, 'Test2.Date'); end; {$ENDREGION} {$REGION 'RevisionStruct'} procedure RevisionStruct.Conversions; var svr: Revision; s: string; d: double; begin svr := '1.3.2.4'; s := svr; d := svr; Assert.AreEqual(4, svr.Count, '''1.3.2.4'' Count'); Assert.AreEqual(1, svr[0], '''1.3.2.4'' Items[0]'); Assert.AreEqual(3, svr[1], '''1.3.2.4'' Items[1]'); Assert.AreEqual(2, svr[2], '''1.3.2.4'' Items[2]'); Assert.AreEqual(4, svr[3], '''1.3.2.4'' Items[3]'); Assert.AreEqual('1.3.2.4', svr.ToString, '''1.3.2.4'' ToString'); Assert.AreEqual('1.3.2.4', s, '''1.3.2.4'' Implicit conversion to string'); Assert.AreEqual('1.3.2.4', string(svr), '''1.3.2.4'' Explicit conversion to string'); Assert.IsTrue(System.Double.IsNaN(d), '''1.3.2.4'' Implicit conversion to float'); Assert.IsTrue(System.Double.IsNaN(Double(svr)), '''1.3.2.4'' Explicit conversion to float'); svr := 12.3; s := svr; d := svr; Assert.AreEqual(2, svr.Count, '12.3 Count'); Assert.AreEqual(12, svr[0], '12.3 Items[0]'); Assert.AreEqual(3, svr[1], '12.3 Items[1]'); Assert.AreEqual('12.3', svr.ToString, '12.3 ToString'); Assert.AreEqual('12.3', s, '12.3 Implicit conversion to string'); Assert.AreEqual('12.3', string(svr), '12.3 Explicit conversion to string'); Assert.AreEqual(12.3, d, '12.3 Implicit conversion to double'); Assert.AreEqual(12.3, Double(svr), '12.3 Explicit conversion to double'); end; procedure RevisionStruct.Comparisons; var svr1: Revision; svr2: Revision; begin svr1 := '1.1'; svr2 := 1.1; Assert.IsTrue(svr1 = svr2, '''1.1'' = 1.1'); Assert.IsFalse(svr1 <> svr2, '''1.1'' <> 1.1'); Assert.IsTrue(svr1 >= svr2, '''1.1'' >= 1.1'); Assert.IsFalse(svr1 > svr2, '''1.1'' > 1.1'); Assert.IsTrue(svr1 <= svr2, '''1.1'' <= 1.1'); Assert.IsFalse(svr1 < svr2, '''1.1'' < 1.1'); Assert.IsTrue(svr1.Equals(svr2), '''1.1'' Equals 1.1'); svr2 := 1.2; Assert.IsFalse(svr1 = svr2, '''1.1'' = 1.2'); Assert.IsTrue(svr1 <> svr2, '''1.1'' <> 1.2'); Assert.IsFalse(svr1 >= svr2, '''1.1'' >= 1.2'); Assert.IsFalse(svr1 > svr2, '''1.1'' > 1.2'); Assert.IsTrue(svr1 <= svr2, '''1.1'' <= 1.2'); Assert.IsTrue(svr1 < svr2, '''1.1'' < 1.2'); Assert.IsFalse(svr1.IsSubBranchOf(svr2), '''1.1'' IsSubBranchOf(1.2)'); Assert.IsFalse(svr2.IsSubBranchOf(svr1), '1.2 IsSubBranchOf(''1.1'')'); svr2 := '1.1.2'; Assert.IsFalse(svr1 = svr2, '''1.1'' = 1.1.2'); Assert.IsTrue(svr1 <> svr2, '''1.1'' <> 1.1.2'); Assert.IsFalse(svr1 >= svr2, '''1.1'' >= 1.1.2'); Assert.IsFalse(svr1 > svr2, '''1.1'' > 1.1.2'); Assert.IsTrue(svr1 <= svr2, '''1.1'' <= 1.1.2'); Assert.IsTrue(svr1 < svr2, '''1.1'' < 1.1.2'); Assert.IsFalse(svr1.IsSubBranchOf(svr2), '''1.1'' IsSubBranchOf(''1.1.2'')'); Assert.IsTrue(svr2.IsSubBranchOf(svr1), '''1.1.2'' IsSubBranchOf(''1.1'')'); svr2 := '1.0.2'; Assert.IsFalse(svr1 = svr2, '''1.1'' = 1.0.2'); Assert.IsTrue(svr1 <> svr2, '''1.1'' <> 1.0.2'); Assert.IsTrue(svr1 >= svr2, '''1.1'' >= 1.0.2'); Assert.IsTrue(svr1 > svr2, '''1.1'' > 1.0.2'); Assert.IsFalse(svr1 <= svr2, '''1.1'' <= 1.0.2'); Assert.IsFalse(svr1 < svr2, '''1.1'' < 1.0.2'); Assert.IsFalse(svr1.IsSubBranchOf(svr2), '''1.1'' IsSubBranchOf(''1.0.2'')'); Assert.IsFalse(svr2.IsSubBranchOf(svr1), '''1.0.2'' IsSubBranchOf(''1.1'')'); end; {$ENDREGION} {$REGION 'SourceInfoClass'} procedure SourceInfoClass.AtLeast; begin Assert.IsTrue(SourceInfo.IsAtLeastRevision(TypeOf(Revision), 1.0), 'Revision-type should be at least 1.0.'); Assert.IsTrue(SourceInfo.IsAtLeastRevision(Self, 1.0), 'Self should be at least 1.0.'); Assert.IsTrue(SourceInfo.IsAtLeastRevision(Self, '1.0.1'), 'Self should be at least 1.0.1.'); Assert.IsFalse(SourceInfo.IsAtLeastRevision(Self, 1.1), 'Self should not be at least 1.1.'); end; procedure SourceInfoClass.Retrieval; var si: SourceInfo; begin si := SourceInfo.GetInfoOf(TypeOf(Revision)); Assert.AreEqual('main' + Path.DirectorySeparatorChar + 'run' + Path.DirectorySeparatorChar + 'Jedi.System.SourceVersioning.pas', si.SourceFile, 'Revision''s SourceFile.'); si := SourceInfo.GetInfoOf(Self); Assert.AreEqual('nunit' + Path.DirectorySeparatorChar + 'source' + Path.DirectorySeparatorChar + 'Jedi.System.SourceVersioning.NUnit.pas', si.SourceFile, 'SourceFile of Self'); Assert.AreEqual(Revision('1.0.1'), si.Revision, 'Revision of Self'); Assert.AreEqual(DateTime.Create(2005, 1, 22, 14, 8, 10), si.Date, 'Date of Self'); si := SourceInfo.GetInfoOf(TypeOf(DateTime)); Assert.IsNotNull(si, 'SourceInfo on DateTime returned nil.'); Assert.AreEqual('', si.SourceFile, 'DateTime''s SourceFile.'); Assert.AreEqual(Revision(0.0), si.Revision, 'DateTime''s Revision.'); Assert.AreEqual(DateTime.Create(0), si.Date, 'DateTime''s Date.'); end; {$ENDREGION} end. Index: Jedi.System.Strings.NUnit.pas =================================================================== RCS file: /cvsroot/jedidotnet/nunit/source/Jedi.System.Strings.NUnit.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.System.Strings.NUnit.pas 6 Dec 2004 11:44:09 -0000 1.1 --- Jedi.System.Strings.NUnit.pas 22 Jan 2005 15:12:37 -0000 1.2 *************** *** 10,20 **** [TestFixture] TabSet = class strict protected TabSet1: StringUtils.TabSet; TabSet2: StringUtils.TabSet; TabSet3: StringUtils.TabSet; public - [TestFixtureSetUp] - procedure Init; [Test] procedure SimpleTabulation; [Test] procedure SpecifiedTabsWithAutoDefault; --- 10,25 ---- [TestFixture] TabSet = class + {$REGION 'Test data'} strict protected TabSet1: StringUtils.TabSet; TabSet2: StringUtils.TabSet; TabSet3: StringUtils.TabSet; + {$ENDREGION} + {$REGION 'SetUp/TearDown methods'} + public + [TestFixtureSetUp] + procedure Init; + {$ENDREGION} public [Test] procedure SimpleTabulation; [Test] procedure SpecifiedTabsWithAutoDefault; *************** *** 28,31 **** --- 33,37 ---- [TestFixture] QuotedStrings = class + {$REGION 'Test constants'} strict protected const sSimpleTest = 'This is a simple test string.'; *************** *** 47,50 **** --- 53,57 ---- 'should always result in the roundtrip, regardless of actual used ' + 'quotation charachter. Scary combinations: ''''abc'''' and """"def"""""'; + {$ENDREGION} public [Test] procedure QuoteComplexString; *************** *** 71,74 **** --- 78,82 ---- [TestFixture] Substrings = class + {$REGION 'After*/Before* test constants'} strict protected const sDelimTest = '|Abc(def){ghi}.jkl;mno=(pqr){stu}.vwx;yz|'; *************** *** 99,104 **** const sDelimTestAfterDot = 'vwx;yz|'; const sDelimTestAfterSemiColon = 'yz|'; ! const sSliceTest = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; public [Test] procedure AfterSingleDelimiter; --- 107,115 ---- const sDelimTestAfterDot = 'vwx;yz|'; const sDelimTestAfterSemiColon = 'yz|'; ! {$ENDREGION} ! {$REGION 'Left/Mid/Right test constants'} ! strict protected const sSliceTest = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + {$ENDREGION} public [Test] procedure AfterSingleDelimiter; *************** *** 117,120 **** --- 128,132 ---- [TestFixture] Manipulations = class + {$REGION 'Tab expansion test constants'} strict protected const sTabTest1 = 'Abc'#9'Def Ghi'#9'Jkl'#9#9'Mno'#9#9#9'Pqr'; *************** *** 128,134 **** --- 140,150 ---- const sTabTest2Output2 = ' Abc Def Ghi Jkl Mno Pqr'; const sTabTest2Output3 = ' Abc Def Ghi Jkl Mno Pqr'; + {$ENDREGION} + {$REGION 'Duplicate removal test constants'} strict protected const sTest1 = '***abc***def***ghi***'; const sTest1Output = '*abc*def*ghi*'; + {$ENDREGION} + {$REGION 'String repetition test constants'} strict protected const sRepeatInput = 'ab(cd)ef'; *************** *** 136,139 **** --- 152,156 ---- const sRepeatOutput1 = 'ab(cd)ef'; const sRepeatOutput10 = 'ab(cd)efab(cd)efab(cd)efab(cd)efab(cd)efab(cd)efab(cd)efab(cd)efab(cd)efab(cd)ef'; + {$ENDREGION} public [Test] procedure ExpandTabs; *************** *** 142,321 **** end; ! implementation ! {$REGION 'TabSet'} ! procedure TabSet.ConvertToString; ! begin ! Assert.AreEqual('[] and every 2', TabSet1.ToString, 'TabSet1.ToString'); ! Assert.AreEqual('[15,20,40,44] and every 4 (automatic)', TabSet2.ToString, 'TabSet2.ToString'); ! Assert.AreEqual('[15,20,40,44] and every 2', TabSet3.ToString, 'TabSet3.ToString'); ! Assert.AreEqual('[] and every 2 (automatic)', StringUtils.TabSet.Create.ToString, ! 'StringUtils.TabSet.Create.ToString'); ! Assert.AreEqual('every 2 (automatic)', StringUtils.TabSet.Create.ToString(True, False, True), ! 'StringUtils.TabSet.Create.ToString(true, false, true)'); ! Assert.AreEqual('15,20,40,44', TabSet2.ToString(False, False, False), 'TabSet2.ToString(false, false, false)'); ! end; ! procedure TabSet.Init; begin ! TabSet1 := StringUtils.TabSet.Create(2); ! TabSet2 := StringUtils.TabSet.Create([15, 20, 40, 44]); ! TabSet3 := StringUtils.TabSet.Create([15, 20, 40, 44], 2); end; ! procedure TabSet.SimpleTabulation; begin ! // TabSet1 should always tabulate to even positions ! Assert.AreEqual(TabSet1.TabFrom(1), 2); ! Assert.AreEqual(TabSet1.TabFrom(2), 4); ! Assert.AreEqual(TabSet1.TabFrom(3), 4); ! Assert.AreEqual(TabSet1.TabFrom(51), 52); ! Assert.AreEqual(TabSet1.TabFrom(52), 54); end; ! procedure TabSet.SpecifiedTabsWithAutoDefault; var ! i: Integer; begin ! // TabSet2 will tabulate to 15, 20, 40 and 44. Beyond that it will tabulate to a multiple of 4 (44-40) ! for i := 0 to 14 do ! Assert.AreEqual(TabSet2.TabFrom(i), 15, 'Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(TabSet2.TabFrom(i), 20, 'Tabulate from {0}', [i]); ! for i := 20 to 39 do ! Assert.AreEqual(TabSet2.TabFrom(i), 40, 'Tabulate from {0}', [i]); ! for i := 40 to 43 do ! Assert.AreEqual(TabSet2.TabFrom(i), 44, 'Tabulate from {0}', [i]); ! for i := 44 to 47 do ! Assert.AreEqual(TabSet2.TabFrom(i), 48, 'Tabulate from {0}', [i]); ! for i := 48 to 51 do ! Assert.AreEqual(TabSet2.TabFrom(i), 52, 'Tabulate from {0}', [i]); end; ! procedure TabSet.SpecifiedTabsWithDefault; ! var ! i: Integer; begin ! // TabSet2 will tabulate to 15, 20, 40 and 44. Beyond that it will tabulate to a multiple of 2 ! for i := 0 to 14 do ! Assert.AreEqual(TabSet3.TabFrom(i), 15, 'Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(TabSet3.TabFrom(i), 20, 'Tabulate from {0}', [i]); ! for i := 20 to 39 do ! Assert.AreEqual(TabSet3.TabFrom(i), 40, 'Tabulate from {0}', [i]); ! for i := 40 to 43 do ! Assert.AreEqual(TabSet3.TabFrom(i), 44, 'Tabulate from {0}', [i]); ! for i := 44 to 45 do ! Assert.AreEqual(TabSet3.TabFrom(i), 46, 'Tabulate from {0}', [i]); ! for i := 46 to 47 do ! Assert.AreEqual(TabSet3.TabFrom(i), 48, 'Tabulate from {0}', [i]); ! for i := 48 to 49 do ! Assert.AreEqual(TabSet3.TabFrom(i), 50, 'Tabulate from {0}', [i]); ! for i := 50 to 51 do ! Assert.AreEqual(TabSet3.TabFrom(i), 52, 'Tabulate from {0}', [i]); end; ! procedure TabSet.CloneAndEqual; ! var ! tempSet: StringUtils.TabSet; begin ! tempSet := StringUtils.TabSet(TabSet1.Clone); ! Assert.AreNotSame(TabSet1, tempSet); ! Assert.AreEqual(TabSet1, tempSet, 'Cloned'); ! tempSet.Add(2); ! Assert.AreEqual(TabSet1, tempSet, 'TabPos=[2], DefaultWidth=2'); ! tempSet.DefaultWidth := 0; ! Assert.AreEqual(TabSet1, tempSet, 'TabPos=[2], DefaultWidth=0 (automatic)'); ! tempSet.Add(4); ! Assert.AreEqual(TabSet1, tempSet, 'TabPos=[2,4], DefaultWidth=0 (automatic)'); ! tempSet.Clear; ! Assert.AreEqual(TabSet1, tempSet, 'TabPos=[], DefaultWidth=0 (automatic)'); end; ! procedure TabSet.RemovingTabs; var ! tempSet: StringUtils.TabSet; ! i: Integer; begin ! tempSet := StringUtils.TabSet(TabSet2.Clone); ! tempSet.Remove(20); ! for i := 0 to 14 do ! Assert.AreEqual(tempSet.TabFrom(i), 15, 'Removed 20; Tabulate from {0}', [i]); ! for i := 15 to 39 do ! Assert.AreEqual(tempSet.TabFrom(i), 40, 'Removed 20; Tabulate from {0}', [i]); ! for i := 40 to 43 do ! Assert.AreEqual(tempSet.TabFrom(i), 44, 'Removed 20; Tabulate from {0}', [i]); ! for i := 44 to 47 do ! Assert.AreEqual(tempSet.TabFrom(i), 48, 'Removed 20; Tabulate from {0}', [i]); ! for i := 48 to 51 do ! Assert.AreEqual(tempSet.TabFrom(i), 52, 'Removed 20; Tabulate from {0}', [i]); ! for i := 52 to 55 do ! Assert.AreEqual(tempSet.TabFrom(i), 56, 'Removed 20; Tabulate from {0}', [i]); ! for i := 56 to 59 do ! Assert.AreEqual(tempSet.TabFrom(i), 60, 'Removed 20; Tabulate from {0}', [i]); ! tempSet := StringUtils.TabSet(TabSet2.Clone); ! tempSet.Remove(40); ! for i := 0 to 14 do ! Assert.AreEqual(tempSet.TabFrom(i), 15, 'Removed 40; Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(tempSet.TabFrom(i), 20, 'Removed 40; Tabulate from {0}', [i]); ! for i := 20 to 43 do ! Assert.AreEqual(tempSet.TabFrom(i), 44, 'Removed 40; Tabulate from {0}', [i]); ! for i := 44 to 67 do ! Assert.AreEqual(tempSet.TabFrom(i), 68, 'Removed 40; Tabulate from {0}', [i]); ! for i := 68 to 91 do ! Assert.AreEqual(tempSet.TabFrom(i), 92, 'Removed 40; Tabulate from {0}', [i]); ! for i := 92 to 115 do ! Assert.AreEqual(tempSet.TabFrom(i), 116, 'Removed 40; Tabulate from {0}', [i]); ! for i := 116 to 139 do ! Assert.AreEqual(tempSet.TabFrom(i), 140, 'Removed 40; Tabulate from {0}', [i]); ! tempSet := StringUtils.TabSet(TabSet2.Clone); ! tempSet.Remove(40, True); ! for i := 0 to 14 do ! Assert.AreEqual(tempSet.TabFrom(i), 15, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(tempSet.TabFrom(i), 20, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 20 to 24 do ! Assert.AreEqual(tempSet.TabFrom(i), 25, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 25 to 29 do ! Assert.AreEqual(tempSet.TabFrom(i), 30, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 30 to 34 do ! Assert.AreEqual(tempSet.TabFrom(i), 35, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 35 to 39 do ! Assert.AreEqual(tempSet.TabFrom(i), 40, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 40 to 44 do ! Assert.AreEqual(tempSet.TabFrom(i), 45, 'Removed 40+; Tabulate from {0}', [i]); end; ! procedure TabSet.AddingTabs; ! var ! tempSet: StringUtils.TabSet; ! tempSet2: StringUtils.TabSet; ! i: Integer; begin ! tempSet := StringUtils.TabSet(TabSet2.Clone); ! tempSet.Add(42); ! for i := 0 to 14 do ! Assert.AreEqual(tempSet.TabFrom(i), 15, 'Added 42; Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(tempSet.TabFrom(i), 20, 'Added 42; Tabulate from {0}', [i]); ! for i := 20 to 39 do ! Assert.AreEqual(tempSet.TabFrom(i), 40, 'Added 42; Tabulate from {0}', [i]); ! for i := 40 to 41 do ! Assert.AreEqual(tempSet.TabFrom(i), 42, 'Added 42; Tabulate from {0}', [i]); ! for i := 42 to 43 do ! Assert.AreEqual(tempSet.TabFrom(i), 44, 'Added 42; Tabulate from {0}', [i]); ! for i := 44 to 45 do ! Assert.AreEqual(tempSet.TabFrom(i), 46, 'Added 42; Tabulate from {0}', [i]); ! for i := 46 to 47 do ! Assert.AreEqual(tempSet.TabFrom(i), 48, 'Added 42; Tabulate from {0}', [i]); ! for i := 48 to 49 do ! Assert.AreEqual(tempSet.TabFrom(i), 50, 'Added 42; Tabulate from {0}', [i]); ! for i := 50 to 51 do ! Assert.AreEqual(tempSet.TabFrom(i), 52, 'Added 42; Tabulate from {0}', [i]); ! tempSet2 := StringUtils.TabSet.Create([40, 20, 15], 2); ! Assert.AreEqual(tempSet2, tempSet); end; {$ENDREGION} --- 159,361 ---- end; ! [TestFixture] ! EscapedStrings = class ! {$REGION 'Test constants'} ! strict protected ! const sTest1Input = 'This string has a newline'#10'and ends with a null character'#0; ! const sTest1Output = 'This string has a newline\nand ends with a null character\0'; ! const sTest2Input = 'This string has a backslash (\) character inside.'; ! const sTest2Output = 'This string has a backslash (\\) character inside.'; ! const sTest3Input = 'This string has a null character, followed by the digit 7: '#0'7.'; ! const sTest3Output = 'This string has a null character, followed by the digit 7: \0007.'; ! const sTest4Input = 'This string has a null character, followed by the digit 8: '#0'8.'; ! const sTest4Output = 'This string has a null character, followed by the digit 8: \08.'; ! const sTest5Input = 'Several ASCII codes below the space (ordinal 32 or 20 hex):'#1#2#4#27; ! const sTest5Output = 'Several ASCII codes below the space (ordinal 32 or 20 hex):\x01\x02\x04\x1b'; ! {$ENDREGION} ! public ! [Test] procedure Escape; ! [Test] procedure ParseEscapedString; ! end; ! [TestFixture] ! NumericConversions = class ! {$REGION 'IntToHex test constants'} ! strict protected ! const IntHex1Input = 255; ! const IntHex1Output = 'ff'; ! const IntHex1OutputByte = 'ff'; ! const IntHex1OutputFixed = '000000ff'; ! const IntHex2Input = 256; ! const IntHex2Output = '100'; ! const IntHex2OutputByte = '0100'; ! const IntHex2OutputFixed = '00000100'; ! const IntHex3Input = -1; ! const IntHex3Output = 'ffffffff'; ! const IntHex3OutputByte = 'ffffffff'; ! const IntHex3OutputFixed = 'ffffffff'; ! {$ENDREGION} ! {$REGION 'HexToInt test constants'} ! strict protected ! const HexInt1Input = 'ff'; ! const HexInt1InputMax = 'ffghijk'; ! const HexInt1CountMax = 2; ! const HexInt1InputLeads = '0000ffghjkl'; ! const HexInt1CountLeads = 6; ! const HexInt1Value = 255; ! const HexInt2Input = '100'; ! const HexInt2InputMax = '100ghijk'; ! const HexInt2CountMax = 3; ! const HexInt2InputLeads = '0000100ghjkl'; ! const HexInt2CountLeads = 7; ! const HexInt2Value = 256; ! const HexInt3Input = 'ffffFFFF'; ! const HexInt3InputMax = 'ffFFfFffghijk'; ! const HexInt3CountMax = 8; ! const HexInt3InputLeads = '0000ffFFFffFghjkl'; ! const HexInt3CountLeads = 12; ! const HexInt3Value = -1; ! {$ENDREGION} ! public ! [Test] procedure HexToInt; ! [Test] procedure IntToHex; ! end; ! implementation ! ! {$REGION 'EscapedStrings'} ! procedure EscapedStrings.Escape; begin ! Assert.AreEqual(sTest1Output, StringUtils.EscapeString(sTest1Input), 'Test1'); ! Assert.AreEqual(sTest2Output, StringUtils.EscapeString(sTest2Input), 'Test2'); ! Assert.AreEqual(sTest3Output, StringUtils.EscapeString(sTest3Input), 'Test3'); ! Assert.AreEqual(sTest4Output, StringUtils.EscapeString(sTest4Input), 'Test4'); ! Assert.AreEqual(sTest5Output, StringUtils.EscapeString(sTest5Input), 'Test5'); end; ! procedure EscapedStrings.ParseEscapedString; begin ! Assert.AreEqual(sTest1Input, StringUtils.ParseEscapedString(sTest1Output), 'Test1'); ! Assert.AreEqual(sTest2Input, StringUtils.ParseEscapedString(sTest2Output), 'Test2'); ! Assert.AreEqual(sTest3Input, StringUtils.ParseEscapedString(sTest3Output), 'Test3'); ! Assert.AreEqual(sTest4Input, StringUtils.ParseEscapedString(sTest4Output), 'Test4'); ! Assert.AreEqual(sTest5Input, StringUtils.ParseEscapedString(sTest5Output), 'Test5'); end; + {$ENDREGION} ! {$REGION 'Manipulations'} ! procedure Manipulations.ExpandTabs; var ! tabSet1: StringUtils.TabSet; ! tabSet2: StringUtils.TabSet; ! tabSet3: StringUtils.TabSet; begin ! tabSet1 := StringUtils.TabSet.Create(2); ! tabSet2 := StringUtils.TabSet.Create([15, 20, 40, 44]); ! tabSet3 := StringUtils.TabSet.Create([15, 20, 40, 44], 2); ! ! Assert.AreEqual(sTabTest1Output1, StringUtils.ExpandTabs(sTabTest1, tabSet1), 'sTabTest1Output1'); ! Assert.AreEqual(sTabTest2Output1, StringUtils.ExpandTabs(sTabTest2, tabSet1), 'sTabTest2Output1'); ! ! Assert.AreEqual(sTabTest1Output2, StringUtils.ExpandTabs(sTabTest1, tabSet2), 'sTabTest1Output2'); ! Assert.AreEqual(sTabTest2Output2, StringUtils.ExpandTabs(sTabTest2, tabSet2), 'sTabTest2Output2'); ! ! Assert.AreEqual(sTabTest1Output3, StringUtils.ExpandTabs(sTabTest1, tabSet3), 'sTabTest1Output3'); ! Assert.AreEqual(sTabTest2Output3, StringUtils.ExpandTabs(sTabTest2, tabSet3), 'sTabTest2Output3'); end; ! procedure Manipulations.RemoveDuplicates; begin ! Assert.AreEqual(sTest1Output, StringUtils.RemoveDuplicateChars(sTest1, '*'), 'sTest1'); end; ! procedure Manipulations.&Repeat; begin ! Assert.AreEqual(sRepeatOutput0, StringUtils.&Repeat(sRepeatInput, 0), 'Count=0'); ! Assert.AreEqual(sRepeatOutput1, StringUtils.&Repeat(sRepeatInput, 1), 'Count=1'); ! Assert.AreEqual(sRepeatOutput10, StringUtils.&Repeat(sRepeatInput, 10), 'Count=10'); end; + {$ENDREGION} ! {$REGION 'NumericConversions'} ! procedure NumericConversions.HexToInt; var ! digitsUsed: Integer; begin ! Assert.AreEqual( ! HexInt1Value, ! StringUtils.HexToInt(HexInt1Input), ! 'Test1, complete string'); ! Assert.AreEqual( ! HexInt1Value, ! StringUtils.HexToInt(HexInt1InputMax, HexInt1CountMax, False, digitsUsed), ! 'Test1, limit string.'); ! Assert.AreEqual( ! HexInt1CountMax, ! digitsUsed, ! 'Test1 digit count.'); ! Assert.AreEqual( ! HexInt1Value, ! StringUtils.HexToInt(HexInt1InputLeads, HexInt1CountMax, True, digitsUsed), ! 'Test1, limit string, ignore leading zeroes.'); ! Assert.AreEqual( ! HexInt1CountLeads, ! digitsUsed, ! 'Test1 digit count, ignoring leading zeroes.'); ! Assert.AreEqual( ! HexInt2Value, ! StringUtils.HexToInt(HexInt2Input), ! 'Test2, complete string'); ! Assert.AreEqual( ! HexInt2Value, ! StringUtils.HexToInt(HexInt2InputMax, HexInt2CountMax, False, digitsUsed), ! 'Test2, limit string.'); ! Assert.AreEqual( ! HexInt2CountMax, ! digitsUsed, ! 'Test2 digit count.'); ! Assert.AreEqual( ! HexInt2Value, ! StringUtils.HexToInt(HexInt2InputLeads, HexInt2CountMax, True, digitsUsed), ! 'Test2, limit string, ignore leading zeroes.'); ! Assert.AreEqual( ! HexInt2CountLeads, ! digitsUsed, ! 'Test2 digit count, ignoring leading zeroes.'); ! Assert.AreEqual( ! HexInt3Value, ! StringUtils.HexToInt(HexInt3Input), ! 'Test3, complete string'); ! Assert.AreEqual( ! HexInt3Value, ! StringUtils.HexToInt(HexInt3InputMax, HexInt3CountMax, False, digitsUsed), ! 'Test3, limit string.'); ! Assert.AreEqual( ! HexInt3CountMax, ! digitsUsed, ! 'Test3 digit count.'); ! Assert.AreEqual( ! HexInt3Value, ! StringUtils.HexToInt(HexInt3InputLeads, HexInt3CountMax, True, digitsUsed), ! 'Test3, limit string, ignore leading zeroes.'); ! Assert.AreEqual( ! HexInt3CountLeads, ! digitsUsed, ! 'Test3 digit count, ignoring leading zeroes.'); end; ! procedure NumericConversions.IntToHex; begin ! Assert.AreEqual(IntHex1Output, StringUtils.IntToHex(IntHex1Input), 'Test1, shortest.'); ! Assert.AreEqual(IntHex1OutputByte, StringUtils.IntToHex(IntHex1Input, True), 'Test1, shortest byte size.'); ! Assert.AreEqual(IntHex1OutputFixed, StringUtils.IntToHex(IntHex1Input, 8), 'Test1, fixed byte size.'); ! Assert.AreEqual(IntHex2Output, StringUtils.IntToHex(IntHex2Input), 'Test2, shortest.'); ! Assert.AreEqual(IntHex2OutputByte, StringUtils.IntToHex(IntHex2Input, True), 'Test2, shortest byte size.'); ! Assert.AreEqual(IntHex2OutputFixed, StringUtils.IntToHex(IntHex2Input, 8), 'Test2, fixed byte size.'); ! Assert.AreEqual(IntHex3Output, StringUtils.IntToHex(IntHex3Input), 'Test3, shortest.'); ! Assert.AreEqual(IntHex3OutputByte, StringUtils.IntToHex(IntHex3Input, True), 'Test3, shortest byte size.'); ! Assert.AreEqual(IntHex3OutputFixed, StringUtils.IntToHex(IntHex3Input, 8), 'Test3, fixed byte size.'); end; {$ENDREGION} *************** *** 617,651 **** {$ENDREGION} ! {$REGION 'Manipulations'} ! procedure Manipulations.ExpandTabs; ! var ! tabSet1: StringUtils.TabSet; ! tabSet2: StringUtils.TabSet; ! tabSet3: StringUtils.TabSet; begin ! tabSet1 := StringUtils.TabSet.Create(2); ! tabSet2 := StringUtils.TabSet.Create([15, 20, 40, 44]); ! tabSet3 := StringUtils.TabSet.Create([15, 20, 40, 44], 2); ! Assert.AreEqual(sTabTest1Output1, StringUtils.ExpandTabs(sTabTest1, tabSet1), 'sTabTest1Output1'); ! Assert.AreEqual(sTabTest2Output1, StringUtils.ExpandTabs(sTabTest2, tabSet1), 'sTabTest2Output1'); ! Assert.AreEqual(sTabTest1Output2, StringUtils.ExpandTabs(sTabTest1, tabSet2), 'sTabTest1Output2'); ! Assert.AreEqual(sTabTest2Output2, StringUtils.ExpandTabs(sTabTest2, tabSet2), 'sTabTest2Output2'); ! Assert.AreEqual(sTabTest1Output3, StringUtils.ExpandTabs(sTabTest1, tabSet3), 'sTabTest1Output3'); ! Assert.AreEqual(sTabTest2Output3, StringUtils.ExpandTabs(sTabTest2, tabSet3), 'sTabTest2Output3'); end; ! procedure Manipulations.RemoveDuplicates; begin ! Assert.AreEqual(sTest1Output, StringUtils.RemoveDuplicateChars(sTest1, '*'), 'sTest1'); end; ! procedure Manipulations.&Repeat; begin ! Assert.AreEqual(sRepeatOutput0, StringUtils.&Repeat(sRepeatInput, 0), 'Count=0'); ! Assert.AreEqual(sRepeatOutput1, StringUtils.&Repeat(sRepeatInput, 1), 'Count=1'); ! Assert.AreEqual(sRepeatOutput10, StringUtils.&Repeat(sRepeatInput, 10), 'Count=10'); end; {$ENDREGION} --- 657,834 ---- {$ENDREGION} ! {$REGION 'TabSet'} ! procedure TabSet.ConvertToString; begin ! Assert.AreEqual('[] and every 2', TabSet1.ToString, 'TabSet1.ToString'); ! Assert.AreEqual('[15,20,40,44] and every 4 (automatic)', TabSet2.ToString, 'TabSet2.ToString'); ! Assert.AreEqual('[15,20,40,44] and every 2', TabSet3.ToString, 'TabSet3.ToString'); ! Assert.AreEqual('[] and every 2 (automatic)', StringUtils.TabSet.Create.ToString, ! 'StringUtils.TabSet.Create.ToString'); ! Assert.AreEqual('every 2 (automatic)', StringUtils.TabSet.Create.ToString(True, False, True), ! 'StringUtils.TabSet.Create.ToString(true, false, true)'); ! Assert.AreEqual('15,20,40,44', TabSet2.ToString(False, False, False), 'TabSet2.ToString(false, false, false)'); ! end; ! procedure TabSet.Init; ! begin ! TabSet1 := StringUtils.TabSet.Create(2); ! TabSet2 := StringUtils.TabSet.Create([15, 20, 40, 44]); ! TabSet3 := StringUtils.TabSet.Create([15, 20, 40, 44], 2); ! end; ! procedure TabSet.SimpleTabulation; ! begin ! // TabSet1 should always tabulate to even positions ! Assert.AreEqual(TabSet1.TabFrom(1), 2); ! Assert.AreEqual(TabSet1.TabFrom(2), 4); ! Assert.AreEqual(TabSet1.TabFrom(3), 4); ! Assert.AreEqual(TabSet1.TabFrom(51), 52); ! Assert.AreEqual(TabSet1.TabFrom(52), 54); ! end; ! procedure TabSet.SpecifiedTabsWithAutoDefault; ! var ! i: Integer; ! begin ! // TabSet2 will tabulate to 15, 20, 40 and 44. Beyond that it will tabulate to a multiple of 4 (44-40) ! for i := 0 to 14 do ! Assert.AreEqual(TabSet2.TabFrom(i), 15, 'Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(TabSet2.TabFrom(i), 20, 'Tabulate from {0}', [i]); ! for i := 20 to 39 do ! Assert.AreEqual(TabSet2.TabFrom(i), 40, 'Tabulate from {0}', [i]); ! for i := 40 to 43 do ! Assert.AreEqual(TabSet2.TabFrom(i), 44, 'Tabulate from {0}', [i]); ! for i := 44 to 47 do ! Assert.AreEqual(TabSet2.TabFrom(i), 48, 'Tabulate from {0}', [i]); ! for i := 48 to 51 do ! Assert.AreEqual(TabSet2.TabFrom(i), 52, 'Tabulate from {0}', [i]); end; ! procedure TabSet.SpecifiedTabsWithDefault; ! var ! i: Integer; begin ! // TabSet2 will tabulate to 15, 20, 40 and 44. Beyond that it will tabulate to a multiple of 2 ! for i := 0 to 14 do ! Assert.AreEqual(TabSet3.TabFrom(i), 15, 'Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(TabSet3.TabFrom(i), 20, 'Tabulate from {0}', [i]); ! for i := 20 to 39 do ! Assert.AreEqual(TabSet3.TabFrom(i), 40, 'Tabulate from {0}', [i]); ! for i := 40 to 43 do ! Assert.AreEqual(TabSet3.TabFrom(i), 44, 'Tabulate from {0}', [i]); ! for i := 44 to 45 do ! Assert.AreEqual(TabSet3.TabFrom(i), 46, 'Tabulate from {0}', [i]); ! for i := 46 to 47 do ! Assert.AreEqual(TabSet3.TabFrom(i), 48, 'Tabulate from {0}', [i]); ! for i := 48 to 49 do ! Assert.AreEqual(TabSet3.TabFrom(i), 50, 'Tabulate from {0}', [i]); ! for i := 50 to 51 do ! Assert.AreEqual(TabSet3.TabFrom(i), 52, 'Tabulate from {0}', [i]); end; ! procedure TabSet.CloneAndEqual; ! var ! tempSet: StringUtils.TabSet; begin ! tempSet := StringUtils.TabSet(TabSet1.Clone); ! Assert.AreNotSame(TabSet1, tempSet); ! Assert.AreEqual(TabSet1, tempSet, 'Cloned'); ! tempSet.Add(2); ! Assert.AreEqual(TabSet1, tempSet, 'TabPos=[2], DefaultWidth=2'); ! tempSet.DefaultWidth := 0; ! Assert.AreEqual(TabSet1, tempSet, 'TabPos=[2], DefaultWidth=0 (automatic)'); ! tempSet.Add(4); ! Assert.AreEqual(TabSet1, tempSet, 'TabPos=[2,4], DefaultWidth=0 (automatic)'); ! tempSet.Clear; ! Assert.AreEqual(TabSet1, tempSet, 'TabPos=[], DefaultWidth=0 (automatic)'); ! end; ! ! procedure TabSet.RemovingTabs; ! var ! tempSet: StringUtils.TabSet; ! i: Integer; ! begin ! tempSet := StringUtils.TabSet(TabSet2.Clone); ! tempSet.Remove(20); ! for i := 0 to 14 do ! Assert.AreEqual(tempSet.TabFrom(i), 15, 'Removed 20; Tabulate from {0}', [i]); ! for i := 15 to 39 do ! Assert.AreEqual(tempSet.TabFrom(i), 40, 'Removed 20; Tabulate from {0}', [i]); ! for i := 40 to 43 do ! Assert.AreEqual(tempSet.TabFrom(i), 44, 'Removed 20; Tabulate from {0}', [i]); ! for i := 44 to 47 do ! Assert.AreEqual(tempSet.TabFrom(i), 48, 'Removed 20; Tabulate from {0}', [i]); ! for i := 48 to 51 do ! Assert.AreEqual(tempSet.TabFrom(i), 52, 'Removed 20; Tabulate from {0}', [i]); ! for i := 52 to 55 do ! Assert.AreEqual(tempSet.TabFrom(i), 56, 'Removed 20; Tabulate from {0}', [i]); ! for i := 56 to 59 do ! Assert.AreEqual(tempSet.TabFrom(i), 60, 'Removed 20; Tabulate from {0}', [i]); ! ! tempSet := StringUtils.TabSet(TabSet2.Clone); ! tempSet.Remove(40); ! for i := 0 to 14 do ! Assert.AreEqual(tempSet.TabFrom(i), 15, 'Removed 40; Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(tempSet.TabFrom(i), 20, 'Removed 40; Tabulate from {0}', [i]); ! for i := 20 to 43 do ! Assert.AreEqual(tempSet.TabFrom(i), 44, 'Removed 40; Tabulate from {0}', [i]); ! for i := 44 to 67 do ! Assert.AreEqual(tempSet.TabFrom(i), 68, 'Removed 40; Tabulate from {0}', [i]); ! for i := 68 to 91 do ! Assert.AreEqual(tempSet.TabFrom(i), 92, 'Removed 40; Tabulate from {0}', [i]); ! for i := 92 to 115 do ! Assert.AreEqual(tempSet.TabFrom(i), 116, 'Removed 40; Tabulate from {0}', [i]); ! for i := 116 to 139 do ! Assert.AreEqual(tempSet.TabFrom(i), 140, 'Removed 40; Tabulate from {0}', [i]); ! ! tempSet := StringUtils.TabSet(TabSet2.Clone); ! tempSet.Remove(40, True); ! for i := 0 to 14 do ! Assert.AreEqual(tempSet.TabFrom(i), 15, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(tempSet.TabFrom(i), 20, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 20 to 24 do ! Assert.AreEqual(tempSet.TabFrom(i), 25, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 25 to 29 do ! Assert.AreEqual(tempSet.TabFrom(i), 30, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 30 to 34 do ! Assert.AreEqual(tempSet.TabFrom(i), 35, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 35 to 39 do ! Assert.AreEqual(tempSet.TabFrom(i), 40, 'Removed 40+; Tabulate from {0}', [i]); ! for i := 40 to 44 do ! Assert.AreEqual(tempSet.TabFrom(i), 45, 'Removed 40+; Tabulate from {0}', [i]); ! end; ! ! procedure TabSet.AddingTabs; ! var ! tempSet: StringUtils.TabSet; ! tempSet2: StringUtils.TabSet; ! i: Integer; ! begin ! tempSet := StringUtils.TabSet(TabSet2.Clone); ! tempSet.Add(42); ! for i := 0 to 14 do ! Assert.AreEqual(tempSet.TabFrom(i), 15, 'Added 42; Tabulate from {0}', [i]); ! for i := 15 to 19 do ! Assert.AreEqual(tempSet.TabFrom(i), 20, 'Added 42; Tabulate from {0}', [i]); ! for i := 20 to 39 do ! Assert.AreEqual(tempSet.TabFrom(i), 40, 'Added 42; Tabulate from {0}', [i]); ! for i := 40 to 41 do ! Assert.AreEqual(tempSet.TabFrom(i), 42, 'Added 42; Tabulate from {0}', [i]); ! for i := 42 to 43 do ! Assert.AreEqual(tempSet.TabFrom(i), 44, 'Added 42; Tabulate from {0}', [i]); ! for i := 44 to 45 do ! Assert.AreEqual(tempSet.TabFrom(i), 46, 'Added 42; Tabulate from {0}', [i]); ! for i := 46 to 47 do ! Assert.AreEqual(tempSet.TabFrom(i), 48, 'Added 42; Tabulate from {0}', [i]); ! for i := 48 to 49 do ! Assert.AreEqual(tempSet.TabFrom(i), 50, 'Added 42; Tabulate from {0}', [i]); ! for i := 50 to 51 do ! Assert.AreEqual(tempSet.TabFrom(i), 52, 'Added 42; Tabulate from {0}', [i]); ! tempSet2 := StringUtils.TabSet.Create([40, 20, 15], 2); ! Assert.AreEqual(tempSet2, tempSet); end; {$ENDREGION} |
From: Marcel B. <jed...@us...> - 2005-01-22 15:13:01
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14975/nunit Modified Files: Nunit.Jedi.System.bdsproj Nunit.Jedi.System.dpk Log Message: * Added Jedi.System.SourceVersioning test-sets * Update Jedi.System.Strings test-sets to include escaped-string tests. Index: Nunit.Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.dpk,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Nunit.Jedi.System.dpk 24 Dec 2004 12:57:22 -0000 1.3 --- Nunit.Jedi.System.dpk 22 Jan 2005 15:12:36 -0000 1.4 *************** *** 25,28 **** --- 25,29 ---- {$IMPLICITBUILD OFF} {$R 'resources\Jedi.System.IniFiles.resources' 'resources\Jedi.System.IniFiles.resx'} + {%File '..\docs\Jedi.System.IniFiles.xml'} requires *************** *** 37,41 **** Jedi.System.Attributes.NUnit in 'source\Jedi.System.Attributes.NUnit.pas', Jedi.System.Strings.NUnit in 'source\Jedi.System.Strings.NUnit.pas', ! Jedi.System.IniFile.NUnit in 'source\Jedi.System.IniFile.NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.System')] --- 38,42 ---- Jedi.System.Attributes.NUnit in 'source\Jedi.System.Attributes.NUnit.pas', Jedi.System.Strings.NUnit in 'source\Jedi.System.Strings.NUnit.pas', ! Jedi.System.SourceVersioning.NUnit in 'source\Jedi.System.SourceVersioning.NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.System')] Index: Nunit.Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.bdsproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Nunit.Jedi.System.bdsproj 24 Dec 2004 12:57:22 -0000 1.3 --- Nunit.Jedi.System.bdsproj 22 Jan 2005 15:12:36 -0000 1.4 *************** *** 121,125 **** <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin;resources</Directories> ! <Directories Name="Packages" Type="String">System.XML.dll;System.Data.dll;System.dll;Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> <Directories Name="DebugSourceDirs" Type="String"></Directories> --- 121,125 ---- <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin;resources</Directories> ! <Directories Name="Packages" Type="String">System.XML.dll;System.Data.dll;Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> <Directories Name="DebugSourceDirs" Type="String"></Directories> *************** *** 172,184 **** <FileList> <File FileName="resources\Jedi.System.IniFiles.resx" ContainerId="ResXCompiler" ModuleName="Jedi.System.IniFiles"/> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> <File FileName="nunit.framework.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="nunit.framework" AssemblyName="nunit.framework" Version="2.2.1.0" LinkUnits="False"/> <File FileName="..\main\bin\Jedi.System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.System" AssemblyName="Jedi.System" Version="1.0.0.0" LinkUnits="False"/> ! <File FileName="System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System" AssemblyName="system" Version="1.0.5000.0" LinkUnits="False"/> ! <File FileName="System.Data.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Data" AssemblyName="system.data" Version="1.0.5000.0" LinkUnits="False"/> ! <File FileName="System.XML.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.XML" AssemblyName="system.xml" Version="1.0.5000.0" LinkUnits="False"/> <File FileName="source\Jedi.System.Attributes.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Attributes.NUnit"/> <File FileName="source\Jedi.System.Strings.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Strings.NUnit"/> ! <File FileName="source\Jedi.System.IniFile.NUnit.pas" ContainerId="" ModuleName="Jedi.System.IniFile.NUnit"/> </FileList> </DelphiDotNet.Personality> --- 172,185 ---- <FileList> <File FileName="resources\Jedi.System.IniFiles.resx" ContainerId="ResXCompiler" ModuleName="Jedi.System.IniFiles"/> + <File FileName="..\docs\Jedi.System.IniFiles.xml" ContainerId="File" ModuleName="Jedi.System.IniFiles"/> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> <File FileName="nunit.framework.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="nunit.framework" AssemblyName="nunit.framework" Version="2.2.1.0" LinkUnits="False"/> <File FileName="..\main\bin\Jedi.System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.System" AssemblyName="Jedi.System" Version="1.0.0.0" LinkUnits="False"/> ! <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System" AssemblyName="system" Version="1.0.5000.0" LinkUnits="False"/> ! <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Data.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Data" AssemblyName="system.data" Version="1.0.5000.0" LinkUnits="False"/> ! <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.XML.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.XML" AssemblyName="system.xml" Version="1.0.5000.0" LinkUnits="False"/> <File FileName="source\Jedi.System.Attributes.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Attributes.NUnit"/> <File FileName="source\Jedi.System.Strings.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Strings.NUnit"/> ! <File FileName="source\Jedi.System.SourceVersioning.NUnit.pas" ContainerId="" ModuleName="Jedi.System.SourceVersioning.NUnit"/> </FileList> </DelphiDotNet.Personality> |
From: Marcel B. <jed...@us...> - 2005-01-22 15:05:13
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13324/main/run Modified Files: Jedi.Collections.InlineEditable.pas Jedi.System.Attributes.pas Log Message: Added SourceInfo attribute Index: Jedi.System.Attributes.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.System.Attributes.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.System.Attributes.pas 5 Dec 2004 13:19:48 -0000 1.1 --- Jedi.System.Attributes.pas 22 Jan 2005 15:05:05 -0000 1.2 *************** *** 29,49 **** uses System.Collections, ! System.ComponentModel; {$ENDREGION} ! {$REGION 'Attributes'} type AttributeArray = array of Attribute; AttributeCombineOperation = (Add, Replace, Delete, AddAndReplace); type AttributeUtils = class (System.Object) strict protected - constructor Create; class function CombineAttributes(attributes1, attributes2: ArrayList; operation: AttributeCombineOperation): ArrayList; overload; static; - class function IndexOf(attrList: ArrayList; attr: System.Object): Integer; static; - class function ToArrayList(attrs: array of Attribute): ArrayList; overload; static; - class function ToArrayList(attrs: AttributeCollection): ArrayList; overload; static; public class function CombineAttributes(attributes1, attributes2: array of Attribute): AttributeArray; overload; static; --- 29,55 ---- uses System.Collections, ! System.ComponentModel, ! Jedi.System.SourceVersioning; {$ENDREGION} ! {$REGION 'Helper types (Delphi only)'} type AttributeArray = array of Attribute; + {$ENDREGION} + + {$REGION 'Enumerations'} + type + [JediSourceInfo('$Header$')] AttributeCombineOperation = (Add, Replace, Delete, AddAndReplace); + {$ENDREGION} + {$REGION 'Attribute list/collection handling'} type + [JediSourceInfo('$Header$')] AttributeUtils = class (System.Object) + {$REGION 'Combining attribute lists'} strict protected class function CombineAttributes(attributes1, attributes2: ArrayList; operation: AttributeCombineOperation): ArrayList; overload; static; public class function CombineAttributes(attributes1, attributes2: array of Attribute): AttributeArray; overload; static; *************** *** 62,69 **** --- 68,89 ---- class function CombineAttributes(attributes1: AttributeCollection; attributes2: array of Attribute; operation: AttributeCombineOperation): AttributeCollection; overload; static; + {$ENDREGION} + {$REGION 'Constructor'} + strict protected + constructor Create; + {$ENDREGION} + {$REGION 'Internal helper methods'} + strict protected + class function IndexOf(attrList: ArrayList; attr: System.Object): Integer; static; + class function ToArrayList(attrs: array of Attribute): ArrayList; overload; static; + class function ToArrayList(attrs: AttributeCollection): ArrayList; overload; static; + {$ENDREGION} + {$REGION 'Retrieval of an attribute'} + public class function GetAttribute(attributes: array of Attribute; attr: Attribute): Attribute; overload; static; class function GetAttribute(attributes: array of Attribute; attrType: System.Type): Attribute; overload; static; class function GetAttribute(attributes: AttributeCollection; attr: Attribute): Attribute; overload; static; class function GetAttribute(attributes: AttributeCollection; attrType: System.Type): Attribute; overload; static; + {$ENDREGION} end; {$ENDREGION} Index: Jedi.Collections.InlineEditable.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.Collections.InlineEditable.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.Collections.InlineEditable.pas 5 Dec 2004 13:19:48 -0000 1.1 --- Jedi.Collections.InlineEditable.pas 22 Jan 2005 15:05:05 -0000 1.2 *************** *** 29,32 **** --- 29,33 ---- uses Jedi.System.Attributes, + Jedi.System.SourceVersioning, System.Collections, System.Collections.Specialized, *************** *** 39,42 **** --- 40,44 ---- {$REGION 'Inline collection editing'} type + [JediSourceInfo('$Header$')] InlineCollectionUtils = class (System.Object) strict private *************** *** 65,68 **** --- 67,71 ---- end; + [JediSourceInfo('$Header$')] IInlineCollection = interface { add an item to the collection. This method is used by the 'new item' semi property when a new value should be *************** *** 82,85 **** --- 85,89 ---- end; + [JediSourceInfo('$Header$')] InlineCollectionConverter = class (System.ComponentModel.CollectionConverter) { when converting to a string uses IInlineCollection.GetCollectionValue. } *************** *** 94,97 **** --- 98,102 ---- end; + [JediSourceInfo('$Header$')] InlineCollectionEditor = class (UITypeEditor) function GetEditStyle(context: ITypeDescriptorContext): UITypeEditorEditStyle; override; *************** *** 104,107 **** --- 109,113 ---- type [TypeConverter(TypeOf(InlineCollectionConverter)), Editor(TypeOf(InlineCollectionEditor), TypeOf(UITypeEditor))] + [JediSourceInfo('$Header$')] InlineCollectionBase = class abstract (CollectionBase, IInlineCollection) strict private *************** *** 128,131 **** --- 134,138 ---- type [TypeConverter(TypeOf(InlineCollectionConverter)), Editor(TypeOf(InlineCollectionEditor), TypeOf(UITypeEditor))] + [JediSourceInfo('$Header$')] InlineDictionaryBase = class abstract (DictionaryBase, IInlineCollection) {$REGION 'IInlineCollection methods'} |
From: Marcel B. <jed...@us...> - 2005-01-22 15:04:47
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13188/main/run Modified Files: Jedi.System.Strings.pas Log Message: * Added string escape handling (ie. \r, \n \t, etc) * Grouped the class into categories * Added SourceInfo attribute Index: Jedi.System.Strings.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.System.Strings.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.System.Strings.pas 6 Dec 2004 10:51:44 -0000 1.2 --- Jedi.System.Strings.pas 22 Jan 2005 15:04:39 -0000 1.3 *************** *** 29,40 **** uses System.Collections, ! System.Text; {$ENDREGION} ! {$REGION 'String utilities'} type ! [Flags] ExtractQuotedStringFlags = (Default = 0, IgnoreGarbage = 1, EndQuoteMandetory = 2); StringUtils = class {$REGION 'TabSet class'} --- 29,45 ---- uses System.Collections, ! System.Text, ! Jedi.System.SourceVersioning; {$ENDREGION} ! {$REGION 'Enumerations'} type ! [Flags, CVSSourceInfo('$Header$')] ExtractQuotedStringFlags = (Default = 0, IgnoreGarbage = 1, EndQuoteMandetory = 2); + {$ENDREGION} + {$REGION 'String utilities class'} + type + [CVSSourceInfo('$Header$')] StringUtils = class {$REGION 'TabSet class'} *************** *** 80,85 **** --- 85,155 ---- end; {$ENDREGION} + {$REGION 'Hidden constructor'} strict protected constructor Create; + {$ENDREGION} + {$REGION 'Escaped strings'} + public + class function EscapeString(s: string): string; overload; static; + class function EscapeString(s: string; escapeCharacters: array of Char): string; overload; static; + class function ParseEscapedString(s: string): string; static; + {$ENDREGION} + {$REGION 'Escaped strings common implementation methods'} + strict protected + class function EscapeStringImpl(s: string; escapeCharacters: array of Char): string; static; + {$ENDREGION} + {$REGION 'Escaped strings constants'} + strict protected + const SpecialEscapeChars = #0#7#8#9#10#11#12#13; + const SpecialEscapeSequences = '0abtnvfr'; + {$ENDREGION} + {$REGION 'Integer<->string in base conversion'} + public + class function BinToInt(s: string): Integer; overload; static; + class function BinToInt(s: string; out digitsUsed: Integer): Integer; overload; static; + class function BinToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean): Integer; overload; static; + class function BinToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean; + out digitsUsed: Integer): Integer; overload; static; + class function IntToBin(value: Integer): string; overload; static; + class function IntToBin(value: Integer; minimumDigits: Integer): string; overload; static; + class function IntToBin(value: Integer; padToShortestByteSize: Boolean): string; overload; static; + class function IntToHex(value: Integer): string; overload; static; + class function IntToHex(value: Integer; minimumDigits: Integer): string; overload; static; + class function IntToHex(value: Integer; padToShortestByteSize: Boolean): string; overload; static; + class function IntToOct(value: Integer): string; overload; static; + class function IntToOct(value: Integer; minimumDigits: Integer): string; overload; static; + class function IntToOct(value: Integer; padToShortestByteSize: Boolean): string; overload; static; + class function HexToInt(s: string): Integer; overload; static; + class function HexToInt(s: string; out digitsUsed: Integer): Integer; overload; static; + class function HexToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean): Integer; overload; static; + class function HexToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean; + out digitsUsed: Integer): Integer; overload; static; + class function OctToInt(s: string): Integer; overload; static; + class function OctToInt(s: string; out digitsUsed: Integer): Integer; overload; static; + class function OctToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean): Integer; overload; static; + class function OctToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean; + out digitsUsed: Integer): Integer; overload; static; + {$ENDREGION} + {$REGION 'Integer<->string in base conversion common implementation methods'} + strict protected + class function IntBaseToStringImpl(value, base, minDigits: Integer): string; static; + class function ParseIntBaseImpl(s: string; base, maxDigits: Integer; ignoreLeadingZeros: Boolean; + out digitsUsed: Integer): Integer; static; + {$ENDREGION} + {$REGION 'Manipulations'} + public + class function RemoveDuplicateChars(s: string; char: System.Char): string; overload; static; + class function RemoveDuplicateChars(s: string; chars: array of System.Char): string; overload; static; + class function &Repeat(s: string; count: Integer): string; static; + {$ENDREGION} + {$REGION 'Quoted strings'} + public + class function ExtractQuotedString(s: string): string; overload; static; + class function ExtractQuotedString(s: string; flags: ExtractQuotedStringFlags): string; overload; static; + class function ExtractQuotedString(s: string; out lastUsedChar: Integer): string; overload; static; + class function QuoteString(s: string): string; overload; static; + class function QuoteString(s: string; quoteChar: Char): string; overload; static; + {$ENDREGION} + {$REGION 'Subsets'} public class function After(s: string; delimiter: System.Char): string; static; *************** *** 91,108 **** class function BeforeLast(s: string; delimiter: System.Char): string; static; class function BeforeLastAnyOf(s: string; delimiters: array of System.Char): string; static; - class function ExpandTabs(s: string; tabs: array of Int32): string; overload; static; - class function ExpandTabs(s: string; tabs: array of Int32; additionalTabsWidth: Int32): string; overload; static; - class function ExpandTabs(s: string; tabSet: TabSet): string; overload; static; - class function ExtractQuotedString(s: string): string; overload; static; - class function ExtractQuotedString(s: string; flags: ExtractQuotedStringFlags): string; overload; static; - class function ExtractQuotedString(s: string; out lastUsedChar: Integer): string; overload; static; class function Left(s: string; length: Integer): string; static; class function Mid(s: string; from, &to: Integer): string; static; - class function RemoveDuplicateChars(s: string; char: System.Char): string; overload; static; - class function RemoveDuplicateChars(s: string; chars: array of System.Char): string; overload; static; - class function &Repeat(s: string; count: Integer): string; static; class function Right(s: string; length: Integer): string; static; ! class function QuoteString(s: string): string; overload; static; ! class function QuoteString(s: string; quoteChar: Char): string; overload; static; end; {$ENDREGION} --- 161,174 ---- class function BeforeLast(s: string; delimiter: System.Char): string; static; class function BeforeLastAnyOf(s: string; delimiters: array of System.Char): string; static; class function Left(s: string; length: Integer): string; static; class function Mid(s: string; from, &to: Integer): string; static; class function Right(s: string; length: Integer): string; static; ! {$ENDREGION} ! {$REGION 'Tab expansions'} ! public ! class function ExpandTabs(s: string; tabs: array of Int32): string; overload; static; ! class function ExpandTabs(s: string; tabs: array of Int32; additionalTabsWidth: Int32): string; overload; static; ! class function ExpandTabs(s: string; tabSet: TabSet): string; overload; static; ! {$ENDREGION} end; {$ENDREGION} *************** *** 112,115 **** --- 178,191 ---- {$AUTOBOX ON} + {$REGION 'implementation uses'} + uses + System.Globalization; + {$ENDREGION} + + {$REGION 'Array type declarations'} + type + CharArray = array of Char; + {$ENDREGION} + {$REGION 'StringUtils'} constructor StringUtils.Create; *************** *** 206,209 **** --- 282,382 ---- end; + class function StringUtils.BinToInt(s: string): Integer; + var + digitsUsed: Integer; + begin + Result := ParseIntBaseImpl(s, 2, s.Length, False, digitsUsed); + end; + + class function StringUtils.BinToInt(s: string; out digitsUsed: Integer): Integer; + begin + Result := ParseIntBaseImpl(s, 2, s.Length, False, digitsUsed); + end; + + class function StringUtils.BinToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean): Integer; + var + digitsUsed: Integer; + begin + Result := ParseIntBaseImpl(s, 2, maxDigits, ignoreLeadingZeros, digitsUsed); + end; + + class function StringUtils.BinToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean; + out digitsUsed: Integer): Integer; + begin + Result := ParseIntBaseImpl(s, 2, maxDigits, ignoreLeadingZeros, digitsUsed); + end; + + class function StringUtils.EscapeString(s: string): string; + var + al: ArrayList; + i: Integer; + begin + al := ArrayList.Create(33); + for i := 0 to 31 do + al.Add(System.Char(i)); + al.Add(System.Char('\')); + Result := EscapeStringImpl(s, CharArray(al.ToArray(TypeOf(System.Char)))); + end; + + class function StringUtils.EscapeString(s: string; escapeCharacters: array of Char): string; + var + al: ArrayList; + i: Integer; + idx: Integer; + begin + al := ArrayList.Create(&Array(escapeCharacters)); + al.Sort; + for i := 0 to 31 do + begin + idx := al.BinarySearch(System.Char(i)); + if idx < 0 then + al.Insert(not idx, System.Char(i)); + end; + idx := al.BinarySearch(System.Char('\')); + if idx < 0 then + al.Insert(not idx, System.Char('\')); + Result := EscapeStringImpl(s, CharArray(al.ToArray(TypeOf(System.Char)))); + end; + + class function StringUtils.EscapeStringImpl(s: string; escapeCharacters: array of Char): string; + var + sb: StringBuilder; + lastIdx: Integer; + idx: Integer; + escapeIdx: Integer; + begin + sb := StringBuilder.Create(s.Length); + lastIdx := 0; + repeat + idx := s.IndexOfAny(escapeCharacters, lastIdx); + if idx < 0 then + idx := s.Length; + if idx > lastIdx then + sb.Append(Mid(s, lastIdx, idx - 1)); + lastIdx := idx + 1; + if idx < s.Length then + begin + sb.Append('\'); + escapeIdx := SpecialEscapeChars.IndexOf(s.Chars[idx]); + if escapeIdx > -1 then + begin + if (escapeIdx > 0) or (lastIdx >= s.Length) or (s.Chars[lastIdx] < '0') or (s.Chars[lastIdx] > '7') then + sb.Append(SpecialEscapeSequences.Chars[escapeIdx]) + else + sb.Append('000'); + end + else + if s.Chars[idx] < ' ' then + begin + sb.Append('x'); + sb.Append(IntBaseToStringImpl(System.Int32(s.Chars[idx]), 16, 2)); + end + else + sb.Append(s.Chars[idx]); + end; + until lastIdx >= s.Length; + Result := sb.ToString; + end; + class function StringUtils.ExpandTabs(s: string; tabs: array of Integer): string; begin *************** *** 310,313 **** --- 483,617 ---- end; + class function StringUtils.IntBaseToStringImpl(value, base, minDigits: Integer): string; + var + adaptedValue: Int64; + sb: StringBuilder; + digits: string; + base64: Int64; + begin + if (base < 2) or (base > 16) then + raise ArgumentOutOfRangeException.Create('base'); + if (minDigits < 0) or (minDigits > 100) then + raise ArgumentOutOfRangeException.Create('minDigits'); + if value < 0 then + adaptedValue := $100000000 + value + else + adaptedValue := value; + sb := StringBuilder.Create(minDigits); + digits := '0123456789abcdef'; + base64 := base; // avoids (repeated) conversion inside the while loop + while adaptedValue <> 0 do + begin + sb.Insert(0, digits.Chars[adaptedValue mod base64]); + adaptedValue := adaptedValue div base64; + end; + if sb.Length < minDigits then + sb.Insert(0, '0', minDigits - sb.Length); + Result := sb.ToString; + end; + + class function StringUtils.IntToBin(value: Integer): string; + begin + Result := IntBaseToStringImpl(value, 2, 1); + end; + + class function StringUtils.IntToBin(value: Integer; minimumDigits: Integer): string; + begin + Result := IntBaseToStringImpl(value, 2, minimumDigits); + end; + + class function StringUtils.IntToBin(value: Integer; padToShortestByteSize: Boolean): string; + var + len: Integer; + begin + Result := IntBaseToStringImpl(value, 2, 1); + if padToShortestByteSize then + begin + len := 8; + while len < Result.Length do + len := len shl 1; + len := len - Result.Length; + if len > 0 then + Result := System.String.Concat(System.String.Create('0', len), Result); + end; + end; + + class function StringUtils.IntToHex(value: Integer): string; + begin + Result := IntBaseToStringImpl(value, 16, 1); + end; + + class function StringUtils.IntToHex(value: Integer; minimumDigits: Integer): string; + begin + Result := IntBaseToStringImpl(value, 16, minimumDigits); + end; + + class function StringUtils.IntToHex(value: Integer; padToShortestByteSize: Boolean): string; + var + len: Integer; + begin + Result := IntBaseToStringImpl(value, 16, 1); + if padToShortestByteSize then + begin + len := 2; + while len < Result.Length do + len := len shl 1; + len := len - Result.Length; + if len > 0 then + Result := System.String.Concat(System.String.Create('0', len), Result); + end; + end; + + class function StringUtils.IntToOct(value: Integer): string; + begin + Result := IntBaseToStringImpl(value, 8, 1); + end; + + class function StringUtils.IntToOct(value: Integer; minimumDigits: Integer): string; + begin + Result := IntBaseToStringImpl(value, 8, minimumDigits); + end; + + class function StringUtils.IntToOct(value: Integer; padToShortestByteSize: Boolean): string; + var + len: Integer; + begin + Result := IntBaseToStringImpl(value, 8, 1); + if padToShortestByteSize then + begin + len := 3; + while len < Result.Length do + len := len shl 1; + len := len - Result.Length; + if len > 0 then + Result := System.String.Concat(System.String.Create('0', len), Result); + end; + end; + + class function StringUtils.HexToInt(s: string): Integer; + var + digitsUsed: Integer; + begin + Result := ParseIntBaseImpl(s, 16, s.Length, False, digitsUsed); + end; + + class function StringUtils.HexToInt(s: string; out digitsUsed: Integer): Integer; + begin + Result := ParseIntBaseImpl(s, 16, s.Length, False, digitsUsed); + end; + + class function StringUtils.HexToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean): Integer; + var + digitsUsed: Integer; + begin + Result := ParseIntBaseImpl(s, 16, maxDigits, ignoreLeadingZeros, digitsUsed); + end; + + class function StringUtils.HexToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean; + out digitsUsed: Integer): Integer; + begin + Result := ParseIntBaseImpl(s, 16, maxDigits, ignoreLeadingZeros, digitsUsed); + end; + class function StringUtils.Left(s: string; length: Integer): string; begin *************** *** 320,323 **** --- 624,735 ---- end; + class function StringUtils.OctToInt(s: string): Integer; + var + digitsUsed: Integer; + begin + Result := ParseIntBaseImpl(s, 8, s.Length, False, digitsUsed); + end; + + class function StringUtils.OctToInt(s: string; out digitsUsed: Integer): Integer; + begin + Result := ParseIntBaseImpl(s, 8, s.Length, False, digitsUsed); + end; + + class function StringUtils.OctToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean): Integer; + var + digitsUsed: Integer; + begin + Result := ParseIntBaseImpl(s, 8, maxDigits, ignoreLeadingZeros, digitsUsed); + end; + + class function StringUtils.OctToInt(s: string; maxDigits: Integer; ignoreLeadingZeros: Boolean; + out digitsUsed: Integer): Integer; + begin + Result := ParseIntBaseImpl(s, 8, maxDigits, ignoreLeadingZeros, digitsUsed); + end; + + class function StringUtils.ParseEscapedString(s: string): string; + var + sb: StringBuilder; + lastIdx: Integer; + idx: Integer; + specIdx: Integer; + parseCount: Integer; + begin + sb := StringBuilder.Create(s.Length); + lastIdx := 0; + repeat + idx := s.IndexOf('\', lastIdx); + if idx > -1 then + begin + sb.Append(Mid(s, lastIdx, idx - 1)); + Inc(idx); + if idx >= s.Length then + raise ArgumentException.Create('Specified string ends with the escape character.'); + specIdx := SpecialEscapeSequences.IndexOf(System.Char.ToLower(s.Chars[idx])); + if System.Char.IsDigit(s, idx) then + begin + sb.Append(System.Char(ParseIntBaseImpl(s.Substring(idx), 8, 3, False, parseCount))); + Inc(idx, parseCount); + end + else + if specIdx > -1 then + begin + sb.Append(SpecialEscapeChars.Chars[specIdx]); + Inc(idx); + end + else + if (s.Chars[idx] = 'x') or (s.Chars[idx] = 'X') then + begin + sb.Append(System.Char(ParseIntBaseImpl(s.Substring(idx + 1), 16, 2, False, parseCount))); + Inc(idx, parseCount + 1); + end + else + begin + sb.Append(s.Chars[idx]); + Inc(idx); + end; + lastIdx := idx; + if lastIdx >= s.Length then + idx := -1; + end + else + sb.Append(s.Substring(lastIdx)); + until idx < 0; + Result := sb.ToString; + end; + + class function StringUtils.ParseIntBaseImpl(s: string; base, maxDigits: Integer; ignoreLeadingZeros: Boolean; + out digitsUsed: Integer): Integer; + var + leadZeroCount: Integer; + digits: string; + newValue: Int64; + begin + if (base < 2) or (base > 16) then + raise ArgumentOutOfRangeException.Create('base'); + if (maxDigits < 0) or (maxDigits > 100) then + raise ArgumentOutOfRangeException.Create('maxDigits'); + digitsUsed := 0; + leadZeroCount := 0; + if ignoreLeadingZeros then + while (leadZeroCount < s.Length) and (s.Chars[leadZeroCount] = '0') do + Inc(leadZeroCount); + maxDigits := Math.Min(s.Length, maxDigits); + s := s.Substring(leadZeroCount, maxDigits).ToUpper(CultureInfo.InvariantCulture); + digits := '0123456789ABCDEF'.Substring(0, base); + newValue := 0; + while (digitsUsed < maxDigits) and (digits.IndexOf(s.Chars[digitsUsed]) > -1) do + begin + newValue := newValue * base + digits.IndexOf(s.Chars[digitsUsed]); + Inc(digitsUsed); + end; + digitsUsed := digitsUsed + leadZeroCount; + if newValue > System.Int32.MaxValue then + Result := newValue - $100000000 + else + Result := newValue; + end; + class function StringUtils.RemoveDuplicateChars(s: string; char: System.Char): string; var |
From: Marcel B. <jed...@us...> - 2005-01-22 14:39:17
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6714/main/run Modified Files: Jedi.System.SourceVersioning.pas Log Message: Completed the unit. Index: Jedi.System.SourceVersioning.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.System.SourceVersioning.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.System.SourceVersioning.pas 21 Jan 2005 20:09:02 -0000 1.2 --- Jedi.System.SourceVersioning.pas 22 Jan 2005 14:39:05 -0000 1.3 *************** *** 1,2 **** --- 1,25 ---- + {--------------------------------------------------------------------------------------------------- + The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you + may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/MPL-1.1.html + + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + KIND, either expressed or implied. See the License for the specific language governing rights and + limitations under the License. + + The Original Code is: Jedi.System.SourceVersioning.pas, released on 2006-01-21. + + The Initial Developer of the Original Code is Marcel Bestebroer + Portions created by Marcel Bestebroer are Copyright (C) 2004 Marcel Bestebroer + All Rights Reserved. + + Contributor(s): + + You may retrieve the latest version of this file at the JEDI.NET home page, located at + http://sf.net/projects/jedidotnet + + Known Issues: + ---------------------------------------------------------------------------------------------------} + // $Id$ unit Jedi.System.SourceVersioning; *************** *** 5,29 **** type {$REGION 'Forward declarations'} ! SourceVersionAttribute = class; ! SourceVersionRevision = record; {$ENDREGION} ! {$REGION 'SourceVersion attribute'} [AttributeUsage(AttributeTargets.Class or AttributeTargets.Delegate or AttributeTargets.Enum or AttributeTargets.Interface or AttributeTargets.Struct, &Inherited = False)] ! SourceVersionAttribute = class (Attribute) {$REGION 'Constructors'} public ! constructor Create(id: string); overload; constructor Create(sourceFile, revision, date: string); overload; ! {$ENDREGION} ! {$REGION 'Constants'} ! strict protected ! const dateFormat = 'yyyy\/MM\/dd HH\:mm\:ss'; {$ENDREGION} {$REGION 'Data'} strict private FDate: DateTime; ! FRevision: SourceVersionRevision; FSourceFile: string; {$ENDREGION} --- 28,53 ---- type {$REGION 'Forward declarations'} ! Revision = record; {$ENDREGION} ! {$REGION 'SourceInfo attribute'} [AttributeUsage(AttributeTargets.Class or AttributeTargets.Delegate or AttributeTargets.Enum or AttributeTargets.Interface or AttributeTargets.Struct, &Inherited = False)] ! SourceInfoAttribute = class (Attribute) ! {$REGION 'Constants'} ! strict protected ! const dateFormat = 'yyyy''/''MM''/''dd HH'':''mm'':''ss'; ! {$ENDREGION} {$REGION 'Constructors'} public ! constructor Create(sourceFile: string; revision: Revision; date: DateTime); overload; ! constructor Create(sourceFile: string; revision: Revision; date: string); overload; constructor Create(sourceFile, revision, date: string); overload; ! constructor Create(sourceFile: string; revision: Double; date: string); overload; {$ENDREGION} {$REGION 'Data'} strict private FDate: DateTime; ! FRevision: Revision; FSourceFile: string; {$ENDREGION} *************** *** 31,51 **** public property Date: DateTime read FDate; ! property Revision: SourceVersionRevision read FRevision; property SourceFile: string read FSourceFile; {$ENDREGION} {$REGION 'Static parsing methods'} public class function ParseDate(date: string): DateTime; static; ! class procedure ParseId(id: string; out source: string; out revision: SourceVersionRevision; out date: DateTime); static; ! class function ParseRevision(revision: string): SourceVersionRevision; static; class function ParseSource(source: string): string; static; {$ENDREGION} end; {$ENDREGION} ! {$REGION 'SourceVersion revision type'} ! [SourceVersion('$Header$')] ! SourceVersionRevision = record (IComparable) {$REGION 'Constructors'} public --- 55,105 ---- public property Date: DateTime read FDate; ! property Revision: Revision read FRevision; property SourceFile: string read FSourceFile; {$ENDREGION} + end; + {$ENDREGION} + + {$REGION 'CVSSourceVersion attribute'} + CVSSourceInfoAttribute = class (SourceInfoAttribute) + {$REGION 'Constructors'} + public + constructor Create(id: string); overload; + constructor Create(id: string; pathIgnoreLevel: Integer); overload; + constructor Create(sourceFile, revision, date: string); overload; + constructor Create(sourceFile, revision, date: string; pathIgnoreLevel: Integer); overload; + {$ENDREGION} {$REGION 'Static parsing methods'} public class function ParseDate(date: string): DateTime; static; ! class procedure ParseId(id: string; out source: string; out revision: Revision; out date: DateTime); static; ! class function ParseRevision(revision: string): Revision; static; class function ParseSource(source: string): string; static; {$ENDREGION} + {$REGION 'Static utility methods'} + strict protected + class function RemovePathLevels(path: string; levels: Integer): string; static; + {$ENDREGION} end; {$ENDREGION} ! {$REGION 'JediSourceVersion attribute'} ! JediSourceInfoAttribute = class (CVSSourceInfoAttribute) ! {$REGION 'Constants'} ! public ! const IgnoreLevel = 2; ! {$ENDREGION} ! {$REGION 'Constructors'} ! public ! constructor Create(id: string); overload; ! constructor Create(sourceFile, revision, date: string); overload; ! {$ENDREGION} ! end; ! {$ENDREGION} ! ! {$REGION 'Revision type'} ! [JediSourceInfoAttribute('$Header$')] ! Revision = record (IComparable) {$REGION 'Constructors'} public *************** *** 65,84 **** {$REGION 'Operators: comparisons'} public ! class operator Equal(left, right: SourceVersionRevision): Boolean; ! class operator GreaterThan(left, right: SourceVersionRevision): Boolean; ! class operator GreaterThanOrEqual(left, right: SourceVersionRevision): Boolean; ! class operator LessThan(left, right: SourceVersionRevision): Boolean; ! class operator LessThanOrEqual(left, right: SourceVersionRevision): Boolean; ! class operator NotEqual(left, right: SourceVersionRevision): Boolean; {$ENDREGION} {$REGION 'Operators: conversions'} public ! class operator Implicit(const Value: Double): SourceVersionRevision; ! class operator Implicit(const Value: SourceVersionRevision): Double; ! class operator Implicit(const Value: string): SourceVersionRevision; ! class operator Implicit(const Value: SourceVersionRevision): string; {$ENDREGION} {$REGION 'Overrides'} public function ToString: string; override; {$ENDREGION} --- 119,139 ---- {$REGION 'Operators: comparisons'} public ! class operator Equal(left, right: Revision): Boolean; ! class operator GreaterThan(left, right: Revision): Boolean; ! class operator GreaterThanOrEqual(left, right: Revision): Boolean; ! class operator LessThan(left, right: Revision): Boolean; ! class operator LessThanOrEqual(left, right: Revision): Boolean; ! class operator NotEqual(left, right: Revision): Boolean; {$ENDREGION} {$REGION 'Operators: conversions'} public ! class operator Implicit(const Value: Double): Revision; ! class operator Implicit(const Value: Revision): Double; ! class operator Implicit(const Value: string): Revision; ! class operator Implicit(const Value: Revision): string; {$ENDREGION} {$REGION 'Overrides'} public + function Equals(obj: &Object): Boolean; override; function ToString: string; override; {$ENDREGION} *************** *** 93,96 **** --- 148,188 ---- property Items[&index: Integer]: Integer read get_Items; default; {$ENDREGION} + {$REGION 'Additional comparisons'} + public + function IsSubBranchOf(revision: Revision): Boolean; + {$ENDREGION} + end; + {$ENDREGION} + + {$REGION 'SourceInfo class'} + type + [JediSourceInfoAttribute('$Header$')] + SourceInfo = class (&Object) + {$REGION 'Constructor'} + strict protected + constructor Create(sourceFile: string; revision: Revision; date: DateTime); + {$ENDREGION} + {$REGION 'Data'} + strict private + FDate: DateTime; + FRevision: Revision; + FSourceFile: string; + {$ENDREGION} + {$REGION 'Properties'} + public + property Date: DateTime read FDate; + property Revision: Revision read FRevision; + property SourceFile: string read FSourceFile; + {$ENDREGION} + {$REGION 'Static retrieval methods'} + public + class function GetInfoOf(obj: &Object): SourceInfo; overload; static; + class function GetInfoOf(&type: &Type): SourceInfo; overload; static; + {$ENDREGION} + {$REGION 'Static revision checks'} + public + class function IsAtLeastRevision(obj: &Object; revision: Revision): Boolean; overload; static; + class function IsAtLeastRevision(&type: &Type; revision: Revision): Boolean; overload; static; + {$ENDREGION} end; {$ENDREGION} *************** *** 103,106 **** --- 195,199 ---- uses System.Globalization, + System.IO, System.Text, Jedi.System.Strings; *************** *** 112,131 **** {$ENDREGION} ! {$REGION 'SourceVersionAttribute'} ! constructor SourceVersionAttribute.Create(id: string); begin ! inherited Create; ! ParseId(id, FSourceFile, FRevision, FDate); end; ! constructor SourceVersionAttribute.Create(sourceFile, revision, date: string); begin ! inherited Create; ! FDate := ParseDate(date); ! FSourceFile := ParseSource(sourceFile); ! FRevision := ParseRevision(revision); end; ! class function SourceVersionAttribute.ParseDate(date: string): DateTime; begin if date.ToLower.StartsWith('$date: ') then --- 205,240 ---- {$ENDREGION} ! {$REGION 'CVSSourceInfoAttribute'} ! constructor CVSSourceInfoAttribute.Create(id: string); begin ! Create(id, 0); end; ! constructor CVSSourceInfoAttribute.Create(id: string; pathIgnoreLevel: Integer); ! var ! source: string; ! revision: Jedi.System.SourceVersioning.Revision; ! date: DateTime; begin ! ParseId(id, source, revision, date); ! if source.StartsWith(Path.AltDirectorySeparatorChar) or source.StartsWith(Path.DirectorySeparatorChar) then ! source := source.Substring(1); ! if pathIgnoreLevel > 0 then ! source := RemovePathLevels(source, pathIgnoreLevel); ! inherited Create(source, revision, date); end; ! constructor CVSSourceInfoAttribute.Create(sourceFile, revision, date: string); ! begin ! Create(sourceFile, revision, date, 0); ! end; ! ! constructor CVSSourceInfoAttribute.Create(sourceFile, revision, date: string; pathIgnoreLevel: Integer); ! begin ! inherited Create(RemovePathLevels(ParseSource(sourceFile), pathIgnoreLevel), ParseRevision(revision), ! ParseDate(date)); ! end; ! ! class function CVSSourceInfoAttribute.ParseDate(date: string): DateTime; begin if date.ToLower.StartsWith('$date: ') then *************** *** 135,139 **** end; ! class procedure SourceVersionAttribute.ParseId(id: string; out source: string; out revision: SourceVersionRevision; out date: DateTime); var --- 244,248 ---- end; ! class procedure CVSSourceInfoAttribute.ParseId(id: string; out source: string; out revision: Revision; out date: DateTime); var *************** *** 163,170 **** if idx < 0 then raise FormatException.Create('date not found in the specified id string.'); ! date := DateTime.ParseExact(id.Substring(0, idx), dateFormat, DateTimeFormatInfo.InvariantInfo); end; ! class function SourceVersionAttribute.ParseRevision(revision: string): SourceVersionRevision; begin if revision.ToLower.StartsWith('$revision: ') then --- 272,282 ---- if idx < 0 then raise FormatException.Create('date not found in the specified id string.'); ! idx := id.IndexOf(' ', idx + 1); ! if idx < 0 then ! raise FormatException.Create('date not found in the specified id string.'); ! date := DateTime.ParseExact(id.Substring(0, idx).Trim, dateFormat, DateTimeFormatInfo.InvariantInfo); end; ! class function CVSSourceInfoAttribute.ParseRevision(revision: string): Revision; begin if revision.ToLower.StartsWith('$revision: ') then *************** *** 174,195 **** end; ! class function SourceVersionAttribute.ParseSource(source: string): string; begin if source.ToLower.StartsWith('$rcsfile: ') then ! Result := source.Substring(10, source.Length - 13) else if source.ToLower.StartsWith('$source: ') then ! Result := source.Substring(9, source.Length - 12) else - begin Result := source.Trim; ! if Result.ToLower.EndsWith(',v') then ! Result := Result.Substring(0, Result.Length - 2); end; end; {$ENDREGION} ! {$REGION 'SourceVersionRevision'} ! constructor SourceVersionRevision.Create(revision: string); var elements: array of string; --- 286,343 ---- end; ! class function CVSSourceInfoAttribute.ParseSource(source: string): string; begin if source.ToLower.StartsWith('$rcsfile: ') then ! Result := source.Substring(10, source.Length - 11).Trim else if source.ToLower.StartsWith('$source: ') then ! Result := source.Substring(9, source.Length - 10).Trim else Result := source.Trim; ! if Result.ToLower.EndsWith(',v') then ! Result := Result.Substring(0, Result.Length - 2); ! if Result.StartsWith(Path.AltDirectorySeparatorChar) or Result.StartsWith(Path.DirectorySeparatorChar) then ! Result := Result.Substring(1); ! end; ! ! class function CVSSourceInfoAttribute.RemovePathLevels(path: string; levels: Integer): string; ! var ! idx: Integer; ! begin ! if levels < 0 then ! raise ArgumentOutOfRangeException.Create('levels', 'Must be zero or positive.'); ! idx := -1; ! while levels > 0 do ! begin ! idx := path.IndexOfAny([System.IO.Path.AltDirectorySeparatorChar, ! System.IO.Path.DirectorySeparatorChar], idx + 1); ! if idx < 0 then ! raise ArgumentOutOfRangeException.Create('levels', 'Path does not contain that many levels.'); ! Dec(levels); end; + Result := path.Substring(idx + 1); end; {$ENDREGION} ! {$REGION 'JediSourceInfoAttribute'} ! constructor JediSourceInfoAttribute.Create(id: string); ! begin ! if id.ToLower.StartsWith('$id: ') then ! inherited Create(id, 0) ! else ! inherited Create(id, IgnoreLevel); ! end; ! ! constructor JediSourceInfoAttribute.Create(sourceFile, revision, date: string); ! begin ! if sourceFile.ToLower.StartsWith('$rcsfile: ') then ! inherited Create(sourceFile, revision, date, 0) ! else ! inherited Create(sourceFile, revision, date, IgnoreLevel); ! end; ! {$ENDREGION} ! ! {$REGION 'Revision'} ! constructor Revision.Create(revision: string); var elements: array of string; *************** *** 203,212 **** end; ! constructor SourceVersionRevision.Create(revision: Double); begin ! Create(revision.ToString('r', NumberFormatInfo.InvariantInfo)); end; ! constructor SourceVersionRevision.Create(major, minor: Integer); begin inherited Create; --- 351,363 ---- end; ! constructor Revision.Create(revision: Double); begin ! if Math.Floor(revision) = revision then ! Create(Trunc(revision), 0) ! else ! Create(revision.ToString('r', NumberFormatInfo.InvariantInfo)); end; ! constructor Revision.Create(major, minor: Integer); begin inherited Create; *************** *** 214,218 **** end; ! constructor SourceVersionRevision.Create(values: array of Integer); begin inherited Create; --- 365,369 ---- end; ! constructor Revision.Create(values: array of Integer); begin inherited Create; *************** *** 220,230 **** end; ! function SourceVersionRevision.CompareTo(obj: &Object): Integer; var ! secRev: SourceVersionRevision; maxIdx: Integer; idx: Integer; begin ! secRev := SourceVersionRevision(obj); maxIdx := Math.Min(&Array(FValues).Length, &Array(secRev.FValues).Length) - 1; Result := 0; --- 371,381 ---- end; ! function Revision.CompareTo(obj: &Object): Integer; var ! secRev: Revision; maxIdx: Integer; idx: Integer; begin ! secRev := Revision(obj); maxIdx := Math.Min(&Array(FValues).Length, &Array(secRev.FValues).Length) - 1; Result := 0; *************** *** 239,273 **** end; ! class operator SourceVersionRevision.Equal(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) = 0; end; ! function SourceVersionRevision.get_Count: Integer; begin Result := &Array(FValues).Length; end; ! function SourceVersionRevision.get_Items(index: Integer): Integer; begin Result := FValues[index]; end; ! class operator SourceVersionRevision.GreaterThan(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) > 0; end; ! class operator SourceVersionRevision.GreaterThanOrEqual(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) >= 0; end; ! class operator SourceVersionRevision.Implicit(const value: Double): SourceVersionRevision; begin ! Result := SourceVersionRevision.Create(value); end; ! class operator SourceVersionRevision.Implicit(const value: SourceVersionRevision): Double; begin if value.Count > 2 then --- 390,429 ---- end; ! class operator Revision.Equal(left, right: Revision): Boolean; begin Result := left.CompareTo(right) = 0; end; ! function Revision.Equals(obj: &Object): Boolean; ! begin ! Result := Self.CompareTo(obj) = 0; ! end; ! ! function Revision.get_Count: Integer; begin Result := &Array(FValues).Length; end; ! function Revision.get_Items(index: Integer): Integer; begin Result := FValues[index]; end; ! class operator Revision.GreaterThan(left, right: Revision): Boolean; begin Result := left.CompareTo(right) > 0; end; ! class operator Revision.GreaterThanOrEqual(left, right: Revision): Boolean; begin Result := left.CompareTo(right) >= 0; end; ! class operator Revision.Implicit(const value: Double): Revision; begin ! Result := Revision.Create(value); end; ! class operator Revision.Implicit(const value: Revision): Double; begin if value.Count > 2 then *************** *** 277,306 **** end; ! class operator SourceVersionRevision.Implicit(const value: string): SourceVersionRevision; begin ! Result := SourceVersionRevision.Create(value); end; ! class operator SourceVersionRevision.Implicit(const value: SourceVersionRevision): string; begin Result := value.ToString; end; ! class operator SourceVersionRevision.LessThan(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) < 0; end; ! class operator SourceVersionRevision.LessThanOrEqual(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) <= 0; end; ! class operator SourceVersionRevision.NotEqual(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) <> 0; end; ! function SourceVersionRevision.ToString: string; var sb: StringBuilder; --- 433,480 ---- end; ! class operator Revision.Implicit(const value: string): Revision; begin ! Result := Revision.Create(value); end; ! class operator Revision.Implicit(const value: Revision): string; begin Result := value.ToString; end; ! function Revision.IsSubBranchOf(revision: Revision): Boolean; ! var ! idx: Integer; ! begin ! if Count > revision.Count then ! begin ! Result := True; ! idx := 0; ! while Result and (idx < revision.Count) do ! begin ! Result := Items[idx] = revision[idx]; ! Inc(idx); ! end; ! end ! else ! Result := False; ! end; ! ! class operator Revision.LessThan(left, right: Revision): Boolean; begin Result := left.CompareTo(right) < 0; end; ! class operator Revision.LessThanOrEqual(left, right: Revision): Boolean; begin Result := left.CompareTo(right) <= 0; end; ! class operator Revision.NotEqual(left, right: Revision): Boolean; begin Result := left.CompareTo(right) <> 0; end; ! function Revision.ToString: string; var sb: StringBuilder; *************** *** 320,322 **** --- 494,573 ---- {$ENDREGION} + {$REGION 'SourceInfoAttribute'} + constructor SourceInfoAttribute.Create(sourceFile: string; revision: Revision; date: DateTime); + begin + inherited Create; + FSourceFile := sourceFile.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); + FRevision := revision; + FDate := date; + end; + + constructor SourceInfoAttribute.Create(sourceFile: string; revision: Revision; date: string); + begin + Create(sourceFile, revision, DateTime.ParseExact(date, dateFormat, DateTimeFormatInfo.InvariantInfo)); + end; + + constructor SourceInfoAttribute.Create(sourceFile, revision, date: string); + begin + Create(sourceFile, Jedi.System.SourceVersioning.Revision(revision), date); + end; + + constructor SourceInfoAttribute.Create(sourceFile: string; revision: Double; date: string); + begin + Create(sourceFile, Jedi.System.SourceVersioning.Revision(revision), date); + end; + {$ENDREGION} + + {$REGION 'SourceInfo'} + constructor SourceInfo.Create(sourceFile: string; revision: Revision; date: DateTime); + begin + inherited Create; + FSourceFile := sourceFile; + FRevision := revision; + FDate := date; + end; + + class function SourceInfo.IsAtLeastRevision(obj: &Object; revision: Revision): Boolean; + begin + if not Assigned(obj) then + raise ArgumentNullException.Create('obj'); + Result := IsAtLeastRevision(obj.GetType, revision); + end; + + class function SourceInfo.IsAtLeastRevision(&type: &Type; revision: Revision): Boolean; + var + si: SourceInfo; + begin + si := GetInfoOf(&type); + Result := si.Revision >= revision; + end; + + class function SourceInfo.GetInfoOf(obj: &Object): SourceInfo; + begin + if not Assigned(obj) then + raise ArgumentNullException.Create('obj'); + Result := GetInfoOf(obj.GetType); + end; + + class function SourceInfo.GetInfoOf(&type: &Type): SourceInfo; + var + attrs: array of &Object; + sourceInfoAttr: SourceInfoAttribute; + begin + if not Assigned(&type) then + raise ArgumentNullException.Create('type'); + attrs := &type.GetCustomAttributes(TypeOf(SourceInfoAttribute), False); + if &Array(attrs).Length <> 1 then + Result := SourceInfo.Create('', 0.0, DateTime.Create(0)) + else + begin + sourceInfoAttr := SourceInfoAttribute(attrs[0]); + if Assigned(sourceInfoAttr) then + Result := SourceInfo.Create(sourceInfoAttr.SourceFile, sourceInfoAttr.Revision, sourceInfoAttr.Date) + else + Result := SourceInfo.Create('', 0.0, DateTime.Create(0)); + end; + end; + {$ENDREGION} + end. |
From: Marcel B. <jed...@us...> - 2005-01-22 14:38:31
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6532/main/assemblies Modified Files: Jedi.System.bdsproj Jedi.System.dpk Log Message: Added SourceVersioning unit Index: Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.dpk,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.System.dpk 24 Dec 2004 12:57:22 -0000 1.2 --- Jedi.System.dpk 22 Jan 2005 14:38:23 -0000 1.3 *************** *** 33,37 **** Jedi.System.Attributes in '..\run\Jedi.System.Attributes.pas', Jedi.System.Strings in '..\run\Jedi.System.Strings.pas', ! Jedi.System.IniFiles in '..\run\Jedi.System.IniFiles.pas'; [assembly: AssemblyTitle('Jedi.System')] --- 33,37 ---- Jedi.System.Attributes in '..\run\Jedi.System.Attributes.pas', Jedi.System.Strings in '..\run\Jedi.System.Strings.pas', ! Jedi.System.SourceVersioning in '..\run\Jedi.System.SourceVersioning.pas'; [assembly: AssemblyTitle('Jedi.System')] Index: Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.bdsproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.System.bdsproj 24 Dec 2004 12:57:12 -0000 1.2 --- Jedi.System.bdsproj 22 Jan 2005 14:38:23 -0000 1.3 *************** *** 172,180 **** <FileList> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="Borland.Delphi" Version="9.0.1761.24408" LinkUnits="False"/> ! <File FileName="System.Drawing.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Drawing" AssemblyName="System.Drawing" Version="1.0.5000.0" LinkUnits="False"/> <File FileName="..\run\Jedi.Collections.InlineEditable.pas" ContainerId="" ModuleName="Jedi.Collections.InlineEditable"/> <File FileName="..\run\Jedi.System.Attributes.pas" ContainerId="" ModuleName="Jedi.System.Attributes"/> <File FileName="..\run\Jedi.System.Strings.pas" ContainerId="" ModuleName="Jedi.System.Strings"/> ! <File FileName="..\run\Jedi.System.IniFiles.pas" ContainerId="" ModuleName="Jedi.System.IniFiles"/> </FileList> </DelphiDotNet.Personality> --- 172,180 ---- <FileList> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="Borland.Delphi" Version="9.0.1761.24408" LinkUnits="False"/> ! <File FileName="$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Drawing.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Drawing" AssemblyName="System.Drawing" Version="1.0.5000.0" LinkUnits="False"/> <File FileName="..\run\Jedi.Collections.InlineEditable.pas" ContainerId="" ModuleName="Jedi.Collections.InlineEditable"/> <File FileName="..\run\Jedi.System.Attributes.pas" ContainerId="" ModuleName="Jedi.System.Attributes"/> <File FileName="..\run\Jedi.System.Strings.pas" ContainerId="" ModuleName="Jedi.System.Strings"/> ! <File FileName="..\run\Jedi.System.SourceVersioning.pas" ContainerId="" ModuleName="Jedi.System.SourceVersioning"/> </FileList> </DelphiDotNet.Personality> |
From: Marcel B. <jed...@us...> - 2005-01-21 20:09:23
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9959/main/run Modified Files: Jedi.System.SourceVersioning.pas Log Message: Keyword check Index: Jedi.System.SourceVersioning.pas =================================================================== RCS file: /cvsroot/jedidotnet/main/run/Jedi.System.SourceVersioning.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.System.SourceVersioning.pas 21 Jan 2005 20:07:20 -0000 1.1 --- Jedi.System.SourceVersioning.pas 21 Jan 2005 20:09:02 -0000 1.2 *************** *** 46,50 **** {$REGION 'SourceVersion revision type'} ! [SourceVersion('$header$')] SourceVersionRevision = record (IComparable) {$REGION 'Constructors'} --- 46,50 ---- {$REGION 'SourceVersion revision type'} ! [SourceVersion('$Header$')] SourceVersionRevision = record (IComparable) {$REGION 'Constructors'} |
From: Marcel B. <jed...@us...> - 2005-01-21 20:07:29
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9583/main/run Added Files: Jedi.System.SourceVersioning.pas Log Message: Attribute that can be used to keep track of source version for classes, delegates, enumerations, interfaces and records --- NEW FILE: Jedi.System.SourceVersioning.pas --- unit Jedi.System.SourceVersioning; interface type {$REGION 'Forward declarations'} SourceVersionAttribute = class; SourceVersionRevision = record; {$ENDREGION} {$REGION 'SourceVersion attribute'} [AttributeUsage(AttributeTargets.Class or AttributeTargets.Delegate or AttributeTargets.Enum or AttributeTargets.Interface or AttributeTargets.Struct, &Inherited = False)] SourceVersionAttribute = class (Attribute) {$REGION 'Constructors'} public constructor Create(id: string); overload; constructor Create(sourceFile, revision, date: string); overload; {$ENDREGION} {$REGION 'Constants'} strict protected const dateFormat = 'yyyy\/MM\/dd HH\:mm\:ss'; {$ENDREGION} {$REGION 'Data'} strict private FDate: DateTime; FRevision: SourceVersionRevision; FSourceFile: string; {$ENDREGION} {$REGION 'Properties'} public property Date: DateTime read FDate; property Revision: SourceVersionRevision read FRevision; property SourceFile: string read FSourceFile; {$ENDREGION} {$REGION 'Static parsing methods'} public class function ParseDate(date: string): DateTime; static; class procedure ParseId(id: string; out source: string; out revision: SourceVersionRevision; out date: DateTime); static; class function ParseRevision(revision: string): SourceVersionRevision; static; class function ParseSource(source: string): string; static; {$ENDREGION} end; {$ENDREGION} {$REGION 'SourceVersion revision type'} [SourceVersion('$header$')] SourceVersionRevision = record (IComparable) {$REGION 'Constructors'} public constructor Create(revision: string); overload; constructor Create(revision: Double); overload; constructor Create(major, minor: Integer); overload; constructor Create(values: array of Integer); overload; {$ENDREGION} {$REGION 'Data'} strict private FValues: array of Integer; {$ENDREGION} {$REGION 'IComparable methods'} strict private function CompareTo(obj: &Object): Integer; {$ENDREGION} {$REGION 'Operators: comparisons'} public class operator Equal(left, right: SourceVersionRevision): Boolean; class operator GreaterThan(left, right: SourceVersionRevision): Boolean; class operator GreaterThanOrEqual(left, right: SourceVersionRevision): Boolean; class operator LessThan(left, right: SourceVersionRevision): Boolean; class operator LessThanOrEqual(left, right: SourceVersionRevision): Boolean; class operator NotEqual(left, right: SourceVersionRevision): Boolean; {$ENDREGION} {$REGION 'Operators: conversions'} public class operator Implicit(const Value: Double): SourceVersionRevision; class operator Implicit(const Value: SourceVersionRevision): Double; class operator Implicit(const Value: string): SourceVersionRevision; class operator Implicit(const Value: SourceVersionRevision): string; {$ENDREGION} {$REGION 'Overrides'} public function ToString: string; override; {$ENDREGION} {$REGION 'Properties (accessors)'} public function get_Count: Integer; function get_Items(index: Integer): Integer; {$ENDREGION} {$REGION 'Properties'} public property Count: Integer read get_Count; property Items[&index: Integer]: Integer read get_Items; default; {$ENDREGION} end; {$ENDREGION} implementation {$AUTOBOX ON} {$REGION 'implementation uses'} uses System.Globalization, System.Text, Jedi.System.Strings; {$ENDREGION} {$REGION 'Array types'} type IntegerArray = array of Integer; {$ENDREGION} {$REGION 'SourceVersionAttribute'} constructor SourceVersionAttribute.Create(id: string); begin inherited Create; ParseId(id, FSourceFile, FRevision, FDate); end; constructor SourceVersionAttribute.Create(sourceFile, revision, date: string); begin inherited Create; FDate := ParseDate(date); FSourceFile := ParseSource(sourceFile); FRevision := ParseRevision(revision); end; class function SourceVersionAttribute.ParseDate(date: string): DateTime; begin if date.ToLower.StartsWith('$date: ') then Result := DateTime.ParseExact(date.Substring(7, date.Length - 8).Trim, dateFormat, DateTimeFormatInfo.InvariantInfo) else Result := DateTime.ParseExact(date.Trim, dateFormat, DateTimeFormatInfo.InvariantInfo); end; class procedure SourceVersionAttribute.ParseId(id: string; out source: string; out revision: SourceVersionRevision; out date: DateTime); var idx: Integer; begin if id.ToLower.StartsWith('$id: ') then id := id.Substring(5, id.Length - 6).Trim else if id.ToLower.StartsWith('$header: ') then id := id.Substring(9, id.Length - 10).Trim else raise FormatException.Create('Not an $Id' + '$ or $Header' + '$ CVS keyword expansion.'); idx := id.ToLower.IndexOf(',v '); if idx <= 0 then raise FormatException.Create('file name not found in the specified id string.'); source := id.Substring(0, idx); id := id.Remove(0, idx + 3).Trim; idx := id.IndexOf(' '); if idx < 0 then raise FormatException.Create('revision number not found in the specified id string.'); revision := id.Substring(0, idx); id := id.Remove(0, idx + 1).Trim; idx := id.IndexOf(' '); if idx < 0 then raise FormatException.Create('date not found in the specified id string.'); date := DateTime.ParseExact(id.Substring(0, idx), dateFormat, DateTimeFormatInfo.InvariantInfo); end; class function SourceVersionAttribute.ParseRevision(revision: string): SourceVersionRevision; begin if revision.ToLower.StartsWith('$revision: ') then Result := revision.Substring(11, revision.Length - 12).Trim else Result := revision.Trim; end; class function SourceVersionAttribute.ParseSource(source: string): string; begin if source.ToLower.StartsWith('$rcsfile: ') then Result := source.Substring(10, source.Length - 13) else if source.ToLower.StartsWith('$source: ') then Result := source.Substring(9, source.Length - 12) else begin Result := source.Trim; if Result.ToLower.EndsWith(',v') then Result := Result.Substring(0, Result.Length - 2); end; end; {$ENDREGION} {$REGION 'SourceVersionRevision'} constructor SourceVersionRevision.Create(revision: string); var elements: array of string; idx: Integer; begin inherited Create; elements := revision.Split(['.']); FValues := new (IntegerArray, &Array(elements).Length); for idx := 0 to &Array(elements).Length - 1 do FValues[idx] := Int32.Parse(elements[idx]); end; constructor SourceVersionRevision.Create(revision: Double); begin Create(revision.ToString('r', NumberFormatInfo.InvariantInfo)); end; constructor SourceVersionRevision.Create(major, minor: Integer); begin inherited Create; FValues := IntegerArray.Create(major, minor); end; constructor SourceVersionRevision.Create(values: array of Integer); begin inherited Create; FValues := values; end; function SourceVersionRevision.CompareTo(obj: &Object): Integer; var secRev: SourceVersionRevision; maxIdx: Integer; idx: Integer; begin secRev := SourceVersionRevision(obj); maxIdx := Math.Min(&Array(FValues).Length, &Array(secRev.FValues).Length) - 1; Result := 0; idx := 0; while (Result = 0) and (idx <= maxIdx) do begin Result := IComparable(FValues[idx]).CompareTo(secRev.FValues[idx]); Inc(idx); end; if Result = 0 then Result := IComparable(&Array(FValues).Length).CompareTo(&Array(secRev.FValues).Length); end; class operator SourceVersionRevision.Equal(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) = 0; end; function SourceVersionRevision.get_Count: Integer; begin Result := &Array(FValues).Length; end; function SourceVersionRevision.get_Items(index: Integer): Integer; begin Result := FValues[index]; end; class operator SourceVersionRevision.GreaterThan(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) > 0; end; class operator SourceVersionRevision.GreaterThanOrEqual(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) >= 0; end; class operator SourceVersionRevision.Implicit(const value: Double): SourceVersionRevision; begin Result := SourceVersionRevision.Create(value); end; class operator SourceVersionRevision.Implicit(const value: SourceVersionRevision): Double; begin if value.Count > 2 then Result := System.Double.Nan else Result := System.Double.Parse(value.ToString, NumberFormatInfo.InvariantInfo); end; class operator SourceVersionRevision.Implicit(const value: string): SourceVersionRevision; begin Result := SourceVersionRevision.Create(value); end; class operator SourceVersionRevision.Implicit(const value: SourceVersionRevision): string; begin Result := value.ToString; end; class operator SourceVersionRevision.LessThan(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) < 0; end; class operator SourceVersionRevision.LessThanOrEqual(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) <= 0; end; class operator SourceVersionRevision.NotEqual(left, right: SourceVersionRevision): Boolean; begin Result := left.CompareTo(right) <> 0; end; function SourceVersionRevision.ToString: string; var sb: StringBuilder; element: Integer; begin sb := StringBuilder.Create; for element in FValues do begin sb.Append(element); sb.Append('.'); end; if sb.Length > 0 then Result := sb.ToString(0, sb.Length - 1) else Result := System.String.Empty; end; {$ENDREGION} end. |
From: Andreas H. <ah...@us...> - 2004-12-26 15:58:55
|
Update of /cvsroot/jedidotnet/dev/ahuser/WinFormsVCL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21311/ahuser/WinFormsVCL Added Files: Jedi.WinForms.VCL.Buttons.pas Jedi.WinForms.VCL.Controls.pas Jedi.WinForms.VCL.Forms.pas Jedi.WinForms.VCL.Graphics.pas Jedi.WinForms.VCL.ImgList.pas Jedi.WinForms.VCL.Menus.pas Log Message: Jedi.WinForms.VCL units --- NEW FILE: Jedi.WinForms.VCL.ImgList.pas --- {----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.WinForms.VCL.ImgList.pas, released on 2004-12-26. The Initial Developer of the Original Code is Andreas Hausladen <Andreas dott Hausladen att gmx dott de> Portions created by Andreas Hausladen are Copyright (C) 2004 Andreas Hausladen. All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the Project JEDI's JVCL home page, located at http://jvcl.sourceforge.net Known Issues: -----------------------------------------------------------------------------} // $Id: Jedi.WinForms.VCL.ImgList.pas,v 1.1 2004/12/26 15:58:41 ahuser Exp $ unit Jedi.WinForms.VCL.ImgList; interface uses System.Collections, System.Drawing, System.Drawing.Imaging, System.Windows.Forms, Borland.Vcl.Classes, Jedi.WinForms.VCL.Graphics; type TImageIndex = Integer; TCustomImageList = class; TChangeLink = class(TObject) private FSender: TCustomImageList; FOnChange: TNotifyEvent; public procedure Change; dynamic; property OnChange: TNotifyEvent read FOnChange write FOnChange; property Sender: TCustomImageList read FSender write FSender; end; TCustomImageList = class(TComponent) private FImageList: System.Windows.Forms.ImageList; FChangeLinks: ArrayList; FOnChange: TNotifyEvent; FBkColor: TColor; protected procedure Changed; virtual; public function get_Count: Integer; procedure set_Height(const Value: Integer); procedure set_Width(const Value: Integer); constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure set_ImageList(const Value: System.Windows.Forms.ImageList); procedure RegisterChanges(ChangeLink: TChangeLink); procedure UnregisterChanges(ChangeLink: TChangeLink); procedure Draw(Canvas: TCanvas; X, Y, Index: Integer; Enabled: Boolean = True); overload; property Count: Integer read get_Count; published function get_Height: Integer; function get_Width: Integer; procedure set_BkColor(const Value: TColor); property ImageList: System.Windows.Forms.ImageList read FImageList write set_ImageList; property Height: Integer read get_Height write set_Height; property Width: Integer read get_Width write set_Width; property BkColor: TColor read FBkColor write set_BkColor; property OnChange: TNotifyEvent read FOnChange write FOnChange; end; TImageList = class(TCustomImageList) end; implementation uses System.ComponentModel; { TChangeLink } procedure TChangeLink.Change; begin if Assigned(FOnChange) then FOnChange(Sender); end; { TCustomImageList } constructor TCustomImageList.Create(AOwner: TComponent); begin inherited Create; FChangeLinks := ArrayList.Create; FImageList := System.Windows.Forms.ImageList.Create; FImageList.ImageSize.Width := 16; FImageList.ImageSize.Height := 16; end; destructor TCustomImageList.Destroy; begin FImageList.Free; inherited Destroy; end; procedure TCustomImageList.Changed; var i: Integer; begin for i := FChangeLinks.Count - 1 downto 0 do TChangeLink(FChangeLinks[i]).Change; end; procedure TCustomImageList.RegisterChanges(ChangeLink: TChangeLink); begin if (ChangeLink <> nil) and not FChangeLinks.Contains(ChangeLink) then begin FChangeLinks.Add(ChangeLink); ChangeLink.Sender := Self; end; end; procedure TCustomImageList.UnregisterChanges(ChangeLink: TChangeLink); begin if (ChangeLink <> nil) and FChangeLinks.Contains(ChangeLink) then begin ChangeLink.Sender := nil; FChangeLinks.Remove(ChangeLink); end; end; procedure TCustomImageList.set_ImageList(const Value: System.Windows.Forms.ImageList); var i: Integer; begin if Value <> FImageList then begin FImageList.Images.Clear; if Value <> nil then begin FImageList.ImageSize := Value.ImageSize; FImageList.ColorDepth := Value.ColorDepth; FImageList.TransparentColor := Value.TransparentColor; FImageList.ImageStream := Value.ImageStream; for i := 0 to Value.Images.Count - 1 do FImageList.Images.Add(Value.Images.Item[i], Value.TransparentColor); Changed; end; end; end; procedure TCustomImageList.Draw(Canvas: TCanvas; X, Y, Index: Integer; Enabled: Boolean); begin if Enabled then ImageList.Draw(Canvas.Handle, X, Y, Index) else ControlPaint.DrawImageDisabled(Canvas.Handle, ImageList.Images[Index], X, Y, ToNETColor(BkColor)); end; function TCustomImageList.get_Count: Integer; begin Result := ImageList.Images.Count; end; procedure TCustomImageList.set_Height(const Value: Integer); begin ImageList.ImageSize.Height := Value; end; procedure TCustomImageList.set_Width(const Value: Integer); begin ImageList.ImageSize.Width := Value; end; function TCustomImageList.get_Height: Integer; begin Result := FImageList.ImageSize.Height; end; function TCustomImageList.get_Width: Integer; begin Result := FImageList.ImageSize.Width; end; procedure TCustomImageList.set_BkColor(const Value: TColor); begin FBkColor := Value; end; end. --- NEW FILE: Jedi.WinForms.VCL.Buttons.pas --- {----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.WinForms.VCL.Buttons.pas, released on 2004-12-26. The Initial Developer of the Original Code is Andreas Hausladen <Andreas dott Hausladen att gmx dott de> Portions created by Andreas Hausladen are Copyright (C) 2004 Andreas Hausladen. All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the Project JEDI's JVCL home page, located at http://jvcl.sourceforge.net Known Issues: -----------------------------------------------------------------------------} // $Id: Jedi.WinForms.VCL.Buttons.pas,v 1.1 2004/12/26 15:58:41 ahuser Exp $ unit Jedi.WinForms.VCL.Buttons; interface uses System.Drawing, System.Windows.Forms, Borland.Vcl.Classes, Borland.Vcl.Messages, Jedi.WinForms.VCL.Controls, Jedi.WinForms.VCL.Graphics; type { Quick & Dirty, simply uses a WinForms Button which has too many features for a TSpeedButton like "Focus". } TEventHelperSpeedButton = class(System.Windows.Forms.Button) strict protected procedure OnClick(e: EventArgs); override; public procedure Click; virtual; end; TSpeedButton = class(TEventHelperSpeedButton) // TGraphicControl private FGlyph: TBitmap; FOnClick: TNotifyEvent; procedure SetGlyph(const Value: TBitmap); function GetFlat: Boolean; procedure SetFlat(const Value: Boolean); function GetCaption: TCaption; procedure SetCaption(const Value: TCaption); strict protected procedure OnInvalidated(e: InvalidateEventArgs); override; protected procedure Paint; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Click; override; published property Caption: TCaption read GetCaption write SetCaption; property Flat: Boolean read GetFlat write SetFlat; property Glyph: TBitmap read FGlyph write SetGlyph; property OnClick: TNotifyEvent read FOnClick write FOnClick; end; implementation { TSpeedButton } procedure TSpeedButton.Click; begin inherited Click; if Assigned(FOnClick) then FOnClick(Self); end; constructor TSpeedButton.Create(AOwner: TComponent); begin inherited Create; FGlyph := TBitmap.Create; TabStop := False; //FOwner := AOwner; end; destructor TSpeedButton.Destroy; begin FGlyph.Free; inherited Destroy; end; function TSpeedButton.GetCaption: TCaption; begin Result := Text; end; function TSpeedButton.GetFlat: Boolean; begin Result := FlatStyle = System.Windows.Forms.FlatStyle.Flat; end; procedure TSpeedButton.Paint; begin Refresh; end; procedure TSpeedButton.OnInvalidated(e: InvalidateEventArgs); begin inherited OnInvalidated(e); if Parent <> nil then begin // Optimization with e.InvalidRect does not work here because the rectangle // is limited to this control and does not apply to the parent control which // seems to do not get any Paint event for the invalidated area at all. // (WinForms Bug?) Parent.Invalidate; end; end; procedure TSpeedButton.SetCaption(const Value: TCaption); begin Text := Value; end; procedure TSpeedButton.SetFlat(const Value: Boolean); begin if Value then FlatStyle := System.Windows.Forms.FlatStyle.Flat else FlatStyle := System.Windows.Forms.FlatStyle.Standard; end; procedure TSpeedButton.SetGlyph(const Value: TBitmap); begin if Value <> FGlyph then FGlyph.Assign(Value); if FGlyph.Empty then Image := nil else Image := FGlyph.Handle; end; { TEventHelperSpeedButton } procedure TEventHelperSpeedButton.Click; begin end; procedure TEventHelperSpeedButton.OnClick(e: EventArgs); begin Click; inherited OnClick(e); end; end. --- NEW FILE: Jedi.WinForms.VCL.Graphics.pas --- {----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.WinForms.VCL.Graphics.pas, released on 2004-12-26. The Initial Developer of the Original Code is Andreas Hausladen <Andreas dott Hausladen att gmx dott de> Portions created by Andreas Hausladen are Copyright (C) 2004 Andreas Hausladen. All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the Project JEDI's JVCL home page, [...1604 lines suppressed...] FHeight := -(Value * 96) / PixelsPerInch; end; procedure TFont.SetStyle(Value: TFontStyles); begin if Value <> FStyle then begin FStyle := Value; Changed; end; end; function TFont.GetBrush: System.Drawing.Brush; begin if not Assigned(FBrush) then FBrush := SolidBrush.Create(ToNETColor(Color)); Result := FBrush; end; end. --- NEW FILE: Jedi.WinForms.VCL.Forms.pas --- {----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.WinForms.VCL.Forms.pas, released on 2004-12-26. The Initial Developer of the Original Code is Andreas Hausladen <Andreas dott Hausladen att gmx dott de> Portions created by Andreas Hausladen are Copyright (C) 2004 Andreas Hausladen. All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the Project JEDI's JVCL home page, located at http://jvcl.sourceforge.net Known Issues: -----------------------------------------------------------------------------} // $Id: Jedi.WinForms.VCL.Forms.pas,v 1.1 2004/12/26 15:58:41 ahuser Exp $ unit Jedi.WinForms.VCL.Forms; interface uses System.Windows.Forms; type TApplication = class(TObject) private FShowHint: Boolean; procedure SetShowHint(const Value: Boolean); public procedure CancelHint; property ShowHint: Boolean read FShowHint write SetShowHint; end; function Application: TApplication; implementation uses Jedi.WinForms.VCL.Controls; var FApplication: TApplication; function Application: TApplication; begin if not Assigned(FApplication) then FApplication := TApplication.Create; Result := FApplication; end; { TApplication } procedure TApplication.CancelHint; begin TWinControl.ControlToolTip.Active := False; TWinControl.ControlToolTip.Active := ShowHint; end; procedure TApplication.SetShowHint(const Value: Boolean); begin if Value <> FShowHint then begin FShowHint := Value; CancelHint; end; end; end. --- NEW FILE: Jedi.WinForms.VCL.Menus.pas --- {----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.WinForms.VCL.Menus.pas, released on 2004-12-26. The Initial Developer of the Original Code is Andreas Hausladen <Andreas dott Hausladen att gmx dott de> Portions created by Andreas Hausladen are Copyright (C) 2004 Andreas Hausladen. All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the Project JEDI's JVCL home page, located at http://jvcl.sourceforge.net Known Issues: -----------------------------------------------------------------------------} // $Id: Jedi.WinForms.VCL.Menus.pas,v 1.1 2004/12/26 15:58:41 ahuser Exp $ unit Jedi.WinForms.VCL.Menus; interface uses System.Drawing, System.Windows.Forms, Borland.Vcl.Classes; type TPopupMenu = System.Windows.Forms.ContextMenu; TPopupMenuHelper = class helper for TPopupMenu public procedure Popup(X, Y: Integer); end; implementation { TPopupMenuHelper } procedure TPopupMenuHelper.Popup(X, Y: Integer); begin if Form.ActiveForm <> nil then Show(Form.ActiveForm, Point.Create(X, Y)); end; end. --- NEW FILE: Jedi.WinForms.VCL.Controls.pas --- {----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.WinForms.VCL.Controls.pas, released on 2004-12-26. The Initial Developer of the Original Code is Andreas Hausladen <Andreas dott Hausladen att gmx dott de> Portions created by Andreas Hausladen are Copyright (C) 2004 Andreas Hausladen. All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the Project JEDI's JVCL home page, located at http://jvcl.sourceforge.net Known Issues: -----------------------------------------------------------------------------} // $Id: Jedi.WinForms.VCL.Controls.pas,v 1.1 2004/12/26 15:58:41 ahuser Exp $ unit Jedi.WinForms.VCL.Controls; interface uses System.Drawing, System.Collections, System.ComponentModel, System.Windows.Forms, System.Windows.Forms.Design, Borland.Vcl.Messages, Borland.Vcl.Classes, Borland.Vcl.Types, Jedi.WinForms.VCL.Graphics, Jedi.WinForms.VCL.Menus; const CM_BASE = $B000; CM_MOUSEENTER = CM_BASE + 19; CM_MOUSELEAVE = CM_BASE + 20; type TCaption = string; TMouseButton = (mbLeft, mbMiddle, mbRight); TDragState = (dsDragEnter, dsDragLeave, dsDragMove); TControlStyle = set of (csAcceptsControls, csCaptureMouse, csDesignInteractive, csClickEvents, csFramed, csSetCaption, csOpaque, csDoubleClicks, csFixedWidth, csFixedHeight, csNoDesignVisible, csReplicatable, csNoStdEvents, csDisplayDragImage, csReflector, csActionClient, csMenuEvents, csNeedsBorderPaint, csParentBackground); TDragObject = class(DragEventArgs) end; TMouseEvent = procedure(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer) of object; TMouseMoveEvent = procedure(Sender: TObject; Shift: TShiftState; X, Y: Integer) of object; TDragOverEvent = procedure(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean) of object; TDragDropEvent = procedure(Sender, Source: TObject; X, Y: Integer) of object; TStartDragEvent = procedure(Sender: TObject; var DragObject: TDragObject) of object; TEndDragEvent = procedure(Sender, Target: TObject; X, Y: Integer) of object; TEventHelperControl = class(System.Windows.Forms.Control) strict protected procedure OnDragEnter(drgevent: DragEventArgs); override; procedure OnDragLeave(e: EventArgs); override; procedure OnDragDrop(drgevent: DragEventArgs); override; procedure OnDragOver(drgevent: DragEventArgs); override; procedure OnDoubleClick(e: EventArgs); override; procedure OnPaintBackground(pevent: PaintEventArgs); override; procedure OnResize(e: EventArgs); override; procedure OnClick(e: EventArgs); override; procedure OnMouseLeave(e: EventArgs); override; procedure OnMouseEnter(e: EventArgs); override; procedure OnMouseMove(e: MouseEventArgs); override; procedure OnMouseUp(e: MouseEventArgs); override; procedure OnMouseDown(e: MouseEventArgs); override; protected procedure Click; virtual; procedure DblClick; virtual; procedure Resize; virtual; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); virtual; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); virtual; procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); virtual; procedure DragDrop(Source: TObject; X, Y: Integer); virtual; procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); virtual; procedure WndProc(var Message: TMessage); virtual; public function Perform(Msg: Cardinal; WParam, LParam: Integer): Integer; end; TAlign = (alNone, alTop, alBottom, alLeft, alRight, alClient, alCustom); TWinControl = class(TEventHelperControl) strict private FOwner: TComponent; FOnClick: TNotifyEvent; FOnDblClick: TNotifyEvent; FOnResize: TNotifyEvent; FOnMouseDown: TMouseEvent; FOnMouseUp: TMouseEvent; FOnMouseMove: TMouseMoveEvent; FOnContextPopup: TNotifyEvent; FOnDragDrop: TDragDropEvent; FOnDragOver: TDragOverEvent; FOnStartDrag: TStartDragEvent; FOnEndDrag: TEndDragEvent; private FPopupMenu: TPopupMenu; FShowHint: Boolean; FHint: string; FControlStyle: TControlStyle; procedure SetAlign(const Value: TAlign); function GetAlign: TAlign; procedure SetPopupMenu(const Value: TPopupMenu); procedure SetShowHint(const Value: Boolean); procedure SetHint(const Value: string); procedure SetControlStyle(const Value: TControlStyle); function GetClientHeight: Integer; function GetClientWidth: Integer; procedure SetClientHeight(const Value: Integer); procedure SetClientWidth(const Value: Integer); protected function GetCaption: string; procedure SetCaption(const Value: string); procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Click; override; procedure DblClick; override; procedure Resize; override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); override; procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); override; procedure DragDrop(Source: TObject; X, Y: Integer); override; procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); override; property ControlStyle: TControlStyle read FControlStyle write SetControlStyle; property Caption: string read GetCaption write SetCaption; public function GetClientRect: TRect; class var ControlToolTip: ToolTip; class constructor Create; constructor Create(AOwner: TComponent); overload; virtual; constructor Create; overload; function ClientToScreen(const Pt: TPoint): TPoint; function ScreenToClient(const Pt: TPoint): TPoint; // Events property OnMouseDown: TMouseEvent read FOnMouseDown write FOnMouseDown; property OnMouseUp: TMouseEvent read FOnMouseUp write FOnMouseUp; property OnMouseMove: TMouseMoveEvent read FOnMouseMove write FOnMouseMove; property OnClick: TNotifyEvent read FOnClick write FOnClick; property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick; property OnContextPopup: TNotifyEvent read FOnContextPopup write FOnContextPopup; property OnResize: TNotifyEvent read FOnResize write FOnResize; property OnDragDrop: TDragDropEvent read FOnDragDrop write FOnDragDrop; property OnDragOver: TDragOverEvent read FOnDragOver write FOnDragOver; property OnStartDrag: TStartDragEvent read FOnStartDrag write FOnStartDrag; property OnEndDrag: TEndDragEvent read FOnEndDrag write FOnEndDrag; property Align: TAlign read GetAlign write SetAlign default alNone; property PopupMenu: TPopupMenu read FPopupMenu write SetPopupMenu; {TODO: PopupMenu} property ShowHint: Boolean read FShowHint write SetShowHint; property Hint: string read FHint write SetHint; property ClientWidth: Integer read GetClientWidth write SetClientWidth; property ClientHeight: Integer read GetClientHeight write SetClientHeight; property ClientRect: TRect read GetClientRect; property Owner: TComponent read FOwner; end; TControlCanvas = class(TCanvas) private FControl: TWinControl; protected procedure CreateHandle; override; public procedure SetControl(const Value: TWinControl); property Control: TWinControl read FControl write SetControl; end; TCustomControl = class(TWinControl) private FCanvas: TCanvas; strict protected procedure OnPaint(e: PaintEventArgs); override; protected procedure Paint; virtual; property Canvas: TCanvas read FCanvas; public constructor Create(AOwner: TComponent); override; end; TGraphicControl = class(TCustomControl) strict protected procedure OnInvalidated(e: InvalidateEventArgs); override; end; function ButtonsToMouseButton(Buttons: System.Windows.Forms.MouseButtons): TMouseButton; function GetShiftState(Buttons: System.Windows.Forms.MouseButtons): TShiftState; implementation {$AUTOBOX ON} function ButtonsToMouseButton(Buttons: System.Windows.Forms.MouseButtons): TMouseButton; begin Result := mbLeft; if Buttons = System.Windows.Forms.MouseButtons.Left then Result := mbLeft; if Buttons = System.Windows.Forms.MouseButtons.Middle then Result := mbMiddle; if Buttons = System.Windows.Forms.MouseButtons.Right then Result := mbRight; end; function GetShiftState(Buttons: System.Windows.Forms.MouseButtons): TShiftState; begin Result := []; case Buttons of System.Windows.Forms.MouseButtons.Left: Include(Result, ssLeft); System.Windows.Forms.MouseButtons.Middle: Include(Result, ssMiddle); System.Windows.Forms.MouseButtons.Right: Include(Result, ssRight); end; {TODO: Shift keys} end; { TEventHelperControl } procedure TEventHelperControl.Click; begin end; procedure TEventHelperControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin end; procedure TEventHelperControl.MouseMove(Shift: TShiftState; X, Y: Integer); begin end; procedure TEventHelperControl.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin end; procedure TEventHelperControl.OnClick(e: EventArgs); begin Click; inherited OnClick(e); end; procedure TEventHelperControl.OnPaintBackground(pevent: PaintEventArgs); begin if Perform(WM_ERASEBKGND, 0, 0) = 0 then inherited OnPaintBackground(pevent); end; procedure TEventHelperControl.OnMouseDown(e: MouseEventArgs); begin MouseDown(ButtonsToMouseButton(e.Button), GetShiftState(e.Button), e.X, e.Y); inherited OnMouseDown(e); end; procedure TEventHelperControl.OnMouseEnter(e: EventArgs); begin Perform(CM_MOUSEENTER, 0, 0); inherited OnMouseEnter(e); end; procedure TEventHelperControl.OnMouseLeave(e: EventArgs); begin Perform(CM_MOUSELEAVE, 0, 0); inherited OnMouseLeave(e); end; procedure TEventHelperControl.OnMouseMove(e: MouseEventArgs); begin MouseMove(GetShiftState(e.Button), e.X, e.Y); inherited OnMouseMove(e); end; procedure TEventHelperControl.OnMouseUp(e: MouseEventArgs); begin MouseUp(ButtonsToMouseButton(e.Button), GetShiftState(e.Button), e.X, e.Y); inherited OnMouseUp(e); end; procedure TEventHelperControl.OnResize(e: EventArgs); begin Resize; inherited OnResize(e); end; procedure TEventHelperControl.Resize; begin end; procedure TEventHelperControl.OnDoubleClick(e: EventArgs); begin DblClick; inherited OnDoubleClick(e); end; procedure TEventHelperControl.DblClick; begin end; procedure TEventHelperControl.OnDragDrop(drgevent: DragEventArgs); begin DragDrop(drgevent, drgevent.X, drgevent.Y); inherited OnDragDrop(drgevent); end; procedure TEventHelperControl.OnDragOver(drgevent: DragEventArgs); var Allowed: Boolean; begin Allowed := False; DragOver(drgevent, drgevent.X, drgevent.Y, dsDragMove, Allowed); if Allowed then drgevent.Effect := DragDropEffects.All else drgevent.Effect := DragDropEffects.None; inherited OnDragOver(drgevent); end; procedure TEventHelperControl.OnDragEnter(drgevent: DragEventArgs); var Allowed: Boolean; begin Allowed := False; DragOver(drgevent, drgevent.X, drgevent.Y, dsDragEnter, Allowed); if Allowed then drgevent.Effect := DragDropEffects.All else drgevent.Effect := DragDropEffects.None; inherited OnDragEnter(drgevent); end; procedure TEventHelperControl.OnDragLeave(e: EventArgs); begin inherited OnDragLeave(e); end; procedure TEventHelperControl.DragDrop(Source: TObject; X, Y: Integer); begin end; procedure TEventHelperControl.DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin end; function TEventHelperControl.Perform(Msg: Cardinal; WParam, LParam: Integer): Integer; var Message: TMessage; begin Message := TMessage.Create(Msg, WParam, LParam); WndProc(Message); Result := Message.Result; end; procedure TEventHelperControl.WndProc(var Message: TMessage); begin Dispatch(Message); end; { TWinControl } class constructor TWinControl.Create; begin ControlToolTip := ToolTip.Create; end; constructor TWinControl.Create; begin Create(nil); end; constructor TWinControl.Create(AOwner: TComponent); begin inherited Create; FOwner := AOwner; end; procedure TWinControl.Click; begin if Assigned(FOnClick) then FOnClick(Self); end; procedure TWinControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Assigned(FOnMouseDown) then FOnMouseDown(Self, Button, Shift, X, Y); end; procedure TWinControl.MouseMove(Shift: TShiftState; X, Y: Integer); begin if Assigned(FOnMouseMove) then FOnMouseMove(Self, Shift, X, Y); end; procedure TWinControl.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Assigned(FOnMouseUp) then FOnMouseUp(Self, Button, Shift, X, Y); end; procedure TWinControl.Resize; begin if Assigned(FOnResize) then FOnResize(Self); end; procedure TWinControl.DragDrop(Source: TObject; X, Y: Integer); begin if Assigned(FOnDragDrop) then FOnDragDrop(Self, Source, X, Y); end; procedure TWinControl.DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin if Assigned(FOnDragOver) then FOnDragOver(Self, Source, X, Y, State, Accept); end; procedure TWinControl.SetAlign(const Value: TAlign); begin case Value of alTop: Dock := DockStyle.Top; alBottom: Dock := DockStyle.Bottom; alLeft: Dock := DockStyle.Left; alRight: Dock := DockStyle.Right; alClient: Dock := DockStyle.Fill; else Dock := DockStyle.None; end; end; function TWinControl.GetAlign: TAlign; begin case Dock of DockStyle.None: Result := alNone; DockStyle.Top: Result := alTop; DockStyle.Bottom: Result := alBottom; DockStyle.Left: Result := alLeft; DockStyle.Right: Result := alRight; DockStyle.Fill: Result := alClient; else Result := alCustom; end; end; procedure TWinControl.SetPopupMenu(const Value: TPopupMenu); begin if Value <> FPopupMenu then begin if Assigned(FPopupMenu) then FPopupMenu.RemoveFreeNotification(Self); ContextMenu := Value; if Assigned(FPopupMenu) then FPopupMenu.FreeNotification(Self); end; end; procedure TWinControl.Notification(AComponent: TComponent; Operation: TOperation); begin inherited Notification(AComponent, Operation); if Operation = opRemove then begin if AComponent = FPopupMenu then PopupMenu := nil; end; end; procedure TWinControl.SetShowHint(const Value: Boolean); begin if Value <> FShowHint then begin if FShowHint then ControlToolTip.SetToolTip(Self, nil); ControlToolTip.Active := True; FShowHint := Value; if FShowHint then ControlToolTip.SetToolTip(Self, Hint); end; end; procedure TWinControl.SetHint(const Value: string); begin if Value <> FHint then begin FHint := Value; if ShowHint then begin ControlToolTip.SetToolTip(Self, FHint); ControlToolTip.Active := True; end; end; end; procedure TWinControl.DblClick; begin if Assigned(FOnDblClick) then FOnDblClick(Self); end; procedure TWinControl.SetControlStyle(const Value: TControlStyle); begin if Value <> FControlStyle then begin FControlStyle := Value; SetStyle(ControlStyles.Opaque, csOpaque in FControlStyle); SetStyle(ControlStyles.FixedWidth, csFixedWidth in FControlStyle); SetStyle(ControlStyles.FixedHeight, csFixedHeight in FControlStyle); SetStyle(ControlStyles.ContainerControl, csAcceptsControls in FControlStyle); SetStyle(ControlStyles.StandardDoubleClick, csDoubleClicks in FControlStyle); SetStyle(ControlStyles.StandardClick, csClickEvents in FControlStyle); end; end; function TWinControl.ClientToScreen(const Pt: TPoint): TPoint; var P: System.Windows.Forms.Control; begin Result := Pt; P := Parent; while P <> nil do begin Inc(Result.X, P.Left); Inc(Result.Y, P.Top); P := P.Parent; end; end; function TWinControl.ScreenToClient(const Pt: TPoint): TPoint; var P: System.Windows.Forms.Control; begin Result := Pt; P := Parent; while P <> nil do begin Dec(Result.X, P.Left); Dec(Result.Y, P.Top); P := P.Parent; end; end; function TWinControl.GetClientHeight: Integer; begin Result := Height; end; function TWinControl.GetClientWidth: Integer; begin Result := Width; end; procedure TWinControl.SetClientHeight(const Value: Integer); begin Height := Value; end; procedure TWinControl.SetClientWidth(const Value: Integer); begin Width := Value; end; function TWinControl.GetClientRect: TRect; begin Result := Rect(0, 0, ClientWidth, ClientHeight); end; function TWinControl.GetCaption: string; begin Result := Text; end; procedure TWinControl.SetCaption(const Value: string); begin Text := Value; end; { TCustomControl } procedure TCustomControl.OnPaint(e: PaintEventArgs); begin Canvas.Handle := e.Graphics; try Paint; finally Canvas.Handle := nil; end; end; procedure TCustomControl.Paint; begin end; constructor TCustomControl.Create(AOwner: TComponent); begin inherited Create(AOwner); FCanvas := TControlCanvas.Create; TControlCanvas(FCanvas).Control := Self; end; { TControlCanvas } procedure TControlCanvas.CreateHandle; begin Handle := Control.CreateGraphics; end; procedure TControlCanvas.SetControl(const Value: TWinControl); begin Handle := nil; FControl := Value; if Value <> nil then AssignedObject := Value.Handle; end; { TGraphicControl } procedure TGraphicControl.OnInvalidated(e: InvalidateEventArgs); begin inherited OnInvalidated(e); if Parent <> nil then begin // Optimization with e.InvalidRect does not work here because the rectangle // is limited to this control and does not apply to the parent control which // seems to do not get any Paint event for the invalidated area at all. // (WinForms Bug?) Parent.Invalidate; end; end; end. |
From: Andreas H. <ah...@us...> - 2004-12-26 15:58:52
|
Update of /cvsroot/jedidotnet/dev/ahuser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21311/ahuser Added Files: readme.txt Log Message: Jedi.WinForms.VCL units --- NEW FILE: readme.txt --- This is Andreas Hausladen's personal play ground |
From: Andreas H. <ah...@us...> - 2004-12-26 15:57:49
|
Update of /cvsroot/jedidotnet/dev/ahuser/WinFormsVCL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21106/WinFormsVCL Log Message: Directory /cvsroot/jedidotnet/dev/ahuser/WinFormsVCL added to the repository |
From: Andreas H. <ah...@us...> - 2004-12-26 15:57:39
|
Update of /cvsroot/jedidotnet/dev/ahuser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21084/ahuser Log Message: Directory /cvsroot/jedidotnet/dev/ahuser added to the repository |
From: Marcel B. <jed...@us...> - 2004-12-24 12:57:40
|
Update of /cvsroot/jedidotnet/nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23620/nunit Modified Files: Nunit.Jedi.System.bdsproj Nunit.Jedi.System.dpk Log Message: Added IniFile handling (incomplete; only partially tested) Index: Nunit.Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.dpk,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Nunit.Jedi.System.dpk 6 Dec 2004 11:44:09 -0000 1.2 --- Nunit.Jedi.System.dpk 24 Dec 2004 12:57:22 -0000 1.3 *************** *** 24,36 **** {$IMAGEBASE $400000} {$IMPLICITBUILD OFF} requires Borland.Delphi, nunit.framework, ! Jedi.System; contains Jedi.System.Attributes.NUnit in 'source\Jedi.System.Attributes.NUnit.pas', ! Jedi.System.Strings.NUnit in 'source\Jedi.System.Strings.NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.System')] --- 24,41 ---- {$IMAGEBASE $400000} {$IMPLICITBUILD OFF} + {$R 'resources\Jedi.System.IniFiles.resources' 'resources\Jedi.System.IniFiles.resx'} requires Borland.Delphi, nunit.framework, ! Jedi.System, ! System, ! System.Data, ! System.XML; contains Jedi.System.Attributes.NUnit in 'source\Jedi.System.Attributes.NUnit.pas', ! Jedi.System.Strings.NUnit in 'source\Jedi.System.Strings.NUnit.pas', ! Jedi.System.IniFile.NUnit in 'source\Jedi.System.IniFile.NUnit.pas'; [assembly: AssemblyTitle('Nunit.Jedi.System')] Index: Nunit.Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/nunit/Nunit.Jedi.System.bdsproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Nunit.Jedi.System.bdsproj 6 Dec 2004 11:44:09 -0000 1.2 --- Nunit.Jedi.System.bdsproj 24 Dec 2004 12:57:22 -0000 1.3 *************** *** 45,49 **** <Compiler Name="ShowHints" Type="Boolean">True</Compiler> <Compiler Name="ShowWarnings" Type="Boolean">True</Compiler> ! <Compiler Name="UnitAliases" Type="String">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.Strings</Compiler> <Compiler Name="NamespacePrefix" Type="String"></Compiler> <Compiler Name="GenerateDocumentation" Type="Boolean">False</Compiler> --- 45,49 ---- <Compiler Name="ShowHints" Type="Boolean">True</Compiler> <Compiler Name="ShowWarnings" Type="Boolean">True</Compiler> ! <Compiler Name="UnitAliases" Type="String">WinTypes=Borland.Vcl.Windows;WinProcs=Borland.Vcl.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;Jedi.System=Jedi.System.Attributes, Jedi.System.Strings, Jedi.System.IniFiles</Compiler> <Compiler Name="NamespacePrefix" Type="String"></Compiler> <Compiler Name="GenerateDocumentation" Type="Boolean">False</Compiler> *************** *** 120,125 **** <Directories Name="PackageDLLOutputDir" Type="String">bin</Directories> <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> ! <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin</Directories> ! <Directories Name="Packages" Type="String">Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> <Directories Name="DebugSourceDirs" Type="String"></Directories> --- 120,125 ---- <Directories Name="PackageDLLOutputDir" Type="String">bin</Directories> <Directories Name="PackageDCPOutputDir" Type="String">bin</Directories> ! <Directories Name="SearchPath" Type="String">$(BDS)\Lib;..\main\bin;resources</Directories> ! <Directories Name="Packages" Type="String">System.XML.dll;System.Data.dll;System.dll;Jedi.System;nunit.framework.dll;Borland.Delphi</Directories> <Directories Name="Conditionals" Type="String"></Directories> <Directories Name="DebugSourceDirs" Type="String"></Directories> *************** *** 171,179 **** --- 171,184 ---- </VersionInfoKeys> <FileList> + <File FileName="resources\Jedi.System.IniFiles.resx" ContainerId="ResXCompiler" ModuleName="Jedi.System.IniFiles"/> <File FileName="Borland.Delphi.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Borland.Delphi" AssemblyName="borland.delphi" Version="9.0.1761.24408" LinkUnits="False"/> <File FileName="nunit.framework.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="nunit.framework" AssemblyName="nunit.framework" Version="2.2.1.0" LinkUnits="False"/> <File FileName="..\main\bin\Jedi.System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="Jedi.System" AssemblyName="Jedi.System" Version="1.0.0.0" LinkUnits="False"/> + <File FileName="System.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System" AssemblyName="system" Version="1.0.5000.0" LinkUnits="False"/> + <File FileName="System.Data.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.Data" AssemblyName="system.data" Version="1.0.5000.0" LinkUnits="False"/> + <File FileName="System.XML.dll" ContainerId="DelphiDotNetAssemblyCompiler" ModuleName="System.XML" AssemblyName="system.xml" Version="1.0.5000.0" LinkUnits="False"/> <File FileName="source\Jedi.System.Attributes.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Attributes.NUnit"/> <File FileName="source\Jedi.System.Strings.NUnit.pas" ContainerId="" ModuleName="Jedi.System.Strings.NUnit"/> + <File FileName="source\Jedi.System.IniFile.NUnit.pas" ContainerId="" ModuleName="Jedi.System.IniFile.NUnit"/> </FileList> </DelphiDotNet.Personality> |
From: Marcel B. <jed...@us...> - 2004-12-24 12:57:38
|
Update of /cvsroot/jedidotnet/main/assemblies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23620/main/assemblies Modified Files: Jedi.System.bdsproj Jedi.System.dpk Log Message: Added IniFile handling (incomplete; only partially tested) Index: Jedi.System.dpk =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.dpk,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.System.dpk 5 Dec 2004 13:19:48 -0000 1.1 --- Jedi.System.dpk 24 Dec 2004 12:57:22 -0000 1.2 *************** *** 32,36 **** Jedi.Collections.InlineEditable in '..\run\Jedi.Collections.InlineEditable.pas', Jedi.System.Attributes in '..\run\Jedi.System.Attributes.pas', ! Jedi.System.Strings in '..\run\Jedi.System.Strings.pas'; [assembly: AssemblyTitle('Jedi.System')] --- 32,37 ---- Jedi.Collections.InlineEditable in '..\run\Jedi.Collections.InlineEditable.pas', Jedi.System.Attributes in '..\run\Jedi.System.Attributes.pas', ! Jedi.System.Strings in '..\run\Jedi.System.Strings.pas', ! Jedi.System.IniFiles in '..\run\Jedi.System.IniFiles.pas'; [assembly: AssemblyTitle('Jedi.System')] Index: Jedi.System.bdsproj =================================================================== RCS file: /cvsroot/jedidotnet/main/assemblies/Jedi.System.bdsproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.System.bdsproj 5 Dec 2004 13:19:48 -0000 1.1 --- Jedi.System.bdsproj 24 Dec 2004 12:57:12 -0000 1.2 *************** *** 176,179 **** --- 176,180 ---- <File FileName="..\run\Jedi.System.Attributes.pas" ContainerId="" ModuleName="Jedi.System.Attributes"/> <File FileName="..\run\Jedi.System.Strings.pas" ContainerId="" ModuleName="Jedi.System.Strings"/> + <File FileName="..\run\Jedi.System.IniFiles.pas" ContainerId="" ModuleName="Jedi.System.IniFiles"/> </FileList> </DelphiDotNet.Personality> |
From: Marcel B. <jed...@us...> - 2004-12-24 12:57:37
|
Update of /cvsroot/jedidotnet/nunit/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23620/nunit/resources Added Files: Jedi.System.IniFiles.resx Log Message: Added IniFile handling (incomplete; only partially tested) --- NEW FILE: Jedi.System.IniFiles.resx --- <?xml version="1.0" encoding="utf-8" ?> <root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="ResMimeType"> <value>text/microsoft-resx</value> </resheader> <resheader name="Version"> <value>1.0.0.0</value> </resheader> <resheader name="Reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="Writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="initest"> <value>MyTestString=Abcdef ghij klmnop; 1+1=2 #a comment, or maybe not, depending on settings [Basics] UseKeyMapper=1 AutoWriteSettings=1 TestString=Just another test. EmptyString= [TempList] Count=3 Item1=Abc Item2=Def Item3=Ghi </value> </data> </root> |
From: Marcel B. <jed...@us...> - 2004-12-24 12:57:37
|
Update of /cvsroot/jedidotnet/main/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23620/main/run Added Files: Jedi.System.IniFiles.pas Log Message: Added IniFile handling (incomplete; only partially tested) --- NEW FILE: Jedi.System.IniFiles.pas --- {--------------------------------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: Jedi.System.IniFiles.pas, released on 2004-12-24. The Initial Developer of the Original Code is Marcel Bestebroer Portions created by Marcel Bestebroer are Copyright (C) 2004 Marcel Bestebroer All Rights Reserved. Contributor(s): You may retrieve the latest version of this file at the JEDI.NET home page, located at http://sf.net/projects/jedidotnet [...1497 lines suppressed...] if hasWritten and emptyLineBetweenSections then writer.WriteLine; writer.WriteLine('[{0}]', sectEnum.Key); SaveKeys(writer, SortedList(sectEnum.Value)); hasWritten := True; end; end; end; procedure InMemoryConfigFile.SaveKeys(writer: TextWriter; list: SortedList); var enum: IDictionaryEnumerator; begin enum := list.GetEnumerator; while enum.MoveNext do writer.WriteLine('{0}={1}', enum.Key, enum.Value); end; {$ENDREGION} end. |
From: Marcel B. <jed...@us...> - 2004-12-24 12:57:37
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23620/nunit/source Added Files: Jedi.System.IniFile.NUnit.pas Log Message: Added IniFile handling (incomplete; only partially tested) --- NEW FILE: Jedi.System.IniFile.NUnit.pas --- unit Jedi.System.IniFile.NUnit; interface uses System.Resources, Jedi.System.IniFiles, NUnit.Framework; type [TestFixture] InMemory = class strict private class var rm: ResourceManager; class constructor Create; public [Test] procedure KeyCollection; [Test] procedure Loading; [Test] procedure SectionCollection; [Test] procedure SectionKeyCollection; end; implementation uses System.Collections, System.IO, System.Text; { InMemory } class constructor InMemory.Create; begin rm := ResourceManager.Create('Jedi.System.IniFiles', TypeOf(InMemory).Assembly); end; procedure InMemory.KeyCollection; var mem: InMemoryConfigFile; kc: ICollection; kl: IList; begin mem := InMemoryConfigFile.Create; mem.Load(StringReader.Create(rm.GetString('initest'))); kc := mem.Keys; Assert.IsNotNull(kc, 'InMemoryConfigFile.Keys does not return an ICollection.'); kl := IList(kc); Assert.IsNotNull(kl, 'InMemoryConfigFile.Keys does not return an IList.'); Assert.AreEqual(1, kl.Count, 'Count'); Assert.AreEqual('MyTestString', kl[0], 'Item[0]'); kl := IList(mem.Keys('')); Assert.IsNotNull(kl, 'InMemoryConfigFile.Keys('''') does not return an IList.'); Assert.AreEqual(1, kl.Count, 'Count'); Assert.AreEqual('MyTestString', kl[0], 'Item[0] (empty section name)'); kl := IList(mem.Keys('TempList')); Assert.IsNotNull(kl, 'InMemoryConfigFile.Keys(''TempList'') does not return an IList.'); Assert.AreEqual(4, kl.Count, 'Count (TempList)'); Assert.AreEqual('Count', kl[0], 'Item[0] (TempList)'); Assert.AreEqual('Item1', kl[1], 'Item[1] (TempList)'); Assert.AreEqual('Item2', kl[2], 'Item[2] (TempList)'); Assert.AreEqual('Item3', kl[3], 'Item[3] (TempList)'); end; procedure InMemory.Loading; var mem: InMemoryConfigFile; begin mem := InMemoryConfigFile.Create; mem.Load(StringReader.Create(rm.GetString('initest'))); Assert.IsTrue(mem.SectionExists('Basics'), 'Section ''{0}'' not found', ['Basics']); Assert.IsTrue(mem.KeyExists('MyTestString'), 'Key ''{0}'' not found.', ['MyTestString']); Assert.AreEqual( 'Abcdef ghij klmnop; 1+1=2 #a comment, or maybe not, depending on settings', mem.ReadString('MyTestString'), 'Key ''{0}''.', ['MyTestString']); end; procedure InMemory.SectionCollection; var mem: InMemoryConfigFile; sc: ICollection; sl: IList; begin mem := InMemoryConfigFile.Create; mem.Load(StringReader.Create(rm.GetString('initest'))); sc := mem.Sections; Assert.IsNotNull(sc, 'InMemoryConfigFile.Sections does not return an ICollection.'); sl := IList(sc); Assert.IsNotNull(sl, 'InMemoryConfigFile.Sections does not return an IList.'); Assert.AreEqual(2, sl.Count, 'sl.Count'); Assert.AreEqual('Basics', sl[0], 'sl[0]'); Assert.AreEqual('TempList', sl[1], 'sl[1]'); end; procedure InMemory.SectionKeyCollection; type StringArray = array of string; var mem: InMemoryConfigFile; sc: ICollection; sl: IList; strArray: StringArray; enumC: IEnumerator; enumA: IEnumerator; begin mem := InMemoryConfigFile.Create; mem.Load(StringReader.Create(rm.GetString('initest'))); sc := mem.SectionKeys; Assert.IsNotNull(sc, 'InMemoryConfigFile.SectionKeys does not return an ICollection.'); sl := IList(sc); Assert.IsNotNull(sl, 'InMemoryConfigFile.SectionKeys does not return an IList.'); Assert.IsTrue(sl.IsReadOnly, 'IsReadOnly'); Assert.IsTrue(sl.IsFixedSize, 'IsFixedSize'); Assert.IsFalse(sl.IsSynchronized, 'IsReadOnly'); Assert.AreEqual(9, sl.Count, 'sl.Count'); Assert.AreEqual('MyTestString', sl[0], 'sl[0]'); Assert.AreEqual( System.String.Concat('Basics', ConfigFileBase.SectionKeySeperatorChar, 'AutoWriteSettings'), sl[1], 'sl[1]'); Assert.AreEqual( System.String.Concat('Basics', ConfigFileBase.SectionKeySeperatorChar, 'EmptyString'), sl[2], 'sl[2]'); Assert.AreEqual( System.String.Concat('Basics', ConfigFileBase.SectionKeySeperatorChar, 'TestString'), sl[3], 'sl[3]'); Assert.AreEqual( System.String.Concat('Basics', ConfigFileBase.SectionKeySeperatorChar, 'UseKeyMapper'), sl[4], 'sl[4]'); Assert.AreEqual( System.String.Concat('TempList', ConfigFileBase.SectionKeySeperatorChar, 'Count'), sl[5], 'sl[5]'); Assert.AreEqual( System.String.Concat('TempList', ConfigFileBase.SectionKeySeperatorChar, 'Item1'), sl[6], 'sl[6]'); Assert.AreEqual( System.String.Concat('TempList', ConfigFileBase.SectionKeySeperatorChar, 'Item2'), sl[7], 'sl[7]'); Assert.AreEqual( System.String.Concat('TempList', ConfigFileBase.SectionKeySeperatorChar, 'Item3'), sl[8], 'sl[8]'); strArray := StringArray.Create( 'MyTestString', System.String.Concat('Basics', ConfigFileBase.SectionKeySeperatorChar, 'AutoWriteSettings'), System.String.Concat('Basics', ConfigFileBase.SectionKeySeperatorChar, 'EmptyString'), System.String.Concat('Basics', ConfigFileBase.SectionKeySeperatorChar, 'TestString'), System.String.Concat('Basics', ConfigFileBase.SectionKeySeperatorChar, 'UseKeyMapper'), System.String.Concat('TempList', ConfigFileBase.SectionKeySeperatorChar, 'Count'), System.String.Concat('TempList', ConfigFileBase.SectionKeySeperatorChar, 'Item1'), System.String.Concat('TempList', ConfigFileBase.SectionKeySeperatorChar, 'Item2'), System.String.Concat('TempList', ConfigFileBase.SectionKeySeperatorChar, 'Item3'), ); enumC := sc.GetEnumerator; enumA := &Array(strArray).GetEnumerator; while enumC.MoveNext and enumA.MoveNext do Assert.AreEqual(enumA.Current, enumC.Current, 'Enumerator check.'); end; end. |
From: Marcel B. <jed...@us...> - 2004-12-24 12:55:48
|
Update of /cvsroot/jedidotnet/nunit/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23361/resources Log Message: Directory /cvsroot/jedidotnet/nunit/resources added to the repository |