rdbModel::Row Class Reference

#include <Column.h>

List of all members.

Public Member Functions

 Row ()
 Row (std::vector< FieldVal > &fields)
 ~Row ()
void rowSort ()
void addField (const FieldVal &f)
void clear ()
FieldValfind (std::string colname)
void regroup (std::vector< std::string > &colNames, std::vector< std::string > &colVals, std::vector< std::string > &nullCols) const
 Reorder information suitable for Connection::insert.

Private Attributes

std::vector< FieldValm_fields
bool m_sorted


Detailed Description

A collection of column names and values.

Definition at line 150 of file Column.h.


Constructor & Destructor Documentation

rdbModel::Row::Row (  )  [inline]

Definition at line 152 of file Column.h.

References m_fields.

00152 : m_sorted(false) {m_fields.clear();}

rdbModel::Row::Row ( std::vector< FieldVal > &  fields  )  [inline]

Definition at line 153 of file Column.h.

00153 : m_fields(fields), m_sorted(false) {}

rdbModel::Row::~Row (  )  [inline]

Definition at line 155 of file Column.h.

References m_fields.

00155 { m_fields.clear(); }


Member Function Documentation

void rdbModel::Row::addField ( const FieldVal f  )  [inline]

Definition at line 157 of file Column.h.

References m_fields, and m_sorted.

Referenced by rdbModel::Table::fillDefaults(), rdbModel::Table::fillProgramCols(), and rdbModel::Table::supersedeRow().

00157 {m_fields.push_back(f); m_sorted = false;}

void rdbModel::Row::clear (  )  [inline]

Definition at line 158 of file Column.h.

References m_fields.

00158 {m_fields.clear();}

FieldVal * rdbModel::Row::find ( std::string  colname  ) 

Definition at line 73 of file Column.cxx.

References m_fields.

Referenced by rdbModel::Table::doInterUpdate(), rdbModel::Table::fillDefaults(), rdbModel::Table::fillProgramCols(), rdbModel::Table::insertLatest(), rdbModel::Table::insertRow(), rdbModel::Assertion::Operator::Operator(), rdbModel::Table::supersedeRow(), rdbModel::Assertion::Operator::verify(), and rdbModel::Assertion::Operator::verifyCompare().

00073                                        {
00074     unsigned nField = m_fields.size();
00075     unsigned minI = 0;
00076     unsigned maxI = nField;
00077 
00078     unsigned guess = maxI/2;
00079     unsigned oldGuess = nField;
00080 
00081     int cmp = colname.compare(m_fields[guess].m_colname);
00082 
00083     while (cmp != 0)  {
00084       if (guess == oldGuess) return 0;        // not found
00085 
00086       if (cmp < 0 ) {    // thing we tried is > colName, so decrease maxI
00087         maxI = guess;
00088       }  else {   // thing we tried is > colName, so increase minI
00089         minI =  guess;
00090       }
00091       oldGuess = guess;
00092       guess = (minI + maxI)/2;
00093       cmp = colname.compare(m_fields[guess].m_colname);
00094     }
00095     return &m_fields[guess];
00096   }

void rdbModel::Row::regroup ( std::vector< std::string > &  colNames,
std::vector< std::string > &  colVals,
std::vector< std::string > &  nullCols 
) const

Reorder information suitable for Connection::insert.

Definition at line 98 of file Column.cxx.

References genRecEmupikp::i, and m_fields.

Referenced by rdbModel::Table::doInterUpdate(), rdbModel::Table::insertLatest(), rdbModel::Table::insertRow(), and rdbModel::Table::updateRows().

00100                                                             {
00101      unsigned nFields = m_fields.size();
00102      colNames.reserve(nFields);
00103      colVals.reserve(nFields);
00104 
00105      for (unsigned i = 0; i < nFields; i++) {
00106        if (m_fields[i].m_null) {
00107          nullCols.push_back(m_fields[i].m_colname);
00108        }
00109        else {
00110          colNames.push_back(m_fields[i].m_colname);
00111          colVals.push_back(m_fields[i].m_val);
00112        }
00113      }
00114    }

void rdbModel::Row::rowSort (  ) 

Definition at line 65 of file Column.cxx.

References m_fields, and m_sorted.

Referenced by rdbModel::Assertion::Assertion(), rdbModel::Table::fillDefaults(), rdbModel::Table::fillProgramCols(), rdbModel::Table::insertLatest(), rdbModel::Table::insertRow(), rdbModel::Table::supersedeRow(), rdbModel::Table::updateRows(), and rdbModel::Assertion::verify().

00065                     {
00066     if (m_sorted) return;
00067 
00068     FieldValCompare cmp;
00069     std::sort(m_fields.begin(), m_fields.end(), cmp);
00070     m_sorted = true;
00071   }


Member Data Documentation

std::vector<FieldVal> rdbModel::Row::m_fields [private]

Definition at line 167 of file Column.h.

Referenced by addField(), clear(), find(), regroup(), Row(), rowSort(), and ~Row().

bool rdbModel::Row::m_sorted [private]

Definition at line 168 of file Column.h.

Referenced by addField(), and rowSort().


Generated on Tue Nov 29 23:36:36 2016 for BOSS_7.0.2 by  doxygen 1.4.7