Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PStringArray PString::Lines (  )  const [inherited]

Split the string into individual lines. The line delimiters may be a carriage return (''), a line feed ('
') or a carriage return and line feed pair ("\r\n"). A line feed and carriage return pair ("\n\r") would yield a blank line. between the characters.

The Tokenise()# function should not be used to split a string into lines as a #"\r\n"# pair consitutes a single line ending. The Tokenise()# function would produce a blank line in between them.

Returns:
string array with a substring for each line in the string.

Definition at line 2178 of file contain.cxx.

References PString::FindOneOf(), PString::GetLength(), PString::IsEmpty(), and PString::operator()().

Referenced by PFTPClient::GetDirectoryNames(), PInternetProtocol::WriteLine(), and PInternetProtocol::WriteResponse().

{
  PStringArray lines;
  
  if (IsEmpty())
    return lines;
    
  PINDEX line = 0;
  PINDEX p1 = 0;
  PINDEX p2;
  while ((p2 = FindOneOf("\r\n", p1)) != P_MAX_INDEX) {
    lines[line++] = operator()(p1, p2-1);
    p1 = p2 + 1;
    if (theArray[p2] == '\r' && theArray[p1] == '\n') // CR LF pair
      p1++;
  }
  if (p1 < GetLength())
    lines[line] = operator()(p1, P_MAX_INDEX);
  return lines;
}


Generated by  Doxygen 1.6.0   Back to index