const classcamAxonPlugin::Etc
sys::Obj camAxonPlugin::Etc
@
Js
Etc provides folio related utility methods.
- compareDis
static Int compareDis(Str a, Str b)
Given two display strings, return 1, 0, or -1 if a is less than, equal to, or greater than b. The comparison is case insensitive and takes into account trailing digits so that a dis str such as "Foo-10" is greater than "Foo-2".
- dictFindAll
static Dict dictFindAll(Dict d, |Obj?,Str->Obj? f)
Apply the given map function to each name/value pair to construct a new Dict.
- dictMap
static Dict dictMap(Dict d, |Obj?,Str->Obj? f)
Apply the given map function to each name/value pair to construct a new Dict.
- dictMerge
static Dict dictMerge(Dict a, Obj? b)
Add/set all the name/value pairs in a with those defined in b. If b defines a remove value then that name/value is removed from a. The b parameter may be any value accepted by makeDict
- dictNames
static Str[] dictNames(Dict d)
Get a read/write list of the dict's name keys.
- dictRemove
static Dict dictRemove(Dict d, Str name)
Set a name/val pair in an existing dict.
- dictSet
static Dict dictSet(Dict d, Str name, Obj? val)
Set a name/val pair in an existing dict.
- dictToDis
static Str? dictToDis(Dict dict, Str? def := "")
Given a dic, attempt to find the best display string:
disMacro
tag returns macro using dict as scopedis
tagname
tagtag
tagid
tag- default
- dictToMap
static Str:Obj? dictToMap(Dict d)
Convert a Dict to a read/write map. This method is expensive, when possible you should instead use Dict.each.
- dictVals
static Obj?[] dictVals(Dict d)
Get all the non-null values mapped by a dictionary.
- dictsNames
static Str[] dictsNames(Dict[] dicts)
Given a list of dictionaries, find all the common names used. Return the names in standard sorted order.
- emptyDict
static Dict emptyDict()
Get the emtpy Dict instance.
- isDictVal
static Bool isDictVal(Obj? val)
Return if the given value is one of the scalar values supported by dictions and grids.
- isTagName
Return if the given string is a legal tag name:
- first char must be ASCII lower case letter:
a
-z
- rest of chars must be ASCII letter or digit:
a
-z
,A
-Z
,0
-9
, or_
- first char must be ASCII lower case letter:
- macro
static Str macro(Str pattern, Dict scope)
Process macro pattern with given scope of variable name/value pairs. The pattern is a Unicode string with embedded expressions:
$tag
: resolve tag name from scope${tag}
: resolve tag name from scope$<pod::key>
: localization key
If a tag resolves to Ref, then we use Ref.dis for string.
- makeDict
static Dict makeDict(Obj? val)
Make a Dict instance where
val
is one of the following:- Dict: return
val
- null: return emptyDict
- Str[]: dictionary of key/Marker value pairs
- Str:Obj?: wrap map as Dict
- Dict: return
- makeDictGrid
static Grid makeDictGrid(Obj? meta, Dict row)
Construct a grid for a Dict row. The meta parameter can be any makeDict value.
- makeDicts
static Dict[] makeDicts(Obj?[] maps)
Make a list of Dict instances using makeDict.
- makeDictsGrid
static Grid makeDictsGrid(Obj? meta, Dict[] rows)
Construct a grid for a list of Dict rows. The meta parameter can be any makeDict value.
- makeEmptyGrid
static Grid makeEmptyGrid(Obj? meta := null)
Construct an empty grid with just the given grid level meta-data. The meta parameter can be any makeDict value.
- makeErrGrid
static Grid makeErrGrid(Err e, Obj? meta := null)
Construct a grid for an error response.
- makeListGrid
static Grid makeListGrid(Obj? meta, Str colName, Obj? colMeta, Obj?[] rows)
Construct a grid with one column for a list. The meta and colMeta parameters can be any makeDict value.
- makeListsGrid
static Grid makeListsGrid(Obj? meta, Str[] colNames, Obj?[]? colMetas, Obj?[][] rows)
Construct a grid for a list of rows, where each row is a list of cells. The meta and colMetas parameters can be any makeDict value.
- makeMapGrid
static Grid makeMapGrid(Obj? meta, Str:Obj? row)
Convenience for makeDictGrid
- makeMapsGrid
static Grid makeMapsGrid(Obj? meta, Str:Obj?[] rows)
Convenience for makeDictsGrid
- relDis
static Str relDis(Str parent, Str child)
Get a relative display name. If the child display name starts with the parent, then we can strip that as the common suffix.
- tagToLocale
static Str tagToLocale(Str name)
Get the localized string for the given tag name for the current locale. See docSkySpark::Localization#tags.
- toGrid
Given an arbitrary object, translate it to a Grid suitable for serizliation with Zinc:
- if grid just return it
- if row in grid of size, return row.grid
- if scalar return 1x1 grid
- if dict return grid where dict is only
- if list of dict return grid where each dict is row
- if list of non-dicts, return one col grid with rows for each item
- if non-zinc type return grid with cols val, type
- toTagName
Take an arbitrary string ane convert into a safe tag name.