//------------------------------------------------------------------------------------
// irr::core::stringw wrappers
//
// PROBLEM: append from string is modified
//------------------------------------------------------------------------------------

extern "C" 
{

	stringw* IrrCore_StringW_new()
	{
		return new stringw();
	}
	
	stringw* IrrCore_StringW_newFromStringW(stringw* other)
	{
		return new stringw(*other);
	}
	
	stringw* IrrCore_StringW_newFromInt(int number)
	{
		return new stringw(number);
	}
	
	stringw* IrrCore_StringW_newFromStringPtr(wchar_t* other)
	{
		return new stringw(other);
	}
	
	stringw* IrrCore_StringW_newFromStringPtrWithLength(wchar_t* other,s32 length)
	{
		return new stringw(other,length);
	}
	
	void IrrCore_StringW_del(stringw* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	s32 IrrCore_StringW_size(stringw* string)
	{
		s32 retval=0;
		
		if (string)
			retval=string->size();
		
		return retval;
	}
	 
	const wchar_t* IrrCore_StringW_c_str(stringw* string)
	{	
		if (string)
			return string->c_str();
		else
			return L"";
	}
	
	void IrrCore_StringW_make_lower(stringw* string)
	{
		if (string)
			string->make_lower();
	}
	
	void IrrCore_StringW_make_upper(stringw* string)
	{
		if (string)
			string->make_upper();
	}
	
	bool IrrCore_StringW_equals_ignore_case(stringw* string,stringw* other)
	{
		bool lRetVal=false;
		if (string)
			lRetVal=string->equals_ignore_case(*other);
		
		return lRetVal;
	}
	
	bool IrrCore_StringW_equalsnStringW(stringw* string,stringw* other,s32 len)
	{
		bool lRetVal=false;
		if (string)
			lRetVal=string->equalsn(*other,len);
		
		return lRetVal;
	}
	
	bool IrrCore_StringW_equalsn(stringw* string,const wchar_t* other,s32 len)
	{
		bool lRetVal=false;
		if (string)
			lRetVal=string->equalsn(other,len);
		
		return lRetVal;
	}
	
	void IrrCore_StringW_appendChar(stringw* string,wchar_t chr)
	{
		if (string)
			string->append(chr);
	}
	
	void IrrCore_StringW_appendStringW(stringw* string,stringw* other)
	{
		if (string)
			string->append(*other);
	}
	
	void IrrCore_StringW_appendStringWWithLength(stringw* string,stringw* other,s32 length)
	{
		// think there is a bug in IrrCore_ with this version of the method.
		// manually doing the length conversion.
		if (string) {
			length=(other->size()<=length,length,other->size());
			string->append(other->subString(0,length));
		}
		//string->append(*other,length);
	}
	
	void IrrCore_StringW_reserve(stringw* string,s32 count)
	{
		if (string)
			string->reserve(count);
	}
	
	s32 IrrCore_StringW_findFirst(stringw* string,wchar_t chr)
	{
		s32 retval=-1;
		
		if (string)
			string->findFirst(chr);
			
		return retval;
	}
	
	s32 IrrCore_StringW_findNext(stringw* string,wchar_t chr,s32 startpos)
	{
		s32 retval=-1;
		
		if (string)
			string->findNext(chr,startpos);
			
		return retval;
	}
	
	s32 IrrCore_StringW_findLast(stringw* string,wchar_t chr)
	{
		s32 retval=-1;
		
		if (string)
			string->findLast(chr);
			
		return retval;
	}
	
	s32 IrrCore_StringW_find(stringw* string,wchar_t* str)
	{
		if (string)
			return string->find(str);
		else return -1;
	}
		
	stringw* IrrCore_StringW_subString(stringw* string,s32 begin,s32 length)
	{
		stringw* retval=0;
		
		if (string)
			retval=new stringw(string->subString(begin,length));
			
		return retval;
	}
	
	void IrrCore_StringW_Eq(stringw* string,stringw* other)
	{
		if (string)
			*string=*other;
	}
	
	void IrrCore_StringW_EqStringPtr(stringw* string,wchar_t* other)
	{
		if (string)
			*string=other;
	}
	
	stringw* IrrCore_StringW_PlusStringPtr(stringw* string,wchar_t* other)
	{
		stringw* retval=0;
		if (string)
			retval=new stringw(*string + other);
			
		return retval;
	}
	
	stringw* IrrCore_StringW_Plus(stringw* string,stringw* other)
	{
		stringw* retval=0;
		if (string)
			retval=new stringw(*string + *other);
			
		return retval;
	}
	
	wchar_t IrrCore_StringW_idx(stringw* string,s32 idx)
	{
		if (string)
			return (*string)[idx];
		else
			return stringw("")[0];
	}
	
	bool IrrCore_StringW_EqEqStringW(stringw* string,stringw* other)
	{
		bool retval=false;
		
		if (string)
			return (*string==*other);
		
		return retval;
	}
	
	bool IrrCore_StringW_EqEq(stringw* string,const wchar_t* other)
	{
		bool retval=false;
		
		if (string)
			return (*string==other);
		
		return retval;
	}
	
	bool IrrCore_StringW_Less(stringw* string,stringw* other)
	{
		bool retval=false;
		
		if (string)
			return (*string<*other);
		
		return retval;
	}
	
	bool IrrCore_StringW_NotEq(stringw* string,stringw* other)
	{
		bool retval=true;
		
		if (string)
			return (*string!=*other);
		
		return retval;
	}
	
	void IrrCore_StringW_PlusEqChar(stringw* string,wchar_t chr)
	{
		if (string)
			*string+=chr;
	}
	
	void IrrCore_StringW_PlusEqString(stringw* string,stringw* other)
	{
		if (string)
			*string+=*other;
	}
	
	void IrrCore_StringW_PlusEqInt(stringw* string,s32 i)
	{
		if (string)
			*string+=i;
	}
	
	void IrrCore_StringW_PlusEqcharString(stringw* string,const wchar_t* other)
	{
		if (string)
			*string+=other;
	}
	
	void IrrCore_StringW_PlusEqDouble(stringw* string,double i)
	{
		if (string)
			*string+=i;
	}
	
	void IrrCore_StringW_appendCharString(stringw* string,const wchar_t* other)
	{
		if (string)
			string->append(other);	
	}

}	

