HiveReturn HiveRowSet::getFieldAsI64U(size_t column_idx, uint64_t* buffer, int* is_null_value, char* err_buf, size_t err_buf_len) { RETURN_ON_ASSERT(buffer == NULL, __FUNCTION__, "Column data output buffer cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(is_null_value == NULL, __FUNCTION__, "Column data is_null_value (output) cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(getColumnCount() == 0, __FUNCTION__, "Rowset contains zero columns.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(column_idx >= getColumnCount(), __FUNCTION__, "Column index out of bounds.", err_buf, err_buf_len, HIVE_ERROR); if (m_last_column_fetched != column_idx) { extractField(column_idx); m_bytes_read = 0; /* Reset the read offset if different from the last column fetched */ m_last_column_fetched = column_idx; m_is_completely_read = false; } if (m_is_completely_read) { return HIVE_NO_MORE_DATA; /* This column has already been completely fetched */ } /* If the column data is the same as the null format spec... */ if (strcmp(getNullFormat(), m_field_buffer) == 0) { *is_null_value = 1; *buffer = 0; } else { *is_null_value = 0; *buffer = ATOI64U(m_field_buffer); } m_is_completely_read = true; return HIVE_SUCCESS; }
/************************************************************************* Move a column segment to a new position *************************************************************************/ void ListHeader::moveColumn(uint column, uint position) { if (column >= getColumnCount()) { CEGUI_THROW(InvalidRequestException( "specified column index is out of range for this ListHeader.")); } else { // if position is too big, move to end. if (position >= getColumnCount()) { position = getColumnCount() - 1; } ListHeaderSegment* seg = d_segments[column]; // remove original copy of segment d_segments.erase(d_segments.begin() + column); // insert the segment at it's new position d_segments.insert(d_segments.begin() + position, seg); // Fire sequence changed event HeaderSequenceEventArgs args(this, column, position); onSegmentSequenceChanged(args); layoutSegments(); } }
/************************************************************************* Insert a new column segment into the header *************************************************************************/ void ListHeader::insertColumn(const String& text, uint id, const UDim& width, uint position) { // if position is too big, insert at end. if (position > getColumnCount()) { position = getColumnCount(); } ListHeaderSegment* seg = createInitialisedSegment(text, id, width); d_segments.insert((d_segments.begin() + position), seg); // add window as a child of this addChild(seg); layoutSegments(); // Fire segment added event. WindowEventArgs args(this); onSegmentAdded(args); // if sort segment is invalid, make it valid now we have a segment attached if (!d_sortSegment) { setSortColumn(position); } }
HiveReturn HiveRowSet::getFieldAsCString(size_t column_idx, char* buffer, size_t buffer_len, size_t* data_byte_size, int* is_null_value, char* err_buf, size_t err_buf_len) { RETURN_ON_ASSERT(buffer == NULL, __FUNCTION__, "Column data output buffer cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(is_null_value == NULL, __FUNCTION__, "Column data is_null_value (output) cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(getColumnCount() == 0, __FUNCTION__, "Rowset contains zero columns.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(column_idx >= getColumnCount(), __FUNCTION__, "Column index out of bounds.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(buffer_len == 0, __FUNCTION__, "Output buffer cannot have a size of zero.", err_buf, err_buf_len, HIVE_ERROR); if (m_last_column_fetched != column_idx) { extractField(column_idx); m_bytes_read = 0; /* Reset the read offset if different from the last column fetched */ m_last_column_fetched = column_idx; m_is_completely_read = false; } if (m_is_completely_read) { return HIVE_NO_MORE_DATA; /* This field has already been completely fetched by a previous call*/ } /* If the column data is the same as the null format spec... */ if (strcmp(getNullFormat(), m_field_buffer) == 0) { /* This value must be NULL */ *is_null_value = 1; if (data_byte_size != NULL) { *data_byte_size = 0; } buffer[0] = '\0'; } else { /* This value has been determined not to be NULL */ *is_null_value = 0; size_t data_total_len = getFieldLen(column_idx); /* Cannot read more data then the total number of bytes available */ assert(data_total_len >= m_bytes_read); size_t bytes_remaining = data_total_len - m_bytes_read; // Excludes null char if (data_byte_size != NULL) { /* Save the number of remaining characters to return before this fetch */ *data_byte_size = bytes_remaining; } /* Move pointer to the read location */ const char* src_str_ptr = m_field_buffer + m_bytes_read; /* The total number of bytes to read (+1 null terminator) should be no more than the * size of the field buffer */ assert(m_bytes_read + bytes_remaining + 1 <= sizeof(m_field_buffer)); /* Copy as many characters as possible from the read location */ size_t bytes_copied = safe_strncpy(buffer, src_str_ptr, min(buffer_len, bytes_remaining + 1)); // +1 for null terminator /* bytes_copied does not count the null terminator */ m_bytes_read += bytes_copied; if (m_bytes_read < data_total_len) { return HIVE_SUCCESS_WITH_MORE_DATA; /* Data truncated; more data to return */ } } m_is_completely_read = true; return HIVE_SUCCESS; /* All data successfully read */ }
HiveReturn HiveRowSet::getFieldDataLen(size_t column_idx, size_t* col_len, char* err_buf, size_t err_buf_len) { RETURN_ON_ASSERT(col_len == NULL, __FUNCTION__, "Pointer to col_len (output) cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(getColumnCount() == 0, __FUNCTION__, "Rowset contains zero columns.", err_buf, err_buf_len, HIVE_ERROR); RETURN_ON_ASSERT(column_idx >= getColumnCount(), __FUNCTION__, "Column index out of bounds.", err_buf, err_buf_len, HIVE_ERROR); *col_len = getFieldLen(column_idx); return HIVE_SUCCESS; }
// // _fillVectors: // void MadelineTable::_fillVectors() { // // set the base class stuff: // _columns = _dataColumns; _rows = _dataRows; for(unsigned long j=0;j< _rows;j++) { for(unsigned i=0;i< _columns;i++) { // // Create the element vector: // _element.push_back(getData(i,j)); } } for(unsigned i=0;i< getColumnCount();i++) { // // Create the column type vector: // _columnType.push_back( _columnOffset[i].getDeclaredType() ); } }
template <class R> string CMatrix<R>::toStringLatex() const { int colCount = getColumnCount(); if ((rows.size() == 0) || (colCount == 0)) { string result; result += "(Matrix has zero rows and/or columns)"; return result; } else { string result; result += "\\left[ \\begin{array}{"; for (int c = 0; c < colCount; c++) result += "c"; result += "}\n"; for (unsigned int r = 0; r < rows.size(); r++) { if (r != 0) result += "\\\\\n"; for (int c = 0; c < colCount; c++) { if (c != 0) result += "&"; result += (*rows[r])[c].toString(); } } result += "\\end{array} \\right]"; return result; } }
/************************************************************************* Set the current sort segment via column index. *************************************************************************/ void ListHeader::setSortColumn(uint column) { if (column >= getColumnCount()) { CEGUI_THROW(InvalidRequestException( "specified column index is out of range for this ListHeader.")); } else { // if column is different to current sort segment if (d_sortSegment != d_segments[column]) { // set sort direction on 'old' sort segment to none. if (d_sortSegment) { d_sortSegment->setSortDirection(ListHeaderSegment::None); } // set-up new sort segment d_sortSegment = d_segments[column]; d_sortSegment->setSortDirection(d_sortDir); // Fire sort column changed event WindowEventArgs args(this); onSortColumnChanged(args); } } }
/** * @brief This method has been reimplemented. It manages the following actions: * - Column resizing * - Header button * * @param[in] event Mouse event * * @return Nothing. */ void AbstractTableView::mouseReleaseEvent(QMouseEvent* event) { if((event->buttons() & Qt::LeftButton) == 0) { if(mGuiState == AbstractTableView::ResizeColumnState) { mGuiState = AbstractTableView::NoState; } else if(mGuiState == AbstractTableView::HeaderButtonPressed) { if(mColumnList[mHeader.activeButtonIndex].header.isMouseOver == true) { //qDebug() << "Button " << mHeader.activeButtonIndex << "has been released."; emit headerButtonReleased(mHeader.activeButtonIndex); } mGuiState = AbstractTableView::NoState; } else { QWidget::mouseReleaseEvent(event); } // Release all buttons for(int i = 0; i < getColumnCount(); i++) { mColumnList[i].header.isPressed = false; } updateViewport(); } }
void applyTanh() { for (int rowIndex = 0; rowIndex < getRowCount(); ++rowIndex) { for (int columnIndex = 0; columnIndex < getColumnCount(); ++columnIndex) { data[rowIndex][columnIndex] = tanh(data[rowIndex][columnIndex]); } } }
// // display: // void MadelineTable::display(void) { for(unsigned int i=0;i<_title.size();i++){ std::cout << _title[i] << "\t"; } std::cout << std::endl; for(unsigned int i=0;i<_columnType.size();i++) { std::cout << i <<":" << _columnType[i] << "\t"; } std::cout << std::endl; for(unsigned int i=0;i<_element.size();i++) { if(i % getColumnCount() == 0) { std::cout << std::endl; } std::cout << _element[i] << "\t"; } std::cout << std::endl; }
template <class R> string CMatrix<R>::toStringHtml() const { int colCount = getColumnCount(); if ((rows.size() == 0) || (colCount == 0)) { string result; result += "(Matrix has zero rows and/or columns)"; return result; } else { string result; result += "<table cellspacing=\"0\" border=\"1\">"; for (unsigned int r = 0; r < rows.size(); r++) { result += "<tr>"; for (int c = 0; c < colCount; c++) { result += "<td><center>"; result += (*rows[r])[c].toString(); result += "</center></td>"; } result += "</tr>"; } result += "</table>"; return result; } }
template <class R> string CMatrix<R>::toString() const { int colCount = getColumnCount(); if ((rows.size() == 0) || (colCount == 0)) { string result; result += "(Matrix has zero rows and/or columns)"; return result; } else { int maxL = 0; vector<vector<string> > strings = vector<vector<string> >(); for (unsigned int r = 0; r < rows.size(); r++) { strings.push_back(vector<string>(colCount)); for (int c = 0; c < colCount; c++) { strings[r][c] = (*rows[r])[c].toString(); int strL = strings[r][c].length(); maxL = (strL > maxL) ? strL : maxL; } } string result; for (unsigned int r = 0; r < rows.size(); r++) { result += "[ "; for (int c = 0; c < colCount; c++) { int spaceCount = (maxL - strings[r][c].length()) - (c == 0 ? 1 : 0); for (int s = spaceCount; s >= 0; s--) result += " "; result += strings[r][c]; } result += " ]\n"; } return result; } }
map<string,int> SQLiteStatement::getColumnNames(){ map<string,int> names; for(int i = 0;i < getColumnCount();i++){ names[string(sqlite3_column_name(m_stmt,i))] = i; } return names; }
void applyScale(float scale) { for (int rowIndex = 0; rowIndex < getRowCount(); ++rowIndex) { for (int columnIndex = 0; columnIndex < getColumnCount(); ++columnIndex) { data[rowIndex][columnIndex] *= scale; } } }
size_t HiveSerializedRowSet::getFieldLen(size_t column_idx) { assert(column_idx < getColumnCount()); assert(m_row_weak_ptr != NULL); size_t len; // If this is the last column... if (column_idx == getColumnCount() - 1) { assert(m_row_weak_ptr->length() >= m_field_offsets[column_idx]); len = m_row_weak_ptr->length() - m_field_offsets[column_idx]; } else { assert(m_field_offsets[column_idx + 1] > m_field_offsets[column_idx]); len = m_field_offsets[column_idx + 1] - m_field_offsets[column_idx] - 1; } /* Enforce the constraint that no data exceed MAX_BYTE_LENGTH */ len = min(len, (size_t) MAX_BYTE_LENGTH); return len; }
void addBy(Matrix const& matrix) { for (int rowIndex = 0; rowIndex < getRowCount(); ++rowIndex) { for (int columnIndex = 0; columnIndex < getColumnCount(); ++columnIndex) { data[rowIndex][columnIndex] += matrix[rowIndex][columnIndex]; } } }
size_t HiveStringVectorRowSet::getFieldLen(size_t column_idx) { assert(column_idx < getColumnCount()); assert(m_fields_weak_ptr != NULL); size_t len = m_fields_weak_ptr->at(column_idx).length(); /* Enforce the constraint that no data exceed MAX_BYTE_LENGTH */ len = min(len, (size_t) MAX_BYTE_LENGTH); return len; }
/************************************************************************* Remove a column from the header *************************************************************************/ void ListHeader::removeColumn(uint column) { if (column >= getColumnCount()) { CEGUI_THROW(InvalidRequestException( "specified column index is out of range for this ListHeader.")); } else { ListHeaderSegment* seg = d_segments[column]; // remove from the list of segments d_segments.erase(d_segments.begin() + column); // have we removed the sort column? if (d_sortSegment == seg) { // any other columns? if (getColumnCount() > 0) { // put first column in as sort column d_sortDir = ListHeaderSegment::None; setSortColumn(0); } // no columns, set sort segment to NULL else { d_sortSegment = 0; } } // detach segment window from the header (this) removeChild(seg); // destroy the segment (done in derived class, since that's where it was created). destroyListSegment(seg); layoutSegments(); // Fire segment removed event. WindowEventArgs args(this); onSegmentRemoved(args); } }
void applyDerivativeOfTanh() { for (int rowIndex = 0; rowIndex < getRowCount(); ++rowIndex) { for (int columnIndex = 0; columnIndex < getColumnCount(); ++columnIndex) { float v = tanh(data[rowIndex][columnIndex]); data[rowIndex][columnIndex] = 1 - v * v; } } }
unsigned ResultSet::getColumnTypeId(int column_idx) { //Throws an error in case the column index is invalid if(column_idx < 0 || column_idx >= getColumnCount()) throw Exception(ERR_REF_TUPLE_COL_INV_INDEX, __PRETTY_FUNCTION__, __FILE__, __LINE__); //Returns the column type id on the specified index return(static_cast<unsigned>(PQftype(sql_result, column_idx))); }
// store the widths of the columns so we can restore them later void CWList::retrieveHeaderParams(CListCtrl& clc) { m_iColumnWidths.RemoveAll(); for(int c=0; c< getColumnCount(); c++) { m_iColumnWidths.Add(clc.GetColumnWidth(c)); } }
QString ResultSet::getColumnName(int column_idx) { //Throws an error in case the column index is invalid if(column_idx < 0 || column_idx >= getColumnCount()) throw Exception(ERR_REF_TUPLE_COL_INV_INDEX, __PRETTY_FUNCTION__, __FILE__, __LINE__); //Returns the column name on the specified index return(QString(PQfname(sql_result, column_idx))); }
sf::IntRect Tileset::getTileAsRect(unsigned long tileIndex) const { sf::IntRect spriteArea; if (tileIndex < getTileCount()) { unsigned long rowIndex = tileIndex / getColumnCount(); unsigned long columnIndex = tileIndex % getColumnCount(); unsigned long tileWidth = m_spacing.getLeft() + m_tileSize.getWidth() + m_spacing.getRight(); unsigned long tileHeight = m_spacing.getTop() + m_tileSize.getHeight() + m_spacing.getBottom(); spriteArea.left = static_cast<unsigned int>(m_margin.getLeft() + columnIndex * tileWidth); spriteArea.top = static_cast<unsigned int>(m_margin.getTop() + rowIndex * tileHeight); spriteArea.width = static_cast<unsigned int>(m_tileSize.getWidth()); spriteArea.height = static_cast<unsigned int>(m_tileSize.getHeight()); } return spriteArea; }
virtual QStringList getColumnNames() { QStringList ret; int count = getColumnCount(); for (int i = 0; i < count; ++i) { ret << getColumnName(i); } return ret; }
template <class R> void CMatrix<R>::combineVertices(int a, int b, const R& aa, const R& ab, const R& ba, const R& bb, int startColumn) { CMatrix& X = *this; for (int j = startColumn; j < getColumnCount(); j++) { R rA = aa * X(a, j) + ab * X(b, j); R rB = ba * X(a, j) + bb * X(b, j); X(a, j) = rA; X(b, j) = rB; } }
int ResultSet::getColumnSize(int column_idx) { //Raise an error in case the column index is invalid if(column_idx < 0 || column_idx >= getColumnCount()) throw Exception(ERR_REF_TUPLE_COL_INV_INDEX, __PRETTY_FUNCTION__, __FILE__, __LINE__); else if(current_tuple < 0 || current_tuple >= getTupleCount()) throw Exception(ERR_REF_INV_TUPLE_COLUMN, __PRETTY_FUNCTION__, __FILE__, __LINE__); //Retorns the column value length on the current tuple return(PQgetlength(sql_result, current_tuple, column_idx)); }
TableColumn* DefaultTableColumnModel::getColumn(const UInt32& columnIndex) const { if(columnIndex < getColumnCount()) { return getInternalColumns(columnIndex); } else { return NULL; } }
/************************************************************************* Layout the segments *************************************************************************/ void ListHeader::layoutSegments(void) { UVector2 pos(cegui_absdim(-d_segmentOffset), cegui_absdim(0.0f)); for (uint i = 0; i < getColumnCount(); ++i) { d_segments[i]->setPosition(pos); pos.d_x += d_segments[i]->getWidth(); } }
template <class R> void CMatrix<R>::transpose() { vector<CVector<R>*> newVertices = vector<CVector<R>*>(); for (int c = 0; c < getColumnCount(); c++) { newVertices.push_back(new CVector<R>(rows.size())); } for (unsigned int r = 0; r < rows.size(); r++) { for (int c = 0; c < getColumnCount(); c++) { (*newVertices[c])[r] = (*rows[r])[c]; } } for (unsigned int r = 0; r < rows.size(); r++) { delete rows[r]; } columnCount = rows.size(); rows = newVertices; }