/*
Very simple byte wrapper.
*/

module Byte;

import std.string;

class Byte
{
private:
	byte _value;
public:
	const byte MINVALUE = -128;
	const byte MAXVALUE = 127;

	this ( ) {
		_value = 0;
	}

	this (byte bt) {
		_value = bt;
	}

	this (Byte bt) {
		_value = bt.value;
	}

	// Property: Set the value of a Byte object
	byte value (byte bt) {
		return _value = bt;
	}

	// Property (overloaded): Set the value of a Byte object
	byte value (Byte bt) {
		return _value = bt.value;
	}

	// Property: Get the value of a Byte object
	byte value ( ) {
		return _value;
	}

	char[] toString ( ) {
		return std.string.toString (_value);
	}

	// Assign a byte type
	void assign (byte bt) {
		_value = bt;
	}

	// Assign a Byte object
	void assign (Byte bt) {
		_value = bt.value;
	}



	// Overload operator ==
	bit opEquals (byte bt) {
		return _value == bt;
	}

	// Overload operator ==
	bit opEquals (Byte bt) {
		return _value == bt.value;
	}

	// Overload operator + (Byte + Byte)
	Byte opAdd (Byte bt) {
		Byte newbt = new Byte();
		newbt.value = _value + bt.value;
		return newbt;
	}

	// Overload operator + (Byte + byte)
	Byte opAdd (byte bt) {
		Byte newbt = new Byte();
		newbt.value = _value + bt;
		return newbt;
	}

	int opCmp (Byte bt) {
		return (_value - bt.value);
		//return 0;
	}

}

