本文整理汇总了C++中WException函数的典型用法代码示例。如果您正苦于以下问题:C++ WException函数的具体用法?C++ WException怎么用?C++ WException使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uri
void WRasterImage::drawImage(const WRectF& rect, const std::string& imgUri,
int imgWidth, int imgHeight,
const WRectF& srect)
{
SkBitmap bitmap;
bool success = false;
if (DataUri::isDataUri(imgUri)) {
DataUri uri(imgUri);
success =
SkImageDecoder::DecodeMemory(&uri.data[0], uri.data.size(),
&bitmap, SkBitmap::kARGB_8888_Config,
SkImageDecoder::kDecodePixels_Mode, 0);
if (!success)
throw WException("WRasterImage: could not decode data URL (mime type "
+ uri.mimeType);
} else {
success =
SkImageDecoder::DecodeFile(imgUri.c_str(),
&bitmap, SkBitmap::kARGB_8888_Config,
SkImageDecoder::kDecodePixels_Mode, 0);
if (!success)
throw WException("WRasterImage: could not load file " + imgUri);
}
SkRect src = SkRect::MakeLTRB(SkDoubleToScalar(srect.left()),
SkDoubleToScalar(srect.top()),
SkDoubleToScalar(srect.right()),
SkDoubleToScalar(srect.bottom()));
SkRect dst = SkRect::MakeLTRB(SkDoubleToScalar(rect.left()),
SkDoubleToScalar(rect.top()),
SkDoubleToScalar(rect.right()),
SkDoubleToScalar(rect.bottom()));
impl_->canvas_->drawBitmapRectToRect(bitmap, &src, dst);
}
示例2: WException
WDialog::DialogCode WDialog::exec(const WAnimation& animation)
{
if (recursiveEventLoop_)
throw WException("WDialog::exec(): already being executed.");
animateShow(animation);
#ifdef WT_TARGET_JAVA
if (!WebController::isAsyncSupported())
throw WException("WDialog#exec() requires a Servlet 3.0 enabled servlet "
"container and an application with async-supported "
"enabled.");
#endif
WApplication *app = WApplication::instance();
recursiveEventLoop_ = true;
if (app->environment().isTest()) {
app->environment().dialogExecuted().emit(this);
if (recursiveEventLoop_)
throw WException("Test case must close dialog");
} else {
do {
app->session()->doRecursiveEventLoop();
} while (recursiveEventLoop_);
}
hide();
return result_;
}
示例3: WException
void Money::checkCurrency(Money& ans, const Money& v1, const Money& v2)
{
if(v1.currency() == "" && v1.valueInCents() != 0){
throw WException("Payment::Money::checkCurrency "
"money with no currency has value.");
}
if(v2.currency() == "" && v2.valueInCents() != 0){
throw WException("Payment::Money::checkCurrency "
"money with no currency has value.");
}
if(v1.currency() == ""){
ans.setCurrency(v2.currency());
return;
}
if(v2.currency() == ""){
ans.setCurrency(v1.currency());
return;
}
if(v1.currency() != v2.currency()){
throw WException("Payment::Money::checkCurrency different currency");
}
}
示例4: intToReadyState
void WMediaPlayer::setFormData(const FormData& formData)
{
if (!Utils::isEmpty(formData.values)) {
std::vector<std::string> attributes;
boost::split(attributes, formData.values[0], boost::is_any_of(";"));
if (attributes.size() == 8) {
try {
status_.volume = boost::lexical_cast<double>(attributes[0]);
status_.currentTime = boost::lexical_cast<double>(attributes[1]);
status_.duration = boost::lexical_cast<double>(attributes[2]);
status_.playing = (attributes[3] == "0");
status_.ended = (attributes[4] == "1");
status_.readyState
= intToReadyState(boost::lexical_cast<int>(attributes[5]));
status_.playbackRate = boost::lexical_cast<double>(attributes[6]);
status_.seekPercent = boost::lexical_cast<double>(attributes[7]);
updateProgressBarState(Time);
updateProgressBarState(Volume);
} catch (const std::exception& e) {
throw WException("WMediaPlayer: error parsing: "
+ formData.values[0] + ": " + e.what());
}
} else
throw WException("WMediaPlayer: error parsing: " + formData.values[0]);
}
}
示例5: while
/*
* Read until finding the boundary, saving to resultString or
* resultFile. The boundary itself is not consumed.
*
* tossAtBoundary controls how many characters extra (<0)
* or few (>0) are saved at the start of the boundary in the result.
*/
void CgiParser::readUntilBoundary(WebRequest& request,
const std::string boundary,
int tossAtBoundary,
std::string *resultString,
std::ostream *resultFile)
{
int bpos;
while ((bpos = index(boundary)) == -1) {
/*
* If we couldn't find it. We need to wind the buffer, but only save
* not including the boundary length.
*/
if (left_ == 0)
throw WException("CgiParser: reached end of input while seeking end of "
"headers or content. Format of CGI input is wrong");
/* save (up to) BUFSIZE from buffer to file or value string, but
* mind the boundary length */
int save = std::min((buflen_ - (int)boundary.length()), (int)BUFSIZE);
if (save > 0) {
if (resultString)
*resultString += std::string(buf_, save);
if (resultFile)
resultFile->write(buf_, save);
/* wind buffer */
windBuffer(save);
}
unsigned amt = static_cast<unsigned>
(std::min(left_,
static_cast< ::int64_t >(BUFSIZE + MAXBOUND - buflen_)));
request.in().read(buf_ + buflen_, amt);
if (request.in().gcount() != (int)amt)
throw WException("CgiParser: short read");
left_ -= amt;
buflen_ += amt;
}
if (resultString)
*resultString += std::string(buf_, bpos - tossAtBoundary);
if (resultFile)
resultFile->write(buf_, bpos - tossAtBoundary);
/* wind buffer */
windBuffer(bpos);
}
示例6: restoreExposeMask
void MessageBox::onClick(std::string buttonId, std::string value)
{
hidden_ = true;
restoreExposeMask(WApplication::instance());
StandardButton b = NoButton;
if (buttonId == "ok") b = Ok;
else if (buttonId == "cancel") b = Cancel;
else if (buttonId == "yes") b = Yes;
else if (buttonId == "no") b = No;
else
throw WException("MessageBox: internal error, unknown buttonId '"
+ buttonId + "';");
bool accepted = b == Ok || b == Yes;
if (accepted)
value_ = WString::fromUTF8(value);
result_ = b;
bool wasDeleted = false;
catchDelete_ = &wasDeleted;
done(accepted ? Accepted : Rejected);
if (!wasDeleted) {
buttonClicked_.emit(b);
catchDelete_ = 0;
}
}
示例7: WException
const User& AuthTokenResult::user() const
{
if (user_.isValid())
return user_;
else
throw WException("AuthTokenResult::user() invalid");
}
示例8: WException
int AuthTokenResult::newTokenValidity() const
{
if (user_.isValid())
return newTokenValidity_;
else
throw WException("AuthTokenResult::newTokenValidity() invalid");
}
示例9: WException
bool WLocalizedStrings::resolvePluralKey(const std::string& key,
long long ModuleId,
std::string& result,
::uint64_t amount)
{
throw WException("WLocalizedStrings::resolvePluralKey is not supported");
}
示例10: WException
void CgiParser::readMultipartData(WebRequest& request,
const std::string type, ::int64_t len)
{
std::string boundary;
if (!fishValue(type, boundary_e, boundary))
throw WException("Could not find a boundary for multipart data.");
boundary = "--" + boundary;
buflen_ = 0;
left_ = len;
spoolStream_ = 0;
currentKey_.clear();
if (!parseBody(request, boundary))
return;
for (;;) {
if (!parseHead(request))
break;
if (!parseBody(request,boundary))
break;
}
}
示例11: width_
WPdfImage::WPdfImage(const WLength& width, const WLength& height)
: width_(width),
height_(height),
painter_(nullptr)
{
myPdf_ = true;
pdf_ = HPDF_New(error_handler, this);
if (!pdf_)
throw WException("Could not create libharu document.");
HPDF_SetCompressionMode(pdf_, HPDF_COMP_ALL);
page_ = HPDF_AddPage(pdf_);
font_ = nullptr;
x_ = y_ = 0;
HPDF_Page_SetWidth(page_, width_.toPixels());
HPDF_Page_SetHeight(page_, height_.toPixels());
HPDF_Page_GSave(page_);
trueTypeFonts_ = new FontSupport(this, FontSupport::TrueTypeOnly);
#if HPDF_VERSION_ID>=20300
HPDF_UseUTFEncodings(pdf_);
#endif
}
示例12: WException
void WWidgetItem::setParentWidget(WWidget *parent)
{
if (!widget_)
return;
if (parent) {
WContainerWidget *pc = dynamic_cast<WContainerWidget *>(parent);
if (widget_->parent()) {
if (widget_->parent() != pc)
throw WException("Cannot move a WWidgetItem to another container");
} else
pc->widgetAdded(widget_.get());
bool flexLayout = dynamic_cast<FlexLayoutImpl *>
(parentLayout_->impl()) != 0;
if (flexLayout)
impl_ = cpp14::make_unique<FlexItemImpl>(this);
else
impl_ = cpp14::make_unique<StdWidgetItemImpl>(this);
} else {
WContainerWidget *pc = dynamic_cast<WContainerWidget *>(widget_->parent());
if (pc)
pc->widgetRemoved(widget_.get(), true);
impl_.reset();
}
}
示例13: fatalFormatError
static void fatalFormatError(const WString& format, int c, const char* cs)
{
std::stringstream s;
s << "WTime format syntax error (for \"" << format.toUTF8()
<< "\"): Cannot handle " << c << " consecutive " << cs;
throw WException(s.str());
}
示例14: WException
void WGLWidget::uniformMatrix4(const UniformLocation &location,
const JavaScriptMatrix4x4 &jsm)
{
if (!jsm.initialized())
throw WException("JavaScriptMatrix4x4: matrix not initialized");
pImpl_->uniformMatrix4(location, jsm);
}
示例15: WException
const std::set<int>& WSelectionBox::selectedIndexes() const
{
if (selectionMode_ != SelectionMode::Extended)
throw WException("WSelectionBox::setSelectedIndexes() can only be used "
"for an SelectionMode::Extended mode");
return selection_;
}