This commit is contained in:
obscuren
2014-06-30 13:09:04 +02:00
parent 5a86892ecb
commit 8ddd4c4c52
4 changed files with 59 additions and 2 deletions

View File

@ -116,6 +116,8 @@ func (val *Value) Bytes() []byte {
return a
} else if s, ok := val.Val.(byte); ok {
return []byte{s}
} else if s, ok := val.Val.(string); ok {
return []byte(s)
}
return []byte{}
@ -196,6 +198,12 @@ func (val *Value) Encode() []byte {
return Encode(val.Val)
}
// Assume that the data we have is encoded
func (self *Value) Decode() {
v, _ := Decode(self.Bytes(), 0)
self.Val = v
}
func NewValueFromBytes(data []byte) *Value {
if len(data) != 0 {
data, _ := Decode(data, 0)