from whatap.value.value_enum import ValueEnum

class Value(object):
    def __init__(self):
        return

    def __repr__(self):
        to_str = '%s: '%(type(self).__name__)
        for key, value in self.__dict__.items():
            if isinstance(value, unicode):
                to_str += '%s=%s, ' % (key, value.encode('utf8'))
            else:
                to_str += '%s=%s, '%(key, str(value))
        return to_str

    def equals(self, object):
        if isinstance(object, Value):
            return self.value == object.value
        return False

    def getValueType(self):
        return 0

    def toObject(self):
        return self

    def write(self, dout):
        return

    def read(self, din):
        return self

def writeValue(out, val ):
	out.writeByte(val.getValueType())
	val.write(out)
	return out

def readValue(in_ ) :
	t = in_.readByte()
	v = ValueEnum.create(t)
	v.read(in_)
	return v
