コード例 #1
0
const char* CGUIGridList_Impl::GetItemText ( int iRow, int hColumn )
{
    try
    {
        CEGUI::MultiColumnList* pMultiColumnList = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow );
        if ( (uint)iRow >= pMultiColumnList->getRowCount() || (uint)GetColumnIndex( hColumn ) >= pMultiColumnList->getColumnCount() )
            return "";

        // Grab the item at the chosen row / column
        CEGUI::ListboxItem* pItem = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> getItemAtGridReference ( CEGUI::MCLGridRef ( iRow, GetColumnIndex ( hColumn ) ) );
        if ( pItem )
        {
            const char *szRet = pItem->getText().c_str ();

            if ( !m_bIgnoreTextSpacer )
            {
                unsigned char ucSpacerSize = (unsigned char)(strlen ( CGUIGRIDLIST_SPACER ));

                if ( GetColumnIndex ( hColumn ) == 0 ) {
                    // Make sure there is a spacer to skip
                    if ( strncmp ( szRet, CGUIGRIDLIST_SPACER, strlen ( CGUIGRIDLIST_SPACER ) ) == 0 )
                        szRet += ucSpacerSize;
                }
            }

            return szRet;
        }
    }
    catch ( CEGUI::Exception )
    {
        return "";
    }

    return "";
}
コード例 #2
0
nsresult
nsXULListCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
  NS_ENSURE_ARG_POINTER(aAttributes);

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  // "table-cell-index" attribute
  nsCOMPtr<nsIAccessibleTable> table;
  GetTable(getter_AddRefs(table));
  NS_ENSURE_STATE(table); // we expect to be in a listbox (table)

  PRInt32 rowIdx = -1;
  GetRowIndex(&rowIdx);
  PRInt32 colIdx = -1;
  GetColumnIndex(&colIdx);

  PRInt32 cellIdx = -1;
  table->GetCellIndexAt(rowIdx, colIdx, &cellIdx);

  nsAutoString stringIdx;
  stringIdx.AppendInt(cellIdx);
  nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::tableCellIndex,
                         stringIdx);

  return NS_OK;
}
コード例 #3
0
void CGUIGridList_Impl::RemoveColumn ( unsigned int uiColumn )
{
    try
    { 
        reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> removeColumn ( GetColumnIndex ( uiColumn ) );
    }
    catch ( CEGUI::Exception ) {}
}
コード例 #4
0
ファイル: Statement.cpp プロジェクト: hnefatl/Chatroom
	bool Statement::GetInt(const std::string &ColumnHeader, Nullable<int> &Out)
	{
		unsigned int ColumnIndex;
		if (!GetColumnIndex(ColumnHeader, ColumnIndex))
			return false;

		return GetInt(ColumnIndex, Out);
	}
コード例 #5
0
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetColumnIndex(PRInt32 *aColumnIndex)
{
  NS_ENSURE_ARG_POINTER(aColumnIndex);
  *aColumnIndex = -1;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  *aColumnIndex = GetColumnIndex();
  return NS_OK;
}
コード例 #6
0
ファイル: MuleListCtrl.cpp プロジェクト: windreamer/amule-dlp
int CMuleListCtrl::GetNewColumnIndex(int oldindex) const
{
	wxStringTokenizer oldcolumns(GetOldColumnOrder(), wxT(","), wxTOKEN_RET_EMPTY_ALL);

	while (oldcolumns.HasMoreTokens()) {
		wxString name = oldcolumns.GetNextToken();
		if (oldindex == 0) {
			return GetColumnIndex(name);
		}
		--oldindex;
	}
	return -1;
}
コード例 #7
0
void FWordCountReportData::SetEntry( int32 RowIndex, const FString& ColumnHeading, const FString& EntryString )
{
	int32 ColumnIndex = GetColumnIndex(ColumnHeading);
	if(INDEX_NONE != ColumnIndex)
	{
		SetEntry(RowIndex, ColumnIndex, EntryString);
	}
	else
	{
		ColumnIndex = AddColumn(&ColumnHeading);
		SetEntry(RowIndex, ColumnIndex, EntryString);
	}

}
コード例 #8
0
NS_IMETHODIMP
nsXULListCellAccessible::GetColumnHeaderCells(nsIArray **aHeaderCells)
{
  NS_ENSURE_ARG_POINTER(aHeaderCells);
  *aHeaderCells = nsnull;

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIAccessibleTable> table;
  GetTable(getter_AddRefs(table));
  NS_ENSURE_STATE(table); // we expect to be in a listbox (table)

  // Get column header cell from XUL listhead.
  nsAccessible *list = nsnull;

  nsRefPtr<nsAccessible> tableAcc(do_QueryObject(table));
  PRInt32 tableChildCount = tableAcc->GetChildCount();
  for (PRInt32 childIdx = 0; childIdx < tableChildCount; childIdx++) {
    nsAccessible *child = tableAcc->GetChildAt(childIdx);
    if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_LIST) {
      list = child;
      break;
    }
  }

  if (list) {
    PRInt32 colIdx = -1;
    GetColumnIndex(&colIdx);

    nsIAccessible *headerCell = list->GetChildAt(colIdx);
    if (headerCell) {
      nsresult rv = NS_OK;
      nsCOMPtr<nsIMutableArray> headerCells =
        do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
      NS_ENSURE_SUCCESS(rv, rv);

      headerCells->AppendElement(headerCell, PR_FALSE);
      NS_ADDREF(*aHeaderCells = headerCells);
      return NS_OK;
    }
  }

  // No column header cell from XUL markup, try to get it from ARIA markup.
  return nsAccUtils::GetHeaderCellsFor(table, this,
                                       nsAccUtils::eColumnHeaderCells,
                                       aHeaderCells);
}
コード例 #9
0
void CGUIGridList_Impl::Sort ( unsigned int uiColumn, SortDirection direction )
{
    reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> setSortColumn( GetColumnIndex ( uiColumn ) );

    switch ( direction )
    {
    case SortDirections::Ascending:
        reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> setSortDirection( CEGUI::ListHeaderSegment::Ascending );
        break;
    case SortDirections::Descending:
        reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> setSortDirection( CEGUI::ListHeaderSegment::Descending );
        break;
    default:
        reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> setSortDirection( CEGUI::ListHeaderSegment::None );
        break;
    }
}
コード例 #10
0
int dbReadInt(int did, char_t *table, char_t *column, int row, int *returnValue)
{
    int			colIndex, *pRow, tid;
    dbTable_t	*pTable;

    a_assert(table);
    a_assert(column);
    a_assert(returnValue);

    tid = dbGetTableId(0, table);
    a_assert(tid >= 0);

    /*
     *	Return -6 if table is not found
     */
    if (tid < 0) {
        return DB_ERR_TABLE_NOT_FOUND;
    }

    /*
     *	Return -7 if table id has been deleted
     */
    pTable = dbListTables[tid];
    if (pTable == NULL) {
        return DB_ERR_TABLE_DELETED;
    }

    a_assert(row >= 0);

    if ((row >= 0) && (row < pTable->nRows)) {
        colIndex = GetColumnIndex(tid, column);
        a_assert(colIndex >= 0);

        if (colIndex >= 0) {
            pRow = pTable->rows[row];
            if (pRow) {
                *returnValue = pRow[colIndex];
                return 0;
            }
            return DB_ERR_ROW_DELETED;
        }
        return DB_ERR_COL_NOT_FOUND;
    }

    return DB_ERR_ROW_NOT_FOUND;
}
コード例 #11
0
int dbWriteInt(int did, char_t *table, char_t *column, int row, int iData)
{
    int			tid, colIndex, *pRow;
    dbTable_t	*pTable;

    a_assert(table);
    a_assert(column);

    /*
     *	Make sure that this table exists
     */
    tid = dbGetTableId(0, table);
    a_assert(tid >= 0);

    if (tid < 0) {
        return DB_ERR_TABLE_NOT_FOUND;
    }

    pTable = dbListTables[tid];

    if (pTable) {
        /*
         *		Make sure that the column exists
         */
        colIndex = GetColumnIndex(tid, column);
        a_assert(colIndex >= 0);
        if (colIndex >= 0) {
            /*
             *			Make sure that the row exists
             */
            a_assert((row >= 0) && (row < pTable->nRows));
            if ((row >= 0) && (row < pTable->nRows)) {
                pRow = pTable->rows[row];
                if (pRow) {
                    pRow[colIndex] = iData;
                    return 0;
                }
                return DB_ERR_ROW_DELETED;
            }
            return DB_ERR_ROW_NOT_FOUND;
        }
        return DB_ERR_COL_NOT_FOUND;
    }

    return DB_ERR_TABLE_DELETED;
}
コード例 #12
0
// Finds a row index by single attribute value. This method can be slow since
// it may search linearly (and vertically) through the table. 
// FIXME: keep row indices for indexed rows in nDictionaries?
nArray<int> CValueTable::InternalFindRowIndicesByAttr(CAttrID AttrID, const CData& Value, bool FirstMatchOnly) const
{
	nArray<int> Result;
	int ColIdx = GetColumnIndex(AttrID);
	const CType* Type = GetColumnValueType(ColIdx);
	n_assert(Type == Value.GetType());
	for (int RowIdx = 0; RowIdx < GetRowCount(); RowIdx++)
	{
		if (IsRowValid(RowIdx))
		{
			void** pObj = GetValuePtr(ColIdx, RowIdx);
			if (Type->IsEqualT(Value.GetValueObjectPtr(), IsSpecialType(Type) ? (void*)pObj : *pObj))
			{
				Result.Append(RowIdx);
				if (FirstMatchOnly) return Result;
			}
		}
	}
	return Result;
}
コード例 #13
0
CGUIListItem* CGUIGridList_Impl::GetItem ( int iRow, int hColumn )
{
    try
    {
        CEGUI::MultiColumnList* pMultiColumnList = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow );
        if ( (uint)iRow >= pMultiColumnList->getRowCount() || (uint)GetColumnIndex( hColumn ) >= pMultiColumnList->getColumnCount() )
            return NULL;

        // Grab the item at the chosen row / column
        CEGUI::ListboxItem* pItem = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> getItemAtGridReference ( CEGUI::MCLGridRef ( iRow, GetColumnIndex ( hColumn ) ) );

        // If it exists, get the CGUIListItem by using the pool
        if ( pItem )
        {
            return GetListItem ( pItem );
        }
    }
    catch ( CEGUI::Exception )
    {}

    return NULL;
}
コード例 #14
0
int32 FWordCountReportData::AddColumn(const FString* ColumnHeading )
{
	int32 RowIndex = 0;
	if( ColumnHeading != NULL && HasHeader() )
	{
		// Check to see if a column with the provided header already exists
		int32 ExistingColumnIndex = GetColumnIndex(*ColumnHeading);
		if(ExistingColumnIndex != INDEX_NONE)
		{
			return ExistingColumnIndex;
		}

		Data[0].Add(*ColumnHeading);
		RowIndex++;
	}

	for(;RowIndex < Data.Num(); RowIndex++)
	{
		Data[RowIndex].Add(FString(TEXT("")));
	}

	return GetColumnCount() - 1;
}
コード例 #15
0
nsresult
nsXULTreeGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
  NS_ENSURE_ARG_POINTER(aAttributes);

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  // "table-cell-index" attribute
  nsCOMPtr<nsIAccessible> accessible;
  mParent->GetParent(getter_AddRefs(accessible));
  nsCOMPtr<nsIAccessibleTable> tableAccessible = do_QueryInterface(accessible);

  // XXX - temp fix for crash bug 516047
  if (!tableAccessible)
    return NS_ERROR_FAILURE;
    
  PRInt32 colIdx = GetColumnIndex();

  PRInt32 cellIdx = -1;
  tableAccessible->GetCellIndexAt(mRow, colIdx, &cellIdx);

  nsAutoString stringIdx;
  stringIdx.AppendInt(cellIdx);
  nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::tableCellIndex,
                         stringIdx);

  // "cycles" attribute
  PRBool isCycler = PR_FALSE;
  nsresult rv = mColumn->GetCycler(&isCycler);
  if (NS_SUCCEEDED(rv) && isCycler)
    nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::cycles,
                           NS_LITERAL_STRING("true"));

  return NS_OK;
}
コード例 #16
0
int dbSearchStr(int did, char_t *tablename,
                char_t *colName, char_t *value, int flags)
{
    int			tid, nRows, nColumns, column;
    dbTable_t	*pTable;

    a_assert(tablename);
    a_assert(colName);
    a_assert(value);

    tid = dbGetTableId(0, tablename);
    a_assert(tid >= 0);

    if ((tid >= 0) && (tid < dbMaxTables) && (dbListTables[tid] != NULL)) {
        pTable = dbListTables[tid];
    } else {
        return DB_ERR_TABLE_NOT_FOUND;
    }

    nColumns = pTable->nColumns;
    nRows = pTable->nRows;
    column = GetColumnIndex(tid, colName);
    a_assert (column >= 0);

    if (column >= 0) {
        char_t	*compareVal;
        int		row, *pRow;
        /*
         *		Scan through rows until we find a match.
         *		Note that some of these rows may be deleted!
         */
        row = 0;
        while (row < nRows) {
            pRow = pTable->rows[row];
            if (pRow) {
                compareVal = (char_t *)(pRow[column]);
                if (compareVal && (gstrcmp(compareVal, value) == 0)) {
                    return row;
                }

                /* Add by Dick Tam */
                /* In order to protect everything inside a directory */
                if (compareVal) {
                    if(gstrncmp(compareVal, value,gstrlen(compareVal)) == 0) {
                        return row;
                    }
                }
                /* Add by Dick Tam End */
            }
            row++;
        }
    } else {
        /*
         *		Return -2 if search column was not found
         */
        trace(3, T("DB: Unable to find column <%s> in table <%s>\n"),
              colName, tablename);
        return DB_ERR_COL_NOT_FOUND;
    }

    return -1;
}
コード例 #17
0
void CGUIGridList_Impl::SetItemImage ( int iRow, int hColumn, CGUIStaticImage* pImage )
{
    // Get the current item at that offset
    CGUIListItem* pItem = GetItem ( iRow, hColumn );
    if ( pItem != NULL )
    {
        pItem->SetImage ( pImage );
    }
    else
    //if ( pImage )
    {
        // If it doesn't, create it and set it in the gridlist
        CGUIListItem_Impl* pNewItem = new CGUIListItem_Impl ( "", CGUIListItem_Impl::ImageItem, (CGUIStaticImage_Impl*) pImage );
        CEGUI::ListboxItem* pListboxItem = pNewItem->GetListItem ();
        reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> setItem ( pListboxItem, CEGUI::MCLGridRef ( iRow, GetColumnIndex ( hColumn ) ), true );

        // Put our new item in the map
        m_Items [ pNewItem->GetListItem () ] = pNewItem;
    }
}
コード例 #18
0
ファイル: MuleListCtrl.cpp プロジェクト: windreamer/amule-dlp
void CMuleListCtrl::LoadSettings()
{
	wxCHECK_RET(!m_name.IsEmpty(), wxT("Cannot load settings for unnamed list"));

	wxConfigBase* cfg = wxConfigBase::Get();

	// Load sort order (including sort-column)
	m_sort_orders.clear();
	wxString sortOrders = cfg->Read(wxT("/eMule/TableOrdering") + m_name, wxEmptyString);
	wxString columnWidths = cfg->Read(wxT("/eMule/TableWidths") + m_name, wxEmptyString);

	// Prevent sorting from occuring when calling SetSorting
	MuleListCtrlCompare sortFunc = m_sort_func;
	m_sort_func = NULL;

	if (columnWidths.Find(wxT(':')) == wxNOT_FOUND) {
		// Old-style config entries...
		ParseOldConfigEntries(sortOrders, columnWidths);
	} else {
		// Sort orders
		wxStringTokenizer tokens(sortOrders, wxT(","));
		// Sort orders are stored in order primary, secondary, ...
		// We want to apply them with SetSorting(), so we have to apply them in reverse order,
		// so that the primary order is applied last and wins.
		// Read them with tokenizer and store them in a list in reverse order.
		CStringList tokenList;
		while (tokens.HasMoreTokens()) {
			tokenList.push_front(tokens.GetNextToken());
		}
		for (CStringList::iterator it = tokenList.begin(); it != tokenList.end(); it++) {
			wxString token = *it;
			wxString name = token.BeforeFirst(wxT(':'));
			long order = StrToLong(token.AfterFirst(wxT(':')).BeforeLast(wxT(':')));
			long alt = StrToLong(token.AfterLast(wxT(':')));
			int col = GetColumnIndex(name);
			if (col >= 0) {
				SetSorting(col, (order ? SORT_DES : 0) | (alt ? SORT_ALT : 0));
			}
		}

		// Column widths
		wxStringTokenizer tkz(columnWidths, wxT(","));
		while (tkz.HasMoreTokens()) {
			wxString token = tkz.GetNextToken();
			wxString name = token.BeforeFirst(wxT(':'));
			long width = StrToLong(token.AfterFirst(wxT(':')));
			int col = GetColumnIndex(name);
			if (col >= 0) {
				if (col >= (int) m_column_sizes.size()) {
					m_column_sizes.resize(col + 1, 0);
				}
				m_column_sizes[col] = abs(width);
				SetColumnWidth(col, (width > 0) ? width : 0);
			}
		}
	}

	// Must have at least one sort-order specified
	if (m_sort_orders.empty()) {
		m_sort_orders.push_back(CColPair(0, 0));
	}

	// Re-enable sorting and resort the contents (if any).
	m_sort_func = sortFunc;
	SortList();	
}
コード例 #19
0
bool CGUIGridList_Impl::IsColumnSegmentSizingEnabled ( int hColumn )
{
    try
    {
        return  reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> isUserColumnSegmentSizingEnabled ( GetColumnIndex ( hColumn ) );
    }
    catch ( CEGUI::Exception )
    {
        return false;
    } 
}
コード例 #20
0
CColumnValue CMySQL::GetColumnValue( const char *pColumnName )
{
	return CColumnValue( this, GetColumnIndex( pColumnName ) );
}
コード例 #21
0
int dbLoad(int did, char_t *filename, int flags)
{
    gstat_t		sbuf;
    char_t		*buf, *keyword, *value, *path, *ptr;
    char_t		*tablename;
    int			fd, tid, row;
    dbTable_t	*pTable;

    a_assert(did >= 0);

    fmtAlloc(&path, FNAMESIZE, T("%s/%s"), basicGetProductDir(), filename);
    trace(4, T("DB: About to read data file <%s>\n"), path);

    if (gstat(path, &sbuf) < 0) {
        trace(3, T("DB: Failed to stat persistent data file.\n"));
        bfree(B_L, path);
        return -1;
    }

    fd = gopen(path, O_RDONLY | O_BINARY, 0666);
    bfree(B_L, path);

    if (fd < 0) {
        trace(3, T("DB: No persistent data file present.\n"));
        return -1;
    }

    if (sbuf.st_size <= 0) {
        trace(3, T("DB: Persistent data file is empty.\n"));
        gclose(fd);
        return -1;
    }
    /*
     *	Read entire file into temporary buffer
     */
    buf = balloc(B_L, sbuf.st_size + 1);
#ifdef CE
    if (readAscToUni(fd, &buf, sbuf.st_size) != (int)sbuf.st_size) {
#else
    if (gread(fd, buf, sbuf.st_size) != (int)sbuf.st_size) {
#endif
        trace(3, T("DB: Persistent data read failed.\n"));
        bfree(B_L, buf);
        gclose(fd);
        return -1;
    }

    gclose(fd);
    *(buf + sbuf.st_size) = '\0';

    row = -1;
    tid = -1;
    pTable = NULL;
    ptr = gstrtok(buf, T("\n"));
    tablename = NULL;

    do {
        if (crack(ptr, &keyword, &value) < 0) {
            trace(5, T("DB: Failed to crack line %s\n"), ptr);
            continue;
        }

        a_assert(keyword && *keyword);

        if (gstrcmp(keyword, KEYWORD_TABLE) == 0) {
            /*
             *			Table name found, check to see if it's registered
             */
            if (tablename) {
                bfree(B_L, tablename);
            }

            tablename = bstrdup(B_L, value);
            tid = dbGetTableId(did, tablename);

            if (tid >= 0) {
                pTable = dbListTables[tid];
            } else {
                pTable = NULL;
            }

        } else if (gstrcmp(keyword, KEYWORD_ROW) == 0) {
            /*
             *			Row/Record indicator found, add a new row to table
             */
            if (tid >= 0) {
                int nRows = dbGetTableNrow(did, tablename);

                if (dbSetTableNrow(did, tablename, nRows + 1) == 0) {
                    row = nRows;
                }
            }

        } else if (row != -1) {
            /*
             *			some other data found, assume it's a COLUMN=value
             */
            int nColumn = GetColumnIndex(tid, keyword);

            if ((nColumn >= 0) && (pTable != NULL)) {
                int nColumnType = pTable->columnTypes[nColumn];
                if (nColumnType == T_STRING) {
                    dbWriteStr(did, tablename, keyword, row, value);
                } else {
                    dbWriteInt(did, tablename, keyword, row, gstrtoi(value));
                }
            }
        }
    } while ((ptr = gstrtok(NULL, T("\n"))) != NULL);

    if (tablename) {
        bfree(B_L, tablename);
    }

    bfree(B_L, buf);

    return 0;
}

/******************************************************************************/
/*
 *	Return a table id given the table name
 */

int dbGetTableId(int did, char_t *tablename)
{
    int			tid;
    dbTable_t	*pTable;

    a_assert(tablename);

    for (tid = 0; (tid < dbMaxTables); tid++) {
        if ((pTable = dbListTables[tid]) != NULL) {
            if (gstrcmp(tablename, pTable->name) == 0) {
                return tid;
            }
        }
    }

    return -1;
}
コード例 #22
0
void CGUIGridList_Impl::AutoSizeColumn ( unsigned int hColumn )
{
    try
    {
        reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> autoSizeColumnHeader ( GetColumnIndex ( hColumn ) );
    }
    catch ( CEGUI::Exception )
    {}
}
コード例 #23
0
int dbWriteStr(int did, char_t *table, char_t *column, int row, char_t *s)
{
    int			tid, colIndex;
    int			*pRow;
    char_t		*ptr;
    dbTable_t	*pTable;

    a_assert(table);
    a_assert(column);

    tid = dbGetTableId(0, table);
    a_assert(tid >= 0);

    if (tid < 0) {
        return DB_ERR_TABLE_NOT_FOUND;
    }

    /*
     *	Make sure that this table exists
     */
    pTable = dbListTables[tid];
    a_assert(pTable);
    if (!pTable) {
        return DB_ERR_TABLE_DELETED;
    }

    /*
     *	Make sure that this column exists
     */
    colIndex = GetColumnIndex(tid, column);
    if (colIndex < 0) {
        return DB_ERR_COL_NOT_FOUND;
    }

    /*
     *	Make sure that this column is a string column
     */
    if (pTable->columnTypes[colIndex] != T_STRING) {
        return DB_ERR_BAD_FORMAT;
    }

    /*
     *	Make sure that the row exists
     */
    a_assert((row >= 0) && (row < pTable->nRows));
    if ((row >= 0) && (row < pTable->nRows)) {
        pRow = pTable->rows[row];
    } else {
        return DB_ERR_ROW_NOT_FOUND;
    }

    if (!pRow) {
        return DB_ERR_ROW_DELETED;
    }

    /*
     *	If the column already has a value, be sure to delete it to prevent
     *	memory leaks.
     */
    if (pRow[colIndex]) {
        bfree(B_L, (char_t *) pRow[colIndex]);
    }

    /*
     *	Make sure we make a copy of the string to write into the column.
     *	This allocated string will be deleted when the row is deleted.
     */
    ptr = bstrdup(B_L, s);
    pRow[colIndex] = (int)ptr;

    return 0;
}
コード例 #24
0
const char* CGUIGridList_Impl::GetColumnTitle ( int hColumn )
{
    return reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> getColumnHeaderTitle ( GetColumnIndex ( hColumn ) );
}
コード例 #25
0
void CPage_Node_Movement::SaveData()
{

	bool bTurnVolumeModified = false;
	UpdateData(1);

	std::map<int, int> IncomingLinkMap;

	DTANode* pNode  = m_pDoc->m_NodeNoMap [m_CurrentNodeID];

	if(	pNode->m_CycleLengthInSecond  != m_CycleLengthInSec || pNode->m_SignalOffsetInSecond   != m_Offset)
	{
		m_pDoc->Modify (true);

		pNode->m_SignalOffsetInSecond   = m_Offset;
	}


	for (unsigned int i=0;i< pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector .size();i++)
	{
		int turning_prohibition_flag=  pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].turning_prohibition_flag;
		
		int PrevQEM_lanes = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_Lanes;
		int QEM_Phase1 =  pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_Phase1;

	
		int obs_turn_hourly_count = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].obs_turn_hourly_count  ;
		int obs_turn_delay = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].obs_turn_delay  ;

		DTA_SIG_MOVEMENT movement_approach_turn = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].movement_approach_turn  ;
		int effective_green=  (int)(pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_EffectiveGreen);
		int saturation_flow_rate=  (int)(pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_SatFlow);

		DTANodeMovement movement = pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i];

		int colume_index = 3;

		CString str;

		str = m_ListCtrl.GetItemText (i,GetColumnIndex("Direction"));

		pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].movement_approach_turn = m_pDoc->GetTurnDirectionFromString(str);

		str = m_ListCtrl.GetItemText (i,GetColumnIndex("Prohibition"));

		if(str.Find("Prohibited") == -1)  // not found 
			pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].turning_prohibition_flag  = 0;
		else
			pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].turning_prohibition_flag  = 1;


		str = m_ListCtrl.GetItemText (i,GetColumnIndex("# of Lanes"));
		pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_Lanes = atoi(str);


		if(m_bSigalizedNode == true)
		{
		str = m_ListCtrl.GetItemText (i,GetColumnIndex("Green Start Time"));
		pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_StartTime  = atoi(str);

		str = m_ListCtrl.GetItemText (i,GetColumnIndex("Green End Time"));
		pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_EndTime  = atoi(str);

		str = m_ListCtrl.GetItemText (i,GetColumnIndex("Sat Flow Rate Per Lane Group"));
		pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].QEM_SatFlow   = atoi(str);
		}

		if(movement_approach_turn != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].movement_approach_turn ||
			obs_turn_hourly_count != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].obs_turn_hourly_count  ||
			obs_turn_delay != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].obs_turn_delay  || 
			turning_prohibition_flag != pNode->m_MovementDataMap[m_TimingPlanName].m_MovementVector[i].turning_prohibition_flag
	)

		{
			m_bModifiedFlag = true;
			m_pDoc->Modify (true);
		}

	}

}
コード例 #26
0
ファイル: asd.WrapperDLL.cpp プロジェクト: altseed/Altseed
int WrapperDLL::Tool_GetColumnIndex(void* self){
	auto self_ = (Tool*)self;
	auto ret = self_->GetColumnIndex();
	return ret;
};
コード例 #27
0
	virtual CColumnValue	GetColumnValue( const char *pColumnName )
	{
		return CColumnValue( this, GetColumnIndex( pColumnName ) );
	}
コード例 #28
0
ファイル: SequencePacker.cpp プロジェクト: Microsoft/CNTK
MBLayoutPtr SequencePacker::PackDenseStream(const StreamBatch& batch, size_t streamIndex)
{
    assert(m_outputStreamDescriptions[streamIndex]->m_storageType == StorageType::dense);
    const auto& stream = m_inputStreamDescriptions[streamIndex];
    auto& buffer = m_streamBuffers[m_currentBufferIndex][streamIndex];
    size_t sampleSize = GetSampleSize(m_outputStreamDescriptions[streamIndex]);
    auto pMBLayout = CreateMBLayout(batch);
    size_t requiredSize = pMBLayout->GetNumCols() * sampleSize;
    if (buffer.m_size < requiredSize)
    {
        buffer.Resize(requiredSize);
    }

    auto elementSize = GetSizeByType(stream->m_elementType);

    const auto& sequenceInfos = pMBLayout->GetAllSequences();

    // Iterate over sequences in the layout, copy samples from the
    // source sequences into the buffer (at appropriate offsets).
    for (int i = 0; i < sequenceInfos.size(); ++i)
    {
        const auto& sequenceInfo = sequenceInfos[i];
        // skip gaps
        if (sequenceInfo.seqId == GAP_SEQUENCE_ID)
        {
            continue;
        }

        const auto& sequence = batch[sequenceInfo.seqId];
        size_t numSamples = sequence->m_numberOfSamples;
        assert(numSamples == sequenceInfo.GetNumTimeSteps());

        char* bufferPtr = buffer.m_data.get();
        // Iterate over all samples in the sequence, keep track of the sample offset (which is especially
        // important for sparse input, where offset == number of preceding nnz elements).
        for (size_t sampleIndex = 0, sampleOffset = 0; sampleIndex < numSamples; ++sampleIndex)
        {
            // Compute the offset into the destination buffer, using the layout information 
            // to get the column index corresponding to the given sample.
            auto destinationOffset = pMBLayout->GetColumnIndex(sequenceInfo, sampleIndex) * sampleSize;
            // verify that there's enough space left in the buffer to fit a full sample.
            assert(destinationOffset <= buffer.m_size - sampleSize);
            auto* destination = bufferPtr + destinationOffset;
            if (stream->m_storageType == StorageType::dense)
            {
                // verify that the offset (an invariant for dense).
                assert(sampleOffset == sampleIndex * sampleSize);
                PackDenseSample(destination, sequence, sampleOffset, sampleSize);
                sampleOffset += sampleSize;
            }
            else if (stream->m_storageType == StorageType::sparse_csc)
            {
                // TODO: make type casts members of the SparseSequenceData
                SparseSequenceDataPtr sparseSequence = static_pointer_cast<SparseSequenceData>(sequence);
                // make sure that the sequence meta-data is correct.
                assert(numSamples == sparseSequence->m_nnzCounts.size());
                PackSparseSampleAsDense(destination, sparseSequence, sampleIndex, sampleOffset, sampleSize, elementSize);
                // move the offset by nnz count of the sample.
                sampleOffset += sparseSequence->m_nnzCounts[sampleIndex];
                // verify that the offset is within the bounds (less or equal 
                // to the total nnz count of the sequence).
                assert(sampleOffset <= sparseSequence->m_totalNnzCount);
            }
            else
            {
                RuntimeError("Storage type %d is not supported.", (int)stream->m_storageType);
            }
        }
    }

    return pMBLayout;
}
コード例 #29
0
ファイル: emfdb.c プロジェクト: LIUSHILI/Graduationceremony
int dbSearchStr(int did, char_t *tablename, 
	char_t *colName, char_t *value, int flags)
{
	int			tid, nRows, nColumns, column;
   int match = 0;
	dbTable_t	*pTable;

	a_assert(tablename);
	a_assert(colName);
	a_assert(value);

	tid = dbGetTableId(0, tablename);
	a_assert(tid >= 0);

	if ((tid >= 0) && (tid < dbMaxTables) && (dbListTables[tid] != NULL)) {
		pTable = dbListTables[tid];
	} else {
		return DB_ERR_TABLE_NOT_FOUND;
	}
	
	nColumns = pTable->nColumns;
	nRows = pTable->nRows;
	column = GetColumnIndex(tid, colName);
	a_assert (column >= 0);

	if (column >= 0) {
		char_t	*compareVal;
		int		row, *pRow;
/*
 *		Scan through rows until we find a match.
 *		Note that some of these rows may be deleted!
 */
		row = 0;
		while (row < nRows) {
			pRow = pTable->rows[row];
			if (pRow) {
				compareVal = (char_t *)(pRow[column]); 
            if (NULL != compareVal)
            {
              if (DB_CASE_INSENSITIVE == flags)
              {
                 match = gstricmp(compareVal, value);
              }
              else
              {
                 match = gstrcmp(compareVal, value);
              }
              if (0 == match)
              {
                 return row;
              }
            }
			}
			row++;
		}
	} else { 
/*
 *		Return -2 if search column was not found
 */
		trace(3, T("DB: Unable to find column <%s> in table <%s>\n"), 
			colName, tablename);
		return DB_ERR_COL_NOT_FOUND;
	}

	return -1;
}
コード例 #30
0
int CGUIGridList_Impl::SetItemText ( int iRow, int hColumn, const char* szText, bool bNumber, bool bSection, bool bFast, const char* szSortText )
{
    try
    {
        CEGUI::MultiColumnList* win = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow );

        // Get the current item at that offset and set the text
        CGUIListItem_Impl* pItem = reinterpret_cast < CGUIListItem_Impl* > ( GetItem ( iRow, hColumn ) );
        if ( pItem )
        {
            if ( bSection )
            {
                // Set section properties
                pItem->SetFont ( "default-bold-small" );
                pItem->SetDisabled ( true );
                pItem->SetText ( szText, szSortText );
            }
            else
            {
                pItem->SetFont ( "default-normal" );
                pItem->SetDisabled ( false );

                if ( GetColumnIndex ( hColumn ) == 0 )
                {
                    // Enable some spacing on regular items, if this is the first item
                    
                    char szBuf[CGUIGRIDLIST_MAX_TEXT_LENGTH];
                    if ( m_bIgnoreTextSpacer )
                    {
                        snprintf ( szBuf, CGUIGRIDLIST_MAX_TEXT_LENGTH - 1, "%s", szText );
                    }
                    else
                    {
                        snprintf ( szBuf, CGUIGRIDLIST_MAX_TEXT_LENGTH - 1, "%s%s", CGUIGRIDLIST_SPACER, szText );
                    }

                    szBuf[CGUIGRIDLIST_MAX_TEXT_LENGTH-1] = NULL;

                    pItem->SetText ( szBuf, szSortText );
                }
                else
                {
                    pItem->SetText ( szText, szSortText );
                }
            }
        }
        else
        {
            // If it doesn't, create it and set it in the gridlist
            pItem = new CGUIListItem_Impl ( szText, bNumber );

            if ( szSortText )
                pItem->SetText ( szText, szSortText );

            CEGUI::ListboxItem* pListboxItem = pItem->GetListItem ();
            win->setItem ( pListboxItem, CEGUI::MCLGridRef ( iRow, GetColumnIndex ( hColumn ) ), bFast );

            // Put our new item into the map
            m_Items [ pItem->GetListItem () ] = pItem;

            if ( bSection )
            {
                // Set section properties
                pItem->SetFont ( "default-bold-small" );
                pItem->SetDisabled ( true );
            }
            else if ( GetColumnIndex ( hColumn ) == 0 )
            {
                // Enable some spacing on regular items, if this is the first item
                char szBuf[CGUIGRIDLIST_MAX_TEXT_LENGTH];

                if ( m_bIgnoreTextSpacer )
                {
                    snprintf ( szBuf, CGUIGRIDLIST_MAX_TEXT_LENGTH-1, "%s", szText );
                }
                else
                {
                    snprintf ( szBuf, CGUIGRIDLIST_MAX_TEXT_LENGTH-1, "%s%s", CGUIGRIDLIST_SPACER, szText );
                }

                szBuf[CGUIGRIDLIST_MAX_TEXT_LENGTH-1] = NULL;               
                pItem->SetText ( szBuf, szSortText );
            }
        }

        // If the list is sorted and we just changed an item in the sorting column,
        // re-sort the list.
        if ( win->getSortDirection () != SortDirections::None &&
             win->getSortColumn () == GetColumnIndex ( hColumn ) )
        {
            win->setSortColumn ( win->getSortColumn () );
            return GetItemRowIndex ( pItem );
        }
        else
        {
            return iRow;
        }
    }
    catch ( CEGUI::Exception ) {}

    return 0;
}