|
PLearn 0.1
|
#include <SimpleDB.h>

Public Member Functions | |
| FieldRowRef (const RowIterator &it) | |
| operator FieldValue () const | |
| Conversion from / assignment into FieldValue. | |
| FieldRowRef & | operator= (const FieldValue &) |
| FieldRowRef & | operator= (const FieldRowRef rhs) |
| RowIterator | operator& () const |
| Taking the address of a FieldRowRef returns a RowIterator. | |
Private Attributes | |
| RowIterator | it_ |
| of course, this just wraps an iterator | |
A FieldRowRef represents a reference to a (polymorphic) field in a row. It can transparently convert itself into a FieldValue, or be assigned from a FieldValue.
Definition at line 1013 of file SimpleDB.h.
| PLearn::FieldRowRef::FieldRowRef | ( | const RowIterator & | it | ) | [inline] |
Definition at line 1016 of file SimpleDB.h.
: it_(it) {}
| PLearn::FieldRowRef::operator FieldValue | ( | ) | const |
Conversion from / assignment into FieldValue.
Definition at line 686 of file SimpleDB.cc.
References PLearn::RowIterator::asCharacter(), PLearn::RowIterator::asDate(), PLearn::RowIterator::asDouble(), PLearn::RowIterator::asFloat(), PLearn::RowIterator::asInt(), PLearn::RowIterator::asShort(), PLearn::RowIterator::asSignedChar(), PLearn::RowIterator::asString(), it_, and x.
{
if (const char* x = it_.asString())
return FieldValue(x);
if (const unsigned char* x = it_.asCharacter())
return FieldValue(*x);
if (const signed char* x = it_.asSignedChar())
return FieldValue(*x);
if (const short* x = it_.asShort())
return FieldValue(*x);
if (const int* x = it_.asInt())
return FieldValue(*x);
if (const float* x = it_.asFloat())
return FieldValue(*x);
if (const double* x = it_.asDouble())
return FieldValue(*x);
if (const PDate* x = it_.asDate())
return FieldValue(*x);
return FieldValue();
}

| RowIterator PLearn::FieldRowRef::operator& | ( | ) | const [inline] |
Taking the address of a FieldRowRef returns a RowIterator.
Definition at line 1192 of file SimpleDB.h.
{
return it_;
}
| FieldRowRef& PLearn::FieldRowRef::operator= | ( | const FieldRowRef | rhs | ) | [inline] |
Definition at line 1022 of file SimpleDB.h.
{
return operator=(FieldValue(rhs));
}
| FieldRowRef & PLearn::FieldRowRef::operator= | ( | const FieldValue & | rhs | ) |
Definition at line 710 of file SimpleDB.cc.
References PLearn::RowIterator::asCharacter(), PLearn::RowIterator::asDate(), PLearn::RowIterator::asDouble(), PLearn::RowIterator::asFloat(), PLearn::RowIterator::asInt(), PLearn::RowIterator::asShort(), PLearn::RowIterator::asSignedChar(), PLearn::RowIterator::asString(), PLearn::FieldValue::date_val_, PLearn::FieldValue::double_val_, PLearn::FieldValue::isDate(), PLearn::FieldValue::isFloating(), PLearn::FieldValue::isIntegral(), it_, PLearn::FieldValue::long_val_, PLERROR, PLearn::RowIterator::precision(), PLearn::FieldValue::toString(), and x.
{
// Strings ==> convert anything into string form
if (char* x = it_.asString()) {
strncpy(x, rhs.toString().c_str(), it_.precision());
x[it_.precision()-1] = '\0';
}
else if (unsigned char* x = it_.asCharacter()) {
if (rhs.isIntegral())
*x = (unsigned char)rhs.long_val_;
else if (rhs.isFloating())
*x = (unsigned char)rhs.double_val_;
else
PLERROR("Cannot convert a string or a date into an unsigned character");
}
else if (signed char* x = it_.asSignedChar()) {
if (rhs.isIntegral())
*x = (signed char)rhs.long_val_;
else if (rhs.isFloating())
*x = (signed char)rhs.double_val_;
else
PLERROR("Cannot convert a string or a date into a signed character");
}
else if (short* x = it_.asShort()) {
if (rhs.isIntegral())
*x = (short)rhs.long_val_;
else if (rhs.isFloating())
*x = (short)rhs.double_val_;
else
PLERROR("Cannot convert a string or a date into a short");
}
else if (int* x = it_.asInt()) {
if (rhs.isIntegral())
*x = (int)rhs.long_val_;
else if (rhs.isFloating())
*x = (int)rhs.double_val_;
else
PLERROR("Cannot convert a string or a date into an int");
}
else if (float* x = it_.asFloat()) {
if (rhs.isIntegral())
*x = (float)rhs.long_val_;
else if (rhs.isFloating())
*x = (float)rhs.double_val_;
else
PLERROR("Cannot convert a string or a date into a float");
}
else if (double* x = it_.asDouble()) {
if (rhs.isIntegral())
*x = (double)rhs.long_val_;
else if (rhs.isFloating())
*x = (double)rhs.double_val_;
else
PLERROR("Cannot convert a string or a date into a double");
}
else if (PDate* x = it_.asDate()) {
if (rhs.isDate())
*x = PDate(rhs.date_val_.year, rhs.date_val_.month,
rhs.date_val_.day);
else
PLERROR("Cannot convert a non-date into a date");
}
else
PLERROR("Unrecognized case in assignment in FieldRowRef from FieldValue");
return *this;
}

RowIterator PLearn::FieldRowRef::it_ [private] |
of course, this just wraps an iterator
Definition at line 1030 of file SimpleDB.h.
Referenced by operator FieldValue(), and operator=().
1.7.4