Esempio n. 1
0
        /// <summary>
        /// Gets next record. Returns true if end of file reached and there are no more records.
        /// </summary>
        /// <returns>Returns true if end of file reached and there are no more records.</returns>
        public bool NextRecord()
        {
            if (!IsDatabaseOpen)
            {
                throw new Exception("Database isn't open, please open database first !");
            }

            //--- Find next record ---------------------------------------------------//
            long nextRowStartOffset = 0;

            if (m_pCurrentRecord == null)
            {
                nextRowStartOffset = m_RowsStartOffset;
            }
            else
            {
                nextRowStartOffset = m_pCurrentRecord.Pointer + m_RowLength;
            }

            while (true)
            {
                if (m_FileLength > nextRowStartOffset)
                {
                    ReadFromFile(nextRowStartOffset, m_RowDataBuffer, 0, m_RowLength);

                    // We want used row
                    if (m_RowDataBuffer[0] == 'u')
                    {
                        if (m_pCurrentRecord == null)
                        {
                            m_pCurrentRecord = new lsDB_FixedLengthRecord(this,
                                                                          nextRowStartOffset,
                                                                          m_RowDataBuffer);
                        }
                        else
                        {
                            m_pCurrentRecord.ReuseRecord(this, nextRowStartOffset, m_RowDataBuffer);
                        }
                        break;
                    }
                }
                else
                {
                    return(true);
                }

                nextRowStartOffset += m_RowLength;
            }
            //-------------------------------------------------------------------------//

            return(false);
        }
Esempio n. 2
0
 /// <summary>
 /// Closes database file.
 /// </summary>
 public void Close()
 {
     if (m_pDbFile != null)
     {
         m_pDbFile.Close();
         m_pDbFile            = null;
         m_DbFileName         = "";
         m_FileLength         = 0;
         m_FilePosition       = 0;
         m_RowLength          = 0;
         m_ColumnsStartOffset = 0;
         m_RowsStartOffset    = 0;
         m_TableLocked        = false;
         m_RowDataBuffer      = null;
         m_pCurrentRecord     = null;
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Moves to first record.
 /// </summary>
 public void MoveFirstRecord()
 {
     m_pCurrentRecord = null;
     //    NextRecord();
 }
        /// <summary>
        /// Gets next record. Returns true if end of file reached and there are no more records.
        /// </summary>
        /// <returns>Returns true if end of file reached and there are no more records.</returns>
        public bool NextRecord()
        {
            if (!IsDatabaseOpen)
            {
                throw new Exception("Database isn't open, please open database first !");
            }

            //--- Find next record ---------------------------------------------------//
            long nextRowStartOffset = 0;
            if (m_pCurrentRecord == null)
            {
                nextRowStartOffset = m_RowsStartOffset;
            }
            else
            {
                nextRowStartOffset = m_pCurrentRecord.Pointer + m_RowLength;
            }

            while (true)
            {
                if (m_FileLength > nextRowStartOffset)
                {
                    ReadFromFile(nextRowStartOffset, m_RowDataBuffer, 0, m_RowLength);

                    // We want used row
                    if (m_RowDataBuffer[0] == 'u')
                    {
                        if (m_pCurrentRecord == null)
                        {
                            m_pCurrentRecord = new lsDB_FixedLengthRecord(this,
                                                                          nextRowStartOffset,
                                                                          m_RowDataBuffer);
                        }
                        else
                        {
                            m_pCurrentRecord.ReuseRecord(this, nextRowStartOffset, m_RowDataBuffer);
                        }
                        break;
                    }
                }
                else
                {
                    return true;
                }

                nextRowStartOffset += m_RowLength;
            }
            //-------------------------------------------------------------------------//

            return false;
        }
 /// <summary>
 /// Moves to first record.
 /// </summary>
 public void MoveFirstRecord()
 {
     m_pCurrentRecord = null;
     //    NextRecord();
 }
 /// <summary>
 /// Closes database file.
 /// </summary>
 public void Close()
 {
     if (m_pDbFile != null)
     {
         m_pDbFile.Close();
         m_pDbFile = null;
         m_DbFileName = "";
         m_FileLength = 0;
         m_FilePosition = 0;
         m_RowLength = 0;
         m_ColumnsStartOffset = 0;
         m_RowsStartOffset = 0;
         m_TableLocked = false;
         m_RowDataBuffer = null;
         m_pCurrentRecord = null;
     }
 }