11// DBF.CPP
2- // Copyright (c) A. Sobolev 1993-2001, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2014, 2015, 2016, 2017
2+ // Copyright (c) A. Sobolev 1993-2001, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2014, 2015, 2016, 2017, 2018
33//
44#include < db.h>
55#pragma hdrstop
@@ -73,9 +73,8 @@ void SLAPI DBFCreateFld::Init(const char * pName, int typ, uint sz, uint prec)
7373//
7474// DbfRecord
7575//
76- SLAPI DbfRecord::DbfRecord (const DbfTable * pTbl)
76+ SLAPI DbfRecord::DbfRecord (const DbfTable * pTbl) : P_Tbl(pTbl)
7777{
78- P_Tbl = pTbl;
7978 P_Buffer = new char [BufSize = P_Tbl->getRecSize ()];
8079 empty ();
8180}
@@ -253,20 +252,9 @@ int SLAPI DbfRecord::put(int fld, double data)
253252 return 0 ;
254253}
255254
256- int SLAPI DbfRecord::put (int fld, float data)
257- {
258- return put (fld, (double )data);
259- }
260-
261- int SLAPI DbfRecord::put (int fld, long data)
262- {
263- return put (fld, (double )data);
264- }
265-
266- int SLAPI DbfRecord::put (int fld, int data)
267- {
268- return put (fld, (double )data);
269- }
255+ int SLAPI DbfRecord::put (int fld, float data) { return put (fld, (double )data); }
256+ int SLAPI DbfRecord::put (int fld, long data) { return put (fld, (double )data); }
257+ int SLAPI DbfRecord::put (int fld, int data) { return put (fld, (double )data); }
270258
271259int SLAPI DbfRecord::put (int fld, const DBFDate * data)
272260{
@@ -477,17 +465,9 @@ int SLAPI DbfTable::releaseBuffer()
477465 return 1 ;
478466}
479467
480- SLAPI DbfTable::DbfTable (const char * pName)
468+ SLAPI DbfTable::DbfTable (const char * pName) : P_Buffer(0 ), Opened(0 ), Mod(0 ), Current(0 ),
469+ P_Flds(0 ), NumFlds(0 ), Stream(0 ), BFirst(0 ), BLast(0 ), P_Name(newStr(pName))
481470{
482- P_Buffer = 0 ;
483- Opened = 0 ;
484- Mod = 0 ;
485- Current = 0 ;
486- P_Name = newStr (pName);
487- P_Flds = 0 ;
488- NumFlds = 0 ;
489- Stream = 0 ;
490- BFirst = BLast = 0 ;
491471 open ();
492472}
493473
@@ -618,10 +598,10 @@ static uint8 CpToLdId(SCodepage cp)
618598 return ldid;
619599}
620600
621- SCodepage SLAPI DbfTable::getCodePage () const
622- {
623- return LdIdToCp ( Head.LdID );
624- }
601+ SCodepage SLAPI DbfTable::getCodePage () const { return LdIdToCp (Head. LdID ); }
602+ ulong SLAPI DbfTable::getNumRecs () const { return Head. NumRecs ; }
603+ size_t SLAPI DbfTable::getRecSize () const { return Head.RecSize ; }
604+ uint SLAPI DbfTable::getNumFields () const { return NumFlds; }
625605
626606int SLAPI DbfTable::create (int aNumFlds, const DBFCreateFld * pFldDescr, SCodepage cp, int infoByte)
627607{
@@ -631,7 +611,7 @@ int SLAPI DbfTable::create(int aNumFlds, const DBFCreateFld * pFldDescr, SCodepa
631611 // @v9.3.5 {
632612 if (!checkdate (cur_dt, 0 ))
633613 cur_dt = encodedate (1 , 1 , 2016 );
634- // } @v9.3.5
614+ // } @v9.3.5
635615 close ();
636616 FILE * f = fopen (P_Name, " wb" );
637617 THROW_S_S (f, SLERR_OPENFAULT, P_Name);
@@ -787,21 +767,6 @@ int FASTCALL DbfTable::getField(uint fldN, DBFF * pField) const
787767 return 0 ;
788768}
789769
790- ulong SLAPI DbfTable::getNumRecs () const
791- {
792- return Head.NumRecs ;
793- }
794-
795- size_t SLAPI DbfTable::getRecSize () const
796- {
797- return Head.RecSize ;
798- }
799-
800- uint SLAPI DbfTable::getNumFields () const
801- {
802- return NumFlds;
803- }
804-
805770int FASTCALL DbfTable::goToRec (ulong recNo)
806771{
807772 if (!Opened || recNo < 1 || recNo > Head.NumRecs )
0 commit comments