Documentation ¶
Overview ¶
Package enums provides common interfaces for enums and bit flag enums and utilities for using them
Package enums provides common interfaces for enums and bit flag enums and utilities for using them
Package enums provides common interfaces for enums and bit flag enums and utilities for using them
Index ¶
Constants ¶
const ( // Version is the version of this package being used Version = "v0.9.56" // GitCommit is the commit just before the latest version commit GitCommit = "399333d" // VersionDate is the date-time of the latest version commit in UTC (in the format 'YYYY-MM-DD HH:MM', which is the Go format '2006-01-02 15:04') VersionDate = "2023-12-26 23:25" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitFlag ¶
type BitFlag interface { Enum // Has returns whether these flags // have the given flag set. HasFlag(f BitFlag) bool // BitIndexString returns the string // representation of the bit flag if // the bit flag is a bit index value // (typically an enum constant), and // not an actual bit flag value. BitIndexString() string }
BitFlag is the interface that all bit flag enum types satisfy. Bit flag enum types support all of the operations that standard enums do, and additionally can check if they have a given bit flag.
type BitFlagSetter ¶ added in v0.9.6
type BitFlagSetter interface { EnumSetter BitFlag // Set sets the value of the given // flags in these flags to the given value. SetFlag(on bool, f ...BitFlag) // SetStringOr sets the bit flag from its // string representation while preserving any // bit flags already set, and returns an // error if the string is invalid. SetStringOr(s string) error }
BitFlagSetter is an expanded interface that all pointers to bit flag enum types satisfy. Pointers to bit flag enum types must satisfy all of the methods of EnumSetter and BitFlag, and must also be able to set a given bit flag.
type Enum ¶
type Enum interface { fmt.Stringer // Int64 returns the enum value as an int64. Int64() int64 // Desc returns the description of the enum value. Desc() string // IsValid returns whether the value is a // valid option for its enum type. IsValid() bool // Values returns all possible values this // enum type has. Values() []Enum }
Enum is the interface that all enum types satisfy. Enum types must be convertable to strings and int64s, must be able to return a description of their value, must be able to report if they are valid, and must be able to return all possible enum values for their type.
type EnumSetter ¶ added in v0.9.6
type EnumSetter interface { Enum // SetString sets the enum value from its // string representation, and returns an // error if the string is invalid. SetString(s string) error // SetInt64 sets the enum value from an int64. SetInt64(i int64) }
EnumSetter is an expanded interface that all pointers to enum types satisfy. Pointers to enum types must satisfy all of the methods of Enum, and must also be settable from strings and int64s.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
enumgen
Package main provides the actual command line implementation of the enumgen library.
|
Package main provides the actual command line implementation of the enumgen library. |
Package enumgen provides functions for generating enum methods for enum types.
|
Package enumgen provides functions for generating enum methods for enum types. |