github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/CatalogHeader.go (about) 1 // Generated SBE (Simple Binary Encoding) message codec 2 3 package codecs 4 5 import ( 6 "fmt" 7 "io" 8 "io/ioutil" 9 "math" 10 ) 11 12 type CatalogHeader struct { 13 Version int32 14 Length int32 15 NextRecordingId int64 16 Alignment int32 17 Reserved int8 18 } 19 20 func (c *CatalogHeader) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 21 if doRangeCheck { 22 if err := c.RangeCheck(c.SbeSchemaVersion(), c.SbeSchemaVersion()); err != nil { 23 return err 24 } 25 } 26 if err := _m.WriteInt32(_w, c.Version); err != nil { 27 return err 28 } 29 if err := _m.WriteInt32(_w, c.Length); err != nil { 30 return err 31 } 32 if err := _m.WriteInt64(_w, c.NextRecordingId); err != nil { 33 return err 34 } 35 if err := _m.WriteInt32(_w, c.Alignment); err != nil { 36 return err 37 } 38 39 for i := 0; i < 11; i++ { 40 if err := _m.WriteUint8(_w, uint8(0)); err != nil { 41 return err 42 } 43 } 44 if err := _m.WriteInt8(_w, c.Reserved); err != nil { 45 return err 46 } 47 return nil 48 } 49 50 func (c *CatalogHeader) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 51 if !c.VersionInActingVersion(actingVersion) { 52 c.Version = c.VersionNullValue() 53 } else { 54 if err := _m.ReadInt32(_r, &c.Version); err != nil { 55 return err 56 } 57 } 58 if !c.LengthInActingVersion(actingVersion) { 59 c.Length = c.LengthNullValue() 60 } else { 61 if err := _m.ReadInt32(_r, &c.Length); err != nil { 62 return err 63 } 64 } 65 if !c.NextRecordingIdInActingVersion(actingVersion) { 66 c.NextRecordingId = c.NextRecordingIdNullValue() 67 } else { 68 if err := _m.ReadInt64(_r, &c.NextRecordingId); err != nil { 69 return err 70 } 71 } 72 if !c.AlignmentInActingVersion(actingVersion) { 73 c.Alignment = c.AlignmentNullValue() 74 } else { 75 if err := _m.ReadInt32(_r, &c.Alignment); err != nil { 76 return err 77 } 78 } 79 io.CopyN(ioutil.Discard, _r, 11) 80 if !c.ReservedInActingVersion(actingVersion) { 81 c.Reserved = c.ReservedNullValue() 82 } else { 83 if err := _m.ReadInt8(_r, &c.Reserved); err != nil { 84 return err 85 } 86 } 87 if actingVersion > c.SbeSchemaVersion() && blockLength > c.SbeBlockLength() { 88 io.CopyN(ioutil.Discard, _r, int64(blockLength-c.SbeBlockLength())) 89 } 90 if doRangeCheck { 91 if err := c.RangeCheck(actingVersion, c.SbeSchemaVersion()); err != nil { 92 return err 93 } 94 } 95 return nil 96 } 97 98 func (c *CatalogHeader) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 99 if c.VersionInActingVersion(actingVersion) { 100 if c.Version < c.VersionMinValue() || c.Version > c.VersionMaxValue() { 101 return fmt.Errorf("Range check failed on c.Version (%v < %v > %v)", c.VersionMinValue(), c.Version, c.VersionMaxValue()) 102 } 103 } 104 if c.LengthInActingVersion(actingVersion) { 105 if c.Length < c.LengthMinValue() || c.Length > c.LengthMaxValue() { 106 return fmt.Errorf("Range check failed on c.Length (%v < %v > %v)", c.LengthMinValue(), c.Length, c.LengthMaxValue()) 107 } 108 } 109 if c.NextRecordingIdInActingVersion(actingVersion) { 110 if c.NextRecordingId < c.NextRecordingIdMinValue() || c.NextRecordingId > c.NextRecordingIdMaxValue() { 111 return fmt.Errorf("Range check failed on c.NextRecordingId (%v < %v > %v)", c.NextRecordingIdMinValue(), c.NextRecordingId, c.NextRecordingIdMaxValue()) 112 } 113 } 114 if c.AlignmentInActingVersion(actingVersion) { 115 if c.Alignment < c.AlignmentMinValue() || c.Alignment > c.AlignmentMaxValue() { 116 return fmt.Errorf("Range check failed on c.Alignment (%v < %v > %v)", c.AlignmentMinValue(), c.Alignment, c.AlignmentMaxValue()) 117 } 118 } 119 if c.ReservedInActingVersion(actingVersion) { 120 if c.Reserved < c.ReservedMinValue() || c.Reserved > c.ReservedMaxValue() { 121 return fmt.Errorf("Range check failed on c.Reserved (%v < %v > %v)", c.ReservedMinValue(), c.Reserved, c.ReservedMaxValue()) 122 } 123 } 124 return nil 125 } 126 127 func CatalogHeaderInit(c *CatalogHeader) { 128 return 129 } 130 131 func (*CatalogHeader) SbeBlockLength() (blockLength uint16) { 132 return 32 133 } 134 135 func (*CatalogHeader) SbeTemplateId() (templateId uint16) { 136 return 20 137 } 138 139 func (*CatalogHeader) SbeSchemaId() (schemaId uint16) { 140 return 101 141 } 142 143 func (*CatalogHeader) SbeSchemaVersion() (schemaVersion uint16) { 144 return 6 145 } 146 147 func (*CatalogHeader) SbeSemanticType() (semanticType []byte) { 148 return []byte("") 149 } 150 151 func (*CatalogHeader) VersionId() uint16 { 152 return 1 153 } 154 155 func (*CatalogHeader) VersionSinceVersion() uint16 { 156 return 0 157 } 158 159 func (c *CatalogHeader) VersionInActingVersion(actingVersion uint16) bool { 160 return actingVersion >= c.VersionSinceVersion() 161 } 162 163 func (*CatalogHeader) VersionDeprecated() uint16 { 164 return 0 165 } 166 167 func (*CatalogHeader) VersionMetaAttribute(meta int) string { 168 switch meta { 169 case 1: 170 return "" 171 case 2: 172 return "" 173 case 3: 174 return "" 175 case 4: 176 return "required" 177 } 178 return "" 179 } 180 181 func (*CatalogHeader) VersionMinValue() int32 { 182 return math.MinInt32 + 1 183 } 184 185 func (*CatalogHeader) VersionMaxValue() int32 { 186 return math.MaxInt32 187 } 188 189 func (*CatalogHeader) VersionNullValue() int32 { 190 return math.MinInt32 191 } 192 193 func (*CatalogHeader) LengthId() uint16 { 194 return 2 195 } 196 197 func (*CatalogHeader) LengthSinceVersion() uint16 { 198 return 0 199 } 200 201 func (c *CatalogHeader) LengthInActingVersion(actingVersion uint16) bool { 202 return actingVersion >= c.LengthSinceVersion() 203 } 204 205 func (*CatalogHeader) LengthDeprecated() uint16 { 206 return 0 207 } 208 209 func (*CatalogHeader) LengthMetaAttribute(meta int) string { 210 switch meta { 211 case 1: 212 return "" 213 case 2: 214 return "" 215 case 3: 216 return "" 217 case 4: 218 return "required" 219 } 220 return "" 221 } 222 223 func (*CatalogHeader) LengthMinValue() int32 { 224 return math.MinInt32 + 1 225 } 226 227 func (*CatalogHeader) LengthMaxValue() int32 { 228 return math.MaxInt32 229 } 230 231 func (*CatalogHeader) LengthNullValue() int32 { 232 return math.MinInt32 233 } 234 235 func (*CatalogHeader) NextRecordingIdId() uint16 { 236 return 3 237 } 238 239 func (*CatalogHeader) NextRecordingIdSinceVersion() uint16 { 240 return 0 241 } 242 243 func (c *CatalogHeader) NextRecordingIdInActingVersion(actingVersion uint16) bool { 244 return actingVersion >= c.NextRecordingIdSinceVersion() 245 } 246 247 func (*CatalogHeader) NextRecordingIdDeprecated() uint16 { 248 return 0 249 } 250 251 func (*CatalogHeader) NextRecordingIdMetaAttribute(meta int) string { 252 switch meta { 253 case 1: 254 return "" 255 case 2: 256 return "" 257 case 3: 258 return "" 259 case 4: 260 return "required" 261 } 262 return "" 263 } 264 265 func (*CatalogHeader) NextRecordingIdMinValue() int64 { 266 return math.MinInt64 + 1 267 } 268 269 func (*CatalogHeader) NextRecordingIdMaxValue() int64 { 270 return math.MaxInt64 271 } 272 273 func (*CatalogHeader) NextRecordingIdNullValue() int64 { 274 return math.MinInt64 275 } 276 277 func (*CatalogHeader) AlignmentId() uint16 { 278 return 4 279 } 280 281 func (*CatalogHeader) AlignmentSinceVersion() uint16 { 282 return 0 283 } 284 285 func (c *CatalogHeader) AlignmentInActingVersion(actingVersion uint16) bool { 286 return actingVersion >= c.AlignmentSinceVersion() 287 } 288 289 func (*CatalogHeader) AlignmentDeprecated() uint16 { 290 return 0 291 } 292 293 func (*CatalogHeader) AlignmentMetaAttribute(meta int) string { 294 switch meta { 295 case 1: 296 return "" 297 case 2: 298 return "" 299 case 3: 300 return "" 301 case 4: 302 return "required" 303 } 304 return "" 305 } 306 307 func (*CatalogHeader) AlignmentMinValue() int32 { 308 return math.MinInt32 + 1 309 } 310 311 func (*CatalogHeader) AlignmentMaxValue() int32 { 312 return math.MaxInt32 313 } 314 315 func (*CatalogHeader) AlignmentNullValue() int32 { 316 return math.MinInt32 317 } 318 319 func (*CatalogHeader) ReservedId() uint16 { 320 return 5 321 } 322 323 func (*CatalogHeader) ReservedSinceVersion() uint16 { 324 return 0 325 } 326 327 func (c *CatalogHeader) ReservedInActingVersion(actingVersion uint16) bool { 328 return actingVersion >= c.ReservedSinceVersion() 329 } 330 331 func (*CatalogHeader) ReservedDeprecated() uint16 { 332 return 0 333 } 334 335 func (*CatalogHeader) ReservedMetaAttribute(meta int) string { 336 switch meta { 337 case 1: 338 return "" 339 case 2: 340 return "" 341 case 3: 342 return "" 343 case 4: 344 return "required" 345 } 346 return "" 347 } 348 349 func (*CatalogHeader) ReservedMinValue() int8 { 350 return math.MinInt8 + 1 351 } 352 353 func (*CatalogHeader) ReservedMaxValue() int8 { 354 return math.MaxInt8 355 } 356 357 func (*CatalogHeader) ReservedNullValue() int8 { 358 return math.MinInt8 359 }