raw

package
v0.24.8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Overview

a non-sql data format for use by the qna runtime

Index

Constants

View Source
const (
	ONE_TO_ONE   = "one_one"
	ONE_TO_MANY  = "one_any"
	MANY_TO_ONE  = "any_one"
	MANY_TO_MANY = "any_any"
)

cardinality

Variables

This section is empty.

Functions

func FindKind

func FindKind(ks []rt.Kind, exactKind string) (ret *rt.Kind, okay bool)

Types

type Data

type Data struct {
	Scenes    []string            // in order with root ( tapestry ) first
	Plurals   []Plural            // pairs of one, many; sorted by one
	Kinds     []rt.Kind           // sorted by .Kind
	Names     []NounName          // sorted by .Name
	Nouns     []NounData          // sorted by .Noun
	Patterns  []PatternData       // sorted by .Pattern
	Relatives []RelativeData      // sorted by .Relation
	Grammar   []grammar.Directive // sorted by .Name
}

func (*Data) GetKindByName

func (q *Data) GetKindByName(kind string) (ret *rt.Kind, err error)

fix? calls are not consistent about which name they use see also BuildKind

type EvalData

type EvalData struct {
	Field string
	Value rt.Assignment
}

func FindValueField

func FindValueField(els []EvalData, name string) (ret EvalData, okay bool)

type NounData

type NounData struct {
	Id         int // mdl_noun
	Domain     string
	Noun       string       // full, unique name
	Kind       string       // alt? id, path, bitarray? ...
	CommonName string       // author defined name
	Aliases    []string     // alpha order for parser
	Values     []EvalData   `json:",omitempty"` // sparse field values, sorted by field name
	Records    []RecordData `json:",omitempty"`
}

func FindNoun

func FindNoun(els []NounData, name string) (ret NounData, okay bool)

type NounName

type NounName struct {
	Name, Noun string // shortname, fullname
}

func FindName

func FindName(els []NounName, name string) (ret NounName, okay bool)

type Pair

type Pair struct {
	One, Other string // noun fullnames
}

type PatternData

type PatternData struct {
	Id        int // mdl_pat
	Pattern   string
	Labels    []string  // the last value is the result, even if blank
	Rules     []rt.Rule `json:",omitempty"`
	UpdateAll bool
}

func FindPattern

func FindPattern(els []PatternData, name string) (ret PatternData, okay bool)

type Plural

type Plural struct {
	One, Many string
}

func FindPlural

func FindPlural(els []Plural, name string) (ret Plural, okay bool)

type RawQuery

type RawQuery struct {
	*Data
	// contains filtered or unexported fields
}

func MakeQuery

func MakeQuery(data *Data) RawQuery

func (RawQuery) ActivateDomains

func (q RawQuery) ActivateDomains(name string) (prev, next []string, err error)

func (RawQuery) Close

func (q RawQuery) Close()

func (RawQuery) IsDomainActive

func (q RawQuery) IsDomainActive(name string) (okay bool, err error)

func (RawQuery) KindOfAncestors

func (q RawQuery) KindOfAncestors(singleOrPlural string) (ret []string, err error)

func (RawQuery) LoadGame

func (q RawQuery) LoadGame(path string) (ret query.CacheMap, err error)

LoadGame implements Query.

func (RawQuery) NounInfo

func (q RawQuery) NounInfo(short string) (ret query.NounInfo, err error)

search using short name

func (RawQuery) NounName

func (q RawQuery) NounName(full string) (ret string, err error)

the best short name for the passed full name

func (RawQuery) NounNames

func (q RawQuery) NounNames(full string) (ret []string, err error)

func (RawQuery) NounValue

func (q RawQuery) NounValue(full, field string) (ret rt.Assignment, err error)

func (RawQuery) NounsWithAncestor added in v0.24.8

func (q RawQuery) NounsWithAncestor(kind string) (ret []string, err error)

ex. give me all nouns of type "actors"

func (RawQuery) PatternLabels

func (q RawQuery) PatternLabels(pat string) (ret []string, err error)

func (RawQuery) PluralFromSingular

func (q RawQuery) PluralFromSingular(singular string) (ret string, _ error)

func (RawQuery) PluralToSingular

func (q RawQuery) PluralToSingular(plural string) (ret string, _ error)

func (RawQuery) Random

func (q RawQuery) Random(inclusiveMin int, exclusiveMax int) int

Random implements Query.

func (RawQuery) ReciprocalsOf

func (q RawQuery) ReciprocalsOf(rel, noun string) (ret []string, err error)

func (RawQuery) Relate

func (q RawQuery) Relate(rel, noun, otherNoun string) (err error)

func (RawQuery) RelativesOf

func (q RawQuery) RelativesOf(rel, noun string) (ret []string, err error)

func (RawQuery) RulesFor

func (q RawQuery) RulesFor(pat string) (ret query.RuleSet, err error)

func (RawQuery) SaveGame

func (q RawQuery) SaveGame(path string, dynamicValues query.CacheMap) error

SaveGame implements Query.

type RecordData

type RecordData struct {
	Field  string
	Packed []byte // json serialized for now
}

record data is json serialized ( via pack/unpack ) because otherwise gobbing would need a way to store variant values package json says []byte encodes as a base64-encoded string,

func FindRecordField

func FindRecordField(els []RecordData, name string) (ret RecordData, okay bool)

type RelativeData

type RelativeData struct {
	Id                 int    // mdl_rel
	Relation           string // a kind
	OneKind, OtherKind string // primary and secondary types
	Cardinality        string // ( these also are recorded in the kind data )
	Pairs              []Pair `json:",omitempty"`
}

func FindRelation

func FindRelation(els []RelativeData, name string) (ret *RelativeData, okay bool)

type SceneData added in v0.24.8

type SceneData struct {
	Scene    string
	Requires []string `json:",omitempty"`
}

Jump to

Keyboard shortcuts

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