CodeSnip's user defined snippets database is stored in an XML file along with a number of data files located in the user database directory. There is a different user database for each logged on user.
The master XML file is named database.xml. It contains all the
information about user defined snippets and categories except for the source
code of each snippet.
The source code for each snippet is stored in separate, sequentially numbered, .dat data files – one per snippet. Each source code file is referenced by the XML file.
There have been several different versions of the XML file format. The differences between versions are explained below. Details of all the changes between versions are listed in the Change Log at the end of this document
CodeSnip 4 stores all user database files using UTF-8 encoding. Files are
saved without any UTF-8 preamble (BOM). The XML processing
instruction of database.xml has an "encoding" atrribute
set to "UTF-8".
Prior to CodeSnip v4 (and database v5) source code data files were encoded using ANSI code page 1252. The XML file was in UTF-8, but its XML processing instruction had no "encoding" atrribute.
CodeSnip v4 must be able to work with all these encodings because it may inherit a copy of a user database in an earlier format.
There have been six different versions of the XML file formats – v1 to v6. Tags from all six versions are explained below with notes describing which versions a tag applies to. Where there is no note the tag is valid in all versions.
Source code is stored separately from the main XML file. The source code of
each snippet has its own file. Files are numbered sequentially and have a
.dat extension, for example 6.dat.
Source code files are referenced by the codesnip-data/routines/routine/source-code tag in the database's XML file.
This section describes the changes between versions of the file format.
There were small changes within versions, that probably should have been given minor version numbers - but weren't. Such minor numbers have been assigned retrospectively below in order to better explain when in-version changes actually took place.
File formats v4 and v5/v6 actually overlapped in the dates they were in use. This is because v4 was used by CodeSnip v3 and v5/v6 were used by CodeSnip 4. Those two versions of CodeSnip were maintained in parallel for a while.
Introduced with CodeSnip v2.0.
Supported Delphi compilers from Delphi 2 to Delphi 2007 plus Free Pascal.
REML not supported.
Data files were ANSI text using code page 1252. The XML file was in UTF-8 format with no BOM and no XML encoding attribute.
Introduced with CodeSnip v2.2.5.
Removed following tags:
Added following tag:
The version of REML supported by the codesnip-data/routines/routine/extra tag was v1.
Introduced with CodeSnip v3.0.
The following tag is no longer supported:
The following tag was introduced:
The version of REML supported by the codesnip-data/routines/routine/extra tag was updated to v2.
Introduced with CodeSnip v3.0.1.
The version of REML supported by the codesnip-data/routines/routine/extra tag was updated to v3.
Introduced with CodeSnip v4.0 alpha 2.
The XML file's encoding was explicitly set to "UTF-8" by setting the encoding attribute of the XML processing instruction to this value.
Snippet names, wherever they occur in the XML file, can now begin with any character that is a valid first character of a Unicode Pascal identifier. Previously the first character of the attribute had to be one of 'A'..'Z', 'a'..'z' or '_'.
Data files changed to use UTF-8 encoding with no BOM instead of the system default encoding.
New "class" and "unit" snippet kinds supported.
The version of REML supported by the codesnip-data/routines/routine/extra tag was updated to v4.
Introduced with CodeSnip v4.0 beta 1.
A snippet's description is now stored as formatted text using REML v4 markup. Previously the description was plain text.
The following tags were introduced:
To ensure backwards compatibility with all user database versions file reader software that works with the latest version of CodeSnip needs to be able to interpret older formats as follows.
Readers of version 1 files must convert the contents of the the following tags:
into valid REML code that simulates the parsed content of the codesnip-data/routines/routine/extra tag.
Readers of v1 and v2 files should map a codesnip-data/routines/routine/standard-format value of "0" to a codesnip-data/routines/routine/kind value of "freeform" and a value of "1" to "routine".
Readers of v1 to v5 files must:
Readers of v2 and later files may parse REML from any file version as if it were REML v6, since all versions of REML up to v6 are compatible.
Readers of v1 to v4 files should interpret all source code .dat files as encoded in ANSI code page 1252 - the files were created using the default code page in the UK, which is 1252. The XML file should be assumed to be in UTF-8 format, regardless of the absence of an encoding attribute.
v5 and later files will always be encoded in UTF-8.