void check_ranges(size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) const
    {
	MTL_DEBUG_THROW_IF(begin_r < begin_row(), range_error("begin_row out of range"));
	// if (end_r > end_row()) std::cout << "end_row out of range\n";
	MTL_DEBUG_THROW_IF(end_r > end_row(), range_error("end_row out of range"));
			      
	MTL_DEBUG_THROW_IF(begin_c < begin_col(), range_error("begin_col out of range"));
	MTL_DEBUG_THROW_IF(end_c > end_col(), range_error("end_col out of range"));
    }
Ejemplo n.º 2
0
static TimeZone::value_type check_value( TimeZone::value_type gmtoff ) {
  if ( gmtoff < MinValue )
    throw range_error(
      BUILD_STRING( gmtoff, ": value < minimum value of ", MinValue )
    );
  if ( gmtoff > MaxValue )
    throw range_error(
      BUILD_STRING( gmtoff, ": value > maximum value of ", MaxValue )
    );
  return gmtoff;
}
Ejemplo n.º 3
0
int
PqTuple::
getIndex( const std::string &fieldName )const
{

	try {
		return result.column_number( fieldName );
	}
	catch( const exception &ex ){
		throw range_error( "Unknown field name: '" + fieldName + "'. (" +ex.what()+")" );
	}
	throw range_error( "Unknown field name: '" + fieldName + "'." );
}
Ejemplo n.º 4
0
RealVector::RealVector(int n) {
	if (n < 0)
		throw range_error("Size must not be negative");

	this->n = n;
	entries = new double[n];
}
Ejemplo n.º 5
0
void listmap <key_t, value_t>::iterator::erase () {
   if (where == NULL){
      throw range_error ("cannot delete empty listmap key");
   //if only one node
   } else if (where == map->head && where == map->tail){
      delete where;
      where = NULL;
      map->head = NULL;
      map->tail = NULL;
   //delete first node only  
   } else if (where == map->head){
      node temp = where->next;
      temp->prev = NULL;
      delete where;
      where = temp;
      map->head = temp;
   //delete last node only
   } else if (where == map->tail){
      node *temp = where;
      temp->next = NULL;
      delete where;
      where = temp;
      map->tail = temp;
   } else {
      node *ptemp = where->prev;
      node *ntemp = where->next;
      ptemp->next = ntemp;
      ntemp->prev = ptemp;
      delete where;
      where = ptemp;
   }
}
/* good2() reverses the bodies in the if statement */
static void good2()
{
    if(globalTrue)
    {
        /* FIX: Throw a specific exception */
        throw range_error("Test");
    }
}
Ejemplo n.º 7
0
int MatchMismatches::offset(unsigned int position) const
{
    if (position < offsets.size())
        return offsets[position];
    else
        throw (range_error("MatchMismatches::offset postion too high: "
                           + to_string(position)));
}
Ejemplo n.º 8
0
 inline basic_val<T> const& basic_val<T>::operator[](std::size_t i) const
 {
   if (!is_array(*this))
     throw type_error("basic_val is not an array");
   if (i >= a_.size())
     throw range_error("out of range");
   return a_[i];
 }
Ejemplo n.º 9
0
typename listmap <key_t, value_t>::iterator &
listmap <key_t, value_t>::iterator::operator-- () {
   if (where == NULL){
      throw range_error ("cannot decrement over NULL element");
   }
   where = where->prev;
   return *this;
}
Ejemplo n.º 10
0
		virtual FILETIME GetFileTime(int index) const 
		{
			if (index < 0 || index >= 5)
			{
				throw range_error("index must between 0 and 5");
			}

			return m_ft[index];
		};
Ejemplo n.º 11
0
static TimeZone::value_type check_value( int hours, int minutes ) {
  bool const negative = hours < 0 || minutes < 0;

  if ( (hours = ::abs( hours )) > MaxHour )
    throw range_error(
      BUILD_STRING( hours, ": |hours| > maximum of ", MaxHour )
    );
  if ( (minutes = ::abs( minutes )) > 59 )
    throw range_error(
      BUILD_STRING( minutes, ": |minutes| > maximum of 59" )
    );
  if ( hours == MaxHour && minutes )
    throw range_error(
      BUILD_STRING( minutes, ": |minutes| > 0 when |hours| is ", MaxHour )
    );

  return (hours * 60 * 60 + minutes * 60) * (negative ? -1 : 1);
}
Ejemplo n.º 12
0
typename listmap <key_t, value_t>::iterator &
listmap <key_t, value_t>::iterator::operator++ () {
   TRACE ('l', "First: " << map << ", " << where);
   TRACE ('l', "Second: " << map->head << ", " << map->tail);
   if (where == NULL){
      throw range_error ("cannot increment over NULL element"); 
   }
   where = where->next;
   return *this;
}
Ejemplo n.º 13
0
Field
PqTuple::
at( int index )const
{
	if( index < 0 || index >= result.columns() ) {
		ostringstream ost;
		ost << "Index '" << index << "' out of range [0," <<  result.columns()  << ">.";
		throw range_error( ost.str() );
	}

	return Field( it.at( index ).c_str(), it.at( index ).is_null(), container.cIsNumber[index] );
}
/* good1() uses if(globalFalse) instead of if(globalTrue) */
static void good1()
{
    if(globalFalse)
    {
        /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
        printLine("Benign, fixed string");
    }
    else
    {
        /* FIX: Throw a specific exception */
        throw range_error("Test");
    }
}
Ejemplo n.º 15
0
void RealVector::resize(int nnew) {
	double *newentries;
	int copysize = min(n, nnew);

	if (nnew < 0)
		throw range_error("Size must not be negative");

	newentries = new double[nnew];
	memcpy(newentries, entries, copysize * sizeof(double));
	delete[] entries;

	entries = newentries;
	n = nnew;
}
Ejemplo n.º 16
0
//------------------------------------------------------------------------------
void stSlimLeafNode::RemoveEntry(stCount idx){
   stCount lastID;
   stCount i;
   stSize rObjSize;

   // Programmer's note: This procedure is simple but tricky! See the
   // SlimIndexNode structure documentation for more details.

   #ifdef __stDEBUG__
   if (idx >= GetNumberOfEntries()){
      // Oops! This idx doesn't exists.
      throw range_error("idx value is out of range.");
   }//end if
   #endif //__stDEBUG__

   // Let's remove
   lastID = Header->Occupation - 1; // The idx of the last object. This
                                    // value will be very useful.
   // Do I need to move something ?
   if (idx != lastID){
      // Yes, I do.
      rObjSize = GetObjectSize(idx);    // Save the removed object size

      // Let's move objects first. We will use memmove() from stdlib because
      // it handles the overlap between src and dst. Remember that src is the
      // offset of the last object and the dst is the offset of the last
      // object plus removed object size.
      memmove(Page->GetData() + Entries[lastID].Offset + rObjSize,
              Page->GetData() + Entries[lastID].Offset,
              Entries[idx].Offset - Entries[lastID].Offset);

      // Let's move entries...
      for (i = idx; i < lastID; i++){
         // Copy all fields with memcpy (it's faster than field copy).
         memcpy(Entries + i, Entries + i + 1, sizeof(stSlimLeafEntry));

         // Update offset by adding the removed object size to it. It will
         // reflect the previous move operation.
         Entries[i].Offset += rObjSize;
      }//end for
   }//end if

   // Update counter...
   Header->Occupation--;
}//end stSlimLeafNode::RemoveEntry
Ejemplo n.º 17
0
Interval::uint64 CodeInterval::descale(Interval::uint64 value) const throw(not_normalized, range_error)
{
	if(!is_normalized()) {
		throw not_normalized("Interval must be normalized before descale.");
	}
	if(!includes(value)) {
		throw range_error("Value not in interval.");
	}
	
	// value = (value - base) · 2⁶⁴ / (range + 1)
	if(range == max) {
		return value - base;
	} else {
		assert(value - base < range + 1);
		std::uint64_t q, r;
		std::tie(q, r) = div128(value - base, 0, range + 1);
		q += (r >= msb) ? 1 : 0;
		return q;
	}
}
Ejemplo n.º 18
0
///////////////////////////////////////////////////////////////////////////////
//
// Command
//
///////////////////////////////////////////////////////////////////////////////
void Command::deserialize()
{
   //find dot delimiter
   string ids;
   size_t pos = command_.find('.');
   if (pos == string::npos)
      ids = command_;
   else
   {
      ids = command_.substr(0, pos);
      args_ = move(Arguments(command_.substr(pos + 1)));
   }

   //tokensize by &
   vector<size_t> posv;
   pos = 0;
   while ((pos = ids.find('&', pos)) != string::npos)
   {
      posv.push_back(pos);
      pos++;
   }

   if (posv.size() == 0)
      throw runtime_error("no IDs found in command string");

   posv.push_back(ids.size());

   for (int i = 0; i < posv.size() - 1; i++)
   {
      ssize_t len = posv[i + 1] - posv[i] - 1;
      if (len < 0)
         throw range_error("invalid id len");
      ids_.push_back(ids.substr(posv[i] + 1, len));
   }

   method_ = ids_.back();
   ids_.pop_back();
}
    void set_ranges(size_type br, size_type er, size_type bc, size_type ec)
    {
	MTL_DEBUG_THROW_IF(br > er, range_error("begin row > end row"));
	MTL_DEBUG_THROW_IF(bc > ec, range_error("begin column > end column"));
	my_begin_row= br; my_end_row= er; my_begin_col= bc; my_end_col= ec;
    }
Ejemplo n.º 20
0
void __throw_range_error(const char* s) { throw range_error(s); }
Ejemplo n.º 21
0
const CShipInfo& CPlayer::operator[] (short index) const
{
	if (index >= NUMPLAYERS)
		throw range_error("index out of range");
	return m_ships[index];
}