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

int FSTProcessor::readSAO ( FILE *  input  )  [private]

Read text from stream (SAO version)

Parameters:
input the stream to read
Returns:
the next symbol in the stream

Definition at line 1330 of file fst_processor.cc.

References Buffer< T >::add(), blankqueue, escaped_chars, input_buffer, Buffer< T >::isEmpty(), isEscaped(), Buffer< T >::next(), readFullBlock(), and streamError().

{
  if(!input_buffer.isEmpty())
  {
    return input_buffer.next();
  }

  wchar_t val = static_cast<wchar_t>(fgetwc_unlocked(input));
  if(feof(input))
  {
    return 0;
  }

  if(escaped_chars.find(val) != escaped_chars.end())
  {
    if(val == L'<')
    {
      wstring str = readFullBlock(input, L'<', L'>');
      if(str.substr(0, 9) == L"<![CDATA[")
      {
        while(str.substr(str.size()-3) != L"]]>")
        {
          str.append(readFullBlock(input, L'<', L'>').substr(1));
        }
        blankqueue.push(str);
        input_buffer.add(static_cast<int>(L' '));
        return static_cast<int>(L' ');
      }
      else
      {
        streamError();
      }
    }
    else if (val == L'\\') {
      val = static_cast<wchar_t>(fgetwc_unlocked(input));
      if(isEscaped(val))
      {
        input_buffer.add(val);
        return static_cast<int>(val);
      }
      else
        streamError();
    }
    else
    {
      streamError();
    }                   
  }

  input_buffer.add(val);
  return static_cast<int>(val);
}


Generated by  Doxygen 1.6.0   Back to index