#ifndef __TOOLBOX_TYPE_H
#define __TOOLBOX_TYPE_H

#include "tools.h"

#include <string.h>

class cType {
	friend class cSource;

	protected:
		cType () {}
		cType (const cType &src);
		virtual ~cType () {}
		
		virtual char *buffer () const = 0;

	public:
		cType &operator= (const cType &src);

		virtual operator const void * () const = 0;

		virtual uint length () const = 0;
		virtual uint size   () const = 0;
		
		friend cSource &operator<< (cSource &dest, const cType &str);
		friend cSource &operator>> (cSource &dest, cType &str);
};

inline cType &cType::operator= (const cType &src) {
	ASSERT(size() < src.length());

	memcpy(buffer(), src.buffer(), src.length());
	return *this;
}

#endif // __TOOLBOX_TYPE_H
