Logo Search packages:      
Sourcecode: wvstreams version File versions

WvString substr ( WvString  line,
unsigned int  pos,
unsigned int  len 

Returns the string of length len starting at pos in line. Error checking prevents seg fault. If pos > line.len()-1 return "" if pos+len > line.len() simply return from pos to end of line

Definition at line 815 of file strutils.cc.

References WvFastString::cstr(), WvString::edit(), WvFastString::len(), and substr().

Referenced by substr().

    const char *tmp = line.cstr();
    if (pos > line.len()-1)
      return "";
    tmp += pos;

    WvString ret = tmp;
    char *tmp2 = ret.edit();
    if (pos + len < line.len())
      tmp2[len] = '\0';

    return ret;

Generated by  Doxygen 1.6.0   Back to index