Exemple #1
0
const std::string& RA_RichPresenceInterpretter::Lookup( const std::string& sName, const std::string& sMemString ) const
{
	static std::string sReturnVal;
	sReturnVal.clear();

	//	check lookups
	for( size_t i = 0; i < m_lookups.size(); ++i )
	{
		if( m_lookups.at( i ).Description().compare( sName ) == 0 )
		{
			//	This lookup! (ugh must be non-const)
			char buffer[1024];
			sprintf_s( buffer, 1024, (char*)sMemString.c_str() );

			ValueSet nValue;
			nValue.ParseMemString( buffer );
			sReturnVal = m_lookups.at( i ).Lookup( static_cast<DataPos>( nValue.GetValue() ) );

			return sReturnVal;
		}
	}

	//	check formatters
	for( size_t i = 0; i < m_formats.size(); ++i )
	{
		if( m_formats.at( i ).Description().compare( sName ) == 0 )
		{
			//	This lookup! (ugh must be non-const)
			char buffer[1024];
			sprintf_s( buffer, 1024, (char*)sMemString.c_str() );

			ValueSet nValue;
			nValue.ParseMemString( buffer );
			sReturnVal = m_formats.at( i ).Lookup( static_cast<DataPos>( nValue.GetValue() ) );

			return sReturnVal;
		}
	}

	return sReturnVal;
}
bool 
StorageElementArray0::WriteYourselfIntoCreateArrayDefinition(ValueSet &values, 
															 RMSTR_CREATE_ARRAY_DEFINITION *pDef,
															 U32 , 
															 ManagedObject	*  ){

	ValueSet		*pSelf, *pMembers, *pSpares;
	U32				memberIndex, i;
	DesignatorId	id;

	pSelf		= (ValueSet *)values.GetValue(SSAPI_STORAGE_MANAGER_ADD_ARRAY_ARRAY_OBJECT);
	pMembers	= (ValueSet *)values.GetValue(SSAPI_STORAGE_MANAGER_ADD_ARRAY_MEMBER_ID_VECTOR);
	pSpares		= (ValueSet *)values.GetValue(SSAPI_STORAGE_MANAGER_ADD_ARRAY_SPARE_ID_VECTOR);

	*((ValueSet *)this) = *pSelf;
	BuildYourselfFromYourValueSet();
	memset( pDef, 0, sizeof(RMSTR_CREATE_ARRAY_DEFINITION) );

	pDef->raidLevel		= RAID0;
	pDef->totalCapacity	= ( m_memberCapacity * pMembers->GetCount() ) / BLOCK_SIZE;
	pDef->memberCapacity= m_memberCapacity / BLOCK_SIZE;
	pDef->peckingOrder	= (RAID_PECKING_ORDER)m_peckingOrder;
	pDef->numberMembers	= pMembers->GetCount();
	pDef->numberSpares	= pSpares? pSpares->GetCount() : 0;
	pDef->dataBlockSize	= m_dataBlockSize / BLOCK_SIZE;

	for( i = memberIndex = 0; i < pMembers->GetCount(); i++, memberIndex++ ){
		pMembers->GetGenericValue( (char *)&id, sizeof(id), i );
		pDef->arrayMembers[memberIndex] = id.GetRowId().GetRowID();
	}

	for( i = 0; pSpares && (i < pSpares->GetCount()); i++, memberIndex++ ){
		pSpares->GetGenericValue( (char *)&id, sizeof(id), i );
		pDef->arrayMembers[memberIndex] = id.GetRowId().GetRowID();
	}

	return true;
}
bool
IntVectorFilter::BuildYourselfFromAValueSet( ValueSet &valueSet ) {

    int			comparatorType, index;
    ValueSet	*pValueVector;
    bool		rc;
    I64			*pValue, value;

    rc = Filter::BuildYourselfFromAValueSet( valueSet );

    ClearValueVector();
    delete m_pComparator;

    valueSet.GetInt( SSAPI_INT_FLOAT_VECTOR_FILTER_FID_FIELD_ID, &m_fieldId );
    valueSet.GetInt( SSAPI_INT_FLOAT_VECTOR_FILTER_FID_COMPARATOR_TYPE, &comparatorType );
    m_pComparator = new Comparator( (Comparator::COMPARATOR_TYPE)comparatorType );

    pValueVector	= (ValueSet *)valueSet.GetValue( SSAPI_INT_FLOAT_VECTOR_FILTER_FID_VALUE_VECTOR );

    if( !pValueVector )
        return false;

    for( index = 0; index < pValueVector->GetCount(); index++ ) {
        if( !pValueVector->GetInt64( index, &value ) ) {
            int i;
            if( !pValueVector->GetInt( index, (int *)&i) )
                return false;
            else
                value = i;
        }

        pValue = new I64;
        *pValue = value;
        m_pValueVector->AddAt( (CONTAINER_ELEMENT)pValue, index );
    }

    return rc;
}
Filter::FILTER_RC
IntVectorFilter::DoesApply( ValueSet &valueSet ) {

    U32			index;
    I64			*pValue;
    ValueSet	*pVector;

    if( !m_pValueVector )
        return NO_MORE_ITEMS_WILL_APPLY;

    pVector = (ValueSet *)valueSet.GetValue( m_fieldId );
    if( !pVector->GetCount() && !m_pValueVector->Count() )
        return APPLIES;

    for( index = 0; index < m_pValueVector->Count(); index++ ) {
        if( !m_pValueVector->GetAt( (CONTAINER_ELEMENT &)pValue, index ) )
            return DOES_NOT_APPLY;

        if( m_pComparator->DoesApply( &valueSet, m_fieldId, *pValue ) )
            return APPLIES;
    }

    return DOES_NOT_APPLY;
}