本文整理汇总了C++中CheckArgument函数的典型用法代码示例。如果您正苦于以下问题:C++ CheckArgument函数的具体用法?C++ CheckArgument怎么用?C++ CheckArgument使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckArgument函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckArgument
int ReminderGlue::FindReminder(lua_State* lua)
{
CheckArgument(lua, 1, LUA_TSTRING);
CheckArgument(lua, 2, LUA_TSTRING);
CheckArgument(lua, 3, LUA_TSTRING);
UnicodeString server = AsUnicode(lua_tostring(lua, 1));
UnicodeString channel = AsUnicode(lua_tostring(lua, 2));
UnicodeString searchString = AsUnicode(lua_tostring(lua, 3));
ReminderManager::ReminderIteratorRange reminders =
reminderManager_->FindReminders(server, channel, searchString);
int reminderCount = std::distance(reminders.first, reminders.second);
lua_createtable(lua, reminderCount, 0);
int mainTableIndex = lua_gettop(lua);
for (ReminderManager::ReminderIterator reminder = reminders.first; reminder
!= reminders.second; ++reminder)
{
lua_createtable(lua, 2, 0);
int subTableIndex = lua_gettop(lua);
lua_pushinteger(lua, reminder->Timestamp - time(0));
lua_rawseti(lua, subTableIndex, 1);
lua_pushstring(lua, AsUtf8(reminder->Message).c_str());
lua_rawseti(lua, subTableIndex, 2);
int currentMainIndex = std::distance(reminders.first, reminder) + 1;
lua_rawseti(lua, mainTableIndex, currentMainIndex);
}
return 1;
}
示例2: CheckArgument
void TimerStat::start() {
if(__CVC4_USE_STATISTICS) {
CheckArgument(!d_running, *this, "timer already running");
clock_gettime(CLOCK_MONOTONIC, &d_start);
d_running = true;
}
}/* TimerStat::start() */
示例3: CheckFunctionCall
static AstExpression CheckFunctionCall(AstExpression expr)
{
AstExpression arg;
Type ty;
AstNode *tail;
int argNo, argFull;
if (expr->kids[0]->op == OP_ID && LookupID(expr->kids[0]->val.p) == NULL)
{
expr->kids[0]->ty = DefaultFunctionType;
expr->kids[0]->val.p = AddFunction(expr->kids[0]->val.p, DefaultFunctionType, TK_EXTERN);
}
else
{
expr->kids[0] = CheckExpression(expr->kids[0]);
}
expr->kids[0] = Adjust(expr->kids[0], 1);
ty = expr->kids[0]->ty;
if (! (IsPtrType(ty) && IsFunctionType(ty->bty)))
{
Error(&expr->coord, "The left operand must be function or function pointer");
ty = DefaultFunctionType;
}
else
{
ty = ty->bty;
}
tail = (AstNode *)&expr->kids[1];
arg = expr->kids[1];
argNo = 1;
argFull = 0;
while (arg != NULL && ! argFull)
{
*tail = (AstNode)CheckArgument((FunctionType)ty, arg, argNo, &argFull);
tail = &(*tail)->next;
arg = (AstExpression)arg->next;
argNo++;
}
*tail = NULL;
if (arg != NULL)
{
while (arg != NULL)
{
CheckExpression(arg);
arg = (AstExpression)arg->next;
}
Error(&expr->coord, "Too many arguments");
}
else if (argNo < LEN(((FunctionType)ty)->sig->params))
{
Error(&expr->coord, "Too few arguments");
}
expr->ty = ty->bty;
return expr;
}
示例4: CheckArgument
void LogicInfo::disableReals() {
CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified");
d_logicString = "";
d_reals = false;
if(!d_integers) {
disableTheory(THEORY_ARITH);
}
}
示例5: throw
void StatisticsRegistry::unregisterStat(Stat* s) throw(CVC4::IllegalArgumentException) {
#ifdef CVC4_STATISTICS_ON
StatSet& stats = current()->d_stats;
CheckArgument(stats.find(s) != stats.end(), s,
"Statistic `%s' was not registered with this registry.",
s->getName().c_str());
stats.erase(s);
#endif /* CVC4_STATISTICS_ON */
}/* StatisticsRegistry::unregisterStat() */
示例6: nms
const Datatype& DatatypeType::getDatatype() const {
NodeManagerScope nms(d_nodeManager);
if( d_typeNode->isParametricDatatype() ) {
CheckArgument( (*d_typeNode)[0].getKind() == kind::DATATYPE_TYPE, this);
const Datatype& dt = (*d_typeNode)[0].getConst<Datatype>();
return dt;
} else {
return d_typeNode->getDatatype();
}
}
示例7: CheckArgument
Type& Type::operator=(const Type& t) {
CheckArgument(d_typeNode != NULL, this, "Unexpected NULL typenode pointer!");
CheckArgument(t.d_typeNode != NULL, t, "Unexpected NULL typenode pointer!");
if(this != &t) {
if(d_nodeManager == t.d_nodeManager) {
NodeManagerScope nms(d_nodeManager);
*d_typeNode = *t.d_typeNode;
} else {
// This happens more than you think---every time you set to or
// from the null Type. It's tricky because each node manager
// must be in play at the right time.
NodeManagerScope nms1(d_nodeManager);
*d_typeNode = TypeNode::null();
NodeManagerScope nms2(t.d_nodeManager);
*d_typeNode = *t.d_typeNode;
d_nodeManager = t.d_nodeManager;
}
}
return *this;
}
示例8: throw
void LogicInfo::setLogicString(std::string logicString) throw(IllegalArgumentException) {
CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified");
for(TheoryId id = THEORY_FIRST; id < THEORY_LAST; ++id) {
d_theories[id] = false;// ensure it's cleared
}
d_sharingTheories = 0;
// Below, ONLY use enableTheory()/disableTheory() rather than
// accessing d_theories[] directly. This makes sure to set up
// sharing properly.
enableTheory(THEORY_BUILTIN);
enableTheory(THEORY_BOOL);
const char* p = logicString.c_str();
if(!strcmp(p, "QF_SAT") || *p == '\0') {
// propositional logic only; we're done.
p += 6;
} else if(!strcmp(p, "QF_ALL_SUPPORTED")) {
// the "all theories included" logic, no quantifiers
enableEverything();
disableQuantifiers();
p += 16;
} else if(!strcmp(p, "ALL_SUPPORTED")) {
// the "all theories included" logic, with quantifiers
enableEverything();
enableQuantifiers();
p += 13;
} else {
if(!strncmp(p, "QF_", 3)) {
disableQuantifiers();
p += 3;
} else {
enableQuantifiers();
}
if(!strncmp(p, "AX", 2)) {
enableTheory(THEORY_ARRAY);
p += 2;
} else {
if(*p == 'A') {
enableTheory(THEORY_ARRAY);
++p;
}
if(!strncmp(p, "UF", 2)) {
enableTheory(THEORY_UF);
p += 2;
}
if(!strncmp(p, "BV", 2)) {
enableTheory(THEORY_BV);
p += 2;
}
if(!strncmp(p, "DT", 2)) {
enableTheory(THEORY_DATATYPES);
p += 2;
}
if(!strncmp(p, "IDL", 3)) {
enableIntegers();
disableReals();
arithOnlyDifference();
p += 3;
} else if(!strncmp(p, "RDL", 3)) {
disableIntegers();
enableReals();
arithOnlyDifference();
p += 3;
} else if(!strncmp(p, "IRDL", 4)) {
// "IRDL" ?! --not very useful, but getLogicString() can produce
// that string, so we really had better be able to read it back in.
enableIntegers();
enableReals();
arithOnlyDifference();
p += 4;
} else if(!strncmp(p, "LIA", 3)) {
enableIntegers();
disableReals();
arithOnlyLinear();
p += 3;
} else if(!strncmp(p, "LRA", 3)) {
disableIntegers();
enableReals();
arithOnlyLinear();
p += 3;
} else if(!strncmp(p, "LIRA", 4)) {
enableIntegers();
enableReals();
arithOnlyLinear();
p += 4;
} else if(!strncmp(p, "NIA", 3)) {
enableIntegers();
disableReals();
arithNonLinear();
p += 3;
} else if(!strncmp(p, "NRA", 3)) {
disableIntegers();
enableReals();
arithNonLinear();
p += 3;
} else if(!strncmp(p, "NIRA", 4)) {
enableIntegers();
enableReals();
//.........这里部分代码省略.........
示例9: throw
SubrangeType::SubrangeType(const Type& t)
throw(IllegalArgumentException) :
Type(t) {
CheckArgument(isNull() || isSubrange(), this);
}
示例10: Begin
void Begin(int argc, char* argv[]) {
char task[64],
buffer[1024];
int i,
cmdLength=0,
cmdBegin=1,
function;
Task* workingtask = NULL;
// vérification arguments
function = CheckArgument(argv[1]);
int AcceptNull = (function==_H||function==_CF||function==_R||function==_I||function==_LT||function==_LD);
// début de traitement
switch (AcceptNull)
{
// cas des commandes qui n'ont pas besoin d'une tache valide
case true :
{
switch (function)
{
case _R : printf("-- number of running task"); TaskFunction = Running; break;
case _CF : printf("-- open configuration file\n"); TaskFunction = OpenConfig; break;
case _H : printf("-- help of the program\n"); TaskFunction = Help; break;
case _I : printf("-- number of running instances"); TaskFunction = Instances; break;
case _LT : printf("-- list all tasks\n"); TaskFunction = ListAllTasks; break;
case _LD : printf("-- list loaded tasks\n"); TaskFunction = ListLoadedTasks; break;
}
break;
}
// cas des commandes nécessitant une tache valide
default :
{
// nom de la tache
if (function != _A && argc > 2) sprintf(task, "%s", argv[2]);
else sprintf(task, "%s", DEFAULT_TASK);
// pointeur sur celle-ci
workingtask=GetTask(task);
if (workingtask==NULL) {
workingtask=LoadTask(task);
if (workingtask==NULL) {
workingtask=AddTask(task);
if (workingtask==NULL) {
// tache introuvable, plus de place
fprintf(stderr, "*** unable to work on task %s, exit\n", task);
exit(2);
}
}
}
// tache valide
switch (function)
{
case _L : printf("-- list %s task\n", task); TaskFunction = ListTask; break;
case _S : printf("-- start %s task\n", task); TaskFunction = StartTask; break;
case _D : printf("-- delete last command in %s task\n", task); TaskFunction = DeleteLastCommand; break;
case _X : printf("-- stop %s task\n", task); TaskFunction = StopTask; break;
case _C : printf("-- clean %s task\n", task); TaskFunction = CleanTask; break;
case _M : {
if (argc > 3) sprintf(DEFAULT_EDITOR, "%s", argv[3]);
printf("-- modify %s task\n", task);
TaskFunction = ModifyTask;
break;
}
case _T : cmdBegin+=2;
case _A : {
GetEnv("$PWD", addedCommand.wd);
sprintf(addedCommand.cmd, "%s", argv[cmdBegin]);
cmdLength = strlen(addedCommand.cmd);
for (i=cmdBegin+1; i<argc; i++) {
cmdLength += strlen(argv[i]);
if (cmdLength >= 1023) {
fprintf(stderr, "*** attention : command is too long (max. size 1024)\n");
fprintf(stderr, " possible unexpected behavior\n");
break;
}
sprintf(buffer, " %s", argv[i]);
strncat(addedCommand.cmd, buffer, 1024);
}
printf("-- add '%s' to %s task\n", addedCommand.cmd, task);
TaskFunction = AddToTask;
break;
}
default : fprintf(stderr, "*** error while interpreting arguments : returning value %d\n", function); break;
}
break;
}
}
TaskFunction(workingtask);
if (workingtask!=NULL) {
if ((!workingtask->exec) && (!workingtask->demand))
workingtask->inuse=0;
}
}
示例11: GetArgument
Arguments<U> Client<T,U>::ParseArguments(int argc, char *argv[], const size_t level,
const GetMetric default_a_ld,
const GetMetric default_b_ld,
const GetMetric default_c_ld) {
auto args = Arguments<U>{};
auto help = std::string{"\n* Options given/available:\n"};
// These are the options which are not for every client: they are optional
for (auto &o: options_) {
// Data-sizes
if (o == kArgM) { args.m = GetArgument(argc, argv, help, kArgM, size_t{512}); }
if (o == kArgN) { args.n = GetArgument(argc, argv, help, kArgN, size_t{512}); }
if (o == kArgK) { args.k = GetArgument(argc, argv, help, kArgK, size_t{512}); }
if (o == kArgKU) { args.ku = GetArgument(argc, argv, help, kArgKU, size_t{128}); }
if (o == kArgKL) { args.kl = GetArgument(argc, argv, help, kArgKL, size_t{128}); }
// Data-layouts
if (o == kArgLayout) { args.layout = GetArgument(argc, argv, help, kArgLayout, Layout::kRowMajor); }
if (o == kArgATransp) { args.a_transpose = GetArgument(argc, argv, help, kArgATransp, Transpose::kNo); }
if (o == kArgBTransp) { args.b_transpose = GetArgument(argc, argv, help, kArgBTransp, Transpose::kNo); }
if (o == kArgSide) { args.side = GetArgument(argc, argv, help, kArgSide, Side::kLeft); }
if (o == kArgTriangle) { args.triangle = GetArgument(argc, argv, help, kArgTriangle, Triangle::kUpper); }
if (o == kArgDiagonal) { args.diagonal = GetArgument(argc, argv, help, kArgDiagonal, Diagonal::kUnit); }
// Vector arguments
if (o == kArgXInc) { args.x_inc = GetArgument(argc, argv, help, kArgXInc, size_t{1}); }
if (o == kArgYInc) { args.y_inc = GetArgument(argc, argv, help, kArgYInc, size_t{1}); }
if (o == kArgXOffset) { args.x_offset = GetArgument(argc, argv, help, kArgXOffset, size_t{0}); }
if (o == kArgYOffset) { args.y_offset = GetArgument(argc, argv, help, kArgYOffset, size_t{0}); }
// Matrix arguments
if (o == kArgALeadDim) { args.a_ld = GetArgument(argc, argv, help, kArgALeadDim, default_a_ld(args)); }
if (o == kArgBLeadDim) { args.b_ld = GetArgument(argc, argv, help, kArgBLeadDim, default_b_ld(args)); }
if (o == kArgCLeadDim) { args.c_ld = GetArgument(argc, argv, help, kArgCLeadDim, default_c_ld(args)); }
if (o == kArgAOffset) { args.a_offset = GetArgument(argc, argv, help, kArgAOffset, size_t{0}); }
if (o == kArgBOffset) { args.b_offset = GetArgument(argc, argv, help, kArgBOffset, size_t{0}); }
if (o == kArgCOffset) { args.c_offset = GetArgument(argc, argv, help, kArgCOffset, size_t{0}); }
if (o == kArgAPOffset) { args.ap_offset= GetArgument(argc, argv, help, kArgAPOffset, size_t{0}); }
// Scalar result arguments
if (o == kArgDotOffset) { args.dot_offset = GetArgument(argc, argv, help, kArgDotOffset, size_t{0}); }
if (o == kArgNrm2Offset) { args.nrm2_offset = GetArgument(argc, argv, help, kArgNrm2Offset, size_t{0}); }
if (o == kArgAsumOffset) { args.asum_offset = GetArgument(argc, argv, help, kArgAsumOffset, size_t{0}); }
if (o == kArgImaxOffset) { args.imax_offset = GetArgument(argc, argv, help, kArgImaxOffset, size_t{0}); }
// Scalar values
if (o == kArgAlpha) { args.alpha = GetArgument(argc, argv, help, kArgAlpha, GetScalar<U>()); }
if (o == kArgBeta) { args.beta = GetArgument(argc, argv, help, kArgBeta, GetScalar<U>()); }
}
// These are the options common to all routines
args.platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0});
args.device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0});
args.precision = GetArgument(argc, argv, help, kArgPrecision, Precision::kSingle);
#ifdef CLBLAST_REF_CLBLAS
args.compare_clblas = GetArgument(argc, argv, help, kArgCompareclblas, 1);
#else
args.compare_clblas = 0;
#endif
#ifdef CLBLAST_REF_CBLAS
args.compare_cblas = GetArgument(argc, argv, help, kArgComparecblas, 1);
#else
args.compare_cblas = 0;
#endif
args.step = GetArgument(argc, argv, help, kArgStepSize, size_t{1});
args.num_steps = GetArgument(argc, argv, help, kArgNumSteps, size_t{0});
args.num_runs = GetArgument(argc, argv, help, kArgNumRuns, size_t{10});
args.print_help = CheckArgument(argc, argv, help, kArgHelp);
args.silent = CheckArgument(argc, argv, help, kArgQuiet);
args.no_abbrv = CheckArgument(argc, argv, help, kArgNoAbbreviations);
warm_up_ = CheckArgument(argc, argv, help, kArgWarmUp);
// Prints the chosen (or defaulted) arguments to screen. This also serves as the help message,
// which is thus always displayed (unless silence is specified).
if (!args.silent) { fprintf(stdout, "%s\n", help.c_str()); }
// Comparison against a non-BLAS routine is not supported
if (level == 4) { // level-4 == level-X
if (args.compare_clblas != 0 || args.compare_cblas != 0) {
if (!args.silent) {
fprintf(stdout, "* Disabling clBLAS and CPU BLAS comparisons for this non-BLAS routine\n\n");
}
}
args.compare_clblas = 0;
args.compare_cblas = 0;
}
// Comparison against clBLAS or a CPU BLAS library is not supported in case of half-precision
if (args.precision == Precision::kHalf) {
if (args.compare_clblas != 0 || args.compare_cblas != 0) {
if (!args.silent) {
fprintf(stdout, "* Disabling clBLAS and CPU BLAS comparisons for half-precision\n\n");
}
}
args.compare_clblas = 0;
args.compare_cblas = 0;
}
// Returns the arguments
//.........这里部分代码省略.........