Describes the elements inside an ItemDescription.

Namespace: TeaTime
Assembly: DiscreteLogics.TeaFiles (in DiscreteLogics.TeaFiles.dll) Version: 1.0.0.16 (1.0.0.16)

Syntax

[FlagsAttribute]
public enum ItemDescriptionElements

Members

Member nameValueDescription
None0no item description part.
ItemName1the item .
ItemSize2the item size.
FieldOffsets4field offsets.
FieldNames12field names.
FieldTypes20field types.
All255all item description parts.

Remarks

A TeaFile holds a description of the item type it stores. This item description has several elements:

  • the name of the item type (e.g. "Tick", "OHLCV")
  • the size of the item
  • the number of fields and their
  • name,
  • offset and
  • type.
A value of this type specifies which elements shall be compared when an existing file is opened with a specific item type.

When a typed TeaFile<(Of <(<'T>)>)> is opened, the ItemDescription of {T} is compared against those in the file. If it does not match those stored in the file, an exception is thrown. This ensures that a TeaFile is read with the correct type. For instance, a file that was written using the item type

CopyC#
struct Tick
{
    public Time Time;
    public double Price;
}
is not accessible using
CopyC#
struct A
{
    public Time Time;
    public short Value1;
    public float Value2;
    public double Value3;
}
TeaFile<A>.OpenRead("lab.tea");
because A has a different type name ("A" vs "Tick"), a different size and field names, types and offsets. Sometimes however, such strong check is undesired. If just the name of the type or the name of a field is altered, the file should still be accessible with a partially different type than the one used for writing. The optional argument elementsToValidate in the OpenRead, Write and Append methods of TeaFile<(Of <(<'T>)>)> allows this:

Examples

CopyC#
struct Tick
{
    public Time Time;
    public double Price;
}
TeaFile<Tick>.Create("lab.tea");

// now we read this file using another type.
struct NewTick
{
    public Time NewTime;
    public double NewPrice;
}
TeaFile<NewTick>.OpenRead("lab.tea", ItemDescriptionElements.FieldTypes);
Since we open the file with a relaxed check that compares field types (and offsets), the call will succeed and the file will be readable with the new type.

See Also