Class xbXBase

Chapter Updated 07/15/26


Class xbXBase - Core Level Class

The xbXBase class is the core class that needs to be in every application program. Establish an instance of class xbXBase before any other Xbase calls are made. xbXBase x

xbXBase is derived from base classes xbTblMgr and xbCore.



MethodDescriptionCategory
xbInt16 CloseAllTables()Close all open tables.Table
xbInt16 OpenHighestVersion( const xbString &sTableName, const xbString &sAlias, xbDbf &dbf, int dummy )Open highest version available for sTableName.Table
xbInt16 OpenHighestVersion( const xbString &sTableName, const xbString &sAlias, xbDbf **dbf )Open highest version available for sTableName.Table
xbDbf * Open( const xbString &sTableName, xbInt16 &iRc )Open the highest available version of the dbf file. Defaults to XB_READ_WRITE and XB_MULTI_USER mode.Table
xbDbf * Open( const xbString &sTableName, const xbString &sAlias, xbInt16 iOpenMode, xbInt16 iShareMode, xbInt16 iVersion, xbInt16 &iRc )Open table.Table

void DisableMsgLogging()Disable logging routines.Logging
void EnableMsgLogging ()Enable logging routines.Logging
xbInt16 FlushLog()Flush any queued logfile updates to disk.Logging
const xbString &GetLogDirectory () constGet the current logfile directory.Logging
const xbString &GetLogFileName () constGet the current logfile name.Logging
const xbString &GetLogFqFileName() constGet fully qualified logfile name.Logging
xbBool GetLogStatus () constGet the logging status.Logging
void SetLogDirectory( const xbString &sLogFileDirectory )Set the log directory. Must be done while logging is off.Logging
void SetLogFileName( const xbString &sLogFileName )Set the log file name. Must be done while logging is off.Logging
void SetLogSize( size_t lSize )Set the logfile size. After the size is reached, the log file roll.Logging
xbInt16 WriteLogBytes ( xbUInt32 lCnt, const char *p )Write lCnt bytes pointed to by pointer p to the logfile.Logging
xbInt16 WriteLogMessage( const xbString &sLogMessage, xbInt16 iOutputOpt = 0 )Write a string to the logfile.Logging

xbInt16 xbXBase::CreateFqn( const xbString &sDirIn, const xbString &sNameIn, const xbString &sExtIn, xbString &sFqnOut ) Create fully qualified file name from directory, file name and optional extension. This routine sets the correct separators dependent on OS. Misc
xbInt16 xbXBase::GetCmdLineOpt( xbInt32 lArgc, char **sArgv, xbString &sOptRqst, xbString &sParmOut )
xbXBase::GetCmdLineOpt( xbInt32 lArgc, char **sArgv, const char *sOptRqst, xbString &sParmOut )
Parse command line values seeking given parameter info.Misc
void xbSleep( xbInt32 lMillisecs )Sleep command, used mainly in lock commands for waiting between retries.Misc

xbInt16 ABS( xbDouble dIn, xbDouble &dOut )dBASE ABS function.Expression
xbInt16 ACOS( xbDouble dIn, xbDouble &dOut )dBASE ACOS function.Expression
xbInt16 ALLTRIM( const xbString &sIn, xbString &sOut )dBASE ALLTRIM function.Expression
xbInt16 ASC( const xbString &s, xbDouble &dAscOut )dBASE ASC function.Expression
xbInt16 ASIN( xbDouble dIn, xbDouble &dOut )dBASE ASIN function.Expression
xbInt16 AT( const xbString &sSrchFor, const xbString &sBase, xbDouble &dPos )dBASE AT function.Expression
xbInt16 ATAN( xbDouble dIn, xbDouble &dOut )dBASE ATAN function.Expression
xbInt16 ATN2( xbDouble dSine,xbDouble dCosine, xbDouble &dOut )dBASE ATN2 function.Expression
xbInt16 CDOW( xbDate &dInDate, xbString &sOutDow )dBASE CDOW function.Expression
xbInt16 CEILING( xbDouble dIn, xbDouble &dOut )dBASE CEILING function.Expression
xbInt16 CENTER( const xbString &sIn, xbUInt32 ulNewLen, char cPadChar, xbString &sOut )dBASE CENTER function.Expression
xbInt16 CHR( xbDouble dAsciCd, xbString &sOut )dBASE CHR function.Expression
xbInt16 CMONTH( xbDate &dInDate, xbString &sOutMonth )dBASE CMONTH function.Expression
xbInt16 COS( xbDouble dIn, xbDouble &dOut )dBASE COS function.Expression
xbInt16 CTOD( const xbString &sInDate, xbDate &dOutDate )dBASE CTOD function.Expression
xbInt16 CTODT( const xbString &sInDateTime, xbTimeStamp &dOutTs )dBASE CTODT function.Expression
xbInt16 CTOT( const xbString &sInTime, xbTime &dOutTm )dBASE CTOT function.Expression
xbInt16 DATE( xbDate &dOutDate )dBASE DATE function.Expression
xbInt16 DATETIME( xbTimeStamp &dOutDateTime )dBASE DATETIME function.Expression
xbInt16 DBF( xbDbf * dbf, xbString &sOutDbfName )dBASE DBF function.Expression
xbInt16 DAY( const xbDate &dInDate, xbDouble &dOutDay )dBASE DAY function.Expression
xbInt16 DEL( xbDbf * dbf, xbString &sOut, xbInt16 iRecBufSw = 0 )dBASE DEL function.Expression
xbInt16 DELETED( xbDbf * dbf, xbBool &bOut, xbInt16 iRecBufSw = 0 )dBASE DELETED function.Expression
xbInt16 DESCEND( const xbString &sIn,xbString &sOut )
xbInt16 DESCEND( const xbDate &dInDate, xbDate &dOutDate )
xbInt16 DESCEND( const xbDouble dIn, xbDouble &dsOut )
dBASE DESCEND function.Expression
xbInt16 DOW( const xbDate &sInDate, xbDouble &dDowOut )dBASE DOW function.Expression
xbInt16 DTOR( xbDouble dDegreesIn, xbDouble &dRadiansOut )dBASE DTOR function.Expression
xbInt16 DTODT( xbDate &dtIn, xbTimeStamp &dOutDateTime )dBASE DTODT function.Expression
xbInt16 DTTOD( xbTimeStamp &dTsIn, xbDate &dtOut )dBASE DTTOD function.Expression
xbInt16 DTTOT( xbTimeStamp &dTsIn, xbTime &tmOut )dBASE DTTOT function.Expression
xbInt16 DTOC( xbDate &dInDate, xbString &sOutFmtDate )dBASE DTOC function.Expression
xbInt16 DTOS( xbDate &dInDate, xbString &sOutFmtDate )dBASE DTOS function.Expression
xbInt16 ELAPSED( xbTime &tm1In, xbTime &tm2In, xbDouble &dOutSecs )dBASE ELAPSED function.Expression
xbInt16 EMPTY( xbDbf *dbf, const xbString &sFldName, xbBool &bResult )dBASE EMPTY function.Expression
xbInt16 EXP( xbDouble dIn, xbDouble &dOut )dBASE EXP function.Expression
xbInt16 FCOUNT( xbDbf *dbf, xbDouble &dOutFldCnt )dBASE FCOUNT function.Expression
xbInt16 FIELD( xbDbf *dbf, xbInt16 iFldNo, xbString &sOutFldName )dBASE FIELD function.Expression
xbInt16 FLDCOUNT( xbDbf *dbf, xbDouble &dOutFldCnt )dBASE FLDCOUNT function.Expression
xbInt16 FLOOR( xbDouble dIn, xbDouble &dOut )dBASE FLOOR function.Expression
xbInt16 HTOI( const xbString &sHexIn, xbDouble &dOut )dBASE HTOI function.Expression
xbInt16 IIF( xbBool bResult, const xbString &sTrueResult, const xbString &sFalseResult, xbString &sResult )dBASE IIF function.Expression
xbInt16 INT( xbDouble dIn, xbDouble &dOut )dBASE INT function.Expression
xbInt16 ISALPHA( const xbString &s, xbBool &bResult )dBASE ISALPHA function.Expression
xbInt16 ISLOWER( const xbString &s, xbBool &bResult )dBASE ISLOWER function.Expression
xbInt16 ISNULL( xbDbf *dbf, const xbString &sFldName, xbBool &bResult )dBASE ISNULL function.Expression
xbInt16 ISUPPER( const xbString &s, xbBool &bResult )dBASE ISUPPER function.Expression
xbInt16 ITOH( xbDouble dIn, xbString &sHexOut )dBASE ITOH function.Expression
xbInt16 LEFT( const xbString &sIn, xbUInt32 lCharCnt, xbString &sOut )dBASE LEF function.Expression
xbInt16 LEN( const xbString &sIn, xbDouble &dLen )dBASE LEN function.Expression
xbInt16 LOG( xbDouble dIn, xbDouble &dOut )dBASE LOG function.Expression
xbInt16 LOG( xbDouble dIn, xbDouble &dOut )dBASE LOG10 function.Expression
xbInt16 LOWER( const xbString &sIn, xbString &sOut )dBASE LOWER function.Expression
xbInt16 LTRIM( const xbString &sIn, xbString & sOut )dBASE LTRIM function.Expression
xbInt16 MAX( xbDouble dIn1, xbDouble dIn2, xbDouble &dOut )dBASE MAX function.Expression
xbInt16 MIN( xbDouble dIn1, xbDouble dIn2, xbDouble &dOut )dBASE MIN function.Expression
xbInt16 MOD( xbDouble dIn, xbDouble dIn2, xbDouble &dOut )dBASE MOD function.Expression
xbInt16 MONTH( xbDate &dInDate, xbDouble &dMonthOut )dBASE MONTH function.Expression
xbInt16 RAT( const xbString &sNeedle, xbString &sHaystack, xbDoublr &dOutPos )dBASE RAT function.Expression
xbInt16 RECCOUNT( xbDbf * d, xbDouble &dRecOut )dBASE RECCOUNT function.Expression
xbInt16 RECNO( xbDbf * d, xbDouble &dRecOut )dBASE RECNO function.Expression
xbInt16 REPLICATE( const xbString &sIn, xbUInt32 ulRepCnt, xbString &sOut )dBASE REPLICATE function.Expression
xbInt16 RIGHT( const xbString &sIn, xbUInt32 iCharCnt, xbString &sOut )dBASE RIGHT function.Expression
xbInt16 RTRIM( const xbString &sIn, xbString &sOut )dBASE RTRIM function.Expression
xbInt16 RTOD( xbDouble &dBase, xbDouble &dAnglesOut )dBASE RTOD function.Expression
xbInt16 SECONDS( xbDouble &dOut )dBASE SECONDS function.Expression
xbInt16 SIGN( xbDouble dBase, xbDouble &dSignOut )dBASE SIGN function.Expression
xbInt16 SIN( xbDouble dRadiansIn, xbDouble &dSignOut )dBASE SIN function.Expression
xbInt16 SOUNDEX( const xbString &ValIn, xbString &sSoundexOut )dBASE SOUNDEX function.Expression
xbInt16 SPACE( xbInt32 lCnt, xbString &sOut )dBASE SPACE function.Expression
xbInt16 SQRT( xbDouble dBASE, xbDouble &dSqrRt )dBASE SQRT function.Expression
xbInt16 STOD( const xbString &sIn, xbDate &sDateOut )dBASE STOD function.Expression
xbInt16 STR( xbDouble dIn, xbString &sOut )dBASE function.Expression
xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbString &sOut )
xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sOut )
xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sPadChar, xbString &sOut )
dBASE STR function.Expression
xbInt16 STRZERO( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sOut )dBASE STRZERO function.Expression
xbInt16 SUBSTR( const xbString &sIn, xbUInt32 ulStartPos, xbUInt32 ulLen, xbString &sOut )dBASE SUBSTR function.Expression
xbInt16 TAN( xbDouble dIn, xbDouble &dTanOut )dBASE TAN function.Expression
xbInt16 TIME( xbTime &dOutTime )dBASE TIME function.Expression
xbInt16 TRIM( const xbString &sIn, xbString &sOut )dBASE TRIM function.Expression
xbInt16 UPPER( const xbString &sIn, xbString &sOut )dBASE UPPER function.Expression
xbInt16 VAL( const xbString &sIn, xbDouble &dOut )dBASE VAL function.Expression
xbInt16 VERSION( xbString &sVersionIn )dBASE VERSION function.Expression
xbInt16 YEAR( xbDate &dInDate, xbDouble &dOutYear )dBASE YEAR function.Expression



Example program using xbXbase methods

/* xb_ex_core.cpp XBase64 Software Library Copyright (c) 1997,2003,2014,2021,2022,2023,2024 Gary A Kunkel The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. Email Contact: XDB-devel@lists.sourceforge.net XDB-users@lists.sourceforge.net This program demonstrates using functionality of the xbCore class (Shared system values) */ #include "xbase.h" using namespace xb; //int main( int ac, char ** av ){ int main( int, char ** av ){ xbXBase x; // set up xbase for business xbString sMsg; // a message string sMsg.Sprintf( "Program [%s] initializing...", av[0] ); std::cout << sMsg.Str() << std::endl; // example code to set up log file usage #ifdef XB_LOGGING_SUPPORT char cSeperator; // is this a unix (/) or windows (\) file system xbString sLog; // general string for log file activities sLog = x.GetLogFqFileName().Str(); // get the system default log file name std::cout << "System default logfile is [" << sLog.Str() << "]" << std::endl; cSeperator = sLog.GetPathSeparator(); // get the seperator from std::cout << "Path seperator = [" << cSeperator << "]" << std::endl; sLog.Sprintf( "..%c", cSeperator ); x.SetLogDirectory( sLog ); std::cout << "sLog = [" << sLog.Str() << "]\n"; sLog = x.GetLogFqFileName().Str(); // get the system default log file name std::cout << "New logfile is [" << sLog.Str() << "]" << std::endl; // turn on logging after file name set x.EnableMsgLogging(); #endif // XB_LOGGING_SUPPORT // const char *GetErrorMessage( xbInt16 ErrorCode ) const; // void DisplayError( xbInt16 ErrorCode ) const; std::cout << "DisplayError( -100 ) - "; x.DisplayError( -100 ); // << "]" << std::endl; // void SetDefaultDateFormat( const xbString &sDefaultDateFormat ); // xbString& GetDefaultDateFormat() const; std::cout << "GetDefaultDateFormat() - " << x.GetDefaultDateFormat().Str() << std::endl; // void SetDataDirectory ( const xbString &sDataDirectory ); // xbString& GetDataDirectory() const; std::cout << "GetDataDirectory() - " << x.GetDataDirectory().Str() << std::endl; // xbInt16 GetEndianType() const; if( x.GetEndianType() == 'L' ) std::cout << "Little Endian Architecture." << std::endl; else std::cout << "Bid Endian Architecture." << std::endl; //xbBool GetDefaultAutoCommit() const; //void SetDefaultAutoCommit( xbBool bDefaultAutoCommit ); if( x.GetDefaultAutoCommit()) std::cout << "AutoCommit is on." << std::endl; else std::cout << "AutoCommit is off." << std::endl; //xbBool GetMultiUser () const; //void SetMultiUser ( xbBool bMultiUser ); if( x.GetMultiUser()) std::cout << "Multi user (locking) is enabled." << std::endl; else std::cout << "Multi user (locking) not enabled." << std::endl; #if defined (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT) // Get / SetDefaultIxTagMode if( x.GetDefaultIxTagMode() == XB_IX_DBASE_MODE ) std::cout << "DefaultTagMode option - XB_IX_DBASE_MODE" << std::endl; else if( x.GetDefaultIxTagMode() == XB_IX_XBASE_MODE ) std::cout << "DefaultTagMode - XB_IX_XBASE_MODE" << std::endl; #endif // (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT) #ifdef XB_LOCKING_SUPPORT //xbInt16 GetDefaultLockRetries () const; //void SetDefaultLockRetries ( xbInt16 iRetryCount ); //xbInt32 GetDefaultLockWait () const; //void SetDefaultLockWait ( xbInt32 lRetryWait ); //xbInt16 GetDefaultLockFlavor () const; //void SetDefaultLockFlavor ( xbInt16 iLockFlavor ); std::cout << "GetDefaultLockRetries() - " << x.GetDefaultLockRetries() << std::endl; std::cout << "GetDefaultLockWait() - " << x.GetDefaultLockWait() << std::endl; #endif // XB_LOCKING_SUPPORT #ifdef XB_MDX_SUPPORT // xbInt16 GetCreateMdxBlockSize() const; // xbInt16 SetCreateMdxBlockSize( xbInt16 ulBlockSize ); std::cout << "GetCreateMdxBlockSize() - " << x.GetCreateMdxBlockSize() << std::endl; #endif // XB_MDX_SUPPORT #ifdef XB_BLOCKREAD_SUPPORT // xbUInt32 GetDefaultBlockReadSize() const; // void SetDefaultBlockReadSize( xbUInt32 ulDfltBlockReadSize ); std::cout << "GetDefaultBlockReadSize() - " << x.GetDefaultBlockReadSize() << std::endl; #endif // XB_BLOCKREAD_SUPPORT //xbBool BitSet ( unsigned char c, xbInt16 iBitNo ) const; //void BitDump ( unsigned char c ) const; //void BitDump ( char c ) const; std::cout << "BitDump( 'A' ) - "; x.BitDump( 'A' ); std::cout << std::endl; return 0; }