Class xbCore

Chapter Updated 07/07/26


Class xbCore - Shared System Values.

Base class xbCore is used for maintaining static variables used system wide by the XBase library routines and is a base class that is used by the xbXBase class. See the diagram in chapter 15 to gain an understanding of where the xbCore class sits in relation to the other classes. Accessing the methods in this class are done via the xbXBase class instance.

Additionally, there are a few other misc routines contained in this class that are available to all subordinate classes/objects.



MethodDescription
void DisplayError( xbInt16 ErrorCode ) constThis routine prints a description for a specifed error to stdout.
xbInt16 GetCmdLineOpt( xbInt32 lArgc, char **sArgv, const char *sOptRqst, xbString &sParmOut )
xbInt16 GetCmdLineOpt( xbInt32 lArgc, char **sArgv, xbString &sOptRqst, xbString &sParmOut )
brief Parse commmand line options for a given parm request
  • lArgc Value passed from main( argc, argv[] )
  • sArgv Valued passed from main
  • sOptRqst Option to search for in the arguments list
  • sParmOut String token immediately to the right of the the option request, if found
  • returns 0 - paramater request not found or 1 - Parameter found
  • xbBool GetConstraintsEnabled() const
    void SetConstraintsEnabled( xbBool bSwitch )
    Get and Set (turn off and on) constraint logic.
    xbInt16 GetCreateMdxBlockSize() const
    xbInt16 SetCreateMdxBlockSize( xbInt16 ulBlockSize )
    Set or get MDX Index block size. Must be a multiple of 512.
    xbString& GetDataDirectory() const
    void SetDataDirectory( const xbString &sDataDirectory )
    Get and Set the current directory where the library routines expect to find the .DBF, .DBT, .NDX and .MDX files.
    xbBool GetDefaultAutoCommit() const
    void SetDefaultAutoCommit( xbBool bDefaultAutoCommit )
    Get and Set the default auto commit status. If auto commit is on, the library will automatically post any updates to the database when navigating away from an updated record.
    xbBool GetDefaultAutoLock () const
    void SetDefaultAutoLock( xbBool bAutoLock )
    void DisableDefaultAutoLock()
    void EnableDefaultAutoLock()
    Get, Set, Enable and Disable auto lock. Enable and Disable to the same thing as the Set.
    xbUInt32 GetDefaultBlockReadSize() const
    void SetDefaultBlockReadSize( xbUInt32 ulDfltBlockReadSize )
    Set or Get the default block size for Block Read functionality. Block reading is used to improve sequentential access performance.
    xbString& GetDefaultDateFormat() const
    void SetDefaultDateFormat( const xbString &sDefaultDateFormat )
    Get and Set the current default date format used by the date formatting routines if no format specifier is provided.
    xbUInt32 GetDefaultIxTagMode() const
    xbInt16 SetDefaultIxTagMode( XB_IX_DBASE_MODE || XB_IX_XBASE_MODE )
    Set or Get the default index tag mode. XB_IX_DBASE_MODE is used for max compatibility.
    xbString& GetDefaultLanguageDriverName() const
    void SetDefaultLanguageDriverName( const xbString &sDefaultLanguageDriverName )
    Get and Set the default language driver name.
    xbInt16 GetDefaultLockFlavor() const
    void SetDefaultLockFlavor( xbInt16 iLockFlavor )
    For future use. With current versions, only dBASE locking offsets are supported.
    xbInt16 GetDefaultLockRetries() const
    void SetDefaultLockRetries( xbInt16 iRetryCount )
    Get and Set the number of times to attempt a lock
    xbInt32 GetDefaultLockWait() const
    void SetDefaultLockWait( xbInt32 lRetryWait )
    Get and Set the wait time between lock attempts.
    xbString& GetDefaultTimeFormat() const
    void SetDefaultTimeFormat( const xbString &sDefaultTimeFormat )
    Get and Set the default time format.
    xbString& GetDefaultTimeStampFormat() const
    void SetDefaultTimeStampFormat( const xbString &sDefaultTimeStampFormat )
    Get and Set the default time stamp format.
    xbInt16 GetEndianType() constReturns the current Endian type of the machine the library is operating on.
    const char *GetErrorMessage( xbInt16 ErrorCode ) constReturns a pointer to an error message for a given error number.
    xbBool GetHomeDir( xbString &sHomeDirOut )Get the home directory for the current user.
    xbString & GetLastConstraintError() const Returns any error text associated with constraints from updating or adding db records.
    xbString& GetLogDirectory() const
    void SetLogDirectory( const xbString &sLogDirectory )
    Get and set the directory location for any system generated logfiles.
    xbInt16 GetLogDispOpt() const
    void SetLogDispOpt( xbInt16 iDispOpt )
    Get and set the log display option setting. (Display part only, separate from writing to logfile.)
  • 0 - Off
  • 1 - stdout
  • 2 - stderr
  • xbString& GetLogFileName() const
    void SetLogFileName( const xbString &sLogFileName )
    Returns the default log file name.
    const xbString &GetLogFqFileName() const Returns the fully qualified current log file name. Log files roll once full. This routine returns the current FQ Log file name.
    size_t GetLogSize() const
    void SetLogSize( size_t lSize )
    Set and get the log file size limit. When the logfile grows to this size, it will close the current logfile and roll to a new logfile.
    xbBool GetLogStatus() const
    void EnableMsgLogging()
    void DisableMsgLogging()
    Get logging status, Enable and Disable logging.
    xbBool GetMultiUser() const
    void SetMultiUser( xbBool bMultiUser )
    Get and set multi user status. This turns auto locking on and off. For better performance in single user applications, turn multuser off.
    char GetPathSeparator() const Get the path separator value for the current environment. Returns either \ (for Windows environment) or / (for Unix environment).
    xbString& GetTempDirectory() const
    void SetTempDirectory( const xbString &sTempDirectory )
    Get and set the temp folder.


    Example program using xbCore

    /* xb_ex_corev.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 ); //xbBool GetDefaultAutoLock () const; //void SetDefaultAutoLock ( xbBool bAutoLock ); //void EnableDefaultAutoLock (); //void DisableDefaultAutoLock (); std::cout << "GetDefaultLockRetries() - " << x.GetDefaultLockRetries() << std::endl; std::cout << "GetDefaultLockWait() - " << x.GetDefaultLockWait() << std::endl; std::cout << "GetDefaultAutoLock() - " << x.GetDefaultAutoLock() << 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 std::cout << std::endl; return 0; }