void net_io::set_options() { if (_socket.is_open()) { try { boost::asio::socket_base::send_buffer_size option, option2(16 * 1024 * 1024); _socket.get_option(option); int old = option.value(); _socket.set_option(option2); _socket.get_option(option); /*ddebug("boost asio send buffer size is %u, set as 16MB, now is %u", old, option.value());*/ boost::asio::socket_base::receive_buffer_size option3, option4(16 * 1024 * 1024); _socket.get_option(option3); old = option3.value(); _socket.set_option(option4); _socket.get_option(option3); /*ddebug("boost asio recv buffer size is %u, set as 16MB, now is %u", old, option.value());*/ } catch (std::exception& ex) { dwarn("network session %s:%d set socket option failed, err = %s", _remote_addr.to_ip_string().c_str(), static_cast<int>(_remote_addr.port), ex.what() ); } } }
void asio_rpc_session::set_options() { if (_socket->is_open()) { try { boost::asio::socket_base::send_buffer_size option, option2(16 * 1024 * 1024); _socket->get_option(option); int old = option.value(); _socket->set_option(option2); _socket->get_option(option); dinfo("boost asio send buffer size is %u, set as 16MB, now is %u", old, option.value()); boost::asio::socket_base::receive_buffer_size option3, option4(16 * 1024 * 1024); _socket->get_option(option3); old = option3.value(); _socket->set_option(option4); _socket->get_option(option3); dinfo("boost asio recv buffer size is %u, set as 16MB, now is %u", old, option.value()); } catch (std::exception& ex) { dwarn("network session 0x%x:%hu set socket option failed, err = %s", remote_address().ip(), remote_address().port(), ex.what() ); } } }
END_TEST START_TEST (test_conversion_options_constructor) { ConversionOption option1("key", "test", ""); fail_unless(option1.getValue() == "test"); fail_unless(option1.getType() == CNV_TYPE_STRING); ConversionOption option2("key", 1.1, ""); fail_unless(option2.getDoubleValue() == 1.1); fail_unless(option2.getType() == CNV_TYPE_DOUBLE); ConversionOption option3("key", 1.1f, ""); fail_unless(option3.getFloatValue() == 1.1f); fail_unless(option3.getType() == CNV_TYPE_SINGLE); ConversionOption option4("key", 10, ""); fail_unless(option4.getIntValue() == 10); fail_unless(option4.getType() == CNV_TYPE_INT); ConversionOption option5("key", false, ""); fail_unless(option5.getBoolValue() == false); fail_unless(option5.getType() == CNV_TYPE_BOOL); }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QMT_CHECK(option); QStyleOptionGraphicsItem option2(*option); option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus); QGraphicsTextItem::paint(painter, &option2, widget); }
SimpleJoint* SimulatedWorld::AddJoint() { SimpleJoint* createdJoint; wxArrayString options; wxString option1("Prismatic"); wxString option2("rotational"); options.Add(option1); options.Add(option2); wxArrayString AxisOptions; wxString AxisOption1("X_AXIS"); wxString AxisOption2("Y_AXIS");wxString AxisOption3("Z_AXIS"); AxisOptions.Add(AxisOption1);AxisOptions.Add(AxisOption2);AxisOptions.Add(AxisOption3); bool prismatic=false; int axis=0;double vmin=-PI; double vmax=PI; wxString Type; wxSingleChoiceDialog myDialog(NULL,wxString("Select joint type"),wxString("Options"),options); if (myDialog.ShowModal()==wxID_OK ) { if(myDialog.GetStringSelection()==wxString("Prismatic")) prismatic=true; else prismatic=false; } wxTextEntryDialog myDialogVmax(NULL,wxString("Introduce Vmax"),wxGetTextFromUserPromptStr,wxEmptyString,wxTextEntryDialogStyle,wxDefaultPosition); if (myDialogVmax.ShowModal()==wxID_OK ) { wxString value=myDialogVmax.GetValue(); value.ToDouble(&vmax); } wxTextEntryDialog myDialogVmin(NULL,wxString("Introduce Vmin"),wxGetTextFromUserPromptStr,wxEmptyString,wxTextEntryDialogStyle,wxDefaultPosition); if (myDialogVmin.ShowModal()==wxID_OK ) { wxString value=myDialogVmin.GetValue(); value.ToDouble(&vmin); if(vmin>=vmax) { wxMessageDialog errorDialog(NULL, wxString("Wrong Value-SimpleJoint will be created with default values") ,wxMessageBoxCaptionStr,wxOK|wxCENTRE,wxDefaultPosition); errorDialog.ShowModal(); vmin=-PI; vmax=PI; } } wxSingleChoiceDialog myDialog2(NULL,wxString("Select Axis"),wxString("Options"),AxisOptions); if (myDialog2.ShowModal()==wxID_OK ) { if(myDialog2.GetStringSelection()==wxString("X_AXIS")) axis=1; if(myDialog2.GetStringSelection()==wxString("Y_AXIS")) axis=2; else axis=3; } if (axis==1) createdJoint=new SimpleJoint(vmax,vmin,true,0,X_AXIS,prismatic); else if(axis==2) createdJoint=new SimpleJoint(vmax,vmin,true,0,Y_AXIS,prismatic); else createdJoint=new SimpleJoint(vmax,vmin,true,0,Z_AXIS,prismatic); return createdJoint; }
int main(int argc, char **argv) { if (argc < 3) { printf("Usage: ./104systemes and requiered arguments.\n"); exit(EXIT_FAILURE); } else { if (argv[1][0] == '1') option1(argv); if (argv[1][0] == '2') option2(argv); if (argv[1][0] == '3') option3(argv); if (argv[1][0] == '4') option4(argv); } return (0); }
int main(int ac, char **av) { if (ac == 9) { if (debuter(av) != 1) { printf("argument non valide\n"); exit(-1); } if (atoi(av[1]) == 1) option1(atoi(av[2]),atoi(av[3]),atoi(av[4]),atoi(av[5]),atoi(av[6]),atoi(av[7]),atoi(av[8])); if (atoi(av[1]) == 2) option2(atoi(av[2]),atoi(av[3]),atoi(av[4]),atoi(av[5]),atoi(av[6]),atoi(av[7]),atoi(av[8])); if (atoi(av[1]) == 3) option3(atoi(av[2]),atoi(av[3]),atoi(av[4]),atoi(av[5]),atoi(av[6]),atoi(av[7]),atoi(av[8])); } else { printf("Arguments invalides \n"); } return(0); }
int main() { int i = get_option(); while (i < 1 || i > 5) { printf("You have entered an invalid input character. Please try again.\n\n"); i = get_option(); } if (i == 1) option1(); else if (i == 2) option2(); else if (i == 3) option3(); else if (i == 4) option4(); else if (i == 5) exit(1); //system("pause"); return 0; }
void DataArrayDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if(renderInColor) { // Get the actual numeric value from the data model so we can // map it to a color. double value = model->data(index, GetDataRole).toDouble(); const unsigned char *rgb = lut->GetLookupTable()->MapValue(value); QColor c(rgb[0], rgb[1], rgb[2]); QStyleOptionViewItem option2(option); option2.palette.setColor(QPalette::Normal, QPalette::Text, c); option2.palette.setColor(QPalette::Normal, QPalette::HighlightedText, c); option2.palette.setColor(QPalette::Disabled, QPalette::Text, c); option2.palette.setColor(QPalette::Disabled, QPalette::HighlightedText, c); option2.palette.setColor(QPalette::Inactive, QPalette::Text, c); option2.palette.setColor(QPalette::Inactive, QPalette::HighlightedText, c); QItemDelegate::paint(painter, option2, index); } else QItemDelegate::paint(painter, option, index); }
void Display::_displayResults(const QString& word) { _checkThesaurus(); QString title; vector<QString> words; int meaning, prev_meaning = -1; for(const char* r = d_thesaurus.next(meaning); r[0]; r = d_thesaurus.next(meaning)) { if (meaning != prev_meaning) { if (prev_meaning != -1) { _createMeaning(title, words); words.clear(); } prev_meaning = meaning; QString option1(r); QString option2(d_thesaurus.next(meaning)); title = (option1.lower() != word.lower()) ? (option1) : (option2); r = d_thesaurus.next(meaning); _checkThesaurus(); } words.push_back(r); } _createMeaning(title, words); d_layout_ptr->addStretch(); d_layout_ptr->activate(); }
void CMDInterpreter::interpret(char* inputToken, int& menuoption, Coordinate& coord, int){ ////////////////// Parse input ////////////////// int collected = 0; int length = strlen(inputToken); if (length == 4) { if (inputToken[0] == option0() || inputToken[0] == option1() || inputToken[0] == option2()) { collected += 2; menuoption = (int)(inputToken[0]) - 48; } else { throw CMDInterpreter::GeneralException("Invalid menu option. Try again punk.\n"); } } if (length == 2) { int tempX = (int)(tolower(inputToken[0])) - 97; int tempY = (int)(inputToken[1]) - 48; if (tempX < coordXa() || tempX > coordXi()) { throw CMDInterpreter::GeneralException("Invalid X coordinate: out of bounds. " "Try again punk.\n"); } else { if (tempY < coordY0() || tempY > coordY8()) { throw CMDInterpreter::GeneralException("Invalid Y coordinate: out of bounds. " "Try again punk.\n"); } else { collected += 2; coord.setX(tempX); coord.setY(tempY); } } } //remove preceeding chars in input, do interpret again strcpy(inputToken, &(inputToken[collected])); }
bool gol::RendererSFML::menu() { m_seedChoice = 0; float fontSize = 20.f; sf::Vector2f textPosition = sf::Vector2f(20.f, 20.f); sf::Text title("CONWAY'S GAME OF LIFE", m_golbalFont, fontSize + 30.f); title.setColor(sf::Color::Green); title.setPosition(sf::Vector2f(textPosition.x, textPosition.y)); sf::Text options("SELECT YOUR CHOICE :-", m_golbalFont, fontSize + 10.f); options.setColor(sf::Color::Red); options.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 70.f)); sf::Text option1("1. Blinker Seed", m_golbalFont, fontSize); option1.setColor(sf::Color::White); option1.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 120.f)); sf::Text option2("2. Toad Seed", m_golbalFont, fontSize); option2.setColor(sf::Color::White); option2.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 145.f)); sf::Text option3("3. Beacon Seed", m_golbalFont, fontSize); option3.setColor(sf::Color::White); option3.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 170.f)); sf::Text option4("4. Pulsar Seed", m_golbalFont, fontSize); option4.setColor(sf::Color::White); option4.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 195.f)); sf::Text option5("5. Glider Seed", m_golbalFont, fontSize); option5.setColor(sf::Color::White); option5.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 220.f)); sf::Text option6("6. Lightweight spaceship (LWSS) Seed", m_golbalFont, fontSize); option6.setColor(sf::Color::White); option6.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 245.f)); sf::Text option7("7. Gosper Glider Gun Seed", m_golbalFont, fontSize); option7.setColor(sf::Color::White); option7.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 270.f)); sf::Text option8("8. R-pentomino Seed", m_golbalFont, fontSize); option8.setColor(sf::Color::White); option8.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 295.f)); sf::Text option9("9. Diehard Seed", m_golbalFont, fontSize); option9.setColor(sf::Color::White); option9.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 325.f)); sf::Text option10("10. Acorn Seed", m_golbalFont, fontSize); option10.setColor(sf::Color::White); option10.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 350.f)); sf::Text option11("11. SPECIFY YOUR OWN SEED", m_golbalFont, fontSize); option11.setColor(sf::Color::White); option11.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 375.f)); sf::Text option12("12. EXIT", m_golbalFont, fontSize); option12.setColor(sf::Color::White); option12.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 400.f)); sf::Text choiceLabel("YOUR CHOICE : ", m_golbalFont, fontSize); choiceLabel.setColor(sf::Color::White); choiceLabel.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 455.f)); sf::Text choiceText("", m_golbalFont, fontSize); choiceText.setColor(sf::Color::Cyan); choiceText.setPosition(sf::Vector2f(textPosition.x + 170.f, textPosition.y + 455.f)); sf::String choiceString; sf::Text userSeedLabel("ENTER THE SEED FILE NAME : ", m_golbalFont, fontSize); userSeedLabel.setColor(sf::Color::Green); userSeedLabel.setPosition(sf::Vector2f(textPosition.x, textPosition.y + 500.f)); sf::Text userSeedText("", m_golbalFont, fontSize); userSeedText.setColor(sf::Color::Cyan); userSeedText.setPosition(sf::Vector2f(textPosition.x + 320.f, textPosition.y + 500.f)); sf::String userSeedString; std::string customSeedFile; bool isInMainMenu = true; while(m_window.isOpen()) { sf::Event event; while(m_window.pollEvent(event)) { if(event.type == sf::Event::Closed) { m_window.close(); return false; } if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Return) { if(m_seedChoice != 0) { if(m_seedChoice == 12) return false; else if(m_seedChoice == 11) isInMainMenu = false; else if(m_seedChoice < 11) return true; } } if(event.type == sf::Event::TextEntered && isInMainMenu) { if(event.text.unicode >= 48 && event.text.unicode <= 57) choiceString += (char)event.text.unicode; else if(event.text.unicode == 8 && choiceString.getSize() > 0) choiceString.erase(choiceString.getSize() - 1, choiceString.getSize()); choiceText.setString(choiceString); std::string str = choiceString.toAnsiString(); m_seedChoice = std::atoi(str.c_str()); } if(m_seedChoice == 11 && !isInMainMenu) { if(event.type == sf::Event::TextEntered) { if((event.text.unicode >= 32 && event.text.unicode <= 57) || (event.text.unicode >= 64 && event.text.unicode <= 126)) userSeedString += (char)event.text.unicode; else if(event.text.unicode == 8 && userSeedString.getSize() > 0) userSeedString.erase(userSeedString.getSize() - 1, userSeedString.getSize()); userSeedText.setString(userSeedString); } if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Return && !userSeedString.isEmpty()) { customSeedFile = userSeedString.toAnsiString(); setSeedFileName(customSeedFile); return true; } } } m_window.clear(sf::Color::Black); m_window.draw(title); m_window.draw(options); m_window.draw(option1); m_window.draw(option2); m_window.draw(option3); m_window.draw(option4); m_window.draw(option5); m_window.draw(option6); m_window.draw(option7); m_window.draw(option8); m_window.draw(option9); m_window.draw(option10); m_window.draw(option11); m_window.draw(option12); m_window.draw(choiceLabel); m_window.draw(choiceText); if(!isInMainMenu) { m_window.draw(userSeedLabel); m_window.draw(userSeedText); } m_window.display(); } }