dsmnd

package module
v0.0.0-...-8bcb3be Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 3 Imported by: 12

README

dsmnd

dsmnd is "Desmond" is Data semantics and metadata

Documentation

Overview

Package dsmnd is short for Data Structure Semantics, Metadata, and Descriptors. Nicknamed "Desmond". It contains constants and structs and other materials for describing a variety of items:

  • data types
  • data enumeration types and values
  • data structures
  • database schemata
  • a (sort of) taxonomy of UI elements

It has no dependencies aside from the stdlib.

(The package description ends here.)

A digression about naming, vis-à-vis SQLite

In principle, ALL names and ALL characters are allowed except beginning with "sqlite_". You can use keywords ("TABLE"), special characters (line noise), and even the empty string ("").

If you use brackets or quotes you can use any name and there is no restriction:

create table [--This is a_valid.table+name!?] (x int);

But table names that don't have surrounding brackets should be an alphanumeric combination that does not start with a digit and does not contain any spaces. In such case you can use underline and $ but you can not use symbols like: + - ? ! * @ % ^ & # = / \ : " '

SQLite's documentation on identifiers says that square brackets are allowed for compatibility with MS Access and SQL Server, but double quotes are standard and appear to be equivalent.

If you want to use a keyword as a name, quote it. There are four ways of quoting keywords in SQLite:

  • 'keyword' A keyword in single quotes is a string literal.
  • "keyword" A keyword in double-quotes is an identifier.
  • [keyword] A keyword in square brackets is an identifier. (This is non-standard SQL, for MS Access and SQL Server compatibility.)
  • `keyword` A keyword enclosed in grave accents (ASCII code 96) is an identifier. (This is non-standard SQL, for MySQL compatibility.)

So, if you double quote the table name you can use any characters, and [tablename] can be used but not a standard SQL. .

Index

Constants

View Source
const (
	SQLITE_ERR     = SqliteDatatype(0)
	SQLITE_INTEGER = SqliteDatatype(1) // 64-bit signed integer
	SQLITE_FLOAT   = SqliteDatatype(2) // 64-bit IEEE FP number
	SQLITE_TEXT    = SqliteDatatype(3) // string; incl JSON
	SQLITE_BLOB    = SqliteDatatype(4) // incl JSONB
	SQLITE_NULL    = SqliteDatatype(5)
	SQLYT_DATETIME = SqliteDatatype(6) // dusnt exist, but should
)
View Source
const (
	BDT_NIL  = BasicDatatype("nil")
	BDT_INTG = BasicDatatype("1234") // INT   // SQLITE_INTEGER 1
	BDT_FLOT = BasicDatatype("1.0f") // FLOAT // SQLITE_FLOAT   2
	BDT_TEXT = BasicDatatype("AaZz") // TEXT  // SQLITE_TEXT    3
	BDT_BLOB = BasicDatatype("blOb") // BLOB  // SQLITE_BLOB    4
	BDT_NULL = BasicDatatype("null") // NULL  // SQLITE_NULL    5
	BDT_DYTM = BasicDatatype("dytm") // DATETIME SQLYT_DATETIME 6
	BDT_KEYY = BasicDatatype("keyy") // PRIMARY/FOREIGN/OTHER KEY (SQLite "INTEGER")
	BDT_LIST = BasicDatatype("list") // List (simple one-dimensional lists)
	BDT_CLXN = BasicDatatype("clxn") // Collection (more-complicated data strux)
	BDT_FSYS = BasicDatatype("fsys") // FS entity (details TBD)
	BDT_OTHR = BasicDatatype("othr") // reserved: expansion
	BDT_NONE = BasicDatatype("none") // reserved
)
View Source
const (
	PBT_NIL  = PandocBlockType("nil")
	PBT_TEXT = PandocBlockType("text")
	PBT_PARA = PandocBlockType("para")
	PBT_CODE = PandocBlockType("code")
	PBT_QUOT = PandocBlockType("quot")
	PBT_PRE  = PandocBlockType("pre") // Line Block
	PBT_RAW  = PandocBlockType("raw")
	PBT_OL   = PandocBlockType("ol")
	PBT_UL   = PandocBlockType("ul")
	PBT_DL   = PandocBlockType("dl")
	PBT_HDR  = PandocBlockType("hdr")
	PBT_HR   = PandocBlockType("hr")
	PBT_TBL  = PandocBlockType("tbl")
	PBT_FIG  = PandocBlockType("fig")
	PBT_DIV  = PandocBlockType("div")
)
View Source
const (
	PIT_NIL  = PandocInlineType("nil")
	PIT_TEXT = PandocInlineType("text")
	PIT_PARA = PandocInlineType("para")
	PIT_CODE = PandocInlineType("code")
	PIT_QUOT = PandocInlineType("quot")
	PIT_PRE  = PandocInlineType("pre") // Line Block
	PIT_RAW  = PandocInlineType("raw")
	PIT_OL   = PandocInlineType("ol")
	PIT_UL   = PandocInlineType("ul")
	PIT_DL   = PandocInlineType("dl")
	PIT_HDR  = PandocInlineType("hdr")
	PIT_HR   = PandocInlineType("hr")
	PIT_TBL  = PandocInlineType("tbl")
	PIT_FIG  = PandocInlineType("fig")
	PIT_DIV  = PandocInlineType("div")
)
View Source
const (
	SCT_NIL   = SemanticClxnType("nil")
	SCT_TABLE = SemanticClxnType("table") // 2-D, rectangular
	SCT_UTREE = SemanticClxnType("utree") // e.g. XML for data
	SCT_OTREE = SemanticClxnType("otree") // e.g. markup
)
View Source
const (
	// ONE-OFFS
	SFT_NIL   = SemanticFieldType("nil")
	SFT_BOOL_ = SemanticFieldType("bool_")
	SFT_FLOAT = SemanticFieldType("float")
	SFT_BLOB_ = SemanticFieldType("blob_")
	SFT_NULL_ = SemanticFieldType("null_")
	// INTEGERS (4) (also needs BYTE_, LONG_ ?)
	SFT_INTEG = SemanticFieldType("integ")
	SFT_COUNT = SemanticFieldType("count")
	SFT_EUPNS = SemanticFieldType("eupns") // EU pennies (eurocents, 0.01€)
	SFT_USPNS = SemanticFieldType("uspns") // US pennies (cents, ¢₵, 0.01$)
	// TEXTS (10)
	SFT_STRNG = SemanticFieldType("strng")
	SFT_TOKEN = SemanticFieldType("token")
	SFT_FTEXT = SemanticFieldType("ftext")
	SFT_MTEXT = SemanticFieldType("mtext")
	SFT_ATEXT = SemanticFieldType("atext")
	SFT_JTEXT = SemanticFieldType("jtext")
	SFT_XTEXT = SemanticFieldType("xtext")
	SFT_HTEXT = SemanticFieldType("htext")
	SFT_MCFMT = SemanticFieldType("mcfmt")
	SFT_QTEXT = SemanticFieldType("qtext")
	// TEXT-BASED MISC. (5)
	SFT_FONUM = SemanticFieldType("fonum")
	SFT_EMAIL = SemanticFieldType("email")
	SFT_FPATH = SemanticFieldType("fpath")
	SFT_URLIN = SemanticFieldType("urlin")
	SFT_SEMVR = SemanticFieldType("semvr")
	// KEYS (3)
	SFT_PRKEY = SemanticFieldType("prkey")
	SFT_FRKEY = SemanticFieldType("frkey")
	SFT_CXKEY = SemanticFieldType("cxkey")
	// DYTM: DATE AND/OR TIME (6)
	SFT_DATIM = SemanticFieldType("datim") // ISO-8601 timestamp
	SFT_DATE_ = SemanticFieldType("date_") // date only
	SFT_DDWWM = SemanticFieldType("ddwmm") // using ISO week number
	SFT_TIME_ = SemanticFieldType("time_") // time only (e.g. for recurring)
	SFT_SESON = SemanticFieldType("seson") // season
	SFT_DYPRT = SemanticFieldType("dyprt") // day part
	// FSYS: FILE SYSTEM ITEMS (4)
	SFT_FSDIR = SemanticFieldType("fsdir") // directory (ulist/olist)
	SFT_FSFIL = SemanticFieldType("fsfil") // file (has content)
	SFT_FSYML = SemanticFieldType("fsyml") // symbolic link (ln -s)
	SFT_FSOTH = SemanticFieldType("fsoth") // other (pipes, etc.)
)
View Source
const (
	SLT_NIL   = SemanticListType("nil")
	SLT_OLIST = SemanticListType("olist")
	SLT_ULIST = SemanticListType("ulist")
	SLT_DLIST = SemanticListType("dlist")
	SLT_RLIST = SemanticListType("rlist")
	SLT_SLIST = SemanticListType("slist")
	SLT_ELIST = SemanticListType("elist")
	SLT_ENUME = SemanticListType("enume")
	SLT_XLIST = SemanticListType("xlist")
	SLT_MLIST = SemanticListType("mlist")
)
View Source
const (
	TT_NIL      = TypeType("nil")
	TT_SQLITE   = TypeType("sqlite")   // TT_SQLITE   is [SqliteDatatype]
	TT_BASIC    = TypeType("basic")    // TT_BASIC    is [BasicDatatype]
	TT_SEMFIELD = TypeType("semfield") // TT_SEMFIELD is [SemanticFieldType]
	TT_SEMLIST  = TypeType("semlist")  // TT_SEMLIST  is [SemanticListType]
	TT_SEMCLXN  = TypeType("semclxn")  // TT_SEMCLXN  is [SemanticClxnType]
)

Variables

View Source
var DD_AbsFP = ColumnSpec{SFT_URLIN.DT(), "absfp", "Abs. path", "Absolute filepath"}
View Source
var DD_RelFP = ColumnSpec{SFT_URLIN.DT(), "relfp", "Rel. path", "Rel.FP (from CLI)"}
View Source
var DD_T_Cre = ColumnSpec{SFT_DATIM.DT(), "t_cre", "Cre. time", "Creation date+time"}
View Source
var DD_T_Edt = ColumnSpec{SFT_DATIM.DT(), "t_edt", "Edit time", "Last edit date+time"}
View Source
var DD_T_Imp = ColumnSpec{SFT_DATIM.DT(), "t_imp", "Imp. time", "DB import date+time"}
View Source
var JsonSchemaBuiltinFormats = []JsonSchemaBuiltinFormat{}
View Source
var PandocBlockDescriptors = []PandocBlockDescriptor{
	{BDT_NIL.DT(), PBT_NIL.S(), "nil", "NOT FOUND"},
	{BDT_TEXT.DT(), PBT_TEXT.S(), "Text", "Plain text [Inline], not a paragraph"},
	{BDT_TEXT.DT(), PBT_PARA.S(), "Para", "Paragraph [Inline]"},
	{BDT_TEXT.DT(), PBT_CODE.S(), "Code", "Code block (literal), with attributes"},
	{BDT_TEXT.DT(), PBT_QUOT.S(), "Quot", "Block quote (list of blocks)"},
	{BDT_TEXT.DT(), PBT_PRE.S(), "Pre", "Pre, line block, mult. non-breaking lines"},
	{BDT_TEXT.DT(), PBT_RAW.S(), "Raw", "Raw block, with format"},
	{BDT_TEXT.DT(), PBT_OL.S(), "OLst", "Ordered list, with attributes and a list of items, each a list of blocks)"},
	{BDT_TEXT.DT(), PBT_UL.S(), "ULst", "Unordered list (bullets), with a list of items, each a list of blocks)"},
	{BDT_TEXT.DT(), PBT_DL.S(), "DLst", "Definition list: pairs: term (a list of inlines) + 1+ definitions (each a list of blocks)"},
	{BDT_TEXT.DT(), PBT_HDR.S(), "Hdr", "Header, with level (integer) and text (inlines)"},
	{BDT_TEXT.DT(), PBT_HR.S(), "HorzR", "Horizontal rule"},
	{BDT_TEXT.DT(), PBT_TBL.S(), "Tbl", "Table Attr Caption [ColSpec] <br/> TableHead [TableBody] TableFoot (a) Table, with attributes, caption, optional short caption, column alignments and <br/> widths (required), table head, table bodies, and table foot <br/> (b) Table w [Inline] [Alignment] [Double] [TableCell] [[TableCell]] <br/> (c) Table, with caption, column alignments, relative column widths (0 = default), <br/> column headers (each a list of blocks), and rows (each a list of lists of blocks)"},
	{BDT_TEXT.DT(), PBT_FIG.S(), "Fig", "Figure, with attributes, caption, and content (list of blocks)"},
	{BDT_TEXT.DT(), PBT_DIV.S(), "Div", "Generic block(s) container with attributes"},
}

PandocBlockDescriptors describe values of PandocBlockType. .

View Source
var PandocInlineDescriptors = []PandocInlineDescriptor{
	{BDT_NIL.DT(), PIT_NIL.S(), "nil", "NOT FOUND"},
	{BDT_TEXT.DT(), PIT_TEXT.S(), "Text", "Plain text [Inline], not a paragraph"},
	{BDT_TEXT.DT(), PIT_PARA.S(), "Para", "Paragraph [Inline]"},
	{BDT_TEXT.DT(), PIT_CODE.S(), "Code", "Code block (literal), with attributes"},
	{BDT_TEXT.DT(), PIT_QUOT.S(), "Quot", "Block quote (list of blocks)"},
	{BDT_TEXT.DT(), PIT_PRE.S(), "Pre", "Pre, line block, mult. non-breaking lines"},
	{BDT_TEXT.DT(), PIT_RAW.S(), "Raw", "Raw block, with format"},
	{BDT_TEXT.DT(), PIT_OL.S(), "OLst", "Ordered list, with attributes and a list of items, each a list of blocks)"},
	{BDT_TEXT.DT(), PIT_UL.S(), "ULst", "Unordered list (bullets), with a list of items, each a list of blocks)"},
	{BDT_TEXT.DT(), PIT_DL.S(), "DLst", "Definition list: pairs: term (a list of inlines) + 1+ definitions (each a list of blocks)"},
	{BDT_TEXT.DT(), PIT_HDR.S(), "Hdr", "Header, with level (integer) and text (inlines)"},
	{BDT_TEXT.DT(), PIT_HR.S(), "HorzR", "Horizontal rule"},
	{BDT_TEXT.DT(), PIT_TBL.S(), "Tbl", "Table Attr Caption [ColSpec] <br/> TableHead [TableBody] TableFoot (a) Table, with attributes, caption, optional short caption, column alignments and <br/> widths (required), table head, table bodies, and table foot <br/> (b) Table w [Inline] [Alignment] [Double] [TableCell] [[TableCell]] <br/> (c) Table, with caption, column alignments, relative column widths (0 = default), <br/> column headers (each a list of blocks), and rows (each a list of lists of blocks)"},
	{BDT_TEXT.DT(), PIT_FIG.S(), "Fig", "Figure, with attributes, caption, and content (list of blocks)"},
	{BDT_TEXT.DT(), PIT_DIV.S(), "Div", "Generic block(s) container with attributes"},
}

PandocInlineDescriptors describe values of PandocInlineType. .

View Source
var PdcTblCellAlnmts = []PdcTblCellAlnmt{
	"AlignLeft", "AlignRight", "AlignCenter", "AlignDefault",
}
View Source
var SemanticClxnDescriptors = []SemanticClxnDescriptor{
	{BDT_NIL.DT(), SCT_NIL.S(), "nil", "NOT FOUND"},
	{BDT_CLXN.DT(), SCT_TABLE.S(), "Tableframe", "Table / dataframe"},
	{BDT_CLXN.DT(), SCT_UTREE.S(), "Unord tree", "Tree of unordered children (e.g. XML data)"},
	{BDT_CLXN.DT(), SCT_OTREE.S(), "Ord'd tree", "Tree of ordered children (XML mixed content)"},
}

SemanticClxnDescriptors describe data structures that are more complex than simple lists. ENUME is included because it (a) uses a Datum and (b) also can implement the hierarchical naming scheme for faceted metadata and other enumerations. .

View Source
var SemanticFieldDescriptors = []SemanticFieldDescriptor{
	{BDT_NIL.DT(), SFT_NIL.S(), "nil", "NOT-FOUND"},

	{BDT_FLOT.DT(), SFT_FLOAT.S(), "Float", "Generic FP number, size unspecified"},
	{BDT_BLOB.DT(), SFT_BLOB_.S(), "Blob", "Binary large object (program / data"},
	{BDT_NULL.DT(), SFT_NULL_.S(), "Null", "Generic Not-a-value"},
	{BDT_INTG.DT(), SFT_BOOL_.S(), "Boolean", "Boolean (0|1)"},

	{BDT_INTG.DT(), SFT_INTEG.S(), "Integer", "Generic integer, size unspecified"},
	{BDT_INTG.DT(), SFT_COUNT.S(), "Count", "Item count (non-neg.), size unspecified"},
	{BDT_INTG.DT(), SFT_EUPNS.S(), "Eurocents", "EUR/100 0.01€"},
	{BDT_INTG.DT(), SFT_USPNS.S(), "USA cents", "UDS/100 0.01$"},

	{BDT_TEXT.DT(), SFT_STRNG.S(), "String", "Generic string, not readable text"},
	{BDT_TEXT.DT(), SFT_TOKEN.S(), "Token", "Generic token or datum tag (no spaces or punc.)"},
	{BDT_TEXT.DT(), SFT_FTEXT.S(), "Free-text", "Generic free-flowing readable text, format unspecified"},
	{BDT_TEXT.DT(), SFT_JTEXT.S(), "JSON", "JSON text"},
	{BDT_TEXT.DT(), SFT_XTEXT.S(), "XML-text", "XML text (incl fragments)"},
	{BDT_TEXT.DT(), SFT_HTEXT.S(), "HTML5-text", "HTML[5!] text"},
	{BDT_TEXT.DT(), SFT_MTEXT.S(), "Markdown", "Markdown/plaintext, incl LwDITA Ext'd-MDITA"},
	{BDT_TEXT.DT(), SFT_ATEXT.S(), "Asciidoc", "Asciidoc text"},
	{BDT_TEXT.DT(), SFT_MCFMT.S(), "Microformat", "Microformat record"},
	{BDT_TEXT.DT(), SFT_QTEXT.S(), "SQL", "SQL (dialect TBS)"},

	{BDT_TEXT.DT(), SFT_FONUM.S(), "Phone-nr.", "Telephone number"},
	{BDT_TEXT.DT(), SFT_EMAIL.S(), "Email", "Email address"},
	{BDT_TEXT.DT(), SFT_FPATH.S(), "F-path", "Filepath or facet path (tree; slash-separated)"},
	{BDT_TEXT.DT(), SFT_URLIN.S(), "URL/URI/URN", "Generic path ID (URL, URI, URN; nmspc'd)"},
	{BDT_TEXT.DT(), SFT_SEMVR.S(), "Sem.ver.nr.", "Semantic version number (x.y.z)"},

	{BDT_KEYY.DT(), SFT_PRKEY.S(), "Pri.key", "Primary table key (unique, non-NULL, int64"},
	{BDT_KEYY.DT(), SFT_FRKEY.S(), "For.key", "Foreign table key (int64)"},
	{BDT_KEYY.DT(), SFT_CXKEY.S(), "Complex for.key", "Complex for.key (e.g. 1/n to other table)"},

	{BDT_DYTM.DT(), SFT_DATIM.S(), "Date & time", "Timestamp (day+time ISO-8601/RFC-3339)"},
	{BDT_DYTM.DT(), SFT_DATE_.S(), "Date", "Date only, no time"},
	{BDT_DYTM.DT(), SFT_DDWWM.S(), "TBD", "Day of week ? Week nr ? Month ?"},
	{BDT_DYTM.DT(), SFT_TIME_.S(), "Time", "Time only, no date (recurring ?)"},
	{BDT_DYTM.DT(), SFT_SESON.S(), "Season", "Season (W S M F)"},
	{BDT_DYTM.DT(), SFT_DYPRT.S(), "Daypart", "Part ofo day (N M A E)"},

	{BDT_FSYS.DT(), SFT_FSDIR.S(), "Dir", "FS directory (unord|ord)"},
	{BDT_FSYS.DT(), SFT_FSFIL.S(), "File", "FS file (contentful)"},
	{BDT_FSYS.DT(), SFT_FSYML.S(), "SymL", "FS symbolic link"},
	{BDT_FSYS.DT(), SFT_FSOTH.S(), "Other", "FS other (pipes, etc.)"},
}

SemanticFieldDescriptors are semantically-meaningful descriptors of simple fields. Descriptor fields:

  1. BasicDatatype (i.e. storage type)
  2. [StorName]: the internal string value of the field type: FIVE UPPER CASE letters
  3. [DispName]: the external (for users) string value of the field type: a single word (or token), Capitalized
  4. [Description]: Capitalized free text describing the field type

One might expect that this would be the place where we would associate an SqliteDatatype with each SemanticFieldDescriptor. However we do not do it here, because

  1. maybe the user wants to override it, and
  2. maybe we will want to set this up for a different DB with a different set of field types, and
  3. FIXME: ?? anyways the values are dead simple: mostly just Text (or Integer or Key)

.

View Source
var SemanticListDescriptors = []SemanticListDescriptor{
	{BDT_NIL.DT(), SLT_NIL.S(), "nil", "NOT FOUND"},
	{BDT_LIST.DT(), SLT_OLIST.S(), "Ord'd list", "Generic ordered list"},
	{BDT_LIST.DT(), SLT_ULIST.S(), "Unord list", "Generic unordered list"},
	{BDT_LIST.DT(), SLT_DLIST.S(), "Def'n list", "Generic definition list"},
	{BDT_LIST.DT(), SLT_RLIST.S(), "Rankd list", "List ordered by ranking"},
	{BDT_LIST.DT(), SLT_SLIST.S(), "Seql. list", "List ordered as a sequence"},
	{BDT_LIST.DT(), SLT_ELIST.S(), "Enum. list", "List of enumerated elements"},
	{"enume", SLT_ENUME.S(), "Enum. item", "Element of enumeration"},
	{BDT_LIST.DT(), SLT_XLIST.S(), "Excl. list", "List (select one only)"},
	{BDT_LIST.DT(), SLT_MLIST.S(), "Mult. list", "List (select multiple)"},
}

SemanticListDescriptors are semantically-meaningful descriptors of simple lists. Descriptor fields:

  1. Datatype of each type of list is BDT_LIST
  2. [Datum.StorName]: the internal string value of the list type: FIVE UPPER CASE letters
  3. [Datum.DispName]: the external (for users) string value of the list type, Capitalized
  4. [Datum.Description]: Capitalized free text describing the list type

ENUME is included because it (a) uses a Datum and (b) also can implement the hierarchical naming scheme for faceted metadata and other enumerations. .

Functions

func DescriptorFor

func DescriptorFor[T ~string](s T) (TypeType, Datum)

Types

type BasicDatatype

type BasicDatatype Datatype

BasicDatatype is a string that expands upon the SQLite datatypes, mainly by adding "key" and "list" and "clxn" (collection).

  • Symbol names are `"BDT_"` + FOUR UPPER CASE letters
  • Symbol values are four lower case letters
  • Lists and Collections are included

These are appropriate for describing DB schemas. For more detail tho, use a [SemFieldType].

But in any case see https://sqlite.org/c3ref/c_blob.html .

func (BasicDatatype) DT

func (bdt BasicDatatype) DT() Datatype

func (BasicDatatype) S

func (bdt BasicDatatype) S() string

type ColumnSpec

type ColumnSpec Datum

ColumnSpec specifies a datum - a struct field and/or a DB column. This includes its generic/portable/DB-independent representation that uses the enumeration SemanticFieldType (or else BasicDatatype). It provides enough detail that DB operations can be based on it. Some values for common DB columns are defined in file `datadxnry.go` . Field usage is as follows:

  • Datatype: a value from [SemanticFieldTypes] (via which one can get the value of the BasicDatatype)
  • [Datum.StorName]: the field name IN THE DB. NOTE: For PKEY or FKEY, is this authoritative ? There could be multiple unique indices, so maybe it should be.
  • [Datum.DispName]: short description. NOTE the exception that for FKEY, this is the name of the ref'd DB table.
  • [Datum.Description]: long description. NOTE that for FKEY, this describes the purpose+function of the ref.

ColumnSpec's are useful in at least three situations:

  • To generate CREATE TABLE statements
  • To validate fields with semantic meaning (RSN)
  • To document fields when displaying them in a UI

.

func (*ColumnSpec) String

func (p *ColumnSpec) String() string

type DB_type

type DB_type string
const (
	// DB_SQLite is NOT "sqlite3"!
	DB_SQLite DB_type = "sqlite"
)

type Datatype

type Datatype string

Datatype can be a BasicDatatype (`BDT_*`) or a SemanticType (`SFT_* SCT_*`) or a PandocType (`PdcXXX_*`). We'd rather not intermix these, but it is unavoidable when defining the first field of a Datum.

type Datum

type Datum struct {
	// BasicDatatype is an SQLite fundamental datatype,
	// enhanced with Primary Key and Foreign Key.
	// TODO: SemanticType (FUTURE).
	Datatype // BasicDatatype
	// StorName is a short unique string token - no
	// spaces or punctuation. For robustness we use
	// string codes not iota-based integer values,
	// because values based on iota could change.
	//  1) When a Datum describes a DB item (table or
	//     column or row's column value), StorName is
	//     the actual name of the DB field or table,
	//     and should be all lower case
	//  2) When a Datum describes an enumeration (set)
	//     or facet, StorName should be all upper case,
	//     and all values of a StorNames in a particular
	//     enumeration "should" be of the same length.
	StorName string
	// DispName is for common use by users when brief
	// is better, such as for column headers.
	DispName string
	// Description is a long-form description.
	Description string
}

Datum is a datum descriptor that contains a data type (a value from one of several sets), a storage name (for when persisted), a short display name (for users), and a freetext description.

NOTE: When used as an enum node (ELIST) or enum value (ENUME), a Datum will need the addition of a namespace and `isSet/hasKids`.

A Datum can be used to describe any of the following:

  • A table spec (schema) for creating a database
  • A table spec (schema) existing (as-is) in a database
  • A column spec for a DB table
  • A field value in a Go struct
  • A facet or enumeration
  • One value in a facet or enumeration
  • An enumeration (set), or a higher node in a hierarchical structure of facets/enumerations

Some example use cases (TODO: this needs revising):

An element of an enumeration (example: Language)

  • DataType: TEXT ("text")
  • StorName: "EN", "FR"
  • DispName: "English", "French"
  • Description: "English (default USA)", "French (default France)"

A database table:

  • e.g. TableSpec{TABL, "inbatch", "INB", "Batch import of files"}
  • DataType: TABL ("tabl")
  • StorName: "inbatch" (in SQL "CREATE TABLE")
  • DispName: "inb" (when used as a prefix, e.g. "inb_idx"))
  • Description: "Input batch of imported files"

A database column:

  • e.g. ColumnSpec{TEXT, "relfp", "Rel. path", "Rel.FP (from CLI)"}
  • DataType: PKEY ("pkey") OOPS, PATH?
  • StorName: "relfp"
  • DispName: "Rel. path"
  • Description: "Rel.FP (from CLI)"

The DataType might sometimes be optional, but not other fields.

NOTE: The discussion that follows (ref: https://www.sqlite.org/datatype3.html) is mostly obsolete now, because we have expanded the set of permissible values for [BasicDataType]...

The SQLite concepts "storage class" and "affinity" are quite similar. The values for these are "INTEGER", "REAL", "NUMERIC, "TEXT", "BLOB". (Note that primary and foreign keys are overloaded with "INTEGER"). It turns out that all of them are both classes/affinities AND ("mostly") specific data types, so they are simple to use if we can ignore details.

For purposes of comparison, note that the dataframe library "gota" uses "string", "int", "float", "bool". We will not use a BOOL data type anywhere, and anyways a BOOL can be stored in SQLite as an INTEGER limited to (0,1).

Furthermore, in SQLite it seems that "BLOBs are always stored as BLOBs regardless of column affinity".

This all means that we can basically

  1. completely ignore SQLite NUMERIC, SQLite BLOB, and gota BOOL,
  2. declare every column to be either "INTG" or "TEXT" (in [BasicDataType]),
  3. but use "INTEGER" (i.e. "KEYY") for a key (primary or foreign), and
  4. not worry about "mistakes" like assigning a BLOB (such as image file) to a TEXT column - because SQLite has got us covered.

.

func (Datum) String

func (d Datum) String() string

type DbColInDb

type DbColInDb Datum

DbColInDb describes a column as-is in the DB (as obtained via reflection), and has a slot to include the value (as a string). Used only in utils/repo/sqlite/meta_table.go .

type GoBasicKind

type GoBasicKind types.BasicKind

See https://pkg.go.dev/go/types#BasicKind:

  • type BasicKind int
  • const (
  • Invalid BasicKind = iota // type is invalid
  • predeclared types
  • Bool Int Int8 Int16 Int32 Int64 Uint Uint8 Uint16 Uint32 Uint64
  • Uintptr Float32 Float64 Complex64 Complex128 String UnsafePointer
  • types for untyped values
  • UntypedBool UntypedInt UntypedRune UntypedFloat
  • UntypedComplex UntypedString UntypedNil
  • aliases
  • Byte = Uint8
  • Rune = Int32

.

type InUI

type InUI struct {
	Visible, Enabled, Selected bool
	Position                   int
}

InUI is meant to be embedded in any struct that uses a Datum to store an entry in a UI.

type NSPath

type NSPath struct {
	NS   string
	Path string
}

NSPath is pretty generic and can represent just about anything. Examples:

  • Imported file: batch nr + abs/rel.path
  • Disk file: PC FQN + abs.pah
  • Facet value: facet FQN + hiercal path

.

type PandocBlockDescriptor

type PandocBlockDescriptor SemanticDescriptor

PandocBlockDescriptor is TBS.

func PandocBlockDescriptorByType

func PandocBlockDescriptorByType(pbt PandocBlockType) (PandocBlockDescriptor, error)

type PandocBlockType

type PandocBlockType PandocType

PandocBlockType takes values from https://hackage.haskell.org/package/pandoc-types-1.23.1/docs/Text-Pandoc-Definition.html

For more information about each field type, see PandocBlockDescriptors. .

func (PandocBlockType) DT

func (pbt PandocBlockType) DT() Datatype

func (PandocBlockType) S

func (pbt PandocBlockType) S() string

type PandocDescriptor

type PandocDescriptor Datum

type PandocInlineDescriptor

type PandocInlineDescriptor SemanticDescriptor

PandocInlineDescriptor is TBS.

func PandocInlineDescriptorByType

func PandocInlineDescriptorByType(pit PandocInlineType) (PandocInlineDescriptor, error)

type PandocInlineType

type PandocInlineType PandocType

PandocInlineType takes values from https://hackage.haskell.org/package/pandoc-types-1.23.1/docs/Text-Pandoc-Definition.html

For more information about each field type, see PandocInlineDescriptors. .

func (PandocInlineType) DT

func (pit PandocInlineType) DT() Datatype

func (PandocInlineType) S

func (pit PandocInlineType) S() string

type PandocMeta

type PandocMeta struct {
	Title, Authors, Date string
}

type PandocType

type PandocType Datatype

type PdcTblCell

type PdcTblCell struct {
	// Cell Attr Alignment RowSpan ColSpan [Block]
	PdcTblCellAlnmt
	// contains filtered or unexported fields
}

type PdcTblCellAlnmt

type PdcTblCellAlnmt string

Alignment of a table column

type SemanticClxnDescriptor

type SemanticClxnDescriptor SemanticDescriptor

SemanticClxnDescriptor is TBS.

func SemanticClxnDescriptorByType

func SemanticClxnDescriptorByType(sct SemanticClxnType) (SemanticClxnDescriptor, error)

type SemanticClxnType

type SemanticClxnType SemanticType

SemanticClxnType characterizes the semantics of data structures that are more complex than simple lists. ENUME is included because it (a) uses a Datum and (b) also can implement the hierarchical naming scheme for faceted metadata and other enumerations.

  • Symbol names are `"SCT_"` + FIVE UPPER CASE letters
  • Symbol values are five lower case letters

For more information about each field type, see SemanticClxnDescriptors. .

func (SemanticClxnType) DT

func (sct SemanticClxnType) DT() Datatype

func (SemanticClxnType) S

func (sct SemanticClxnType) S() string

type SemanticDescriptor

type SemanticDescriptor Datum

type SemanticFieldDescriptor

type SemanticFieldDescriptor SemanticDescriptor

SemanticFieldDescriptor details the semantics of a simple field. An app that uses SemanticFieldDescriptor's should know how to handle each field type, so that the app can in each case:

  1. create the appropriate SQLite field, and
  2. create a translation layer btwn the app and SQLite, and
  3. create the proper rendering in HTML (or plain text), and
  4. maybe do basic validation

N.B. An "enume" is: one value in an enumeration. .

func SemanticFieldDescriptorByType

func SemanticFieldDescriptorByType(sft SemanticFieldType) (SemanticFieldDescriptor, error)

type SemanticFieldType

type SemanticFieldType SemanticType

SemanticFieldType assigns the semantics of a simple field. Semantically-based field validation is desirable but TBD.

  • Symbol names: "SFT_" + FIVE UPPER CASE letters
  • Symbol values: five lower case alphanumeric

For more information about each field type, see SemanticFieldDescriptors. .

func (SemanticFieldType) BasicDatatype

func (sft SemanticFieldType) BasicDatatype() BasicDatatype

func (SemanticFieldType) DT

func (sft SemanticFieldType) DT() Datatype

func (SemanticFieldType) Descriptor

func (sft SemanticFieldType) Descriptor() SemanticFieldDescriptor

func (SemanticFieldType) S

func (sft SemanticFieldType) S() string

type SemanticListDescriptor

type SemanticListDescriptor SemanticDescriptor

SemanticListDescriptor details the semantics of a simple list. An app that uses SemanticListDescriptor's should know how to handle each field type, so that the app can in each case:

  1. create the appropriate SQLite field (single/multi value), and
  2. create a translation layer btwn the app and SQLite, and
  3. create the proper HTML widget (or plain text UI)

N.B. An "enume" is: one value in an enumeration. .

func SemanticListDescriptorByType

func SemanticListDescriptorByType(slt SemanticListType) (SemanticListDescriptor, error)

type SemanticListType

type SemanticListType SemanticType

SemanticListType assigns the semantics of a simple list.

  • Symbol names are `"SFT_"` + FIVE UPPER CASE letters
  • Symbol values are five lower case letters

For more information about each field type, see SemanticListDescriptors. .

func (SemanticListType) DT

func (slt SemanticListType) DT() Datatype

func (SemanticListType) S

func (slt SemanticListType) S() string

type SemanticType

type SemanticType Datatype

type SqliteDatatype

type SqliteDatatype int

SqliteDatatype is one of the five basic ones defined by & for SQLite, plus the addition of a date-time. See https://sqlite.org/c3ref/c_blob.html

Note that there's also complicating factors like NUMERIC (and REAL). .

type TableSummary

type TableSummary Datum

TableSummary sums up a DB table (but not its columns). Field usage is as follows:

  • Datatype: SCT_TABL
  • [Datum.StorName]: the name of the table IN THE DB - a "long name"
  • [Datum.DispName]: a short name (3 ltrs!) for use in building up field names (mainly: primary & foreign keys)
  • [Datum.Description]: long description

.

type TypeType

type TypeType string

TypeType enumerates the basic types defined in this package. Datum is not in this list. .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL