static PyObject *t_resourcebundle_get(t_resourcebundle *self, PyObject *arg) { UErrorCode status = U_ZERO_ERROR; charsArg key; int i; if (!parseArg(arg, "i", &i)) { ResourceBundle rb = self->object->get(i, status); if (U_FAILURE(status)) return ICUException(status).reportError(); return wrap_ResourceBundle(rb); } if (!parseArg(arg, "n", &key)) { ResourceBundle rb = self->object->get(key, status); if (U_FAILURE(status)) return ICUException(status).reportError(); return wrap_ResourceBundle(rb); } return PyErr_SetArgsError((PyObject *) self, "get", arg); }
jboolean rvmInitOptions(int argc, char* argv[], Options* options, jboolean ignoreRvmArgs) { char path[PATH_MAX]; if (!realpath(argv[0], path)) { return FALSE; } strcpy(options->executablePath, path); jint i = strlen(path); while (i >= 0 && path[i] != '/') { path[i--] = '\0'; } if (i >= 0 && path[i] == '/') { path[i] = '\0'; } strcpy(options->basePath, path); // Look for a robovm.ini next to the executable strcat(path, "/robovm.ini"); FILE* f = fopen(path, "r"); if (f) { char* line = NULL; size_t linecap = 0; ssize_t linelen; while ((linelen = getline(&line, &linecap, f)) > 0) { line = trim(line); if (strlen(line) > 0 && line[0] != '#') { parseArg(line, options); } } if (line) { free(line); } fclose(f); } jint firstJavaArg = 1; for (i = 1; i < argc; i++) { if (startsWith(argv[i], "-rvm:")) { if (!ignoreRvmArgs) { char* arg = &argv[i][5]; parseArg(arg, options); } firstJavaArg++; } else { break; } } options->commandLineArgs = NULL; options->commandLineArgsCount = argc - firstJavaArg; if (options->commandLineArgsCount > 0) { options->commandLineArgs = &argv[firstJavaArg]; } return options->mainClass != NULL; }
static PyObject *t_regexpattern_richcmp(t_regexpattern *self, PyObject *arg, int op) { RegexPattern *pattern; int b = 0; if (!parseArg(arg, "P", TYPE_CLASSID(RegexPattern), &pattern)) { switch (op) { case Py_EQ: case Py_NE: b = *self->object == *pattern; if (op == Py_EQ) Py_RETURN_BOOL(b); Py_RETURN_BOOL(!b); case Py_LT: case Py_LE: case Py_GT: case Py_GE: PyErr_SetNone(PyExc_NotImplementedError); return NULL; } } return PyErr_SetArgsError((PyObject *) self, "__richcmp__", arg); }
static PyObject *t_forwardcharacteriterator_richcmp(t_forwardcharacteriterator *self, PyObject *arg, int op) { int b = 0; ForwardCharacterIterator *i; if (!parseArg(arg, "P", TYPE_ID(ForwardCharacterIterator), &i)) { switch (op) { case Py_EQ: case Py_NE: b = *self->object == *i; if (op == Py_EQ) Py_RETURN_BOOL(b); Py_RETURN_BOOL(!b); case Py_LT: case Py_LE: case Py_GT: case Py_GE: PyErr_SetNone(PyExc_NotImplementedError); return NULL; } } return PyErr_SetArgsError((PyObject *) self, "__richcmp__", arg); }
void parseLoop (void) { char* cnd; const char* cmd[MAX_ARGS]; char input[MAX_BUFFER]; int argc; do { clean(cmd); argc = parseArg(cnd, cmd, input); if (argc == 0) { continue; } // Is the poor soul asking for help ? Give him some succour if (strcmp(cmd[0], "help") == 0 || strcmp(cmd[0], "?") == 0) { help(); continue; } // Are we done ? if (strcmp(cmd[0], "exit") == 0 || strcmp(cmd[0], "quit") == 0 ) { break; } execute(argc, cmd); } while (true); return; }
inline void parseAndSet_b(const TString& input, TString arg, bool& value) { TString newval = parseArg(input, arg); if (!newval.IsNull()) { if (newval.IsBin()) value = newval.Atoi(); else if (newval == "true") value = true; else if (newval == "false") value = false; } }
int main(int argc, char* argv[]) { parseArg(); connectToBootRom(); dlBootLoader(); return 0; }
void CApp::parseArgs(int argc, const char* const* argv, int& i) { // about these use of assert() here: // previously an /analyze warning was displayed if we only used assert and // did not return on failure. however, this warning does not appear to show // any more (could be because new compiler args have been added). // the asserts are programmer benefit only; the os should never pass 0 args, // because the first is always the binary name. the only way assert would // evaluate to true, is if this parse function were implemented incorrectly, // which is unlikely because it's old code and has a specific use. // we should avoid using anything other than assert here, because it will // look like important code, which it's not really. assert(argsBase().m_pname != NULL); assert(argv != NULL); assert(argc >= 1); // set defaults argsBase().m_name = ARCH->getHostName(); LOG((CLOG_INFO "CApp::parseArgs call")); // parse options for (i = 1; i < argc; ++i) { if (parseArg(argc, argv, i)) { continue; } else if (isArg(i, argc, argv, "--", NULL)) { // remaining arguments are not options ++i; break; } else if (argv[i][0] == '-') { std::cerr << "Unrecognized option: " << argv[i] << std::endl; m_bye(kExitArgs); } else { // this and remaining arguments are not options break; } } #if SYSAPI_WIN32 // suggest that user installs as a windows service. when launched as // service, process should automatically detect that it should run in // daemon mode. if (argsBase().m_daemon) { LOG((CLOG_ERR "The --daemon argument is not supported on Windows. " "Instead, install %s as a service (--service install).", argsBase().m_pname)); m_bye(kExitArgs); } #endif }
static PyObject *t_collationelementiterator_tertiaryOrder(PyTypeObject *type, PyObject *arg) { int i; if (!parseArg(arg, "i", &i)) return PyInt_FromLong(CollationElementIterator::tertiaryOrder(i)); return PyErr_SetArgsError(type, "tertiaryOrder", arg); }
static PyObject *t_collationelementiterator_strengthOrder(t_collationelementiterator *self, PyObject *arg) { int i; if (!parseArg(arg, "i", &i)) return PyInt_FromLong(self->object->strengthOrder(i)); return PyErr_SetArgsError((PyObject *) self, "strengthOrder", arg); }
static PyObject *t_collationelementiterator_getMaxExpansion(t_collationelementiterator *self, PyObject *arg) { int i; if (!parseArg(arg, "i", &i)) return PyInt_FromLong(self->object->getMaxExpansion(i)); return PyErr_SetArgsError((PyObject *) self, "getMaxExpansion", arg); }
static PyObject *t_searchiterator_setText(t_searchiterator *self, PyObject *arg) { UnicodeString *u; CharacterIterator *chars; if (!parseArg(arg, "W", &u, &self->text)) { STATUS_CALL(self->object->setText(*u, status)); /* ref'd */ Py_RETURN_NONE; } else if (!parseArg(arg, "P", TYPE_ID(CharacterIterator), &chars)) { STATUS_CALL(self->object->setText(*chars, status)); /* copied */ Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "setText", arg); }
static PyObject *t_breakiterator_preceding(t_breakiterator *self, PyObject *arg) { int32_t offset; if (!parseArg(arg, "i", &offset)) return PyInt_FromLong(self->object->preceding(offset)); return PyErr_SetArgsError((PyObject *) self, "preceding", arg); }
static PyObject *t_characteriterator_setIndex32(t_characteriterator *self, PyObject *arg) { int i; if (!parseArg(arg, "i", &i)) return PyInt_FromLong((long) self->object->setIndex32(i)); return PyErr_SetArgsError((PyObject *) self, "setIndex32", arg); }
int main(int argc, char *argv[]) { // Задание кодировки приложения #ifndef QT_NO_TEXTCODEC QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); #endif /// Параметр -debug влияет на вывод qDebug() в консоль. parseArg(argc, argv); QApplication app(argc, argv); // Заполняем глобальные переменные QFileInfo mainFile(app.applicationFilePath()); if (app.applicationName().isEmpty()) { app.setApplicationName( mainFile.baseName() ); } if (app.applicationVersion().isEmpty()) { qApp->setApplicationVersion(QString("%1.%2.%3").arg(VERSION_MAJOR).arg(VERSION_MINOR).arg(VERSION_PATCH)); } QDir *mainDir = new QDir(SettingsFile::getDefaultUserDataPath()); mainDir->mkpath(mainDir->path()); delete mainDir; // Перенаправляем вывод отладочной информации в файл // On Unix: Projects > Run Settings > Run in terminal qInstallMsgHandler(myMessageOutput); // Инициируем перевод через Qt Linguist const QString localeFile = SettingsFile::getDefaultResourcePath() + "/translations/" + mainFile.baseName() + "_" + QLocale::system().name(); QTranslator translator; if (!translator.load( localeFile )) { qDebug() << "Can't load QM (TS):" << localeFile; } app.installTranslator(&translator); // Для Win32 указываем искать плагины в директории с приложением #if defined(Q_WS_WIN32) app.addLibraryPath(app.applicationDirPath()); #endif MainWindow w; w.show(); return app.exec(); }
static PyObject *t_stringsearch_setPattern(t_stringsearch *self, PyObject *arg) { UnicodeString *u, _u; if (!parseArg(arg, "S", &u, &_u)) { STATUS_CALL(self->object->setPattern(*u, status)); /* copied */ Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "setPattern", arg); }
static PyObject *t_regexmatcher_replaceAll(t_regexmatcher *self, PyObject *arg) { UnicodeString *u, _u, result; if (!parseArg(arg, "S", &u, &_u)) { STATUS_CALL(result = self->object->replaceAll(*u, status)); return PyUnicode_FromUnicodeString(&result); } return PyErr_SetArgsError((PyObject *) self, "replaceAll", arg); }
static PyObject *t_locale_removeKeywordValue(t_locale *self, PyObject *arg) { charsArg name; if (!parseArg(arg, "n", &name)) { STATUS_CALL(self->object->setKeywordValue(name, "", status)); Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "removeKeywordValue", arg); }
static PyObject *t_localedata_setNoSubstitute(t_localedata *self, PyObject *arg) { int setting; if (!parseArg(arg, "b", &setting)) { ulocdata_setNoSubstitute(self->object, setting); Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "setNoSubstitute", arg); }
static PyObject *t_regexmatcher_appendTail(t_regexmatcher *self, PyObject *arg) { UnicodeString *u, _u, result; if (!parseArg(arg, "S", &u, &_u)) { result = self->object->appendTail(*u); return PyUnicode_FromUnicodeString(&result); } return PyErr_SetArgsError((PyObject *) self, "appendTail", arg); }
static PyObject *t_collationelementiterator_isIgnorable(PyTypeObject *type, PyObject *arg) { int i; if (!parseArg(arg, "i", &i)) { i = CollationElementIterator::isIgnorable(i); Py_RETURN_BOOL(i); } return PyErr_SetArgsError(type, "isIgnorable", arg); }
static PyObject *t_collationelementiterator_setOffset(t_collationelementiterator *self, PyObject *arg) { int offset; if (!parseArg(arg, "i", &offset)) { STATUS_CALL(self->object->setOffset(offset, status)); Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "setOffset", arg); }
static PyObject *t_collationelementiterator_setText(t_collationelementiterator *self, PyObject *arg) { UnicodeString *u, _u; if (!parseArg(arg, "S", &u, &_u)) { STATUS_CALL(self->object->setText(*u, status)); /* copied */ Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "setText", arg); }
static PyObject *t_breakiterator_setText(t_breakiterator *self, PyObject *arg) { UnicodeString *u; if (!parseArg(arg, "W", &u, &self->text)) { self->object->setText(*u); /* ref'd */ Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "setText", arg); }
Formattable *toFormattable(PyObject *arg) { UDate date; double d; int i; PY_LONG_LONG l; UnicodeString *u; UnicodeString _u; char *s; if (!parseArg(arg, "d", &d)) return new Formattable(d); if (!parseArg(arg, "i", &i)) return new Formattable(i); if (!parseArg(arg, "L", &l)) return new Formattable((int64_t) l); if (!parseArg(arg, "c", &s)) return new Formattable(s); if (!parseArg(arg, "S", &u, &_u)) return new Formattable(*u); if (!parseArg(arg, "E", &date)) return new Formattable(date, Formattable::kIsDate); return NULL; }
static PyObject *t_regexmatcher_setStackLimit(t_regexmatcher *self, PyObject *arg) { int32_t limit; if (!parseArg(arg, "i", &limit)) { STATUS_CALL(self->object->setStackLimit(limit, status)); Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "setStackLimit", arg); }
static PyObject *t_canonicaliterator_setSource(t_canonicaliterator *self, PyObject *arg) { UnicodeString *u, _u; if (!parseArg(arg, "S", &u, &_u)) { STATUS_CALL(self->object->setSource(*u, status)); /* transient */ Py_RETURN_NONE; } return PyErr_SetArgsError((PyObject *) self, "setSource", arg); }
static PyObject *t_searchiterator_getAttribute(t_searchiterator *self, PyObject *arg) { USearchAttribute attribute; if (!parseArg(arg, "i", &attribute)) { USearchAttributeValue value = self->object->getAttribute(attribute); return PyInt_FromLong(value); } return PyErr_SetArgsError((PyObject *) self, "getAttribute", arg); }
static PyObject *t_breakiterator_isBoundary(t_breakiterator *self, PyObject *arg) { int32_t i; if (!parseArg(arg, "i", &i)) { int b = self->object->isBoundary(i); Py_RETURN_BOOL(b); } return PyErr_SetArgsError((PyObject *) self, "isBoundary", arg); }
static PyObject *t_searchiterator_preceding(t_searchiterator *self, PyObject *arg) { int32_t position, preceding; if (!parseArg(arg, "i", &position)) { STATUS_CALL(preceding = self->object->preceding(position, status)); return PyInt_FromLong(preceding); } return PyErr_SetArgsError((PyObject *) self, "preceding", arg); }