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

extern "C" 
{

	stringc* IrrCore_StringC_new()
	{
		return new stringc();
	}
	
	stringc* IrrCore_StringC_newFromStringC(stringc* other)
	{
		return new stringc(*other);
	}
	
	stringc* IrrCore_StringC_newFromInt(int number)
	{
		return new stringc(number);
	}
	
	stringc* IrrCore_StringC_newFromStringPtr(c8* other)
	{
		return new stringc(other);
	}
	
	stringc* IrrCore_StringC_newFromStringPtrWithLength(c8* other,s32 length)
	{
		return new stringc(other,length);
	}
	
	void IrrCore_StringC_del(stringc* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	s32 IrrCore_StringC_size(stringc* string)
	{
		s32 retval=0;
		
		if (string)
			retval=string->size();
		
		return retval;
	}
	 
	const c8* IrrCore_StringC_c_str(stringc* string)
	{	
		if (string)
			return string->c_str();
		else
			return "";
	}
	
	void IrrCore_StringC_make_lower(stringc* string)
	{
		if (string)
			string->make_lower();
	}
	
	void IrrCore_StringC_make_upper(stringc* string)
	{
		if (string)
			string->make_upper();
	}
	
	bool IrrCore_StringC_equals_ignore_case(stringc* string,stringc* other)
	{
		bool lRetVal=false;
		if (string)
			lRetVal=string->equals_ignore_case(*other);
		
		return lRetVal;
	}
	
	bool IrrCore_StringC_equalsnStringC(stringc* string,stringc* other,s32 len)
	{
		bool lRetVal=false;
		if (string)
			lRetVal=string->equalsn(*other,len);
		
		return lRetVal;
	}
	
	bool IrrCore_StringC_equalsn(stringc* string,const c8* other,s32 len)
	{
		bool lRetVal=false;
		if (string)
			lRetVal=string->equalsn(other,len);
		
		return lRetVal;
	}
	
	void IrrCore_StringC_appendChar(stringc* string,c8 chr)
	{
		if (string)
			string->append(chr);
	}
	
	void IrrCore_StringC_appendStringC(stringc* string,stringc* other)
	{
		if (string)
			string->append(*other);
	}
	
	void IrrCore_StringC_appendStringCWithLength(stringc* string,stringc* 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_StringC_reserve(stringc* string,s32 count)
	{
		if (string)
			string->reserve(count);
	}
	
	s32 IrrCore_StringC_findFirst(stringc* string,c8 chr)
	{
		s32 retval=-1;
		
		if (string)
			string->findFirst(chr);
			
		return retval;
	}
	
	s32 IrrCore_StringC_findNext(stringc* string,c8 chr,s32 startpos)
	{
		s32 retval=-1;
		
		if (string)
			string->findNext(chr,startpos);
			
		return retval;
	}
	
	s32 IrrCore_StringC_findLast(stringc* string,c8 chr)
	{
		s32 retval=-1;
		
		if (string)
			string->findLast(chr);
			
		return retval;
	}
	
	s32 IrrCore_StringC_find(stringc* string,c8* other)
	{
		if (string)
			return string->find(other);
		else return -1;
	}
	
	stringc* IrrCore_StringC_subString(stringc* string,s32 begin,s32 length)
	{
		stringc* retval=0;
		
		if (string)
			retval=new stringc(string->subString(begin,length));
			
		return retval;
	}
	
	void IrrCore_StringC_Eq(stringc* string,stringc* other)
	{
		if (string)
			*string=*other;
	}
	
	void IrrCore_StringC_EqStringPtr(stringc* string,c8* other)
	{
		if (string)
			*string=other;
	}
	
	stringc* IrrCore_StringC_PlusStringPtr(stringc* string,c8* other)
	{
		stringc* retval=0;
		if (string)
			retval=new stringc(*string + other);
			
		return retval;
	}
	
	stringc* IrrCore_StringC_Plus(stringc* string,stringc* other)
	{
		stringc* retval=0;
		if (string)
			retval=new stringc(*string + *other);
			
		return retval;
	}
	
	c8 IrrCore_StringC_idx(stringc* string,s32 idx)
	{
		if (string)
			return (*string)[idx];
		else
			return stringc("")[0];
	}
	
	bool IrrCore_StringC_EqEqStringC(stringc* string,stringc* other)
	{
		bool retval=false;
		
		if (string)
			return (*string==*other);
		
		return retval;
	}
	
	bool IrrCore_StringC_EqEq(stringc* string,const c8* other)
	{
		bool retval=false;
		
		if (string)
			return (*string==other);
		
		return retval;
	}
	
	bool IrrCore_StringC_Less(stringc* string,stringc* other)
	{
		bool retval=false;
		
		if (string)
			return (*string<*other);
		
		return retval;
	}
	
	bool IrrCore_StringC_NotEq(stringc* string,stringc* other)
	{
		bool retval=true;
		
		if (string)
			return (*string!=*other);
		
		return retval;
	}
	
	void IrrCore_StringC_PlusEqChar(stringc* string,c8 chr)
	{
		if (string)
			*string+=chr;
	}
	
	void IrrCore_StringC_PlusEqString(stringc* string,stringc* other)
	{
		if (string)
			*string+=*other;
	}
	
	void IrrCore_StringC_PlusEqInt(stringc* string,s32 i)
	{
		if (string)
			*string+=i;
	}
	
	void IrrCore_StringC_PlusEqcharString(stringc* string,const c8* other)
	{
		if (string)
			*string+=other;
	}
	
	void IrrCore_StringC_PlusEqDouble(stringc* string,double i)
	{
		if (string)
			*string+=i;
	}
	
	void IrrCore_StringC_appendCharString(stringc* string,const c8* other)
	{
		if (string)
			string->append(other);	
	}

}
