MCPcopy
hub / github.com/uber/aresdb / AppendBool

Method AppendBool

utils/serialization.go:159–176  ·  view source on GitHub ↗

AppendBool append a boolean value to buffer and advances byte/bit offset.

(value bool)

Source from the content-addressed store, hash-verified

157
158// AppendBool append a boolean value to buffer and advances byte/bit offset.
159func (b *BufferWriter) AppendBool(value bool) error {
160 if b.offset >= len(b.buffer) {
161 return StackError(nil, "Failed to write bool to buffer at offset (%d,%d)", b.offset, b.bitOffset)
162 }
163 // Need to advance to the next byte.
164 if value {
165 b.buffer[b.offset] |= 0x1 << uint8(b.bitOffset)
166 } else {
167 b.buffer[b.offset] &^= 0x1 << uint8(b.bitOffset)
168 }
169 if b.bitOffset == 7 {
170 b.offset++
171 b.bitOffset = 0
172 } else {
173 b.bitOffset++
174 }
175 return nil
176}
177
178// AppendInt8 writes a int8 value to buffer and advances offset.
179func (b *BufferWriter) AppendInt8(value int8) error {

Callers 3

AppendToBufferMethod · 0.95
WriteMethod · 0.80

Calls 1

StackErrorFunction · 0.85

Tested by

no test coverage detected