byteio - memlittleendian.go
1 package byteio
2
3 // File automatically generated with ./gen.sh.
4
5 import (
6 "io"
7 "math"
8 )
9
10 // MemLittleEndian is a byte slice that has methods to make it easier to read and write fundamental types.
11 type MemLittleEndian []byte
12
13 // ReadBool Reads a boolean.
14 func (e *MemLittleEndian) ReadBool() bool {
15 return e.ReadUint8() != 0
16 }
17
18 // ReadInt8 Reads a 8 bit int as a int8 from the byte slice.
19 func (e *MemLittleEndian) ReadInt8() int8 {
20 if len(*e) < 1 {
21 return 0
22 }
23
24 d := (*e)[0]
25 *e = (*e)[1:]
26
27 return int8(d)
28 }
29
30 // ReadInt16 Reads a 16 bit int as a int16 from the byte slice.
31 func (e *MemLittleEndian) ReadInt16() int16 {
32 if len(*e) < 2 {
33 return 0
34 }
35
36 d := uint16((*e)[0]) | uint16((*e)[1])<<8
37 *e = (*e)[2:]
38
39 return int16(d)
40 }
41
42 // ReadInt24 Reads a 24 bit int as a int32 from the byte slice.
43 func (e *MemLittleEndian) ReadInt24() int32 {
44 if len(*e) < 3 {
45 return 0
46 }
47
48 d := uint32((*e)[0]) | uint32((*e)[1])<<8 | uint32((*e)[2])<<16
49
50 if d >= 0x00800000 {
51 d |= 0xff000000
52 }
53
54 *e = (*e)[3:]
55
56 return int32(d)
57 }
58
59 // ReadInt32 Reads a 32 bit int as a int32 from the byte slice.
60 func (e *MemLittleEndian) ReadInt32() int32 {
61 if len(*e) < 4 {
62 return 0
63 }
64
65 d := uint32((*e)[0]) | uint32((*e)[1])<<8 | uint32((*e)[2])<<16 | uint32((*e)[3])<<24
66 *e = (*e)[4:]
67
68 return int32(d)
69 }
70
71 // ReadInt40 Reads a 40 bit int as a int64 from the byte slice.
72 func (e *MemLittleEndian) ReadInt40() int64 {
73 if len(*e) < 5 {
74 return 0
75 }
76
77 d := uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32
78
79 if d >= 0x0000008000000000 {
80 d |= 0xffffff0000000000
81 }
82
83 *e = (*e)[5:]
84
85 return int64(d)
86 }
87
88 // ReadInt48 Reads a 48 bit int as a int64 from the byte slice.
89 func (e *MemLittleEndian) ReadInt48() int64 {
90 if len(*e) < 6 {
91 return 0
92 }
93
94 d := uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32 | uint64((*e)[5])<<40
95
96 if d >= 0x0000800000000000 {
97 d |= 0xffff000000000000
98 }
99
100 *e = (*e)[6:]
101
102 return int64(d)
103 }
104
105 // ReadInt56 Reads a 56 bit int as a int64 from the byte slice.
106 func (e *MemLittleEndian) ReadInt56() int64 {
107 if len(*e) < 7 {
108 return 0
109 }
110
111 d := uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32 | uint64((*e)[5])<<40 | uint64((*e)[6])<<48
112
113 if d >= 0x0080000000000000 {
114 d |= 0xff00000000000000
115 }
116
117 *e = (*e)[7:]
118
119 return int64(d)
120 }
121
122 // ReadInt64 Reads a 64 bit int as a int64 from the byte slice.
123 func (e *MemLittleEndian) ReadInt64() int64 {
124 if len(*e) < 8 {
125 return 0
126 }
127
128 d := uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32 | uint64((*e)[5])<<40 | uint64((*e)[6])<<48 | uint64((*e)[7])<<56
129 *e = (*e)[8:]
130
131 return int64(d)
132 }
133
134 // ReadUint8 Reads a 8 bit uint as a uint8 from the byte slice.
135 func (e *MemLittleEndian) ReadUint8() uint8 {
136 if len(*e) < 1 {
137 return 0
138 }
139
140 d := (*e)[0]
141 *e = (*e)[1:]
142
143 return d
144 }
145
146 // ReadUint16 Reads a 16 bit uint as a uint16 from the byte slice.
147 func (e *MemLittleEndian) ReadUint16() uint16 {
148 if len(*e) < 2 {
149 return 0
150 }
151
152 d := uint16((*e)[0]) | uint16((*e)[1])<<8
153 *e = (*e)[2:]
154
155 return d
156 }
157
158 // ReadUint24 Reads a 24 bit uint as a uint32 from the byte slice.
159 func (e *MemLittleEndian) ReadUint24() uint32 {
160 if len(*e) < 3 {
161 return 0
162 }
163
164 d := uint32((*e)[0]) | uint32((*e)[1])<<8 | uint32((*e)[2])<<16
165 *e = (*e)[3:]
166
167 return d
168 }
169
170 // ReadUint32 Reads a 32 bit uint as a uint32 from the byte slice.
171 func (e *MemLittleEndian) ReadUint32() uint32 {
172 if len(*e) < 4 {
173 return 0
174 }
175
176 d := uint32((*e)[0]) | uint32((*e)[1])<<8 | uint32((*e)[2])<<16 | uint32((*e)[3])<<24
177 *e = (*e)[4:]
178
179 return d
180 }
181
182 // ReadUint40 Reads a 40 bit uint as a uint64 from the byte slice.
183 func (e *MemLittleEndian) ReadUint40() uint64 {
184 if len(*e) < 5 {
185 return 0
186 }
187
188 d := uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32
189 *e = (*e)[5:]
190
191 return d
192 }
193
194 // ReadUint48 Reads a 48 bit uint as a uint64 from the byte slice.
195 func (e *MemLittleEndian) ReadUint48() uint64 {
196 if len(*e) < 6 {
197 return 0
198 }
199
200 d := uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32 | uint64((*e)[5])<<40
201 *e = (*e)[6:]
202
203 return d
204 }
205
206 // ReadUint56 Reads a 56 bit uint as a uint64 from the byte slice.
207 func (e *MemLittleEndian) ReadUint56() uint64 {
208 if len(*e) < 7 {
209 return 0
210 }
211
212 d := uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32 | uint64((*e)[5])<<40 | uint64((*e)[6])<<48
213 *e = (*e)[7:]
214
215 return d
216 }
217
218 // ReadUint64 Reads a 64 bit uint as a uint64 from the byte slice.
219 func (e *MemLittleEndian) ReadUint64() uint64 {
220 if len(*e) < 8 {
221 return 0
222 }
223
224 d := uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32 | uint64((*e)[5])<<40 | uint64((*e)[6])<<48 | uint64((*e)[7])<<56
225 *e = (*e)[8:]
226
227 return d
228 }
229
230 // ReadFloat32 Reads a 32 bit float as a float32 from the byte slice.
231 func (e *MemLittleEndian) ReadFloat32() float32 {
232 if len(*e) < 4 {
233 return 0
234 }
235
236 d := math.Float32frombits(uint32((*e)[0]) | uint32((*e)[1])<<8 | uint32((*e)[2])<<16 | uint32((*e)[3])<<24)
237 *e = (*e)[4:]
238
239 return d
240 }
241
242 // ReadFloat64 Reads a 64 bit float as a float64 from the byte slice.
243 func (e *MemLittleEndian) ReadFloat64() float64 {
244 if len(*e) < 8 {
245 return 0
246 }
247
248 d := math.Float64frombits(uint64((*e)[0]) | uint64((*e)[1])<<8 | uint64((*e)[2])<<16 | uint64((*e)[3])<<24 | uint64((*e)[4])<<32 | uint64((*e)[5])<<40 | uint64((*e)[6])<<48 | uint64((*e)[7])<<56)
249 *e = (*e)[8:]
250
251 return d
252 }
253
254 // ReadBytes Reads a []byte.
255 func (e *MemLittleEndian) ReadBytes(size int) []byte {
256 if len(*e) < size {
257 return nil
258 }
259
260 d := []byte((*e)[:size])
261 *e = (*e)[size:]
262
263 return d
264 }
265
266 // MemLittleEndianReader implements io.Reader.
267 func (e *MemLittleEndian) Read(p []byte) (int, error) {
268 n := copy(p, *e)
269
270 if n == 0 && len(p) != 0 {
271 return 0, io.EOF
272 }
273
274 *e = (*e)[n:]
275
276 return n, nil
277 }
278
279 // ReadBytesX Reads the length of the Bytes, using ReadUintX and then Reads the bytes.
280 func (e *MemLittleEndian) ReadBytesX() []byte {
281 return e.ReadBytes(int(e.ReadUintX()))
282 }
283
284 // ReadBytes8 Reads the length of the Bytes, using ReadUint8 and then Reads the bytes.
285 func (e *MemLittleEndian) ReadBytes8() []byte {
286 return e.ReadBytes(int(e.ReadUint8()))
287 }
288
289 // ReadBytes16 Reads the length of the Bytes, using ReadUint16 and then Reads the bytes.
290 func (e *MemLittleEndian) ReadBytes16() []byte {
291 return e.ReadBytes(int(e.ReadUint16()))
292 }
293
294 // ReadBytes24 Reads the length of the Bytes, using ReadUint24 and then Reads the bytes.
295 func (e *MemLittleEndian) ReadBytes24() []byte {
296 return e.ReadBytes(int(e.ReadUint24()))
297 }
298
299 // ReadBytes32 Reads the length of the Bytes, using ReadUint32 and then Reads the bytes.
300 func (e *MemLittleEndian) ReadBytes32() []byte {
301 return e.ReadBytes(int(e.ReadUint32()))
302 }
303
304 // ReadBytes40 Reads the length of the Bytes, using ReadUint40 and then Reads the bytes.
305 func (e *MemLittleEndian) ReadBytes40() []byte {
306 return e.ReadBytes(int(e.ReadUint40()))
307 }
308
309 // ReadBytes48 Reads the length of the Bytes, using ReadUint48 and then Reads the bytes.
310 func (e *MemLittleEndian) ReadBytes48() []byte {
311 return e.ReadBytes(int(e.ReadUint48()))
312 }
313
314 // ReadBytes56 Reads the length of the Bytes, using ReadUint56 and then Reads the bytes.
315 func (e *MemLittleEndian) ReadBytes56() []byte {
316 return e.ReadBytes(int(e.ReadUint56()))
317 }
318
319 // ReadBytes64 Reads the length of the Bytes, using ReadUint64 and then Reads the bytes.
320 func (e *MemLittleEndian) ReadBytes64() []byte {
321 return e.ReadBytes(int(e.ReadUint64()))
322 }
323
324 // ReadString Reads a string.
325 func (e *MemLittleEndian) ReadString(size int) string {
326 if len(*e) < size {
327 return ""
328 }
329
330 d := string((*e)[:size])
331 *e = (*e)[size:]
332
333 return d
334 }
335
336 // ReadStringX Reads the length of the String, using ReadUintX and then Reads the bytes.
337 func (e *MemLittleEndian) ReadStringX() string {
338 return e.ReadString(int(e.ReadUintX()))
339 }
340
341 // ReadString8 Reads the length of the String, using ReadUint8 and then Reads the bytes.
342 func (e *MemLittleEndian) ReadString8() string {
343 return e.ReadString(int(e.ReadUint8()))
344 }
345
346 // ReadString16 Reads the length of the String, using ReadUint16 and then Reads the bytes.
347 func (e *MemLittleEndian) ReadString16() string {
348 return e.ReadString(int(e.ReadUint16()))
349 }
350
351 // ReadString24 Reads the length of the String, using ReadUint24 and then Reads the bytes.
352 func (e *MemLittleEndian) ReadString24() string {
353 return e.ReadString(int(e.ReadUint24()))
354 }
355
356 // ReadString32 Reads the length of the String, using ReadUint32 and then Reads the bytes.
357 func (e *MemLittleEndian) ReadString32() string {
358 return e.ReadString(int(e.ReadUint32()))
359 }
360
361 // ReadString40 Reads the length of the String, using ReadUint40 and then Reads the bytes.
362 func (e *MemLittleEndian) ReadString40() string {
363 return e.ReadString(int(e.ReadUint40()))
364 }
365
366 // ReadString48 Reads the length of the String, using ReadUint48 and then Reads the bytes.
367 func (e *MemLittleEndian) ReadString48() string {
368 return e.ReadString(int(e.ReadUint48()))
369 }
370
371 // ReadString56 Reads the length of the String, using ReadUint56 and then Reads the bytes.
372 func (e *MemLittleEndian) ReadString56() string {
373 return e.ReadString(int(e.ReadUint56()))
374 }
375
376 // ReadString64 Reads the length of the String, using ReadUint64 and then Reads the bytes.
377 func (e *MemLittleEndian) ReadString64() string {
378 return e.ReadString(int(e.ReadUint64()))
379 }
380
381 // ReadString0 Reads the bytes of the string until a 0 byte is read.
382 func (e *MemLittleEndian) ReadString0() string {
383 var d string
384
385 for n, c := range *e {
386 if c == 0 {
387 d = string((*e)[:n])
388 *e = (*e)[n+1:]
389
390 break
391 }
392 }
393
394 return d
395 }
396
397 // WriteBool Writes a boolean.
398 func (e *MemLittleEndian) WriteBool(b bool) {
399 if b {
400 e.WriteUint8(1)
401 } else {
402 e.WriteUint8(0)
403 }
404 }
405
406 // WriteInt8 Writes a 8 bit int as a int8 to the byte slice.
407 func (e *MemLittleEndian) WriteInt8(d int8) {
408 c := uint8(d)
409 *e = append(*e,
410 byte(c),
411 )
412 }
413
414 // WriteInt16 Writes a 16 bit int as a int16 to the byte slice.
415 func (e *MemLittleEndian) WriteInt16(d int16) {
416 c := uint16(d)
417 *e = append(*e,
418 byte(c),
419 byte(c>>8),
420 )
421 }
422
423 // WriteInt24 Writes a 24 bit int as a int32 to the byte slice.
424 func (e *MemLittleEndian) WriteInt24(d int32) {
425 c := uint32(d)
426 *e = append(*e,
427 byte(c),
428 byte(c>>8),
429 byte(c>>16),
430 )
431 }
432
433 // WriteInt32 Writes a 32 bit int as a int32 to the byte slice.
434 func (e *MemLittleEndian) WriteInt32(d int32) {
435 c := uint32(d)
436 *e = append(*e,
437 byte(c),
438 byte(c>>8),
439 byte(c>>16),
440 byte(c>>24),
441 )
442 }
443
444 // WriteInt40 Writes a 40 bit int as a int64 to the byte slice.
445 func (e *MemLittleEndian) WriteInt40(d int64) {
446 c := uint64(d)
447 *e = append(*e,
448 byte(c),
449 byte(c>>8),
450 byte(c>>16),
451 byte(c>>24),
452 byte(c>>32),
453 )
454 }
455
456 // WriteInt48 Writes a 48 bit int as a int64 to the byte slice.
457 func (e *MemLittleEndian) WriteInt48(d int64) {
458 c := uint64(d)
459 *e = append(*e,
460 byte(c),
461 byte(c>>8),
462 byte(c>>16),
463 byte(c>>24),
464 byte(c>>32),
465 byte(c>>40),
466 )
467 }
468
469 // WriteInt56 Writes a 56 bit int as a int64 to the byte slice.
470 func (e *MemLittleEndian) WriteInt56(d int64) {
471 c := uint64(d)
472 *e = append(*e,
473 byte(c),
474 byte(c>>8),
475 byte(c>>16),
476 byte(c>>24),
477 byte(c>>32),
478 byte(c>>40),
479 byte(c>>48),
480 )
481 }
482
483 // WriteInt64 Writes a 64 bit int as a int64 to the byte slice.
484 func (e *MemLittleEndian) WriteInt64(d int64) {
485 c := uint64(d)
486 *e = append(*e,
487 byte(c),
488 byte(c>>8),
489 byte(c>>16),
490 byte(c>>24),
491 byte(c>>32),
492 byte(c>>40),
493 byte(c>>48),
494 byte(c>>56),
495 )
496 }
497
498 // WriteUint8 Writes a 8 bit uint as a uint8 to the byte slice.
499 func (e *MemLittleEndian) WriteUint8(d uint8) {
500 *e = append(*e,
501 byte(d),
502 )
503 }
504
505 // WriteUint16 Writes a 16 bit uint as a uint16 to the byte slice.
506 func (e *MemLittleEndian) WriteUint16(d uint16) {
507 *e = append(*e,
508 byte(d),
509 byte(d>>8),
510 )
511 }
512
513 // WriteUint24 Writes a 24 bit uint as a uint32 to the byte slice.
514 func (e *MemLittleEndian) WriteUint24(d uint32) {
515 *e = append(*e,
516 byte(d),
517 byte(d>>8),
518 byte(d>>16),
519 )
520 }
521
522 // WriteUint32 Writes a 32 bit uint as a uint32 to the byte slice.
523 func (e *MemLittleEndian) WriteUint32(d uint32) {
524 *e = append(*e,
525 byte(d),
526 byte(d>>8),
527 byte(d>>16),
528 byte(d>>24),
529 )
530 }
531
532 // WriteUint40 Writes a 40 bit uint as a uint64 to the byte slice.
533 func (e *MemLittleEndian) WriteUint40(d uint64) {
534 *e = append(*e,
535 byte(d),
536 byte(d>>8),
537 byte(d>>16),
538 byte(d>>24),
539 byte(d>>32),
540 )
541 }
542
543 // WriteUint48 Writes a 48 bit uint as a uint64 to the byte slice.
544 func (e *MemLittleEndian) WriteUint48(d uint64) {
545 *e = append(*e,
546 byte(d),
547 byte(d>>8),
548 byte(d>>16),
549 byte(d>>24),
550 byte(d>>32),
551 byte(d>>40),
552 )
553 }
554
555 // WriteUint56 Writes a 56 bit uint as a uint64 to the byte slice.
556 func (e *MemLittleEndian) WriteUint56(d uint64) {
557 *e = append(*e,
558 byte(d),
559 byte(d>>8),
560 byte(d>>16),
561 byte(d>>24),
562 byte(d>>32),
563 byte(d>>40),
564 byte(d>>48),
565 )
566 }
567
568 // WriteUint64 Writes a 64 bit uint as a uint64 to the byte slice.
569 func (e *MemLittleEndian) WriteUint64(d uint64) {
570 *e = append(*e,
571 byte(d),
572 byte(d>>8),
573 byte(d>>16),
574 byte(d>>24),
575 byte(d>>32),
576 byte(d>>40),
577 byte(d>>48),
578 byte(d>>56),
579 )
580 }
581
582 // WriteFloat32 Writes a 32 bit float as a float32 to the byte slice.
583 func (e *MemLittleEndian) WriteFloat32(d float32) {
584 c := math.Float32bits(d)
585 *e = append(*e,
586 byte(c),
587 byte(c>>8),
588 byte(c>>16),
589 byte(c>>24),
590 )
591 }
592
593 // WriteFloat64 Writes a 64 bit float as a float64 to the byte slice.
594 func (e *MemLittleEndian) WriteFloat64(d float64) {
595 c := math.Float64bits(d)
596 *e = append(*e,
597 byte(c),
598 byte(c>>8),
599 byte(c>>16),
600 byte(c>>24),
601 byte(c>>32),
602 byte(c>>40),
603 byte(c>>48),
604 byte(c>>56),
605 )
606 }
607
608 // WriteBytes Writes a []byte.
609 func (e *MemLittleEndian) WriteBytes(d []byte) {
610 *e = append(*e, d...)
611 }
612
613 // MemLittleEndianWriter implements io.Writer.
614 func (e *MemLittleEndian) Write(p []byte) (int, error) {
615 *e = append(*e, p...)
616
617 return len(p), nil
618 }
619
620 // WriteBytesX Writes the length of the Bytes, using WriteUintX and then Writes the bytes.
621 func (e *MemLittleEndian) WriteBytesX(p []byte) {
622 e.WriteUintX(uint64(len(p)))
623 e.WriteBytes(p)
624 }
625
626 // WriteBytes8 Writes the length of the Bytes, using WriteUint8 and then Writes the bytes.
627 func (e *MemLittleEndian) WriteBytes8(p []byte) {
628 e.WriteUint8(uint8(len(p)))
629 e.WriteBytes(p)
630 }
631
632 // WriteBytes16 Writes the length of the Bytes, using WriteUint16 and then Writes the bytes.
633 func (e *MemLittleEndian) WriteBytes16(p []byte) {
634 e.WriteUint16(uint16(len(p)))
635 e.WriteBytes(p)
636 }
637
638 // WriteBytes24 Writes the length of the Bytes, using WriteUint24 and then Writes the bytes.
639 func (e *MemLittleEndian) WriteBytes24(p []byte) {
640 e.WriteUint24(uint32(len(p)))
641 e.WriteBytes(p)
642 }
643
644 // WriteBytes32 Writes the length of the Bytes, using WriteUint32 and then Writes the bytes.
645 func (e *MemLittleEndian) WriteBytes32(p []byte) {
646 e.WriteUint32(uint32(len(p)))
647 e.WriteBytes(p)
648 }
649
650 // WriteBytes40 Writes the length of the Bytes, using WriteUint40 and then Writes the bytes.
651 func (e *MemLittleEndian) WriteBytes40(p []byte) {
652 e.WriteUint40(uint64(len(p)))
653 e.WriteBytes(p)
654 }
655
656 // WriteBytes48 Writes the length of the Bytes, using WriteUint48 and then Writes the bytes.
657 func (e *MemLittleEndian) WriteBytes48(p []byte) {
658 e.WriteUint48(uint64(len(p)))
659 e.WriteBytes(p)
660 }
661
662 // WriteBytes56 Writes the length of the Bytes, using WriteUint56 and then Writes the bytes.
663 func (e *MemLittleEndian) WriteBytes56(p []byte) {
664 e.WriteUint56(uint64(len(p)))
665 e.WriteBytes(p)
666 }
667
668 // WriteBytes64 Writes the length of the Bytes, using WriteUint64 and then Writes the bytes.
669 func (e *MemLittleEndian) WriteBytes64(p []byte) {
670 e.WriteUint64(uint64(len(p)))
671 e.WriteBytes(p)
672 }
673
674 // WriteString Writes a string.
675 func (e *MemLittleEndian) WriteString(d string) (int, error) {
676 *e = append(*e, d...)
677
678 return len(d), nil
679 }
680
681 // WriteStringX Writes the length of the String, using WriteUintX and then Writes the bytes.
682 func (e *MemLittleEndian) WriteStringX(p string) {
683 e.WriteUintX(uint64(len(p)))
684 e.WriteString(p)
685 }
686
687 // WriteString8 Writes the length of the String, using WriteUint8 and then Writes the bytes.
688 func (e *MemLittleEndian) WriteString8(p string) {
689 e.WriteUint8(uint8(len(p)))
690 e.WriteString(p)
691 }
692
693 // WriteString16 Writes the length of the String, using WriteUint16 and then Writes the bytes.
694 func (e *MemLittleEndian) WriteString16(p string) {
695 e.WriteUint16(uint16(len(p)))
696 e.WriteString(p)
697 }
698
699 // WriteString24 Writes the length of the String, using WriteUint24 and then Writes the bytes.
700 func (e *MemLittleEndian) WriteString24(p string) {
701 e.WriteUint24(uint32(len(p)))
702 e.WriteString(p)
703 }
704
705 // WriteString32 Writes the length of the String, using WriteUint32 and then Writes the bytes.
706 func (e *MemLittleEndian) WriteString32(p string) {
707 e.WriteUint32(uint32(len(p)))
708 e.WriteString(p)
709 }
710
711 // WriteString40 Writes the length of the String, using WriteUint40 and then Writes the bytes.
712 func (e *MemLittleEndian) WriteString40(p string) {
713 e.WriteUint40(uint64(len(p)))
714 e.WriteString(p)
715 }
716
717 // WriteString48 Writes the length of the String, using WriteUint48 and then Writes the bytes.
718 func (e *MemLittleEndian) WriteString48(p string) {
719 e.WriteUint48(uint64(len(p)))
720 e.WriteString(p)
721 }
722
723 // WriteString56 Writes the length of the String, using WriteUint56 and then Writes the bytes.
724 func (e *MemLittleEndian) WriteString56(p string) {
725 e.WriteUint56(uint64(len(p)))
726 e.WriteString(p)
727 }
728
729 // WriteString64 Writes the length of the String, using WriteUint64 and then Writes the bytes.
730 func (e *MemLittleEndian) WriteString64(p string) {
731 e.WriteUint64(uint64(len(p)))
732 e.WriteString(p)
733 }
734
735 // WriteString0 Writes the bytes of the string ending with a 0 byte.
736 func (e *MemLittleEndian) WriteString0(p string) {
737 e.WriteString(p)
738 e.WriteUint8(0)
739 }
740