-
Notifications
You must be signed in to change notification settings - Fork 13
/
datastore_change_meta_compare_param.go
223 lines (177 loc) · 8.04 KB
/
datastore_change_meta_compare_param.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// Package types implements all the types used by the DataStore protocol
package types
import (
"bytes"
"fmt"
"strings"
"github.com/PretendoNetwork/nex-go"
)
// DataStoreChangeMetaCompareParam is sent in the ChangeMeta method
type DataStoreChangeMetaCompareParam struct {
nex.Structure
ComparisonFlag uint32
Name string
Permission *DataStorePermission
DelPermission *DataStorePermission
Period uint16
MetaBinary []byte
Tags []string
ReferredCnt uint32
DataType uint16
Status uint8
}
// ExtractFromStream extracts a DataStoreChangeMetaCompareParam structure from a stream
func (dataStoreChangeMetaCompareParam *DataStoreChangeMetaCompareParam) ExtractFromStream(stream *nex.StreamIn) error {
var err error
dataStoreChangeMetaCompareParam.ComparisonFlag, err = stream.ReadUInt32LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.ComparisonFlag. %s", err.Error())
}
dataStoreChangeMetaCompareParam.Name, err = stream.ReadString()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.Name. %s", err.Error())
}
permission, err := stream.ReadStructure(NewDataStorePermission())
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.Permission. %s", err.Error())
}
dataStoreChangeMetaCompareParam.Permission = permission.(*DataStorePermission)
delPermission, err := stream.ReadStructure(NewDataStorePermission())
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.DelPermission. %s", err.Error())
}
dataStoreChangeMetaCompareParam.DelPermission = delPermission.(*DataStorePermission)
dataStoreChangeMetaCompareParam.Period, err = stream.ReadUInt16LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.Period. %s", err.Error())
}
dataStoreChangeMetaCompareParam.MetaBinary, err = stream.ReadQBuffer()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.MetaBinary. %s", err.Error())
}
dataStoreChangeMetaCompareParam.Tags, err = stream.ReadListString()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.Tags. %s", err.Error())
}
dataStoreChangeMetaCompareParam.ReferredCnt, err = stream.ReadUInt32LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.ReferredCnt. %s", err.Error())
}
dataStoreChangeMetaCompareParam.DataType, err = stream.ReadUInt16LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.DataType. %s", err.Error())
}
dataStoreChangeMetaCompareParam.Status, err = stream.ReadUInt8()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreChangeMetaCompareParam.Status. %s", err.Error())
}
return nil
}
// Copy returns a new copied instance of DataStoreChangeMetaCompareParam
func (dataStoreChangeMetaCompareParam *DataStoreChangeMetaCompareParam) Copy() nex.StructureInterface {
copied := NewDataStoreChangeMetaCompareParam()
copied.SetStructureVersion(dataStoreChangeMetaCompareParam.StructureVersion())
copied.ComparisonFlag = dataStoreChangeMetaCompareParam.ComparisonFlag
copied.Name = dataStoreChangeMetaCompareParam.Name
copied.Permission = dataStoreChangeMetaCompareParam.Permission.Copy().(*DataStorePermission)
copied.DelPermission = dataStoreChangeMetaCompareParam.DelPermission.Copy().(*DataStorePermission)
copied.Period = dataStoreChangeMetaCompareParam.Period
copied.MetaBinary = make([]byte, len(dataStoreChangeMetaCompareParam.MetaBinary))
copy(copied.MetaBinary, dataStoreChangeMetaCompareParam.MetaBinary)
copied.Tags = make([]string, len(dataStoreChangeMetaCompareParam.Tags))
copy(copied.Tags, dataStoreChangeMetaCompareParam.Tags)
copied.ReferredCnt = dataStoreChangeMetaCompareParam.ReferredCnt
copied.DataType = dataStoreChangeMetaCompareParam.DataType
copied.Status = dataStoreChangeMetaCompareParam.Status
return copied
}
// Equals checks if the passed Structure contains the same data as the current instance
func (dataStoreChangeMetaCompareParam *DataStoreChangeMetaCompareParam) Equals(structure nex.StructureInterface) bool {
other := structure.(*DataStoreChangeMetaCompareParam)
if dataStoreChangeMetaCompareParam.StructureVersion() != other.StructureVersion() {
return false
}
if dataStoreChangeMetaCompareParam.ComparisonFlag != other.ComparisonFlag {
return false
}
if dataStoreChangeMetaCompareParam.Name != other.Name {
return false
}
if dataStoreChangeMetaCompareParam.Permission.Equals(other.Permission) {
return false
}
if dataStoreChangeMetaCompareParam.DelPermission.Equals(other.DelPermission) {
return false
}
if dataStoreChangeMetaCompareParam.Period != other.Period {
return false
}
if !bytes.Equal(dataStoreChangeMetaCompareParam.MetaBinary, other.MetaBinary) {
return false
}
if len(dataStoreChangeMetaCompareParam.Tags) != len(other.Tags) {
return false
}
for i := 0; i < len(dataStoreChangeMetaCompareParam.Tags); i++ {
if dataStoreChangeMetaCompareParam.Tags[i] != other.Tags[i] {
return false
}
}
if dataStoreChangeMetaCompareParam.ReferredCnt != other.ReferredCnt {
return false
}
if dataStoreChangeMetaCompareParam.DataType != other.DataType {
return false
}
if dataStoreChangeMetaCompareParam.Status != other.Status {
return false
}
return true
}
// String returns a string representation of the struct
func (dataStoreChangeMetaCompareParam *DataStoreChangeMetaCompareParam) String() string {
return dataStoreChangeMetaCompareParam.FormatToString(0)
}
// FormatToString pretty-prints the struct data using the provided indentation level
func (dataStoreChangeMetaCompareParam *DataStoreChangeMetaCompareParam) FormatToString(indentationLevel int) string {
indentationValues := strings.Repeat("\t", indentationLevel+1)
indentationEnd := strings.Repeat("\t", indentationLevel)
var b strings.Builder
b.WriteString("DataStoreChangeMetaCompareParam{\n")
b.WriteString(fmt.Sprintf("%sstructureVersion: %d,\n", indentationValues, dataStoreChangeMetaCompareParam.StructureVersion()))
b.WriteString(fmt.Sprintf("%sComparisonFlag: %d,\n", indentationValues, dataStoreChangeMetaCompareParam.ComparisonFlag))
b.WriteString(fmt.Sprintf("%sName: %q,\n", indentationValues, dataStoreChangeMetaCompareParam.Name))
if dataStoreChangeMetaCompareParam.Permission != nil {
b.WriteString(fmt.Sprintf("%sPermission: %s,\n", indentationValues, dataStoreChangeMetaCompareParam.Permission.FormatToString(indentationLevel+1)))
} else {
b.WriteString(fmt.Sprintf("%sPermission: nil,\n", indentationValues))
}
if dataStoreChangeMetaCompareParam.DelPermission != nil {
b.WriteString(fmt.Sprintf("%sDelPermission: %s,\n", indentationValues, dataStoreChangeMetaCompareParam.DelPermission.FormatToString(indentationLevel+1)))
} else {
b.WriteString(fmt.Sprintf("%sDelPermission: nil,\n", indentationValues))
}
b.WriteString(fmt.Sprintf("%sPeriod: %d,\n", indentationValues, dataStoreChangeMetaCompareParam.Period))
b.WriteString(fmt.Sprintf("%sMetaBinary: %x,\n", indentationValues, dataStoreChangeMetaCompareParam.MetaBinary))
b.WriteString(fmt.Sprintf("%sTags: %v,\n", indentationValues, dataStoreChangeMetaCompareParam.Tags))
b.WriteString(fmt.Sprintf("%sReferredCnt: %d,\n", indentationValues, dataStoreChangeMetaCompareParam.ReferredCnt))
b.WriteString(fmt.Sprintf("%sDataType: %d,\n", indentationValues, dataStoreChangeMetaCompareParam.DataType))
b.WriteString(fmt.Sprintf("%sStatus: %d\n", indentationValues, dataStoreChangeMetaCompareParam.Status))
b.WriteString(fmt.Sprintf("%s}", indentationEnd))
return b.String()
}
// NewDataStoreChangeMetaCompareParam returns a new DataStoreChangeMetaCompareParam
func NewDataStoreChangeMetaCompareParam() *DataStoreChangeMetaCompareParam {
return &DataStoreChangeMetaCompareParam{
ComparisonFlag: 0,
Name: "",
Permission: NewDataStorePermission(),
DelPermission: NewDataStorePermission(),
Period: 0,
MetaBinary: make([]byte, 0),
Tags: make([]string, 0),
ReferredCnt: 0,
DataType: 0,
Status: 0,
}
}