-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_error.go
43 lines (33 loc) · 884 Bytes
/
print_error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2024 ROBON INC.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package primitives
import (
"encoding/xml"
)
// PrintErrorType is a type to encode XSD ST_PrintError
type PrintErrorType byte
var (
ToPrintErrorType map[string]PrintErrorType
FromPrintErrorType map[PrintErrorType]string
)
func (t PrintErrorType) String() string {
return FromPrintErrorType[t]
}
// MarshalXMLAttr marshal PatternType
func (t *PrintErrorType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{Name: name}
if v, ok := FromPrintErrorType[*t]; ok {
attr.Value = v
} else {
attr = xml.Attr{}
}
return attr, nil
}
// UnmarshalXMLAttr unmarshal PatternType
func (t *PrintErrorType) UnmarshalXMLAttr(attr xml.Attr) error {
if v, ok := ToPrintErrorType[attr.Value]; ok {
*t = v
}
return nil
}