Common.h File Reference

Some common declarations for the DavisDB project. More...

#include <limits.h>

Go to the source code of this file.

Classes

struct  AttributeInfo
 Metadata about an attribute. More...
struct  RelationAttributeInfo
 Metadata about an attribute with relation name. More...
struct  RelationAttribute
 Structure to hold a relation name, attribute name pair. More...
struct  TypedValue
 Variant structure to hold an integer, float, or string pointer. More...
struct  AttributeOrValue
 Variant structure to hold an attribute name or a constant value. More...
struct  Condition
 A selection condition. More...

Defines

#define BUILD_BUG_ON(condition)   ((void)sizeof(char[1 - 2*!!(condition)]))
 A helpful macro for compile-time assertions.
#define ARRAYSIZE(a)   sizeof(a)/sizeof(a[0])
 A helpful macro for returning sizes of arrays.
#define ATOMIC_DELETE(a)   if (a != 0) { delete a; a = 0; }
 A helpful macro for safely deleting an object, and setting the reference to zero.
#define ATOMIC_ARRAY_DELETE(a)   if (a != 0) { delete[] a; a = 0; }
 A helpful macro for safely deleting an array object, and setting the reference to zero.

Typedefs

typedef unsigned int uint
 Shorthand for unsigned int.
typedef unsigned char uchar
 Shorthand for unsigned char.
typedef unsigned long ulong
 Shorthand for unsigned long.

Enumerations

enum  ReturnCode {
  RC_OK, RC_EOF, RC_PAGE_PINNED, RC_PAGE_NOT_IN_BUFFER,
  RC_PAGE_UNPINNED, RC_PAGE_FREE, RC_INVALID_PAGE, RC_FILE_OPEN,
  RC_CLOSED_FILE, RC_FILE_NOT_FOUND, RC_INVALID_ARGUMENT, RC_FILE_ALREADY_EXISTS,
  RC_PAGE_NOT_FOUND, RC_PAGE_NOT_DIRTY, RC_NOT_OPEN_FILE, RC_RECORD_TOO_LARGE,
  RC_RECORD_NOT_FOUND, RC_RECORD_ALREADY_IN_INDEX, RC_OUT_OF_MEMORY, RC_OUT_OF_BUFFER,
  RC_INCOMPLETE_READ, RC_INCOMPLETE_WRITE, RC_INCOMPLETE_HEADER_READ, RC_INCOMPLETE_HEADER_WRITE,
  RC_PAGE_IN_BUFFER, RC_INVALID_NAME, RC_UNIX, RC_CORRUPT_FILE,
  RC_FILE_TOO_BIG, RC_UNIMPLEMENTED
}
enum  AttributeType { INTEGER, FLOAT, STRING }
 Attribute types supported by RecordFileScan. More...
enum  ComparisonOp {
  EQ_OP, LT_OP, GT_OP, LE_OP,
  GE_OP, NE_OP, NO_OP
}
 The comparisons supported by RecordFileScan. More...

Functions

const char * OpToString (ComparisonOp op)
 Utility function to return the string representation of a ComparisonOp.
void printAttributeList (const RelationAttributeInfo *attributes, int count, bool includeTypes)
 Utility function to print (via std::cout) a list of attributes.
void printIndent (uint indent)
 Utility function to print (via std::cout) the given number of spaces.
void printCondition (const Condition *condition)
 Utility function to print (via std:cout) a Condition.
void printValue (const TypedValue *value)
 Utility function to print (via std::cout) a TypedValue.
ComparisonOp reverse (ComparisonOp op)
 Utility function to compute op' such that A op B = B op' A.


Detailed Description

Some common declarations for the DavisDB project.


Define Documentation

#define ARRAYSIZE (  )     sizeof(a)/sizeof(a[0])

A helpful macro for returning sizes of arrays.

A macro for returning the size of an array. Careful not to call it on an object of pointer (rather than array) type!

#define BUILD_BUG_ON ( condition   )     ((void)sizeof(char[1 - 2*!!(condition)]))

A helpful macro for compile-time assertions.

A helpful macro for compile-time assertions, used to break the build if the condition is not satisfied. This can be useful, e.g., to ensure that a given structure will fit on a PF_PAGE_SIZE-byte page. See AllocationPage for sample usage.


Enumeration Type Documentation

Attribute types supported by RecordFileScan.

Enumerator:
INTEGER  integer (int)
FLOAT  floating point (float)
STRING  character string of length <= MAX_STRING_LEN

The comparisons supported by RecordFileScan.

Enumerator:
EQ_OP  equal (i.e., attribute == value)
LT_OP  less-than (i.e., attribute < value)
GT_OP  greater-than (i.e., attribute > value)
LE_OP  less-than-or-equal (i.e., attribute <= value)
GE_OP  greater-than-or-equal (i.e., attribute >= value)
NE_OP  not-equal (i.e., attribute != value)
NO_OP  no comparison (when value is a null pointer)

enum ReturnCode

Standard return codes for DavisDB components, indicating success or various errors and exceptions.

Enumerator:
RC_OK  success
RC_EOF  end of file
RC_PAGE_PINNED  page pinned in buffer
RC_PAGE_NOT_IN_BUFFER  page to be unpinned is not in buffer
RC_PAGE_UNPINNED  page already unpinned
RC_PAGE_FREE  page already free
RC_INVALID_PAGE  invalid page number
RC_FILE_OPEN  file handle already open
RC_CLOSED_FILE  file is closed
RC_FILE_NOT_FOUND  file not found
RC_INVALID_ARGUMENT  invalid argument to function
RC_FILE_ALREADY_EXISTS  file already exists
RC_PAGE_NOT_FOUND  specified page not found
RC_PAGE_NOT_DIRTY  forced page was not dirty
RC_NOT_OPEN_FILE  handle not refers to an open file
RC_RECORD_TOO_LARGE  record size larger than page size
RC_RECORD_NOT_FOUND  specified record was not found
RC_RECORD_ALREADY_IN_INDEX  specified record is already in the index
RC_OUT_OF_MEMORY  out of memory
RC_OUT_OF_BUFFER  out of buffer space
RC_INCOMPLETE_READ  incomplete read of page from file
RC_INCOMPLETE_WRITE  incomplete write of page to file
RC_INCOMPLETE_HEADER_READ  incomplete read of header from file
RC_INCOMPLETE_HEADER_WRITE  incomplete write of header to file
RC_PAGE_IN_BUFFER  new allocated page already in buffer
RC_INVALID_NAME  invalid file name
RC_UNIX  Unix error.
RC_CORRUPT_FILE  file appears to be corrupt
RC_FILE_TOO_BIG  file is at maximum length
RC_UNIMPLEMENTED  method is unimplemented


Generated on Mon May 16 17:05:06 2011 by  doxygen 1.5.6