void TString::IntToStr(int value) { char buf[128]; sprintf(buf,"%d",value); PrepareSpace(strlen(buf)+1); strcpy(data,buf); }
void TString::DoubleToStr(double value) { char buf[128]; sprintf(buf,"%*g",5,value); PrepareSpace(strlen(buf)+1); strcpy(data,buf); }
void TString::sprintf(char* format, ...) { va_list args; char buf[128]; va_start(args,format); vsprintf(buf,format,args); PrepareSpace(strlen(buf)+1); strcpy(data,buf); va_end(args); }
vint MemoryStream::Write(void* _buffer, vint _size) { CHECK_ERROR(block!=0, L"MemoryStream::Write(pos_t)#Stream is closed, cannot perform this operation."); CHECK_ERROR(_size>=0, L"MemoryStream::Write(void*, vint)#Argument size cannot be negative."); PrepareSpace(size+_size); memmove(buffer+position, _buffer, _size); position+=_size; if(size<position) { size=position; } return _size; }
void TString::RFrac(int frompos) { char *keep; if (frompos>Length()-1) return; keep = (char *) xmalloc(size); strcpy(keep,data); PrepareSpace(frompos+1); if (frompos>1) memcpy(data,keep,frompos); data[frompos] = '\0'; free(keep); }
void TString::LFrac(int topos) { int count; char *keep; if (topos<0) return; keep = (char *) xmalloc(size); strcpy(keep,data); count = Length()-topos; PrepareSpace(count); memcpy(data,&keep[topos+1],count); free(keep); }
TString &TString::operator=(char *s) { PrepareSpace(strlen(s)+1); strcpy(data,s); return *this; }
TString &TString::operator+(char *s) { PrepareSpace(Length()+strlen(s)+1); strcat(data,s); return *this; }
TString &TString::operator+(TString &s) { PrepareSpace(Length()+s.Length()+1); strcat(data,s.data); return *this; }
void TString::Copy(TString &source, int from, int count) { PrepareSpace(count+1); memcpy(data,&source.data[from],count); data[count] = '\0'; }
TString &TString::operator=(TString &s) { PrepareSpace(s.size); strcpy(data,s.data); return *this; }