All pastes #1830200 Raw Edit

qchar

public cpp v1 · immutable
#1830200 ·published 2010-03-09 16:28 UTC
rendered paste body
#pragma once#define NO_NED_NAMESPACE 1#define NO_MALLINFO 1#include "../../../Global_Win/Codes/nedmalloc/nedmalloc.h"//Copyright Mahmoud Al-Qudsi, 2010//A very, very thin wrapper around TCHAR*//Uses a bit less memory than CString, auto-deletes when scope expiresclass qchar{public:	TCHAR *t;private:	void Copy(const TCHAR * str)	{		//NO Deallocation happens here		if(str)		{			//t = new TCHAR[_tcsclen(str)+1];			t = (TCHAR*) nedmalloc((_tcsclen(str) + 1) * sizeof(TCHAR));			_tcscpy(t, str);		}		else		{			t = NULL;		}	}public:	inline ~qchar()	{		if(t)		{			nedfree(t);			t = NULL;		}	} 	inline qchar() 	{ 		t = NULL; 	}	inline qchar(const qchar &str)	{		Copy(str.t);	}	inline qchar(const TCHAR *str)	{		Copy(str);	}	qchar&  operator= (const TCHAR *str)	{		if(t)			nedfree(t);		Copy(str);		return *this;	}	qchar&  operator= (const qchar &str)	{		if(this != &str)		{			if(t)				nedfree(t);			Copy(str.t);		}		return *this;	}};