/** * Set the options. */ DynamicContext::DynamicContext(struct dynamic_options &dopt): ProcessControl( ) { // check every choosen option if (dopt.min_attr <= 0) throw InputException("Invalid number of minimun attributes"); else if (dopt.max_attr < dopt.min_attr) throw InputException("Invalid number of maximun attributes"); else if (dopt.inc_attr <= 0) throw InputException("Invalid number of increase attributes"); else if (dopt.min_objc <= 0) throw InputException("Invalid number of minimum objects"); else if (dopt.max_objc < dopt.min_objc) throw InputException("Invalid number of maximum objects"); else if (dopt.objc_mode && dopt.inc_objc <= 0) throw InputException("Invalid objects increase rate"); else if (!dopt.objc_mode && dopt.sample_objc <= 0) throw InputException("Invalid objects sample"); else if (dopt.sample_den <= 0) throw InputException("Invalid density sample"); else if (!dopt.intervals) throw InputException("Invalid discretization intervals"); this->dopt = dopt; }
void QTestlibXmlParser::parse(QSharedPointer<QSettings>, const QStringList& filenames) { Q_FOREACH(const QString& filename, filenames) { QFile file(filename); if (!file.exists()) throw InputException(tr("File not found: %1").arg(filename)); if (!file.open(QIODevice::ReadOnly)) throw InputException(tr("Unable to open file: %1").arg(filename)); std::wcerr << tr("Parsing input file %1.").arg(filename).toStdWString() << std::endl; QXmlStreamReader reader(&file); BenchmarkResult result; QFileInfo fileInfo(file); result.filename_ = fileInfo.baseName(); readTestCase(&reader, result); }
/** * Constructor * 1) check that all the coordinates are not negative * 2) check that the points are not on the same line * 3) creates the triangle * 4) set the area * 5) set the bounding box * 6) set the center of the bounding box * */ Triangle::Triangle(int ax,int ay,int bx,int by,int cx,int cy,string color){ if(ax<0 || ay<0 || bx<0 || by<0 || cx<0 || cy<0) throw InputException(("Negative values in the points coordinates")); if((ax == bx && bx == cx) || (ay == by && by == cy)) throw InputException("More than two points on the same line"); if (inLinePoints(ax,ay,bx,by,cx,cy)) throw InputException("More than two points on the same line"); this->a = Point(ax, ay); this->b = Point(bx, by); this->c = Point(cx, cy); this->area = erone(this->a, this->b, this->c); this->setBoundingBox(); this->setCenter(); this->setRotation(); this->setColor(color); }
void GPUPipeline::bind_shader_input(Buffer& buff, const Shader::InputDef& input, long offset, GLsizei stride) { if (input.def_type != Shader::InputDef::ATTRIBUTE) throw InputException(input.name, "invalid type"); buff.bind(); bind_shader_input((void*)offset, input, stride); buff.unbind(); }
ModelInput& ModelInputList::add(const std::string& name) { for (auto& inp : m_List) { if (inp->getName() == name) { throw InputException("Duplicate model input name"); } } m_List.emplace_back(new ModelInput(name)); return *(m_List.back().get()); }
void Joystick::ReleaseButton(Uint8& button) { try { m_button_states.at(button).Release(); } catch (std::out_of_range) { BOOST_THROW_EXCEPTION(InputException() << StringErrorInfo("Joystick button is out of range")); } }
ButtonState& Joystick::GetButton(Uint8& button) { try { return m_button_states.at(button); } catch (std::out_of_range) { BOOST_THROW_EXCEPTION(InputException() << StringErrorInfo("Joystick button is out of range")); } }
/** * Constructor * 1) check that all the coordinates are not negative * 2) create the circle * 3) set the area * 4) set the bounding box * 5) the center of the bounding box is the center of the circle * */ Circle::Circle(int rad, int x, int y, string color) { //TODO mettere a posto questo controllo!!!! if(x < 0 || y < 0 || rad <= 0 || x-rad <0 || y-rad <0) throw InputException(("Negative values in the points coordinates")); radius = rad; center.x = x; center.y = y; area = rad * rad * M_PI; setBbox(x-rad, y-rad, 2*rad, 2*rad); this->setRotation(); this->setColor(color); }
void Joystick::SetAxisPosition(Uint8 axis_num, float position) { try { m_axis_updates.at(axis_num) = true; m_axis_states.at(axis_num).Update(position); } catch (std::out_of_range) { BOOST_THROW_EXCEPTION(InputException() << StringErrorInfo("Joystick axis is out of range")); } }
bool OptionsFromStreamPack ::StringToBool( const char* opt_name, const char* str ) { if( !::strcmp( str, "true" ) ) return true; if( !::strcmp( str, "false" ) ) return false; std::ostringstream omsg; omsg << "StringToBool(...): " << "Error, the string \"" << str << "\" must be \"true\" or \"false\" for \"" << opt_name << "\""; throw InputException( omsg.str() ); return false; // will never execute. }
int Grid<V>::get_size(char dim) const { try { if (dim == 'x') { return size_x; } else if (dim == 'y') { return size_y; } else if (dim == 'z') { return size_z; } else { throw InputException("Wrong literal index in Grid::get_size!!!"); } } catch(std::exception& e) { std::cout << "Grid exception :" << e.what() << std::endl; } }
void WordFile::process() throw (InputException) { ifstream file(this->_filepath.c_str()); if (!file) { string msj = "WordFile exception: error opening input file "; msj += this->_filepath.c_str(); throw InputException(msj); } cout << getName() << " processing each character in file." << endl; string word; while(!file.eof()) { file >> word; this->_processor->process(word); } file.close(); }
/** * 1) control that the value of the bounding box are consistent * 2) create the bounding box * */ void Object::setBbox(int x, int y, int height, int width){ if(x<0 || y < 0 || height <=0 || width <= 0) throw InputException("Negative values in the points coordinates"); bbox = Rect(x, y, height, width); }