Documentation ¶
Index ¶
- func WildcardMatch(wildcard, tag string) bool
- type DiffMembership
- type StringDiff
- func (this *StringDiff) Add(tag string)
- func (this StringDiff) AddedSet() StringSet
- func (this *StringDiff) Apply(tag string)
- func (this *StringDiff) ApplyArray(tag_diff []string)
- func (this *StringDiff) ApplyArrays(add_tags, remove_tags, reset_tags []string)
- func (this *StringDiff) ApplyStringWithDelimiter(tag_diff, delimiter string)
- func (this *StringDiff) ApplyStringsWithDelimiter(add_tags, remove_tags, reset_tags, delimiter string)
- func (this StringDiff) Array() []string
- func (this *StringDiff) Clear()
- func (this StringDiff) Difference(other StringDiff) StringDiff
- func (this StringDiff) Equal(other StringDiff) bool
- func (this StringDiff) Invert() StringDiff
- func (this StringDiff) IsZero() bool
- func (this StringDiff) Len() int
- func (this *StringDiff) Remove(tag string)
- func (this StringDiff) RemovedSet() StringSet
- func (this *StringDiff) Reset(tag string)
- func (this *StringDiff) Status(tag string) DiffMembership
- func (this StringDiff) StringWithDelimiter(delimiter string) string
- func (this StringDiff) Union(other StringDiff) StringDiff
- type StringDiffArray
- type StringSet
- func (this *StringSet) Apply(t string)
- func (this *StringSet) ApplyArray(tags []string)
- func (this *StringSet) ApplyDiff(diff StringDiff)
- func (this *StringSet) ApplyStringWithDelimiter(tags, delim string)
- func (this *StringSet) Clear(t string)
- func (this StringSet) Clone() StringSet
- func (this StringSet) Equal(other StringSet) bool
- func (this StringSet) Len() int
- func (this *StringSet) Merge(other StringSet)
- func (this *StringSet) Reset()
- func (this *StringSet) Set(t string)
- func (this *StringSet) Status(tag string) DiffMembership
- func (this StringSet) StringWithDelimiter(delim string) string
- func (this *StringSet) ToggleArray(tags []string)
- func (this *StringSet) ToggleStringWithDelimiter(tags, delim string)
- type TagDiff
- func TagDiffFromArray(tag_diff []string) TagDiff
- func TagDiffFromArrays(add_tags, remove_tags []string) TagDiff
- func TagDiffFromString(tag_diff string) TagDiff
- func TagDiffFromStringWithDelimiter(tag_diff, delimiter string) TagDiff
- func TagDiffFromStrings(add_tags, remove_tags string) TagDiff
- func TagDiffFromStringsWithDelimiter(add_tags, remove_tags, delimiter string) TagDiff
- func (this TagDiff) APIString() string
- func (this TagDiff) AddedSet() TagSet
- func (this *TagDiff) ApplyString(tag_diff string)
- func (this *TagDiff) ApplyStrings(add_tags, remove_tags, reset_tags string)
- func (this TagDiff) Difference(other TagDiff) TagDiff
- func (this TagDiff) Equal(other TagDiff) bool
- func (this TagDiff) Invert() TagDiff
- func (this TagDiff) RemovedSet() TagSet
- func (this TagDiff) String() string
- func (this TagDiff) Union(other TagDiff) TagDiff
- type TagDiffArray
- type TagSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WildcardMatch ¶
Types ¶
type DiffMembership ¶
type DiffMembership int
const AddsTag DiffMembership = 1
const NotPresent DiffMembership = 0
const RemovesTag DiffMembership = -1
const ResetsTag DiffMembership = 0
type StringDiff ¶
type StringDiff struct { AddList map[string]bool `json:"add"` RemoveList map[string]bool `json:"remove"` }
func StringDiffFromArray ¶
func StringDiffFromArray(tag_diff []string) StringDiff
StringDiffFromArray (singular) builds a new StringDiff using the specified tag list. all of the *single argument* constructor functions for StringDiff and TagDiff fkow through this function. It's not simply implemented in terms of Apply because that function is designed to interpret tags starting with = as "reset" tags, i.e. remove them from both lists, and because of that it also treats + as a special prefix to enable adding natural tags beginning with =. All in all, it creates a bit of a mess, so it's useful to separate that logic (which is more suitable for ongoing mutations of existing objects) from this logic, which is useful for constructing new objects, most typically from API-compatible string exports of old ones.
func StringDiffFromArrays ¶
func StringDiffFromArrays(add_tags, remove_tags []string) StringDiff
StringDiffFromArrays builds a new StringDiff using the specified add and remove tags. Ultimately, all of the other constructor functions for StringDiff and TagDiff flow through this function.
func StringDiffFromStringWithDelimiter ¶
func StringDiffFromStringWithDelimiter(tag_diff, delimiter string) StringDiff
func StringDiffFromStringsWithDelimiter ¶
func StringDiffFromStringsWithDelimiter(add_tags, remove_tags, delimiter string) StringDiff
func (*StringDiff) Add ¶
func (this *StringDiff) Add(tag string)
func (StringDiff) AddedSet ¶
func (this StringDiff) AddedSet() StringSet
func (*StringDiff) Apply ¶
func (this *StringDiff) Apply(tag string)
func (*StringDiff) ApplyArray ¶
func (this *StringDiff) ApplyArray(tag_diff []string)
func (*StringDiff) ApplyArrays ¶
func (this *StringDiff) ApplyArrays(add_tags, remove_tags, reset_tags []string)
func (*StringDiff) ApplyStringWithDelimiter ¶
func (this *StringDiff) ApplyStringWithDelimiter(tag_diff, delimiter string)
func (*StringDiff) ApplyStringsWithDelimiter ¶
func (this *StringDiff) ApplyStringsWithDelimiter(add_tags, remove_tags, reset_tags, delimiter string)
func (StringDiff) Array ¶
func (this StringDiff) Array() []string
func (*StringDiff) Clear ¶
func (this *StringDiff) Clear()
func (StringDiff) Difference ¶
func (this StringDiff) Difference(other StringDiff) StringDiff
func (StringDiff) Equal ¶
func (this StringDiff) Equal(other StringDiff) bool
func (StringDiff) Invert ¶
func (this StringDiff) Invert() StringDiff
func (StringDiff) IsZero ¶
func (this StringDiff) IsZero() bool
func (StringDiff) Len ¶
func (this StringDiff) Len() int
func (*StringDiff) Remove ¶
func (this *StringDiff) Remove(tag string)
func (StringDiff) RemovedSet ¶
func (this StringDiff) RemovedSet() StringSet
func (*StringDiff) Reset ¶
func (this *StringDiff) Reset(tag string)
func (*StringDiff) Status ¶
func (this *StringDiff) Status(tag string) DiffMembership
func (StringDiff) StringWithDelimiter ¶
func (this StringDiff) StringWithDelimiter(delimiter string) string
func (StringDiff) Union ¶
func (this StringDiff) Union(other StringDiff) StringDiff
type StringDiffArray ¶
type StringDiffArray []StringDiff
func (StringDiffArray) Flatten ¶
func (this StringDiffArray) Flatten() StringDiff
type StringSet ¶
func (*StringSet) Apply ¶
apply a single string. accepts strings prefixed with -, which negates. when negating, accepts simple asterisk wildcards to match any number of characters (as a trivial example, '-*' unsets all matches)
func (*StringSet) ApplyArray ¶
applies each tag in an array. accepts tags prefixed with -.
func (*StringSet) ApplyDiff ¶
func (this *StringSet) ApplyDiff(diff StringDiff)
apply a diff to the tag set.
func (*StringSet) ApplyStringWithDelimiter ¶
applies each token in a string with specified delimiter. accepts strings prefixed with -.
func (*StringSet) Status ¶
func (this *StringSet) Status(tag string) DiffMembership
checks to see if a specific tag is set. does not accept prefixed tags.
func (StringSet) StringWithDelimiter ¶
Emits the string set as a single string with the specified delimiter.
func (*StringSet) ToggleArray ¶
toggles each tag in an array, deselecting them if they are currently selected and vice versa. accepts tags prefixed with either + or -, which overrides toggling behavior (the prefix always signals the end state)
func (*StringSet) ToggleStringWithDelimiter ¶
toggles each tag in an array, deselecting them if they are currently selected and vice versa. accepts tags prefixed with either + or -, which overrides toggling behavior (the prefix always signals the end state)
type TagDiff ¶
type TagDiff struct {
StringDiff
}
This represents a diff to be applied to a tag set. It is specialized for string-delimited tags. Tags can, using some functions, be prefixed with +, -, or = to override default behaviors, check function docs to see where this is allowed.
TagDiff embeds StringDiff, and thus provides many of the same functions which are integral to its usage, and are documented by StringDiff.
func TagDiffFromArray ¶
This is the same as TagDiffFromString, except that you specify an array of pre-split tags.
func TagDiffFromArrays ¶
This is the same as TagDiffFromStrings, except that you specify arrays of pre-split tags.
func TagDiffFromString ¶
TagDiffFromString is the reverse operation of APIString. It is unambiguous for any API-legal string. Its argument is a string consisting of tags delimited by spaces, with the following prefixes: - to denote removal no prefix to denote addition (this is the default)
func TagDiffFromStringWithDelimiter ¶
This is the same as TagDiffFromString, except that you may specify the delimiter.
func TagDiffFromStrings ¶
TagDiffFromStrings takes a list of tags to add and a list of tags to remove, both delimited by spaces, and builds a TagDiff as though each tag in the add list was passed to Add, and each tag in the remove list passed to Remove. No prefixes are permitted, tags will be passed verbatim (and if they are present, it may be possible to build a TagDiff which is not API-legal)
func TagDiffFromStringsWithDelimiter ¶
This is the same as TagDiffFromStrings, except that you may specify the delimiter.
func (TagDiff) APIString ¶
Builds an API compatible representation of the tag difference. Substrings are ordered first (adds, removes), then alphabetically. Removes are prefixed by a minus sign. Adds are unprefixed, and no prefix is permitted.
func (TagDiff) AddedSet ¶
AddedSet produces an ALIAS to the tags added by this TagDiff. Changes made to one will reflect upon the other.
func (*TagDiff) ApplyString ¶
ApplyString delimits the provided string by spaces and applies each tag in it. Tags can be prefixed: + forces addition (this is the default if a prefix isn't specified) - forces removal = forces reset (undoing a previous add or remove)
func (*TagDiff) ApplyStrings ¶
ApplyStrings takes three strings, representing tags to add, remove, and reset. Each string is delimited by spaces and each tag in it is applied. Prefixes are not allowed in this function, if they are present they will be included literally (this is not usually the desired result).
func (TagDiff) Difference ¶
Difference yields a TagDiff such that every tag added or removed by `this` will be processed UNLESS that tag is to be added or removed by `other`, in which case the opposite will occur. Tags are added and removed by `this` first, and then by `other` second (in case the two inputs try to both add or remove the same tag).
func (TagDiff) Equal ¶
Compares a TagDiff to another. The two are only equal if they both add the same set of new tags, and remove the same set of existing tags.
func (TagDiff) Invert ¶
Invert yields a TagDiff with its add and remove sets swapped. In the case where a TagDiff applies perfectly to a TagSet (i.e. every tag in its add list was absent and added, and in its remove list, present and removed), Applying that tag diff's Invert() value will undo the change. (If that precondition is not true, it's a little more complicated, be careful)
func (TagDiff) RemovedSet ¶
RemovedSet produces an ALIAS to the tags removed by this TagDiff. Changes made to one will reflect upon the other.
type TagDiffArray ¶
type TagDiffArray []TagDiff
This represents a list of diffs, applied sequentially.
func (TagDiffArray) Flatten ¶
func (this TagDiffArray) Flatten() TagDiff
Flatten sequentially applies every operation from a TagDiffArray as though calling Union on them over and over, starting with the first.
type TagSet ¶
type TagSet struct {
StringSet
}