Пример #1
0
ECode AttributesImpl::RemoveAttribute(
    /* [in] */ Int32 index)
{
    if (index >= 0 && index < mLength) {
        if (index < mLength - 1) {

            for(Int32 i = index * 5; i < (mLength - 1) * 5; i++) {
                (*mData)[i] = (*mData)[i + 5];
            }
            //System.Arraycopy(data, (index+1)*5, data, index*5, (mLength-index-1) * 5);
        }

        index = (mLength - 1) * 5;

        (*mData)[index++] = NULL;
        (*mData)[index++] = NULL;
        (*mData)[index++] = NULL;
        (*mData)[index++] = NULL;
        (*mData)[index] = NULL;

        mLength--;
    } else {
        return BadIndex(index);
    }

    return NOERROR;
}
Пример #2
0
char
SQLTypeAdapter::at(size_type i) const throw(std::out_of_range)
{
	if (buffer_) {
		if (i <= length()) {
			return *(buffer_->data() + i);
		}
		else {
			throw BadIndex("Not enough chars in SQLTypeAdapter", int(i),
					int(length()));
		}
	}
	else {
		throw BadIndex("SQLTypeAdapter buffer not initialized", int(i), -1);
	}
}
Пример #3
0
size_t CResourceRefArray::FindResourceName( RES_TYPE restype, LPCTSTR pszKey ) const
{
	ADDTOCALLSTACK("CResourceRefArray::FindResourceName");
	// Is this resource already in the list ?
	CResourceLink * pResourceLink = dynamic_cast <CResourceLink *>( g_Cfg.ResourceGetDefByName( restype, pszKey ));
	if ( pResourceLink == NULL )
		return BadIndex();
	return FindPtr(pResourceLink);
}
Пример #4
0
void Matrix::set (int i, int j, double n)
{
   if (i >= height || j >= width)
   {
      std::cout << i <<  ' ' << height << ' ' << j << ' ' << width << ' ' << n << std::endl;
      throw BadIndex();
   }
   mElements[i*width + j] = n;
}
Пример #5
0
double Matrix::get (int i, int j) const
{
   if (i >= height || j >= width)
   {
      std::cout << i << ' ' << j << std::endl;
      std::cout << height << ' ' << width << std::endl;
      throw BadIndex();
   }

   return mElements[i*width + j];
}
Пример #6
0
ECode AttributesImpl::SetValue(
    /* [in] */ Int32 index,
    /* [in] */ const String& value)
{
    if (index >= 0 && index < mLength) {
        (*mData)[index*5+4] = value;
    } else {
        return BadIndex(index);
    }

    return NOERROR;
}
Пример #7
0
ECode AttributesImpl::SetQName(
    /* [in] */ Int32 index,
    /* [in] */ const String& qName)
{
    if (index >= 0 && index < mLength) {
        (*mData)[index*5+2] = qName;
    } else {
        return BadIndex(index);
    }

    return NOERROR;
}
Пример #8
0
ECode AttributesImpl::SetURI(
    /* [in] */ Int32 index,
    /* [in] */ const String& uri)
{
    if (index >= 0 && index < mLength) {
        (*mData)[index*5] = uri;
    } else {
        return BadIndex(index);
    }

    return NOERROR;
}
Пример #9
0
size_t CResourceQtyArray::Load(LPCTSTR pszCmds)
{
	ADDTOCALLSTACK("CResourceQtyArray::Load");
	//	clear-before-load in order not to mess with the previous data
	if ( !m_mergeOnLoad )
	{
		RemoveAll();
	}

	// 0 = clear the list.
	size_t iValid = 0;
	ASSERT(pszCmds);
	while ( *pszCmds )
	{
		if ( *pszCmds == '0' && 
			( pszCmds[1] == '\0' || pszCmds[1] == ',' ))
		{
			RemoveAll();	// clear any previous stuff.
			pszCmds ++;
		}
		else
		{
			CResourceQty res;
			if ( !res.Load(pszCmds) )
				break;

			if ( res.GetResourceID().IsValidUID())
			{
				// Replace any previous refs to this same entry ?
				size_t i = FindResourceID( res.GetResourceID() );
				if ( i != BadIndex() )
				{
					SetAt(i, res); 
				}
				else
				{
					Add(res);
				}
				iValid++;
			}
		}

		if ( *pszCmds != ',' )
		{
			break;
		}

		pszCmds++;
	}

	return( iValid );
}
Пример #10
0
size_t CResourceQtyArray::FindResourceMatch( CObjBase * pObj ) const
{
	ADDTOCALLSTACK("CResourceQtyArray::FindResourceMatch");
	// Is there a more vague match in the array ?
	// Use to find intersection with this pOBj raw material and BaseResource creation elements.
	for ( size_t i = 0; i < GetCount(); i++ )
	{
		RESOURCE_ID ridtest = GetAt(i).GetResourceID();
		if ( pObj->IsResourceMatch( ridtest, 0 ))
			return i;
	}
	return BadIndex();
}
Пример #11
0
size_t CResourceQtyArray::FindResourceID( RESOURCE_ID_BASE rid ) const
{
	ADDTOCALLSTACK("CResourceQtyArray::FindResourceID");
	// is this RESOURCE_ID in the array ?
	// BadIndex = fail
	for ( size_t i = 0; i < GetCount(); i++ )
	{
		RESOURCE_ID ridtest = GetAt(i).GetResourceID();
		if ( rid == ridtest )
			return i;
	}
	return BadIndex();
}
Пример #12
0
size_t CResourceQtyArray::FindResourceType( RES_TYPE type ) const
{
	ADDTOCALLSTACK("CResourceQtyArray::FindResourceType");
	// is this RES_TYPE in the array ?
	// BadIndex = fail
	for ( size_t i = 0; i < GetCount(); i++ )
	{
		RESOURCE_ID ridtest = GetAt(i).GetResourceID();
		if ( type == ridtest.GetResType() )
			return i;
	}
	return BadIndex();
}
Пример #13
0
size_t CResourceRefArray::FindResourceType( RES_TYPE restype ) const
{
	ADDTOCALLSTACK("CResourceRefArray::FindResourceType");
	// Is this resource already in the list ?
	size_t iQty = GetCount();
	for ( size_t i = 0; i < iQty; ++i )
	{
		RESOURCE_ID ridtest = GetAt(i).GetRef()->GetResourceID();
		if ( ridtest.GetResType() == restype )
			return( i );
	}
	return BadIndex();
}
Пример #14
0
size_t CResourceRefArray::FindResourceID( RESOURCE_ID_BASE rid ) const
{
	ADDTOCALLSTACK("CResourceRefArray::FindResourceID");
	// Is this resource already in the list ?
	size_t iQty = GetCount();
	for ( size_t i = 0; i < iQty; i++ )
	{
		RESOURCE_ID ridtest = GetAt(i).GetRef()->GetResourceID();
		if ( ridtest == rid )
			return i;
	}
	return BadIndex();
}
Пример #15
0
ECode AttributesImpl::SetAttribute(
    /* [in] */ Int32 index,
    /* [in] */ const String& uri,
    /* [in] */ const String& localName,
    /* [in] */ const String& qName,
    /* [in] */ const String& type,
    /* [in] */ const String& value)
{
    if (index >= 0 && index < mLength) {
        (*mData)[index*5] = uri;
        (*mData)[index*5+1] = localName;
        (*mData)[index*5+2] = qName;
        (*mData)[index*5+3] = type;
        (*mData)[index*5+4] = value;
    } else {
        return BadIndex(index);
    }

    return NOERROR;
}
Пример #16
0
 void indexTest(unsigned i) const
 {
     if (i >= len_) throw BadIndex();
 }
PtrCAbstractPoint NormalizedPointsSpace<T>::operator [](const unsigned &pid) const throw(BadIndex)
{
    if(!this->points__.count(pid) == 0)
        throw BadIndex();
    return this->points__.at(pid);
}