leveldb_xdr.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // ************************************************************
  2. // This file is automatically generated by genxdr. Do not edit.
  3. // ************************************************************
  4. package files
  5. import (
  6. "bytes"
  7. "io"
  8. "github.com/calmh/xdr"
  9. )
  10. /*
  11. fileVersion Structure:
  12. 0 1 2 3
  13. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  14. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  15. | |
  16. + version (64 bits) +
  17. | |
  18. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  19. | Length of node |
  20. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  21. / /
  22. \ node (variable length) \
  23. / /
  24. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25. struct fileVersion {
  26. unsigned hyper version;
  27. opaque node<>;
  28. }
  29. */
  30. func (o fileVersion) EncodeXDR(w io.Writer) (int, error) {
  31. var xw = xdr.NewWriter(w)
  32. return o.encodeXDR(xw)
  33. }
  34. func (o fileVersion) MarshalXDR() []byte {
  35. return o.AppendXDR(make([]byte, 0, 128))
  36. }
  37. func (o fileVersion) AppendXDR(bs []byte) []byte {
  38. var aw = xdr.AppendWriter(bs)
  39. var xw = xdr.NewWriter(&aw)
  40. o.encodeXDR(xw)
  41. return []byte(aw)
  42. }
  43. func (o fileVersion) encodeXDR(xw *xdr.Writer) (int, error) {
  44. xw.WriteUint64(o.version)
  45. xw.WriteBytes(o.node)
  46. return xw.Tot(), xw.Error()
  47. }
  48. func (o *fileVersion) DecodeXDR(r io.Reader) error {
  49. xr := xdr.NewReader(r)
  50. return o.decodeXDR(xr)
  51. }
  52. func (o *fileVersion) UnmarshalXDR(bs []byte) error {
  53. var br = bytes.NewReader(bs)
  54. var xr = xdr.NewReader(br)
  55. return o.decodeXDR(xr)
  56. }
  57. func (o *fileVersion) decodeXDR(xr *xdr.Reader) error {
  58. o.version = xr.ReadUint64()
  59. o.node = xr.ReadBytes()
  60. return xr.Error()
  61. }
  62. /*
  63. versionList Structure:
  64. 0 1 2 3
  65. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  66. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  67. | Number of versions |
  68. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  69. / /
  70. \ Zero or more fileVersion Structures \
  71. / /
  72. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  73. struct versionList {
  74. fileVersion versions<>;
  75. }
  76. */
  77. func (o versionList) EncodeXDR(w io.Writer) (int, error) {
  78. var xw = xdr.NewWriter(w)
  79. return o.encodeXDR(xw)
  80. }
  81. func (o versionList) MarshalXDR() []byte {
  82. return o.AppendXDR(make([]byte, 0, 128))
  83. }
  84. func (o versionList) AppendXDR(bs []byte) []byte {
  85. var aw = xdr.AppendWriter(bs)
  86. var xw = xdr.NewWriter(&aw)
  87. o.encodeXDR(xw)
  88. return []byte(aw)
  89. }
  90. func (o versionList) encodeXDR(xw *xdr.Writer) (int, error) {
  91. xw.WriteUint32(uint32(len(o.versions)))
  92. for i := range o.versions {
  93. _, err := o.versions[i].encodeXDR(xw)
  94. if err != nil {
  95. return xw.Tot(), err
  96. }
  97. }
  98. return xw.Tot(), xw.Error()
  99. }
  100. func (o *versionList) DecodeXDR(r io.Reader) error {
  101. xr := xdr.NewReader(r)
  102. return o.decodeXDR(xr)
  103. }
  104. func (o *versionList) UnmarshalXDR(bs []byte) error {
  105. var br = bytes.NewReader(bs)
  106. var xr = xdr.NewReader(br)
  107. return o.decodeXDR(xr)
  108. }
  109. func (o *versionList) decodeXDR(xr *xdr.Reader) error {
  110. _versionsSize := int(xr.ReadUint32())
  111. o.versions = make([]fileVersion, _versionsSize)
  112. for i := range o.versions {
  113. (&o.versions[i]).decodeXDR(xr)
  114. }
  115. return xr.Error()
  116. }