--- a/src/types.cc Wed Jan 08 13:57:10 2014 +0200 +++ b/src/types.cc Wed Jan 08 21:43:46 2014 +0200 @@ -367,205 +367,6 @@ // ============================================================================= // ----------------------------------------------------------------------------- -File::File() -{ - // Make a null file - m_file = null; - m_textstream = null; -} - -File::File (QString path, OpenType rtype) -{ - m_file = null; - m_path = path; - open (path, rtype); -} - -File::File (FILE* fp, OpenType rtype) -{ - m_file = null; - open (fp, rtype); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -File::~File() -{ - if (m_file) - { - m_file->close(); - delete m_file; - - if (m_textstream) - delete m_textstream; - } -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -bool File::open (FILE* fp, OpenType rtype) -{ - return open ("", rtype, fp); -} - -bool File::open (QString path, OpenType rtype, FILE* fp) -{ - close(); - - if (!m_file) - m_file = new QFile; - - m_file->setFileName (path); - - bool result; - - QIODevice::OpenMode mode = - (rtype == Read) ? QIODevice::ReadOnly : - (rtype == Write) ? QIODevice::WriteOnly : QIODevice::Append; - - if (fp) - result = m_file->open (fp, mode); - else - result = m_file->open (mode); - - if (result) - { - m_textstream = new QTextStream (m_file); - m_path = path; - return true; - } - - delete m_file; - m_file = null; - return false; -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -File::iterator File::begin() -{ - return iterator (this); -} - -File::iterator& File::end() -{ - return m_endIterator; -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -void File::write (QString msg) -{ - m_file->write (msg.toUtf8(), msg.length()); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -bool File::readLine (QString& line) -{ - if (!m_textstream || m_textstream->atEnd()) - return false; - - line = m_textstream->readLine(); - return true; -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -bool File::atEnd() const -{ - assert (m_textstream != null); - return m_textstream->atEnd(); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -bool File::isNull() const -{ - return m_file == null; -} - -bool File::operator!() const -{ - return isNull(); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -void File::close() -{ - if (!m_file) - return; - - delete m_file; - m_file = null; - - if (m_textstream) - { - delete m_textstream; - m_textstream = null; - } -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -bool File::flush() -{ - return m_file->flush(); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -File::operator bool() const -{ - return !isNull(); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -void File::rewind() -{ - m_file->seek (0); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -File::iterator::iterator (File* f) : m_file (f) -{ - operator++(); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -void File::iterator::operator++() -{ - m_gotdata = m_file->readLine (m_text); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -QString File::iterator::operator*() -{ - return m_text; -} - -// ============================================================================= -// The prime contestant for the weirdest operator== 2013 award? -// ----------------------------------------------------------------------------- -bool File::iterator::operator== (File::iterator& other) -{ - return (other.m_file == null && !m_gotdata); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -bool File::iterator::operator!= (File::iterator& other) -{ - return !operator== (other); -} - -// ============================================================================= -// ----------------------------------------------------------------------------- LDBoundingBox::LDBoundingBox() { reset();