ndk::event::result input_handler::pimpl::on_kbd_common (ndk::keyboard const &ev) { switch (ev.code ()) { case ndk::key::error: throw std::runtime_error ("ERR"); // control actions case ndk::key::ctrl_d: case ndk::key::q: perform (ev.sender (), action::quit); return ndk::event::accepted; case ndk::key::ctrl_l: perform (ev.sender (), action::redraw); return ndk::event::accepted; case ndk::key::resize: perform (ev.sender (), action::resize); return ndk::event::accepted; case ndk::key::F10: perform (ev.sender (), action::maximise); return ndk::event::accepted; default: return ndk::event::ignored; } }
void Trade::agree(Character *c) { // No player agreed if (mState == TRADE_CONFIRMED) { // One player agreed, if it's the player 2, make it player 1 if (c == mChar2) { std::swap(mChar1, mChar2); std::swap(mItems1, mItems2); std::swap(mMoney1, mMoney2); } // First player agrees. mState = TRADE_CONFIRM_WAIT; // Send the other player that the first player has confirmed MessageOut msg(GPMSG_TRADE_AGREED); mChar2->getClient()->send(msg); return; } if (mState == TRADE_AGREE_WAIT && c == mChar1) { // We don't care about the first player, he already agreed return; } // The second player has agreed // Check if both player has the objects in their inventories // and enouth money, then swap them. Inventory v1(mChar1, true), v2(mChar2, true); if (mChar1->getAttribute(mCurrencyId) >= mMoney1 - mMoney2 && mChar2->getAttribute(mCurrencyId) >= mMoney2 - mMoney1 && perform(mItems1, v1, v2) && perform(mItems2, v2, v1)) { mChar1->setAttribute(mCurrencyId, mChar1->getAttribute(mCurrencyId) - mMoney1 + mMoney2); mChar2->setAttribute(mCurrencyId, mChar2->getAttribute(mCurrencyId) - mMoney2 + mMoney1); } else { v1.cancel(); v2.cancel(); cancel(); return; } MessageOut msg(GPMSG_TRADE_COMPLETE); mChar1->getClient()->send(msg); mChar2->getClient()->send(msg); delete this; }
void dashboard_conn_check(std::string cloud_name) { if(!msattrs) { APIDictionary result(perform("cldshow", cloud_name, "metricstore")); host = APIString(result["hostname"]); port = APIString(result["port"]); msci.connect(host + ":" + port + "/metrics"); result = APIDictionary(perform("cldshow", cloud_name, "time")); username = APIString(result["username"]); msattrs = 1; } }
int test(char *URL) { CURLM *multi; CURL *easy; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } if ((multi = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } if ((easy = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_multi_cleanup(multi); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1); curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite); curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); curl_easy_setopt(easy, CURLOPT_URL, URL); curl_multi_add_handle(multi, easy); if (perform(multi) != CURLM_OK) printf("retrieve 1 failed\n"); curl_multi_remove_handle(multi, easy); curl_easy_reset(easy); curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); curl_easy_setopt(easy, CURLOPT_URL, arg2); curl_multi_add_handle(multi, easy); if (perform(multi) != CURLM_OK) printf("retrieve 2 failed\n"); curl_multi_remove_handle(multi, easy); curl_easy_cleanup(easy); curl_multi_cleanup(multi); curl_global_cleanup(); printf("Finished!\n"); return 0; }
LoaderDatabaseConnection::LoaderDatabaseConnection(const LoaderConfiguration & config) : pqxx::connection(config.database().pqDatabaseConnection()), config_(new LoaderConfiguration(config)) { if ( config.loading().nameSpace.empty() ) perform ( BeginWci(config.database().user) ); else if (config.loading().nameSpace == "test" ) perform ( BeginWci(config.database().user, 999, 999, 999) ); else if (config.loading().nameSpace == "default" ) perform ( BeginWci(config.database().user, 0, 0, 0) ); else throw std::logic_error("Unknown name space specification: " + config.loading().nameSpace ); setup_(); }
DBI::Error Transaction::truncate(const AnyString& tablename) { if (YUNI_UNLIKELY(not IsValidIdentifier(tablename))) return errInvalidIdentifier; assert(!(!pChannel)); // the adapter ::yn_dbi_adapter& adapter = pChannel->adapter; // The DBI interface should provide the most appropriate way for // truncating a table (autoincrement / cascade...) if (YUNI_LIKELY(adapter.truncate)) { return (DBI::Error) adapter.truncate(adapter.dbh, tablename.c_str(), tablename.size()); } else { // Fallback to a failsafe method // -- stmt << "TRUNCATE " << tablename << ';'; // The SQL command Truncate is not supported by all databases. `DELETE FROM` // is not the most efficient way for truncating a table // but it should work almost everywhere String stmt; stmt << "DELETE FROM " << tablename << ';'; return perform(stmt); } }
int main(int argc, char *argv[]) { toxdump_args_t args = TOXDUMP_INIT_ARGS; parse_args(argc, argv, &args); int ret = perform(&args); return ret; }
DisplayWindow *FourierDCT::invert(ComplexArray *ca, QString title, QImage::Format format, QWidget *p) { int w = ca->shape()[1]; int h = ca->shape()[2]; perform(ca, true); ColorParser cp(format); QImage result(w, h, format); result.fill(Qt::black); if (format == QImage::Format_Indexed8) { QVector<QRgb> colors; colors.reserve(256); for (int i = 0; i < 256; i++) { colors << qRgb(i, i, i); } result.setColorTable(colors); } for (unsigned int i = 1; i < ca->shape()[0]; i += 2) { qreal min = 0; qreal max = 0; for (unsigned int j = 0; j < ca->shape()[1]; j++) { for (unsigned int k = 0; k < ca->shape()[2]; k++) { Complex c = (*ca)[i][j][k]; qreal real = c.real(); if (real > max) { max = real; } else if (real < min) { min = real; } } } for (unsigned int j = 0; j < ca->shape()[1]; j++) { for (unsigned int k = 0; k < ca->shape()[2]; k++) { Complex c = (*ca)[i][j][k]; qreal p = (c.real() - min) / (max - min) * 255.0; { QVector3D oldPixel = cp.pixel(k, j, result); QVector3D newPixel; switch (i / 2) { case 0: newPixel.setX(p); break; case 1: newPixel.setY(p); break; case 2: newPixel.setZ(p); break; default: break; } cp.setPixel(k, j, result, cp.merge(oldPixel, newPixel)); } } } } result = result.rgbSwapped(); PhotoWindow *pw = new PhotoWindow(result, title + ", IFDCT", p); return pw; }
bool HttpCurl::post(string url, string content) { CURLcode result; initRequest(url); m_sendBuffer.initialize(content); // set request type to post if ((result = curl_easy_setopt(m_curl, CURLOPT_POST, 1L)) != 0) { CurlException ex(result, m_message); throw ex; } if ((result = curl_easy_setopt(m_curl, CURLOPT_POSTFIELDSIZE, content.length())) != 0) { CurlException ex(result, m_message); throw ex; } perform(); return true; }
// Default constructor UltimateErodedBinaryImage::UltimateErodedBinaryImage(BinaryImage& img) : BinaryImage(img) { perform(this); }
//============================================================================== void PaintElementPath::movePoint (int index, int pointNumber, double newX, double newY, const Rectangle<int>& parentArea, const bool undoable) { if (PathPoint* const p = points [index]) { PathPoint newPoint (*p); jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo); jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo); RelativePositionedRectangle& pr = newPoint.pos [pointNumber]; double x, y, w, h; pr.getRectangleDouble (x, y, w, h, parentArea, getDocument()->getComponentLayout()); pr.updateFrom (newX, newY, w, h, parentArea, getDocument()->getComponentLayout()); if (undoable) { perform (new ChangePointAction (p, index, newPoint), "Move path point"); } else { *p = newPoint; changed(); } } }
// Default constructor RegionalMinImage::RegionalMinImage(GreyLevelImage& img) : GreyLevelImage(img) { perform(this); }
bool RegistrationOperation::performSafely( const RegistrationArguments& args , RegistrationController& controller , QWidget* dialogParent ) { const QString msgBoxTitle = QString::fromStdString( name ); QApplication::setOverrideCursor( Qt::WaitCursor ); try { perform( args, controller, dialogParent ); QApplication::restoreOverrideCursor(); return true; } catch( const std::exception& ex ) { QMessageBox::critical( dialogParent, msgBoxTitle, QString::fromStdString( ex.what() ) ); } catch( ... ) { QMessageBox::critical( dialogParent, msgBoxTitle, "Unknown error" ); } QApplication::restoreOverrideCursor(); return false; }
OpenBinaryImage::OpenBinaryImage(const BinaryImage& anImg, unsigned int anOpenSize) throw(QgarErrorDomain) : BinaryImage(anImg) { int sqsize = (2 * anOpenSize) + 1; // Effective mask size if ((sqsize > anImg.width()) || (sqsize > anImg.height())) { std::ostringstream os; os << "Opening size [" << sqsize << " X " << sqsize << "] too large for image [" << anImg.width() << " X " << anImg.height() << "]"; throw QgarErrorDomain(__FILE__, __LINE__, "void qgar::OpenBinaryImage::OpenBinaryImage(const qgar::BinaryImage&, unsigned int)", os.str()); } perform(this, anOpenSize); }
// Default constructor RegionalMaxBinaryImage::RegionalMaxBinaryImage(BinaryImage& anImg) : BinaryImage(anImg) { perform(this); }
// Default constructor CloseImage::CloseImage(GreyLevelImage& anImg, unsigned int aClosingSize) : GreyLevelImage(anImg) { int sqsize = (2 * aClosingSize) + 1; // Effective mask size if ((sqsize > anImg.width()) || (sqsize > anImg.height())) { std::ostringstream os; os << "Closing size [" << aClosingSize << " -> " << sqsize << "] too large for image [" << anImg.width() << " X " << anImg.height() << "]"; throw QgarErrorDomain(__FILE__, __LINE__, "qgar::CloseImage::CloseImage(qgar::GreyLevelImage&, unsigned int)", os.str()); } perform(this, aClosingSize); }
void PaintElementPath::setPoint (int index, int pointNumber, const RelativePositionedRectangle& newPos, const bool undoable) { if (PathPoint* const p = points [index]) { PathPoint newPoint (*p); jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo); jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo); if (newPoint.pos [pointNumber] != newPos) { newPoint.pos [pointNumber] = newPos; if (undoable) { perform (new ChangePointAction (p, index, newPoint), "Change path point position"); } else { *p = newPoint; changed(); } } } else { jassertfalse; } }
// Default constructor GeodesicRecImage::GeodesicRecImage(GreyLevelImage& aMarkImg, GreyLevelImage& aResImg) throw(QgarErrorDomain) : GreyLevelImage(aMarkImg) { if ( (aMarkImg.width() != aResImg.width()) || (aMarkImg.height() != aResImg.height())) { std::ostringstream os; os << "Marker image size (" << aMarkImg.width() << " X " << aMarkImg.height() << ") does not match result image size (" << aResImg.width() << " X " << aResImg.height() << ')'; throw QgarErrorDomain(__FILE__, __LINE__, "qgar::GeodesicRecImage::GeodesicRecImage(qgar::GreyLevelImage&, qgar::GreyLevelImage&)", os.str()); } perform(this, &aResImg); }
ErodedBinaryImage::ErodedBinaryImage(BinaryImage& anImg, unsigned int anEroSize) throw(QgarErrorDomain) : BinaryImage(anImg) { int sqsize = (2 * anEroSize) + 1; // Effective mask size if ((sqsize > anImg.width()) || (sqsize > anImg.height())) { std::ostringstream os; os << "Erosion size (" << sqsize << " X " << sqsize << ") too large for an image " << anImg.width() << " X " << anImg.height(); throw QgarErrorDomain(__FILE__, __LINE__, "qgar::ErodedBinaryImage::ErodedBinaryImage(qgar::BinaryImage&, unsigned int)", os.str()); } perform(this, anEroSize); }
subroutine createchart(io chart, in ledgercode) { //clear the last chart record to make a new chart record var nmvfns = fin.chartmvfns.dcount(VM); for (var fnn = 1; fnn <= nmvfns; ++fnn) { chart.r(fin.chartmvfns.a(1, fnn), ""); };//fnn; chart.write(fin.charts, ledgercode); chart.write(fin.ledgers, ledgercode); //simulate proper ledger creation //storerecord=@record //storeorec=orec //storeid=@id //@record=chart //orec='' //@id=ledgercode //cant call directly since contains common variables unlike this subroutine //call ledger.subs('WRITE') //@id=storeid //orec=storerec //@record=storerecord var storepseudo = PSEUDO; PSEUDO = ledgercode ^ FM ^ chart; perform("WINDOWSTUB LEDGER.SUBS PSEUDOWRITE"); PSEUDO = storepseudo; return; }
Circle::Circle(string str) : Ellipse(str) { this->str = str; perform2(); perform(); }
bool Effect::tryPerform(Unit* owner) { if (_firstPerform) { onApply(owner); _firstPerform = false; } //if force remove we do not want the effect to get another tick if (_forceRemove) { //remove me onRemoving(owner); return false; } double now = BW_Time::getMilliSecondsCached(); if (_tickDelay != NOTICK && _lastperform < now - _tickDelay) { perform(owner); _lastperform += _tickDelay; } //if timeover we want to give the effect the chance for a last tick if (_removeTime != FOREVER && now > _removeTime) { //remove me onRemoving(owner); return false; } return true; }
/* //callback */ xui_method_explain(xui_toolbar, on_invalid, void )( xui_method_args& args ) { if (m_widgetvec.size() > 0) { xui_vector<s32> sz = (m_flow == FLOWSTYLE_H) ? xui_vector<s32>(m_border.ax+m_border.bx, get_renderh()) : xui_vector<s32>(get_renderw(), m_border.ay+m_border.by); for (u32 i = 0; i < m_widgetvec.size(); ++i) { switch (m_flow) { case FLOWSTYLE_H: sz.w += m_widgetvec[i]->get_renderw()+m_grap; break; case FLOWSTYLE_V: sz.h += m_widgetvec[i]->get_renderh()+m_grap; break; } } //²¼¾Ö if (get_rendersz() != sz) { set_rendersz(sz); } else { perform(); } } }
//----------------------------------------------------------------------------------------- void gsBEncoder::processReplacing (float** inputs, float** outputs, VstInt32 sampleFrames) { int nin = (int)inputBuffers.size(); int nout = (int)outputBuffers.size(); int n = 0; while(n < sampleFrames) { int toprocess = MIN(bufferSize, (sampleFrames-n)); for(int i=0; i < nin; i++) { FloatToSample(inputBuffers[i], inputs[i]+n, toprocess); } for(int i=nin; i < inputBuffers.size(); i++) { zeroBuffer(inputBuffers[i], toprocess); } perform( gen, &(inputBuffers[0]), inputBuffers.size(), &(outputBuffers[0]), outputBuffers.size(), toprocess ); for(int i=0; i < nout; i++) { FloatFromSample(outputs[i]+n, outputBuffers[i], toprocess); } n += toprocess; } }
void EvaluatePosition(char Array[]) { int length,i,operand1,operand2; char result; length=strlen(Array); for(i=0;i<length-1;i++) { if(Array[i]=='*' ||Array[i]=='+' || Array[i]=='-' || Array[i]=='/') { operand2=Top(); pop(); operand1=Top(); pop(); printf("operands are %d %d\n",operand1,operand2 ); result=perform(Array[i],operand1,operand2); printf("the result is %c\n",result+'0'); push(result+'0'); } else { push(Array[i]); } Print(); } }
std::string engine::file_request(std::string server, const std::string& key, const std::string& user, const std::string& subject, const std::string& message, report_level s, validate_cert v) { init_curl(key, s, v); server += "/requests"; curl_easy_setopt(m_curl, CURLOPT_URL, server.c_str()); curl_header_guard hg(m_curl); std::string data = std::string( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ <request>\ <recipient>") + user + std::string("</recipient>\ <subject>") + subject + std::string("</subject>\ <message>") + message + std::string("</message>\ <send_email>true</send_email>\ "); data += "</request>\n"; curl_easy_setopt(m_curl, CURLOPT_HTTPPOST, 0); curl_easy_setopt(m_curl, CURLOPT_POSTFIELDS, data.c_str()); if (s >= NORMAL) { io::mout << "Sending file request to user '" << user << "'" << io::endl; } return process_file_request_responce(perform(), s); }
//============================================================================== bool ApplicationCommandTarget::tryToInvoke (const InvocationInfo& info, const bool async) { if (isCommandActive (info.commandID)) { if (async) { if (messageInvoker == nullptr) messageInvoker = new MessageTarget (*this); messageInvoker->postMessage (new MessageTarget::InvokedMessage (info)); return true; } else { const bool success = perform (info); jassert (success); // hmm - your target should have been able to perform this command. If it can't // do it at the moment for some reason, it should clear the 'isActive' flag when it // returns the command's info. return success; } } return false; }
void engine::filedrop_attachments_impl(std::string server, const std::string& key, const std::string& user, const std::string& subject, const std::string& message, const strings& fs, report_level s) { curl_easy_setopt(m_curl, CURLOPT_URL, server.c_str()); curl_header_guard hg(m_curl); std::string data = std::string( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ <message>\ <api_key>") + key + std::string("</api_key>\ <from>") + user + std::string("</from>\ <subject>") + subject + std::string("</subject>\ <message>") + message + std::string("</message>\ <attachments type='array'>\ "); for (strings::const_iterator i = fs.begin(); i != fs.end(); ++i) { data += " <attachment>"; data += *i; data += "</attachment>\n"; } data += " </attachments>\ </message>\n"; curl_easy_setopt(m_curl, CURLOPT_HTTPPOST, 0); curl_easy_setopt(m_curl, CURLOPT_POSTFIELDS, data.c_str()); if (s >= NORMAL) { io::mout << "Sending message to filedrop" << io::endl; } process_filedrop_responce(perform(), s); }
void WatershedOp::updateSmoothing(int sm) { if(sm % 2 == 0) sm +=1; smoothing = sm; controller->getPM()->setNamedParameter("wsm", smoothing); perform(); }
subroutine list(in mode) { //input //data<1>=mv list of topics //data<2>=date from which interested //mode<2> USER1 = mode.field(FM, 2, 9999); var heading = "What\'\'s New in NEOSYS"; var cmd = "LIST CHANGELOG ID-SUPP"; //cmd:=' KEYWORD TEXT' cmd ^= " DATE"; cmd ^= " KEYWORDS TEXT2"; //cmd:=' BY KEYWORD' cmd ^= " BY KEYWORDS"; cmd ^= " BY NUMBER"; if (USER1.a(2)) { heading ^= " Since " ^ (USER1.a(2)).oconv("[DATE,4*]"); } if (USER1.a(1)) { heading ^= "\'L\'" ^ USER1.a(1); heading.swapper(SVM, ", "); heading.swapper(VM, ", "); } cmd ^= " HEADING " ^ heading.quote(); perform(cmd); return; }