#ifndef __CBOOL_H__
#define __CBOOL_H__

#include "cstring.h"

class V2_CLASS_API CBool
{
private:
	bool m_bBool;
	bool m_bSet;
public:
	CBool() : m_bBool(false), m_bSet(false) {}
	CBool(const bool p_bBool) {
		m_bBool = p_bBool;
		m_bSet = true;
	}
	CBool(const CBool &p_Obj) {
		m_bBool = p_Obj.m_bBool;
		m_bSet = p_Obj.m_bSet;
	}
	~CBool() {
		m_bBool = false;
		m_bSet = false;
	}

	// assign
	CBool &operator=(const CBool &p_Obj) {
		m_bBool = p_Obj.m_bBool;
		m_bSet = p_Obj.m_bSet;
		return *this;
	}
	CBool &operator=(const bool p_bBool) {
		m_bBool = p_bBool;
		m_bSet = true;
		return *this;
	}

	bool IsValid(void) const { return m_bSet; }
	void SetNull(void) { m_bSet = false; m_bBool = false; }

	operator bool () const { return m_bBool; }

	CString Repr(void) const {
		return (m_bSet) ? ((m_bBool) ? CString("<CBool: true>") : CString("<CBool: false>")) : CString("<CBool: unset>");
	}

	// operator ==
	bool operator ==(const CBool &p_Obj) const {
		return (m_bBool == p_Obj.m_bBool) ? true : false;
	}
	bool operator ==(const bool p_bBool) const {
		return (m_bBool == p_bBool) ? true : false;
	}
	friend bool operator ==(const bool p_bBool, const CBool &p_Obj) {
		return (p_bBool == p_Obj.m_bBool) ? true : false;
	}

	// operator !=
	bool operator !=(const CBool &p_Obj) const {
		return (m_bBool != p_Obj.m_bBool) ? true : false;
	}
	bool operator !=(const bool p_bBool) const {
		return (m_bBool != p_bBool) ? true : false;
	}
	friend bool operator !=(const bool p_bBool, const CBool &p_Obj) {
		return (p_bBool != p_Obj.m_bBool) ? true : false;
	}

};

#endif	// __CBOOL_H__

