//======================================================== // Name : _SetString // Desc : put string of (psz~end) on ps string // Param : trim - will be trim? // Return : //-------------------------------------------------------- // Coder Date Desc // bro 2002-10-29 //======================================================== void _SetString( LPTSTR psz, LPTSTR end, HM::String* ps, bool trim = FALSE, int escape = 0 ) { //trim if( trim ) { while( psz && psz < end && _istspace(*psz) ) psz++; while( (end-1) && psz < (end-1) && _istspace(*(end-1)) ) end--; } int len = end - psz; if( len <= 0 ) return; if( escape ) { len = _tcselen( escape, psz, end ); LPTSTR pss = ps->GetBufferSetLength( len ); _tcsecpy( pss, escape, psz, end ); ps->ReleaseBuffer(); } else { //varför öka på strängens längd med ett här?! LPTSTR pss = ps->GetBufferSetLength( (len + 1) * sizeof(TCHAR)) ; memcpy( pss, psz, len * sizeof(TCHAR) ); ps->ReleaseBuffer(); } }
//======================================================== // Desc : put std::string of (psz~end) on ps std::string // Param : trim - will be trim? //======================================================== void _Setstring( char* psz, char* end, std::string* ps, bool trim = FALSE, int escape = 0 ) { //trim if( trim ) { while( psz && psz < end && (*psz == ' ' || *psz == 9 ) ) psz++; while( (end-1) && psz < (end-1) && (*(end-1) == ' ' || *(end-1) == 9 ) ) end--; } int len = (int)(end - psz); if( len <= 0 ) return; if( escape ) { len = _tcselen( escape, psz, end ); //char* pss = ps->GetBufferSetLength( len ); //_tcsecpy( pss, escape, psz, end ); ps->assign ( psz , len ); } else { ps->assign ( psz , len ); //char* pss = ps->GetBufferSetLength(len + 1 ); //memcpy( pss, psz, len ); //pss[len] = '\0'; } }