Formatter option is now composed of two data: flags (lower 16 bits) and indentation size (higher 16 bits).
DictType and ListType formatter use both indent and flag options. Simple-store now makes a DictType from its data and its ToString() function returns dict.ToString()
This commit is contained in:
+13
-1
@@ -6,7 +6,7 @@ package expr
|
||||
|
||||
import "fmt"
|
||||
|
||||
type FmtOpt uint16
|
||||
type FmtOpt uint32 // lower 16 bits hold a bit-mask, higher 16 bits hold an indentation number
|
||||
|
||||
const (
|
||||
TTY FmtOpt = 1 << iota
|
||||
@@ -30,6 +30,18 @@ func TruncateString(s string) (trunc string) {
|
||||
return
|
||||
}
|
||||
|
||||
func MakeFormatOptions(flags FmtOpt, indent int) FmtOpt {
|
||||
return FmtOpt(indent<<16) | flags
|
||||
}
|
||||
|
||||
func GetFormatFlags(opt FmtOpt) FmtOpt {
|
||||
return opt & 0xFFFF
|
||||
}
|
||||
|
||||
func GetFormatIndent(opt FmtOpt) int {
|
||||
return int(opt >> 16)
|
||||
}
|
||||
|
||||
type Formatter interface {
|
||||
ToString(options FmtOpt) string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user