Example #1
0
Record& Table::rowAt(int index) {
	if(index >= rows.size())
		throw OutOfBoundsException();
	//first check if the index exceeds the row count
	//then make sure that the index is a valid number
	else if(index < 0)
		throw OutOfBoundsException();
	else return rows[index];
}
Example #2
0
void ProbabilityMatrix::setElement(
        int const & row, int const & column, const double value)
throw (OutOfBoundsException) {
    if (0 > row
            || row >= noRows) {
        throw (OutOfBoundsException(row, noRows));
    } else if (0 > column
            || column >= noColumns) {
        throw (OutOfBoundsException(column, noColumns));
    }
    matrix[row][column] = value;
}
Example #3
0
double const ProbabilityMatrix::getElement(
        int const & row, int const & column) const
throw (OutOfBoundsException) {
    if (0 > row
            || row >= noRows) {
        throw (OutOfBoundsException(row, noRows));
    } else if (0 > column
            || column >= noColumns) {
        throw (OutOfBoundsException(column, noColumns));
    }
    return matrix[row][column];
}
Example #4
0
/** Internal constructor.
 * @param shmem_lut_id shared memory LUT ID
 * @param destroy_on_free true to delete the shared memory segment to delete, false to keep the segment
 * @param depth Y depth
 * @param width U depth
 * @param height V depth
 */
void
YuvColormap::constructor(unsigned int depth,
                         unsigned int width,
                         unsigned int height,
                         const char * shmem_lut_id,
                         bool         destroy_on_free)
{
	if (depth > 256) {
		throw OutOfBoundsException("YuvColormap depth out of bounds", depth, 1, 256);
	}
	if ((depth != 1) && (depth != 2) && (depth != 4) && (depth != 8) && (depth != 16) && (depth != 32)
	    && (depth != 64) && (depth != 128) && (depth != 256)) {
		throw IllegalArgumentException("Depth must be of the form d=2^n with n from [1,8]");
	}

	if (width > 256) {
		throw OutOfBoundsException("YuvColormap width out of bounds", width, 1, 256);
	}
	if ((width != 1) && (width != 2) && (width != 4) && (width != 8) && (width != 16) && (width != 32)
	    && (width != 64) && (width != 128) && (width != 256)) {
		throw IllegalArgumentException("Width must be of the form d=2^n with n from [1,8]");
	}

	if (height > 256) {
		throw OutOfBoundsException("YuvColormap height out of bounds", height, 1, 256);
	}
	if ((height != 1) && (height != 2) && (height != 4) && (height != 8) && (height != 16)
	    && (height != 32) && (height != 64) && (height != 128) && (height != 256)) {
		throw IllegalArgumentException("Height must be of the form d=2^n with n from [1,8]");
	}

	width_      = width;
	height_     = height;
	depth_      = depth;
	depth_div_  = 256 / depth_;
	width_div_  = 256 / width_;
	height_div_ = 256 / height_;
	plane_size_ = width_ * height_;

	if (shmem_lut_id != NULL) {
		shm_lut_ =
		  new SharedMemoryLookupTable(shmem_lut_id, width_, height_, depth_, /* bytes p. cell */ 1);
		shm_lut_->set_destroy_on_delete(destroy_on_free);
		lut_      = shm_lut_->buffer();
		lut_size_ = shm_lut_->data_size();
	} else {
		shm_lut_  = NULL;
		lut_size_ = (size_t)width_ * (size_t)height_ * (size_t)depth_;
		lut_      = (unsigned char *)malloc(lut_size_);
	}
	memset(lut_, C_OTHER, lut_size_);
}
Example #5
0
void Array<T>::boundsCheck(int i) const
{
#ifdef SAFE_ARRAYS
  if ( ! inBounds(i) )
    throw OutOfBoundsException();
#endif
}
Example #6
0
AmArg& AmArg::get(size_t idx) {
  assertArray();  
  if (idx >= v_array->size())
    throw OutOfBoundsException();
    
  return (*v_array)[idx];
}
Example #7
0
    int             StringToInteger(std::string s, int radix) {
	if (radix < 2 || radix > 32) {
	    throw          
		OutOfBoundsException("Bounds of radix exception");
	}

	return (int) strtol(s.c_str(), NULL, radix);
    }
Profile* ProfileManager::getProfile(int idx)
{
	if (idx < 0  ||  idx >= profiles.size()) {
		throw OutOfBoundsException(idx, __FILE__, __LINE__);
	}

	return profiles[idx];
}
Example #9
0
const DFFFrame* DFFFrame::getChild(uint32_t index) const
{
	if (index >= children.size()) {
		throw OutOfBoundsException(index, __FILE__, __LINE__);
	}

	return children[index];
}
Example #10
0
/** Copy single U/V plane.
 * This will copy the given U/V plane to the given level in this colormap.
 * @param uvplane buffer of U/V plane to copy
 * @param level level to copy the plane to
 * @exception OutOfBoundsException thrown if level > depth()
 */
void
YuvColormap::copy_uvplane(unsigned char *uvplane, unsigned int level)
{
	if (level > depth_) {
		throw OutOfBoundsException("YuvColormap::copy_uvplane(): Invalid level", level, 0, depth_);
	}

	memcpy(lut_ + level * plane_size_, uvplane, plane_size_);
}
Example #11
0
std::string StringTokenizer::front() {
    if (myStarts.size()==0) {
        throw OutOfBoundsException();
    }
    if (myLengths[0]==0) {
        return "";
    }
    return myTosplit.substr(myStarts[0],myLengths[0]);
}
Example #12
0
void Array<T>::SetElement(int index, const T& newT)
{
	if (index < 0 || index >= m_size)
	{
		throw OutOfBoundsException(index);
	}

	m_data[index] = newT;
}
Example #13
0
		T& Array<T>::GetElement(unsigned int index) const
		{
			if (index >= 0 && index < m_size) {
				return m_data[index];
			}
			else {
				throw OutOfBoundsException(-1);
			}
		}
Example #14
0
		void Array<T>::SetElement(unsigned int index, const T& obj)
		{
			if (index >= 0 && index < m_size) {
				m_data[index] = obj;
			}
			else {
				throw OutOfBoundsException(-1);
			}
		}
Example #15
0
	void DialogueOptionsBox::setSelectedOptionIndex(size_t index)
	{
		if(index>=options.size() && index!=NO_OPTION)
		{
			throw OutOfBoundsException((String)"Option index is out of bounds at index "+index+" with option count "+options.size());
		}
		selectedOptionIndex = index;
		updateScrollPosY();
	}
Example #16
0
SUMOTime
ODMatrix::parseSingleTime(const std::string& time) {
    if (time.find('.') == std::string::npos) {
        throw OutOfBoundsException();
    }
    std::string hours = time.substr(0, time.find('.'));
    std::string minutes = time.substr(time.find('.') + 1);
    return TIME2STEPS(TplConvert::_2int(hours.c_str()) * 3600 + TplConvert::_2int(minutes.c_str()) * 60);
}
Example #17
0
const T& Array<T>::operator [] (int index) const
{
	if (index < 0 || index >= m_size)
	{
		throw OutOfBoundsException(index);
	}

	return m_data[index];
}
Example #18
0
T& Array<T>::GetElement(int index) const
{
	if (index < 0 || index >= m_size)
	{
		throw OutOfBoundsException(index);
	}

	return m_data[index];
}
Example #19
0
void setScalarAsFloat(T* data, Vector3i position, Vector3i size, float value, uchar channel, uchar nrOfChannels) {

    if(position.x() < 0 || position.y() < 0 || position.z() < 0 ||
            position.x() > size.x()-1 || position.y() > size.y()-1 || position.z() > size.z()-1 || channel >= nrOfChannels)
        throw OutOfBoundsException();

    data[(position.x() + position.y()*size.x() + position.z()*size.x()*size.y())*nrOfChannels + channel] = value;

}
Example #20
0
		const T& Array<T>::operator [] (int index) const
		{
			if (index >= 0 && index < m_size)
			{
				return m_data[index];
			}
			else
			{
				throw OutOfBoundsException(-1);
			}
		}
Example #21
0
std::string StringTokenizer::get(size_t pos) const {
    if (pos>=myStarts.size()) {
        throw OutOfBoundsException();
    }
    if (myLengths[pos]==0) {
        return "";
    }
    size_t start = myStarts[pos];
    size_t length = myLengths[pos];
    return myTosplit.substr(start, length);
}
/*! Retorna a coordenada do vetor correspondente ao &iacute;ndice passado como par&acirc;metro.
 *  Lembrando que os &iacute;ndices 0, 1, 2 e 3 correspondem, respectivamente, a X, Y, Width e Height
 *  @throws OutOfBoundsException Se o &iacute;ndice usado estiver fora do intervalo [0,3].
 *  @return A coordenada na posi&ccedil;&atilde;o requisitada.
 */
const int &
Rect::operator[] ( const int _iIdx ) const {
    // Validate index range.
    if ( _iIdx < X || _iIdx > H )
        throw OutOfBoundsException();

    if ( _iIdx == X )      return miX;
    else if ( _iIdx == Y ) return miY;
    else if ( _iIdx == W ) return miW;
    else                   return miH;

}
Example #23
0
std::string StringTokenizer::next() {
    if (myPos>=myStarts.size()) {
        throw OutOfBoundsException();
    }
    if (myLengths[myPos]==0) {
        myPos++;
        return "";
    }
    size_t start = myStarts[myPos];
    size_t length = myLengths[myPos++];
    return myTosplit.substr(start,length);
}
Example #24
0
    long long       StringToLong(std::string s, int radix) {
	if (radix < 2 || radix > 32) {
	    throw          
		OutOfBoundsException("Bounds of radix exception");
	}
	// #ifndef __CYGWIN32__
#if !defined(__CYGWIN32__) && !defined(_BCB)
	return (long long) strtoll(s.c_str(), NULL, radix);
#else
	// TODO:: cygwin
	return (long long) strtol(s.c_str(), NULL, radix);
#endif
    }
Example #25
0
inline
void
OpenDDS::Model::Service< ModelName, InstanceTraits>::copyPublicationQos(
  unsigned int        which,
  DDS::DataWriterQos& writerQos
)
{
  typename DataWriters::Values writer = static_cast< typename DataWriters::Values>( which);
  if( writer < 0 || writer >= DataWriters::LAST_INDEX) {
    throw OutOfBoundsException();
  }
  this->modelData_.copyPublicationQos( writer, writerQos);
}
Example #26
0
inline
void
OpenDDS::Model::Service< ModelName, InstanceTraits>::copySubscriptionQos(
  unsigned int        which,
  DDS::DataReaderQos& readerQos
)
{
  typename DataReaders::Values reader = static_cast< typename DataReaders::Values>( which);
  if( reader < 0 || reader >= DataReaders::LAST_INDEX) {
    throw OutOfBoundsException();
  }
  this->modelData_.copySubscriptionQos( reader, readerQos);
}
Example #27
0
/** Get value of current enum field as integer.
 * @return field value
 * @param index array index (only use if field is an array)
 * @exception NullPointerException invalid iterator, possibly end iterator
 * @exception TypeMismatchException thrown if field is not of type int
 * @exception OutOfBoundsException thrown if index is out of bounds
 */
int32_t
InterfaceFieldIterator::get_enum(unsigned int index) const
{
  if ( __infol == NULL ) {
    throw NullPointerException("Cannot get value of end element");
  } else if ( __infol->type != IFT_ENUM ) {
    throw TypeMismatchException("Requested value is not of type enum");
  } else if (index >= __infol->length) {
    throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
  } else {
    return ((int32_t *)__infol->value)[index];
  }
}
Example #28
0
/** Set value of current field as unsigned integer.
 * @param v the new value
 * @param index array index (only use if field is an array)
 * @exception NullPointerException invalid iterator, possibly end iterator
 * @exception TypeMismatchException thrown if field is not of type unsigned int
 * @exception OutOfBoundsException thrown if index is out of bounds
 */
void
InterfaceFieldIterator::set_uint16(uint16_t v, unsigned int index)
{
  if ( __infol == NULL ) {
    throw NullPointerException("Cannot set value of end element");
  } else if ( __infol->type != IFT_UINT16 ) {
    throw TypeMismatchException("Field to be written is not of type unsigned int");
  } else if (index >= __infol->length) {
    throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
  } else {
    char* dst = (char *) __infol->value + index * sizeof(uint16_t);
    memcpy((void *) dst, &v, sizeof(uint16_t));
  }
}
Example #29
0
/** Copy data from private memory to buffer.
 * @param buffer buffer number to copy to
 */
void
Interface::copy_private_to_buffer(unsigned int buffer)
{
  if (buffer >= __num_buffers) {
    throw OutOfBoundsException("Buffer ID out of bounds",
			       buffer, 0, __num_buffers);
  }


  __data_mutex->lock();
  void *buf = (char *)__buffers + buffer * data_size;
  memcpy(buf, data_ptr, data_size);
  __data_mutex->unlock();
}
Example #30
0
/** Get time of a buffer.
 * @param buffer buffer number
 * @return timestamp stored in the interface
 */
Time
Interface::buffer_timestamp(unsigned int buffer)
{
  if (buffer >= __num_buffers) {
    throw OutOfBoundsException("Buffer ID out of bounds",
			       buffer, 0, __num_buffers);
  }


  MutexLocker lock(__data_mutex);
  void *buf = (char *)__buffers + buffer * data_size;
  interface_data_ts_t *buf_ts = (interface_data_ts_t *)buf;
  return Time(buf_ts->timestamp_sec, buf_ts->timestamp_usec);
}