Field descriptions

Back to index


STANDALONE FIELDS

Standalone versions of these classes are prefixed with 'oof'. For example, an oofDate is a date type you can use without a database.

The oof... field types are lightweight subclasses of the main fields and exist only to make the construction declare some private storage, instead of connecting a field to a database.

eg: the constructor for dbText:
oofText() : dbText(dbField::eFieldIsStandalone) {}

dbDate

Stores a calendar date, without times.
Unlike dates based on counting seconds, can represent any date.

IN: - char* by assignment and setString
- long by assignment (internal representation is a long)
- set of 3 longs by setDate(Year, Month, Day)
- current date by setDateToday()

OUT:
- char*
- long
- set of 3 longs

DAY NUMBERS
daynum(), and ymd2daynum() convert a Gregorian calendar date to the corresponding Julian day number.
Algorithm 199 from Communications of the ACM, Volume 6, No. 8,
(Aug. 1963), p. 444. Gregorian calendar started on Sep. 14, 1752.
This function is not valid before that.

NOTES:
Conversion of character strings to dates has a default order of DMY. You can change this to orderYMD, or orderMDY with a single line at the start of your program:
dbDate::sDefaultDateOrder=dbDate::orderMDY;

UTILITIES:
Static conversion utilities to let you use the same long representation. (Yes, I know this is a bit grotty but it was on request.) You can also apply the same parsing to string or stream to get the numbers back (subject to the default parsing order above).

ymd2Long
long2ymd

chars2ymd
chars2Long
istream2ymd
ymd2stream

today2ymd() // returns the system date
today // stream manipulator, use as below (NOT with function call parens)
cout << dbDate::today << endl

currentDate() returns an oofDate with the current date, that can be further used or assigned to other dbDate or oofDate fields. eg:, from ooftst01.cpp
People.search(People.LastPaid > dbDate::currentDate()-14);

Other utilities are currentCentury, currentYear, currentMonth & currentDay.

The stream input or string input to a date is extremely flexible, as shown in detail in ooftst05.

Numeric Types

These all behave the same as their c++ native equivalents, with simple assignment to and from.

dbLong
dbUlong
dbShort
dbUshort
dbReal ( equivalent to standard 8-byte double)

dbChar

Fixed length string type.
A length() function returns the current length of the contents, as opposed to fieldLength() which is the length that *can* be stored.

The operator[] lets you directly access characters in a dbChar or oofChar field, eg:
Stock.JobCode[0] = "X";

dbText

Variable length string type. Based on dbBLOB. Can't be indexed other than by method (eg: keyword indexing). The standalone variation, oofText, provides a long string type limited only by available memory.

dbBLOB

Base type for general Blobs that are "lazily loaded" as required.

Access methods:
adoptBody
allocRoomFor
bodyAddress
orphanBody
reset

dbFixedBinary

Data type for basing your own special types on. Internally maps to a character array so the current cross-platform implementation won't flip bytes.


Back to index