| 1 | /* Go IPP - IPP core protocol implementation in pure Go |
| 2 | * |
| 3 | * Copyright (C) 2020 and up by Alexander Pevzner ([email protected]) |
| 4 | * See LICENSE for license terms and conditions |
| 5 | * |
| 6 | * Enumeration of value types |
| 7 | */ |
| 8 | |
| 9 | package goipp |
| 10 | |
| 11 | import ( |
| 12 | "fmt" |
| 13 | ) |
| 14 | |
| 15 | // Type enumerates all possible value types |
| 16 | type Type int |
| 17 | |
| 18 | const ( |
| 19 | TypeInvalid Type = -1 |
| 20 | TypeVoid Type = iota |
| 21 | TypeInteger |
| 22 | TypeBoolean |
| 23 | TypeString |
| 24 | TypeDateTime |
| 25 | TypeResolution |
| 26 | TypeRange |
| 27 | TypeTextWithLang |
| 28 | TypeBinary |
| 29 | TypeCollection |
| 30 | ) |
| 31 | |
| 32 | // String converts Type to string, for debugging |
| 33 | func (t Type) String() string { |
| 34 | switch t { |
| 35 | case TypeInvalid: |
| 36 | return "Invalid" |
| 37 | case TypeVoid: |
| 38 | return "Void" |
| 39 | case TypeInteger: |
| 40 | return "Integer" |
| 41 | case TypeBoolean: |
| 42 | return "Boolean" |
| 43 | case TypeString: |
| 44 | return "String" |
| 45 | case TypeDateTime: |
| 46 | return "DateTime" |
| 47 | case TypeResolution: |
| 48 | return "Resolution" |
| 49 | case TypeRange: |
| 50 | return "Range" |
| 51 | case TypeTextWithLang: |
| 52 | return "TextWithLang" |
| 53 | case TypeBinary: |
| 54 | return "Binary" |
| 55 | case TypeCollection: |
| 56 | return "Collection" |
| 57 | } |
| 58 | |
| 59 | return fmt.Sprintf("Unknown type %d", int(t)) |
| 60 | } |