Exemplo n.º 1
0
void CValueTable::SetValue(int ColIdx, int RowIdx, const CData& Val)
{
	const CType* Type = GetColumnValueType(ColIdx);
	n_assert(!Type || Type == Val.GetType());
	n_assert(IsRowValid(RowIdx));
	
	void** pObj = GetValuePtr(ColIdx, RowIdx);
	if (Type) Type->Copy(IsSpecialType(Type) ? (void**)&pObj : pObj, Val.GetValueObjectPtr());
	else *(CData*)pObj = Val;
	
	if (Flags.Is(_TrackModifications))
	{
		RowStateBuffer[RowIdx] |= UpdatedRow;
		Flags.Set(_IsModified);
		Flags.Set(_HasModifiedRows);
	}
}
Exemplo n.º 2
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;
}