| 1 |
package encoder |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
"io" |
| 6 |
) |
| 7 |
|
| 8 |
type OptionFlag uint16 |
| 9 |
|
| 10 |
const ( |
| 11 |
HTMLEscapeOption OptionFlag = 1 << iota |
| 12 |
IndentOption |
| 13 |
UnorderedMapOption |
| 14 |
DebugOption |
| 15 |
ColorizeOption |
| 16 |
ContextOption |
| 17 |
NormalizeUTF8Option |
| 18 |
FieldQueryOption |
| 19 |
// OptimizeFieldOrderOption lets the encoder order the fields of a struct as it encodes them fastest: |
| 20 |
// the fields of the same kind together, and a recursive field last. The opcodes of a type are compiled |
| 21 |
// for it apart from the ones for the order of the struct. |
| 22 |
OptimizeFieldOrderOption |
| 23 |
) |
| 24 |
|
| 25 |
type Option struct { |
| 26 |
Flag OptionFlag |
| 27 |
ColorScheme *ColorScheme |
| 28 |
Context context.Context |
| 29 |
DebugOut io.Writer |
| 30 |
DebugDOTOut io.WriteCloser |
| 31 |
} |
| 32 |
|
| 33 |
type EncodeFormat struct { |
| 34 |
Header string |
| 35 |
Footer string |
| 36 |
} |
| 37 |
|
| 38 |
type EncodeFormatScheme struct { |
| 39 |
Int EncodeFormat |
| 40 |
Uint EncodeFormat |
| 41 |
Float EncodeFormat |
| 42 |
Bool EncodeFormat |
| 43 |
String EncodeFormat |
| 44 |
Binary EncodeFormat |
| 45 |
ObjectKey EncodeFormat |
| 46 |
Null EncodeFormat |
| 47 |
} |
| 48 |
|
| 49 |
type ( |
| 50 |
ColorScheme = EncodeFormatScheme |
| 51 |
ColorFormat = EncodeFormat |
| 52 |
) |