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

PString PChannel::ReadString ( PINDEX  len  )  [inherited]

Read len# character into a string from the channel. This function simply uses ReadBlock(), so all remarks pertaining to that function also apply to this one.

String that was read.

Definition at line 374 of file pchannel.cxx.

References PString::Empty(), PChannel::lastReadCount, PChannel::Read(), PChannel::ReadBlock(), and PString::SetSize().

Referenced by PHTTPClient::ReadResponse().

  PString str;

  if (len == P_MAX_INDEX) {
    PINDEX l = 0;
    for (;;) {
      char * p = l + str.GetPointer(l+1000+1);
      if (!Read(p, 1000))
      l += lastReadCount;

    /*Need to put in a null at the end to allow for MSDOS/Win32 text files
      which returns fewer bytes than actually read as it shrinks the data into
      the removed carriage returns, so it actually changes the buffer beyond
      what it indicated. */
    str[l] = '\0';
  else {
    if (!ReadBlock(str.GetPointer(len+1), len))
      return PString::Empty();

  return str;

Generated by  Doxygen 1.6.0   Back to index