PLearn 0.1
|
#include <SimpleDB.h>
Public Member Functions | |
Schema () | |
Schema (size_type n, const T &value) | |
Schema (int n, const T &value) | |
Schema (long n, const T &value) | |
Schema (size_type n) | |
Schema (const Schema &x) | |
Schema (const_iterator first, const_iterator last) | |
bool | findColumn (const string &name, int &position, int &start, int &precision) const |
(Use inherited dtor and op=) | |
FieldPtr | findColumn (int position) const |
Make a pointer-to-field from a column number (zero-based) | |
FieldPtr | findColumn (const string &name) const |
Make a pointer-to-field from a column name. | |
FieldPtr | operator() (int position) const |
FieldPtr | operator() (const string &name) const |
Private Types | |
typedef vector< Field > | inherited |
typedef Field | T |
A schema is essentially a vector of fields, with a few extensions to more easily find individual fields within the schema.
(Impl. note: we really should be using private inheritance here, but this is difficult to achieve since then every single function in the base class would have to be made visible through using-decl. In addition, special provisions would have to be hacked up for ensuring a smooth working of iterators. In any case, since we don't add any data member, an (accidental) destruction of a Schema by vector's destructor is in practice harmless.)
Definition at line 352 of file SimpleDB.h.
typedef vector<Field> PLearn::Schema::inherited [private] |
Definition at line 354 of file SimpleDB.h.
typedef Field PLearn::Schema::T [private] |
Definition at line 355 of file SimpleDB.h.
PLearn::Schema::Schema | ( | ) | [inline] |
-- Forwarding functions for base-class constructors
Definition at line 359 of file SimpleDB.h.
: inherited() {}
PLearn::Schema::Schema | ( | size_type | n, |
const T & | value | ||
) | [inline] |
Definition at line 360 of file SimpleDB.h.
Definition at line 361 of file SimpleDB.h.
: inherited(n, value) {}
PLearn::Schema::Schema | ( | long | n, |
const T & | value | ||
) | [inline] |
Definition at line 362 of file SimpleDB.h.
PLearn::Schema::Schema | ( | size_type | n | ) | [inline, explicit] |
Definition at line 363 of file SimpleDB.h.
PLearn::Schema::Schema | ( | const Schema & | x | ) | [inline] |
__STL_MEMBER_TEMPLATES
Definition at line 364 of file SimpleDB.h.
PLearn::Schema::Schema | ( | const_iterator | first, |
const_iterator | last | ||
) | [inline] |
__STL_MEMBER_TEMPLATES
Definition at line 371 of file SimpleDB.h.
bool PLearn::Schema::findColumn | ( | const string & | name, |
int & | position, | ||
int & | start, | ||
int & | precision | ||
) | const |
(Use inherited dtor and op=)
-- Additional functionality specific to Schema
Find a schema entry ("column") by name, return true if found, and return to position, total bytes before in a row, and number of bytes in the column
Definition at line 59 of file SimpleDB.cc.
{ const_iterator it = begin(), end = this->end(); position = start = precision = 0; for (; it != end; start += it->precision, ++it, ++position) if (it->name == name) { precision = it->precision; break; } return (it == end)? false : true; }
Make a pointer-to-field from a column number (zero-based)
Definition at line 74 of file SimpleDB.cc.
{ int orig_position = position; ptrdiff_t offset_= 0; const_iterator it=begin(), end=this->end(); for (; position && it != end; --position, ++it) offset_+= it->precision; if (it == end) PLERROR("Column %d does not exist in schema", orig_position); return FieldPtr(orig_position, offset_); }
FieldPtr PLearn::Schema::findColumn | ( | const string & | name | ) | const |
Make a pointer-to-field from a column name.
Definition at line 88 of file SimpleDB.cc.
References PLERROR.
{ int position, start, precision; bool found = findColumn(name, position, start, precision); if (!found) PLERROR("Column %s does not exist in schema", name.c_str()); return FieldPtr(position, start); }
For convenience, operator() on a string or an integer position return findColumn(). This does not conflict with any member inherited from vector<>
Definition at line 396 of file SimpleDB.h.
{ return findColumn(position); }
FieldPtr PLearn::Schema::operator() | ( | const string & | name | ) | const [inline] |
Definition at line 400 of file SimpleDB.h.
{ return findColumn(name); }