Files
dolt/types/string.go
Erik Arvidsson 16353f38f8 NomDL: Make the new serialization default
This makes the new typed serialization the default (the old
serialization is not used but the code has not been cleaned up yet).

Some things are no working in the new world:

Chunking -  The compound list is not working correctly any more. The
Chunks method is having issues because it assumed things based on the
old implicit chunking.

Commit - uses a `Set(Commit)` which means that the parent commit is
embedded. We need to change that to be `Set(Ref(Commit))` so that the
parent commit is referenced instead.
2015-10-21 19:04:22 -04:00

50 lines
758 B
Go

package types
import (
"bytes"
"github.com/attic-labs/noms/ref"
)
type String struct {
s string
ref *ref.Ref
}
func NewString(s string) String {
return String{s, &ref.Ref{}}
}
func (fs String) Blob() (Blob, error) {
return NewBlob(bytes.NewBufferString(fs.s))
}
func (fs String) String() string {
return fs.s
}
func (fs String) Ref() ref.Ref {
return EnsureRef(fs.ref, fs)
}
func (s String) Equals(other Value) bool {
if other, ok := other.(String); ok {
return s.Ref() == other.Ref()
}
return false
}
func (fs String) Chunks() []Future {
return nil
}
var typeRefForString = MakePrimitiveTypeRef(StringKind)
func (fs String) TypeRef() TypeRef {
return typeRefForString
}
func StringFromVal(v Value) String {
return v.(String)
}