本文整理汇总了C++中IllegalArgumentException函数的典型用法代码示例。如果您正苦于以下问题:C++ IllegalArgumentException函数的具体用法?C++ IllegalArgumentException怎么用?C++ IllegalArgumentException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IllegalArgumentException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void DecodeHints::addFormat(BarcodeFormat toadd) {
switch (toadd) {
case BarcodeFormat_QR_CODE: hints |= BARCODEFORMAT_QR_CODE_HINT; break;
case BarcodeFormat_DATA_MATRIX: hints |= BARCODEFORMAT_DATA_MATRIX_HINT; break;
case BarcodeFormat_UPC_E: hints |= BARCODEFORMAT_UPC_E_HINT; break;
case BarcodeFormat_UPC_A: hints |= BARCODEFORMAT_UPC_A_HINT; break;
case BarcodeFormat_EAN_8: hints |= BARCODEFORMAT_EAN_8_HINT; break;
case BarcodeFormat_EAN_13: hints |= BARCODEFORMAT_EAN_13_HINT; break;
case BarcodeFormat_CODE_128: hints |= BARCODEFORMAT_CODE_128_HINT; break;
case BarcodeFormat_CODE_39: hints |= BARCODEFORMAT_CODE_39_HINT; break;
case BarcodeFormat_ITF: hints |= BARCODEFORMAT_ITF_HINT; break;
default: throw IllegalArgumentException("Unrecognizd barcode format");
}
}
示例2: setName
void PFPChunk::setName(const String &chunkname)
/*!\brief Name des Chunks setzen
*
* \desc
* Mit dieser Funktion wird der Name eines Chunks definiert. Der Name muss
* exakt 4 Byte lang sein und darf nur Großbuchstaben enthalten (es wird
* eine automatische Konvertierung durchgeführt). Ausserdem sind nur Zeichen
* aus dem Zeichensatz US-ASCII erlaubt.
*
* \param chunkname String mit dem Namen des Strings
* \exception IllegalArgumentException Wird geworfen, wenn der Name des Chunks ungültig ist
*
*/
{
if (chunkname.len()!=4) throw IllegalArgumentException();
String s=chunkname;
s.upperCase();
for (size_t i=0;i<4;i++) {
wchar_t c=s[i];
if (c<32 || c>127) throw IllegalArgumentException();
}
this->chunkname=s;
}
示例3: IllegalArgumentException
void KnownIdentities::fromFile(QString const& filename, bool dryRun) {
if (!QFile::exists(filename)) {
throw IllegalArgumentException() << QString("Could not open the specified contacts file as it does not exist: %1").arg(filename).toStdString();
}
QFile inputFile(filename);
if (!inputFile.open(QFile::ReadOnly | QFile::Text)) {
throw IllegalArgumentException() << QString("Could not open the specified contacts file for reading: %1").arg(filename).toStdString();
}
QRegExp commentRegExp("^\\s*#.*$", Qt::CaseInsensitive, QRegExp::RegExp2);
QRegExp identityRegExp("^\\s*([A-Z0-9]{8})\\s*:\\s*([a-fA-F0-9]{64})\\s*(?::\\s*(.*)\\s*)?$", Qt::CaseInsensitive, QRegExp::RegExp2);
QTextStream in(&inputFile);
while (!in.atEnd()) {
QString line = in.readLine();
if (line.trimmed().isEmpty() || commentRegExp.exactMatch(line)) {
continue;
} else if (identityRegExp.exactMatch(line)) {
if (!dryRun) {
accessMutex.lock();
identityToPublicKeyHashMap.insert(identityRegExp.cap(1), PublicKey::fromHexString(identityRegExp.cap(2)));
if (!identityRegExp.cap(3).trimmed().isEmpty()) {
// Nickname given.
identityToNicknameHashMap.insert(identityRegExp.cap(1), identityRegExp.cap(3));
}
accessMutex.unlock();
}
} else {
throw IllegalArgumentException() << QString("Invalid or ill-formated line in contacts file \"%1\". Problematic line: %2").arg(filename).arg(line).toStdString();
}
}
inputFile.close();
emit identitiesChanged();
}
示例4: ASSERT
void HmacImpl<HASH,DRBGINFO>::nextBytesImpl(byte bytes[], size_t size)
{
// Assert here. Parameters are validated in HmacGenerate()
ASSERT(DigestLength == m_v.size());
ASSERT(DigestLength == m_k.size());
// Has a catastrophic error been encountered previously?
ASSERT(!m_catastrophic);
if(m_catastrophic)
throw EncryptionException("A catastrophic error was previously encountered");
ASSERT(bytes && size);
if( !(bytes && size) )
throw IllegalArgumentException("Unable to generate bytes from hash drbg. The buffer or size is not valid");
ASSERT(m_rctr <= MaxReseed);
if( !(m_rctr <= MaxReseed) )
throw IllegalArgumentException("Unable to generate bytes from hash drbg. A reseed is required");
ASSERT(size <= MaxRequest);
if( !(size <= MaxRequest) )
throw IllegalArgumentException("Unable to generate bytes from hash drbg. The requested size exceeds the maximum this DRBG can produce");
try
{
// Set up a temporary so we don't leak bits on an exception
CryptoPP::SecByteBlock temp(size);
HmacGenerate(temp.data(), temp.size());
::memcpy(bytes, temp.data(), size);
}
catch(CryptoPP::Exception& ex)
{
m_catastrophic = true;
throw EncryptionException(NarrowString("Internal error: ") + ex.what());
}
}
示例5: IllegalArgumentException
void CGImageLuminanceSource::init (CGImageRef cgimage, int left, int top, int width, int height) {
data_ = 0;
image_ = cgimage;
left_ = left;
top_ = top;
width_ = width;
height_ = height;
dataWidth_ = (int)CGImageGetWidth(image_);
dataHeight_ = (int)CGImageGetHeight(image_);
if (left_ + width_ > dataWidth_ ||
top_ + height_ > dataHeight_ ||
top_ < 0 ||
left_ < 0) {
throw IllegalArgumentException("Crop rectangle does not fit within image data.");
}
CGColorSpaceRef space = CGImageGetColorSpace(image_);
CGColorSpaceModel model = CGColorSpaceGetModel(space);
if (model != kCGColorSpaceModelMonochrome || CGImageGetBitsPerComponent(image_) != 8 || CGImageGetBitsPerPixel(image_) != 8) {
CGColorSpaceRef gray = CGColorSpaceCreateDeviceGray();
CGContextRef ctx = CGBitmapContextCreate(0, width, height, 8, width, gray, kCGImageAlphaNone);
CGColorSpaceRelease(gray);
if (top || left) {
CGContextClipToRect(ctx, CGRectMake(0, 0, width, height));
}
CGContextDrawImage(ctx, CGRectMake(-left, -top, width, height), image_);
image_ = CGBitmapContextCreateImage(ctx);
bytesPerRow_ = width;
top_ = 0;
left_ = 0;
dataWidth_ = width;
dataHeight_ = height;
CGContextRelease(ctx);
} else {
CGImageRetain(image_);
}
CGDataProviderRef provider = CGImageGetDataProvider(image_);
data_ = CGDataProviderCopyData(provider);
}
示例6: switch
void InternalJob::SetPriority(int newPriority)
{
switch (newPriority)
{
case Job::INTERACTIVE:
case Job::SHORT:
case Job::LONG:
case Job::BUILD:
case Job::DECORATE:
ptr_manager->SetPriority(InternalJob::Pointer(this), newPriority);
break;
default:
throw IllegalArgumentException(newPriority);
}
}
示例7: project
void project(Coordinate* c) const
{
double inx = c->x;
double iny = c->y;
if (_transform->Transform(1, &c->x, &c->y) == FALSE)
{
QString err = QString("Error projecting point. Is the point outside of the projection's "
"bounds?");
LOG_WARN("Source Point, x:" << inx << " y: " << iny);
LOG_WARN("Source SRS: " << MapReprojector::toWkt(_transform->GetSourceCS()));
LOG_WARN("Target Point, x:" << c->x << " y: " << c->y);
LOG_WARN("Target SRS: " << MapReprojector::toWkt(_transform->GetTargetCS()));
throw IllegalArgumentException(err);
}
}
示例8: initFieldType
SortField::SortField(const String& field, ParserPtr parser, bool reverse)
{
if (boost::dynamic_pointer_cast<IntParser>(parser))
initFieldType(field, INT);
else if (boost::dynamic_pointer_cast<ByteParser>(parser))
initFieldType(field, BYTE);
else if (boost::dynamic_pointer_cast<LongParser>(parser))
initFieldType(field, LONG);
else if (boost::dynamic_pointer_cast<DoubleParser>(parser))
initFieldType(field, DOUBLE);
else
boost::throw_exception(IllegalArgumentException(L"Parser instance does not subclass existing numeric parser from FieldCache"));
this->reverse = reverse;
this->parser = parser;
}
示例9: IllegalArgumentException
void ActionPerformer::performAction(const String&name)
{
Action*action = nullptr;
size_t actions_size = actions.size();
for(size_t i=0; i<actions_size; i++)
{
ActionInfo actInfo = actions.get(i);
if(actInfo.name.equals(name))
{
action = actInfo.action;
i = actions_size;
}
}
if(action == nullptr)
{
throw IllegalArgumentException("name", "action does not exist");
}
else if(action->performer != nullptr && ((!action->finishing && !action->cancelling) || action->reran))
{
throw IllegalArgumentException("perform", "cannot perform on multiple performers");
}
else if(action_current != nullptr && ((!action_current->finishing && !action_current->cancelling) || action_current->reran))
{
throw IllegalStateException("current action must be cancelled or finished before another action is performed");
}
else if(action_current==action && action_current->cancelling)
{
throw IllegalArgumentException("action", "action is cancelling");
}
action_current = action;
action_name = name;
action_current->perform(this);
}
示例10: IllegalArgumentException
GF256Poly *GF256Poly::multiplyByMonomial(int degree,
int coefficient) {
if (degree < 0) {
throw IllegalArgumentException("Degree must be non-negative");
}
if (coefficient == 0) {
return field.getZero();
}
int size = coefficients.size();
ArrayRef<int> product (new Array<int>(size + degree));
for (int i = 0; i < size; i++) {
product[i] = field.multiply(coefficients[i], coefficient);
}
return new GF256Poly(field, product);
}
示例11: switch
bool Field::isStored(Store store)
{
switch (store)
{
case STORE_YES:
return true;
case STORE_NO:
return false;
default:
boost::throw_exception(IllegalArgumentException(L"Invalid field store"));
return false;
}
}
示例12: requireParser
/**
* Parses a datetime from the given text, returning the number of
* milliseconds since the epoch, 1970-01-01T00:00:00Z.
* <p>
* The parse will use the ISO chronology, and the default time zone.
* If the text contains a time zone string then that will be taken into account.
*
* @param text text to parse
* @return parsed value expressed in milliseconds since the epoch
* @throws UnsupportedOperationException if parsing is not supported
* @throws IllegalArgumentException if the text to parse is invalid
*/
int64_t DateTimeFormatter::parseMillis(string text) {
DateTimeParser *parser = requireParser();
Chronology *chrono = selectChronology(iChrono);
DateTimeParserBucket *bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
int newPos = parser->parseInto(bucket, text, 0);
if (newPos >= 0) {
if (newPos >= text.size()) {
return bucket->computeMillis(true, text);
}
} else {
newPos = ~newPos;
}
throw IllegalArgumentException(FormatUtils::createErrorMessage(text, newPos));
}
示例13: throw
void
Thread::setSpecific(Key& key, void* value)
throw (IllegalArgumentException,
SystemException)
{
int ret;
ret = pthread_setspecific(key.theKey(), value);
if(ret) {
if(ret == EINVAL) {
throw IllegalArgumentException("Thread::setSpecific()", ret);
} else {
throw SystemException("Thread::setSpecific()",ret);
}
}
};
示例14: IllegalArgumentException
// The API asks for rows, but we're rotated, so we return columns.
unsigned char* GreyscaleRotatedLuminanceSource::getRow(int y, unsigned char* row) {
if (y < 0 || y >= getHeight()) {
throw IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
if (row == NULL) {
row = new unsigned char[width];
}
int offset = (left_ * dataWidth_) + (dataWidth_ - (y + top_));
for (int x = 0; x < width; x++) {
row[x] = greyData_[offset];
offset += dataWidth_;
}
return row;
}
示例15: IllegalArgumentException
bool ScriptMatchCreator::isMatchCandidate(ConstElementPtr element, const ConstOsmMapPtr& map)
{
if (!_script)
{
throw IllegalArgumentException("The script must be set on the ScriptMatchCreator.");
}
if (!_matchCandidateChecker.get())
{
vector<const Match *> emptyMatches;
_matchCandidateChecker.reset(
new ScriptMatchVisitor(map, emptyMatches, ConstMatchThresholdPtr(), _script));
_matchCandidateChecker->customScriptInit();
}
return _matchCandidateChecker->isMatchCandidate(element);
}