| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
package goipp |
| 10 |
|
| 11 |
import ( |
| 12 |
"fmt" |
| 13 |
) |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
type Tag int |
| 18 |
|
| 19 |
const ( |
| 20 |
|
| 21 |
TagZero Tag = 0x00 |
| 22 |
TagOperationGroup Tag = 0x01 |
| 23 |
TagJobGroup Tag = 0x02 |
| 24 |
TagEnd Tag = 0x03 |
| 25 |
TagPrinterGroup Tag = 0x04 |
| 26 |
TagUnsupportedGroup Tag = 0x05 |
| 27 |
TagSubscriptionGroup Tag = 0x06 |
| 28 |
TagEventNotificationGroup Tag = 0x07 |
| 29 |
TagResourceGroup Tag = 0x08 |
| 30 |
TagDocumentGroup Tag = 0x09 |
| 31 |
TagSystemGroup Tag = 0x0a |
| 32 |
TagFuture11Group Tag = 0x0b |
| 33 |
TagFuture12Group Tag = 0x0c |
| 34 |
TagFuture13Group Tag = 0x0d |
| 35 |
TagFuture14Group Tag = 0x0e |
| 36 |
TagFuture15Group Tag = 0x0f |
| 37 |
|
| 38 |
|
| 39 |
TagUnsupportedValue Tag = 0x10 |
| 40 |
TagDefault Tag = 0x11 |
| 41 |
TagUnknown Tag = 0x12 |
| 42 |
TagNoValue Tag = 0x13 |
| 43 |
TagNotSettable Tag = 0x15 |
| 44 |
TagDeleteAttr Tag = 0x16 |
| 45 |
TagAdminDefine Tag = 0x17 |
| 46 |
TagInteger Tag = 0x21 |
| 47 |
TagBoolean Tag = 0x22 |
| 48 |
TagEnum Tag = 0x23 |
| 49 |
TagString Tag = 0x30 |
| 50 |
TagDateTime Tag = 0x31 |
| 51 |
TagResolution Tag = 0x32 |
| 52 |
TagRange Tag = 0x33 |
| 53 |
TagBeginCollection Tag = 0x34 |
| 54 |
TagTextLang Tag = 0x35 |
| 55 |
TagNameLang Tag = 0x36 |
| 56 |
TagEndCollection Tag = 0x37 |
| 57 |
TagText Tag = 0x41 |
| 58 |
TagName Tag = 0x42 |
| 59 |
TagReservedString Tag = 0x43 |
| 60 |
TagKeyword Tag = 0x44 |
| 61 |
TagURI Tag = 0x45 |
| 62 |
TagURIScheme Tag = 0x46 |
| 63 |
TagCharset Tag = 0x47 |
| 64 |
TagLanguage Tag = 0x48 |
| 65 |
TagMimeType Tag = 0x49 |
| 66 |
TagMemberName Tag = 0x4a |
| 67 |
TagExtension Tag = 0x7f |
| 68 |
) |
| 69 |
|
| 70 |
|
| 71 |
func (tag Tag) IsDelimiter() bool { |
| 72 |
return tag < 0x10 |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
func (tag Tag) Type() Type { |
| 77 |
if tag.IsDelimiter() { |
| 78 |
return TypeInvalid |
| 79 |
} |
| 80 |
|
| 81 |
switch tag { |
| 82 |
case TagInteger, TagEnum: |
| 83 |
return TypeInteger |
| 84 |
|
| 85 |
case TagBoolean: |
| 86 |
return TypeBoolean |
| 87 |
|
| 88 |
case TagUnsupportedValue, TagDefault, TagUnknown, TagNotSettable, |
| 89 |
TagDeleteAttr, TagAdminDefine: |
| 90 |
|
| 91 |
return TypeVoid |
| 92 |
|
| 93 |
case TagText, TagName, TagReservedString, TagKeyword, TagURI, TagURIScheme, |
| 94 |
TagCharset, TagLanguage, TagMimeType, TagMemberName: |
| 95 |
return TypeString |
| 96 |
|
| 97 |
case TagDateTime: |
| 98 |
return TypeDateTime |
| 99 |
|
| 100 |
case TagResolution: |
| 101 |
return TypeResolution |
| 102 |
|
| 103 |
case TagRange: |
| 104 |
return TypeRange |
| 105 |
|
| 106 |
case TagTextLang, TagNameLang: |
| 107 |
return TypeTextWithLang |
| 108 |
|
| 109 |
case TagBeginCollection: |
| 110 |
return TypeCollection |
| 111 |
|
| 112 |
case TagEndCollection: |
| 113 |
return TypeVoid |
| 114 |
|
| 115 |
default: |
| 116 |
return TypeBinary |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
func (tag Tag) String() string { |
| 122 |
switch tag { |
| 123 |
case TagZero: |
| 124 |
return "zero" |
| 125 |
case TagOperationGroup: |
| 126 |
return "operation-attributes-tag" |
| 127 |
case TagJobGroup: |
| 128 |
return "job-attributes-tag" |
| 129 |
case TagEnd: |
| 130 |
return "end-of-attributes-tag" |
| 131 |
case TagPrinterGroup: |
| 132 |
return "printer-attributes-tag" |
| 133 |
case TagUnsupportedGroup: |
| 134 |
return "unsupported-attributes-tag" |
| 135 |
case TagSubscriptionGroup: |
| 136 |
return "subscription-attributes-tag" |
| 137 |
case TagEventNotificationGroup: |
| 138 |
return "event-notification-attributes-tag" |
| 139 |
case TagResourceGroup: |
| 140 |
return "resource-attributes-tag" |
| 141 |
case TagDocumentGroup: |
| 142 |
return "document-attributes-tag" |
| 143 |
case TagSystemGroup: |
| 144 |
return "system-attributes-tag" |
| 145 |
|
| 146 |
|
| 147 |
case TagUnsupportedValue: |
| 148 |
return "unsupported" |
| 149 |
case TagDefault: |
| 150 |
return "default" |
| 151 |
case TagUnknown: |
| 152 |
return "unknown" |
| 153 |
case TagNoValue: |
| 154 |
return "no-value" |
| 155 |
case TagNotSettable: |
| 156 |
return "not-settable" |
| 157 |
case TagDeleteAttr: |
| 158 |
return "delete-attribute" |
| 159 |
case TagAdminDefine: |
| 160 |
return "admin-define" |
| 161 |
case TagInteger: |
| 162 |
return "integer" |
| 163 |
case TagBoolean: |
| 164 |
return "boolean" |
| 165 |
case TagEnum: |
| 166 |
return "enum" |
| 167 |
case TagString: |
| 168 |
return "octetString" |
| 169 |
case TagDateTime: |
| 170 |
return "dateTime" |
| 171 |
case TagResolution: |
| 172 |
return "resolution" |
| 173 |
case TagRange: |
| 174 |
return "rangeOfInteger" |
| 175 |
case TagBeginCollection: |
| 176 |
return "collection" |
| 177 |
case TagTextLang: |
| 178 |
return "textWithLanguage" |
| 179 |
case TagNameLang: |
| 180 |
return "nameWithLanguage" |
| 181 |
case TagEndCollection: |
| 182 |
return "endCollection" |
| 183 |
case TagText: |
| 184 |
return "textWithoutLanguage" |
| 185 |
case TagName: |
| 186 |
return "nameWithoutLanguage" |
| 187 |
case TagKeyword: |
| 188 |
return "keyword" |
| 189 |
case TagURI: |
| 190 |
return "uri" |
| 191 |
case TagURIScheme: |
| 192 |
return "uriScheme" |
| 193 |
case TagCharset: |
| 194 |
return "charset" |
| 195 |
case TagLanguage: |
| 196 |
return "naturalLanguage" |
| 197 |
case TagMimeType: |
| 198 |
return "mimeMediaType" |
| 199 |
case TagMemberName: |
| 200 |
return "memberAttrName" |
| 201 |
} |
| 202 |
|
| 203 |
return fmt.Sprintf("0x%2.2x", int(tag)) |
| 204 |
} |