Exemple #1
0
        /***************************************************************
         *    Function: getLine
         *    Description: Returns true on EOF, false otherwise.
         *    Guarantees not to return a blank line, or a line
         *    of zero length.
         **************************************************************/
        public bool getLine
        (
        )
        {
            string lineStr;
            int    elem;

            /* Has EOF already been reached? */
            if (m_eof_reached)
            {
                return(EOF);
            }

            /* Pushback current line? */
            if (m_pushback_line)
            {
                m_pushback_line = false;

                /* Check for empty line. */
                for (elem = 0; elem < m_line_read; ++elem)
                {
                    if (false == CUtility.isspace(m_line[elem]))
                    {
                        break;
                    }
                }

                /* Nonempty? */
                if (elem < m_line_read)
                {
                    m_line_index = 0;
                    return(NOT_EOF);
                }
            }

            while (true)
            {
                if (null == (lineStr = m_input.ReadLine()))
                {
                    m_eof_reached = true;
                    m_line_index  = 0;
                    return(EOF);
                }
                m_line      = (lineStr + "\n").ToCharArray();
                m_line_read = m_line.Length;
                ++m_line_number;

                /* Check for empty lines and discard them. */
                elem = 0;
                while (CUtility.isspace(m_line[elem]))
                {
                    ++elem;
                    if (elem == m_line_read)
                    {
                        break;
                    }
                }

                if (elem < m_line_read)
                {
                    break;
                }
            }

            m_line_index = 0;
            return(NOT_EOF);
        }