Index

Exceptions

Purpose:

This section describes the DK data access exception classes and their hierarchy.

Exceptions:

DKException

All classes below are created using the DKEXCLASSIMPLEMENT macro and are subclasses of DKException.

    dkDatastoreError
    dkSystemError
    dkUsageError
    dkXDOError

DKDatastoreAccessError is also a subclass of DKException, and it has some subclasses listed below. These exceptions have return code and state information.

    dkDatastoreAccessError
      dkXDOAccessError
      dkDataObjectNotFound
 

The meaning of each exception is described in the description of each class which throws the exception.

Class summary:

 class DKException : public DKExceptionBase {
public:
  DKException(const char *errorText, long errorId = 0,
              Severity severity = 
              dkExceptionBase::unrecoverable,
              long errorCode = 0,
              const char* errorState = "");
     );
  DKException(const DKException& exception);
  virtual DKException();
 
  virtual const char* name() const;
  virtual const char* errorState() const;
  virtual long  errorCode() const;
  virtual DKBoolean errorProvided() const;
  virtual short exceptionId() const;
 
  };
 

Class summary:

#define DKEXCLASSDECLARE(child,parent) class child : public parent {
public:
  child(const char* a, unsigned long b = 0,
        Severity c = DKException::unrecoverable);
  virtual const char* name() const;
  virtual child();
  child(const child& );
  virtual DKException& logExceptionData();
  }
 
#define DKDAEXCLASSDECLARE(child,parent) class child : public parent {
public:
  child(const char* a, unsigned long b = 0,
        Severity c = DKException::unrecoverable,
        long aCODE = 0,
        const char* aSTATE = "" );
  virtual const char* name() const;
  virtual child();
  child(const child& );
  virtual DKException& logExceptionData();
  virtual const char* errorState() const;
  virtual long errorCode() const;
  }
 
 

Class summary:

class DKExceptionBase : public IException    
 { 
    public:   
      enum DKSeverity (unrecoverable, recoverable);       
      DKExceptionBase (const char *errorText, unsigned long errorID 
              = 0, dkSeverity severity = dkExceptionBase::unrecoverable);        
      DKExceptionBase( const DKExceptionBase& exc);        
      const DKExceptionLocation =locationAtIndex (unsigned long locationIndex) const;        
      const char* text(unsigned long i=0) const;        
      unsigned long textCount();        
      static void setThrown(short thrown);        
      static short isThrown();     );  
 
 //For Windows the code above would be:
class DKExceptionBase : public CException  
{   
   public:        
      enum DKSeverity {unrecoverable, recoverable};        
      DKExceptionBase (const char *errorText, unsigned long errorID 
               = 0, dkSeverity severity = dkExceptionBase::unrecoverable);        
     DKExceptionBase( const DKExceptionBase& exc);        
     virtual DKExceptionBase();         
     const char * text (unsigned long i = 0) const;        
     unsigned long textCount();        
     void addLocation (const DKExceptionLocation &location );        
     unsigned long locationCount() const;        
     const DKExceptionLocation *locationAtIndex (unsigned long locationIndex) const;        
     void appendText (const char *errorText);         
     void setText (const char *errorText);       
     unsigned long errorId() const;        
     static void setThrown(short thrown);        
     static short isThrown();
};  

Class summary:

For AIX
 
 class DKExceptionLocation : public IExceptionLocation
   {
public:
       DKExceptionLocation (const char* fileName = 0, 
                            const char* functionName = 0,
                            unsigned long lineNumber = 0);
          
   );
 
For Windows
 
 class DKExceptionLocation {
 {
  public:
       DKExceptionLocation (const char* fileName = 0, 
                            const char* functionName = 0,
                            unsigned long lineNumber = 0);                           
       DKExceptionLocation (const DKExceptionLocation& from);
 
  public:
          const char
         *fileName() const:  // file name
          const char
         *functionName() const:  // function name
          unsigned long
          lineNumber() const;  // line number
 
       DKExceptionLocation& operator = 
                              (const DKExceptionLocation& from);
       virtual DKExceptionLocation();
 
     };
 

Members:

Constructor
The inputs to this class are errorText, errorId and (optionally) a severity code, an error code and a severity state. The error ID is for the error text. Severity is either recoverable or unrecoverable; the error code is a datastore access type, and the same is true for the error state.
  DKException (const char *errorText, long errorId = 0,
               Severity severity = 
               DKExceptionBase::unrecoverable,
               long errorCode = 0,
               const char* errorState = "");
     );
  DKException(const DKException& exception);

Member functions

name
Returns the exception name.
     virtual const char* name() const;

errorState
Returns the error state.
     virtual const char* errorState() const;

errorCode
Returns the error code.
     virtual long errorCode() const;

errorProvided
Returns as TRUE if the errorCode and state are provided.

     virtual DKBoolean errorProvided() const;

exceptionId
Returns as TRUE if the errorCode and state are provided.

     virtual short exceptionId() const;

text
Returns the text at a certain index. Indexing is started from zero.
     const char * text (unsigned long i = 0) const;

textCount
Returns the number of error text messages.
     unsigned long textCount();

addLocation
Adds the exception location to the exception.
     void addLocation (const DKExceptionLocation &location );

locationCount
Returns the number of exception locations.
     unsigned long locationCount() const ;

locationAtIndex
Returns the location at a certain index. Indexing is initialized at zero.
   const DKExceptionLocation *locationAtIndex 
                            (unsigned long locationIndex) const;

appendText
Appends text to the top of the exception text stack.
     void appendText (const char *errorText);

setText
Resets the exception text stack, and inputs text to the top of the text stack.
     void setText (const char *errorText);

errorId
Returns the error ID for an exception.
     unsigned long errorId() const;

setThrown
Sets the thrown state of an exception. The thrown paramater of this method can be set to one of two values. A value of 1 indicates that the exception was thrown; a value of 0 indicates that the exception was caught. The value of 1 is set automatically when the exception is thrown. The value of 0 is set when the const char* text(unsigned long i=0) const or unsigned long textCount() methods are called in a catch block. If you catch an exception without calling these methods, you should call the static void setThrown((short)0) method to indicate that the exception was caught.
     static void setThrown(short thrown);

isThrown
Used to see if an exception has already been thrown and has not been caught.
     static short isThrown();

DKConstant.h

DKConstant.h contains some constant values. DKConstant.h includes DKConstant2.h, and DKConstant2.h contains the other constants that the C++ OO API uses.

DKString

Class summary:
For AIX
 
 #define DKString IString
 
For Windows
 
 class DKString : public CString
 {
  public:
       DKString();
       DKString (const char* s);
       DKString (const DKString &s);
       DKString (void *pBuffer, unsigned long lenBuffer);
       DKString (char * pc);
       DKString (char c);
       DKString (int v);
       DKString (unsigned int v);
       DKString (short v);
       DKString (long v);
       DKString (unsigned short v);     
       DKString (unsigned long v);
       DKString (double v);
       virtual DKString();
 
 
       const DKString operator = (const DKString &cst) const;
       const DKString operator = (const CString &cst) const;
       const DKString operator = (const char * cst) const;
       const DKString operator = (const char c) const;
       const DKString operator + (const DKString &cst) const;
       const DKString operator + (const CString &cst) const;
       const DKString operator + (const char * cst) const;
       const DKString operator + (const char c) const;
       const DKString operator += (const DKString &cst) const;
       const DKString operator += (const CString &cst) const;
       const DKString operator += (const char * cst) const;
       const DKString operator += (const char c) const;
 
       dkBoolean operator==(char *s) const;
       dkBoolean operator==(const char *s) const;
       dkBoolean operator==(const DKString *s) const;
 
       dkBoolean operator!=(char *s) const;
       dkBoolean operator!=(const char *s) const;
       dkBoolean operator!=(const DKString *s) const;
       unsigned long size() const;
       dkString subString (unsigned long position, 
                           unsigned long len) const;
       void strip();
       unsigned long length() const;
       unsigned long indexOf (char ch) const;
       unsigned long indexOf (const DKString str, 
                              unsigned long position) const;
       unsigned long indexOf (char ch, 
                              unsigned long position) const;
 
       dkString& remove (unsigned long position, 
                         unsigned long len);
       dkString& insert (const DKString str, 
                         unsigned long position);
       dkString& leftJustify (unsigned long len)
       dkBoolean isDigits();
       long asInt();
       unsigned long asUnsigned();
       operator CString();
       operator char *();
       char operator [](unsigned long index);
       DKString& upperCase();
};
          

Members:

Constructor

The inputs to this class are listed below:

  DKString();
  DKString (const char* s);
  DKString (const DKString &s);
  DKString (void *pBuffer, 
            unsigned long lenBuffer);
  DKString (char * pc);
  DKString (char c);
  DKString (int v);
  DKString (unsigned int v);
  DKString (short v);
  DKString (long v);
  DKString (unsigned short v);
  DKString (unsigned long v);
  DKString (double v);
 

Member functions

operator=
The assignment operator allows a new value to be assigned to the string.
const DKString operator = (const DKString &cst) const;
const DKString operator = (const char * cst) const;
const DKString operator = (const char c) const;
// only on MSVC
const DKString operator = (const CString &cst) const;

operator+
This operator allows concatenation to the string.
const DKString operator + (const DKString &cst) const;
const DKString operator + (const char * cst) const;
const DKString operator + (const char c) const;
// only on MSVC
const DKString operator + (const CString &cst) const;

operator+=
This operator allows concatenation to the string, and to assign it a new value.
const DKString operator += (const DKString &cst) const;
const DKString operator += (const char * cst) const;
const DKString operator += (const char c) const;
// only on MSVC
const DKString operator += (const CString &cst) const;

operator==
This operator is used for comparing strings for equality.
dkBoolean operator==(char *s) const;
dkBoolean operator==(const char *s) const;
dkBoolean operator==(const DKString *s) const;

operator!=
This operator is used for testing strings for inequality.
dkBoolean operator!=(char *s) const;
dkBoolean operator!=(const char *s) const;
dkBoolean operator!=(const DKString *s) const;

size
Returns the size of the string.
unsigned long size() const;

subString
Gets a substring of the subject string. position 1 represents the first character of the string.
dkString subString (unsigned long position,
unsigned long len) const;

strip
Strips the leading and trailing blanks in a string.
void strip();

length
Returns the length of a string.
unsigned long length() const;

indexOf
Returns the starting position of the input string within a given string. position 1 represents the first character of the string. If the input string is not found, a zero value is returned.
unsigned long indexOf (char ch) const;
unsigned long indexOf (const DKString str, 
unsigned long position) const;
unsigned long indexOf (char ch, 
unsigned long position) const;

remove
Removes a specified portion of the string. position 1 represents the first character of the string.
dkString& remove (unsigned long position, unsigned long len);

insert
Inserts the input string into the given string. position 1 represents the first character of the string. If the specified string length is longer than the current string length, the string is extended by the pad character, which is a blank character.
dkString& insert (const DKString& str, unsigned long position);

leftJustify
Left-justifies the subject string of the specified length. If the specified string length is longer than the current string length, the string is extended by the pad character, which is a blank character.
dkString& leftJustify (unsigned long len);

isDigits
Returns a TRUE value if the string content is digits.
dkBoolean isDigits();

asInt
Converts a string to long.
unsigned long asInt();

asUnsigned
Converts a string to unsigned long.
unsigned long asUnsigned();

operator CString
Returns the CString of a string's content.Restriction: this operator is only valid for Microsoft Visual C++.
operator CString();

operator char *
Returns the char* of a string's content.
operator char *();

operator []
position 1 represents the first character of the string.

char operator []( unsigned long index );

upperCase
Creates a new string with all upper case characters.
DKString& upperCase();

(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.