void CValueTable::Clear() { // This is a lot like DeleteRowData but checks type only once per column for (int ColIdx = 0; ColIdx < Columns.Size(); ColIdx++) { const CType* Type = GetColumnValueType(ColIdx); //???use Type->Delete()? virtual call even if type will call empty destructor like !int() if (Type == TString) for (int RowIdx = 0; RowIdx < NumRows; RowIdx++) DATA_TYPE_NV(nString)::Delete(GetValuePtr(ColIdx, RowIdx)); else if (Type == DATA_TYPE(CBuffer)) for (int RowIdx = 0; RowIdx < NumRows; RowIdx++) DATA_TYPE_NV(CBuffer)::Delete(GetValuePtr(ColIdx, RowIdx)); else if (!Type) for (int RowIdx = 0; RowIdx < NumRows; RowIdx++) ((CData*)GetValuePtr(ColIdx, RowIdx))->Clear(); } SAFE_FREE(ValueBuffer); SAFE_FREE(RowStateBuffer); NumRows = 0; AllocatedRows = 0; //???need? /* FirstNewRowIndex = MAX_SDWORD; NewRowsCount = 0; FirstDeletedRowIndex = MAX_SDWORD; DeletedRowsCount = 0; */ Flags.Clear(_IsModified); Flags.Clear(_HasModifiedRows); //UserData.Clear(); }
// Clears all data associated with cells of one row (string, blob and guid) void CValueTable::DeleteRowData(int RowIdx) { for (int ColIdx = 0; ColIdx < GetNumColumns(); ColIdx++) { const CType* Type = GetColumnID(ColIdx)->GetType(); if (Type == TString) DATA_TYPE_NV(nString)::Delete(GetValuePtr(ColIdx, RowIdx)); else if (Type == DATA_TYPE(CBuffer)) DATA_TYPE_NV(CBuffer)::Delete(GetValuePtr(ColIdx, RowIdx)); else if (!Type) ((CData*)GetValuePtr(ColIdx, RowIdx))->Clear(); } }
// Compress function always creates local time. void Library_corlib_native_System_DateTime::Compress( CLR_RT_StackFrame& stack, const SYSTEMTIME& st ) { NATIVE_PROFILE_CLR_CORE(); CLR_INT64* val = GetValuePtr( stack ); if(val) { *val = Time_FromSystemTime( &st ); } }
BOOL CRKey::Get(LPCTSTR pName, CRKey *pRk) {_STTEX(); if ( !pRk ) return FALSE; // Lose current variables pRk->Destroy(); // Read in new variables return pRk->ReadInline( (LPBYTE)GetValuePtr( pName ), GetValueSize( pName ) ); }
HRESULT Library_corlib_native_System_TimeSpan::_ctor___VOID__I4__I4__I4__I4__I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock* pArgs = &(stack.Arg1()); CLR_INT64* val = GetValuePtr( stack ); FAULT_ON_NULL(val); ConstructTimeSpan( val, pArgs[ 0 ].NumericByRef().s4, pArgs[ 1 ].NumericByRef().s4, pArgs[ 2 ].NumericByRef().s4, pArgs[ 3 ].NumericByRef().s4, pArgs[ 4 ].NumericByRef().s4 ); TINYCLR_NOCLEANUP(); }
BOOL CReg::Get(LPCTSTR pKey, LPCTSTR pName, CReg *pReg, BOOL bMerge ) {_STTEX(); if ( !pReg ) return FALSE; if ( !bMerge ) pReg->Destroy(); return pReg->ReadInline( (LPBYTE)GetValuePtr( pKey, pName ), GetValueSize( pKey, pName ) ); }
void Library_corlib_native_System_DateTime::Expand( CLR_RT_StackFrame& stack, SYSTEMTIME& st ) { NATIVE_PROFILE_CLR_CORE(); CLR_INT64* val = GetValuePtr( stack ); if(val) { // The most significant bit of *val keeps flag if time is UTC. // We cannot change *val, so we create copy and clear the bit. CLR_INT64 ticks = *val & s_TickMask; Time_ToSystemTime( ticks, &st ); } }
HRESULT Library_corlib_native_System_TimeSpan::ToString___STRING( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); char rgBuffer[ 128 ]; LPSTR szBuffer = rgBuffer; size_t iBuffer = ARRAYSIZE(rgBuffer); CLR_INT64* val = GetValuePtr( stack ); FAULT_ON_NULL(val); Time_TimeSpanToStringEx( *val, szBuffer, iBuffer ); TINYCLR_SET_AND_LEAVE(stack.SetResult_String( rgBuffer )); TINYCLR_NOCLEANUP(); }
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); } }
// 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; }
CLR_INT64* Library_corlib_native_System_TimeSpan::GetValuePtr( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); return GetValuePtr( stack.Arg0() ); }