bool operator!=( const SymProduct & operant ) const { return compare(operant) != 0; };
bool equals(const StringRef& ref) const { return compare(ref) == 0; }
static TermList * ParseRankedQuery (stemmed_dict * sd, char *QueryLine, int Sort) { u_char Word[MAXSTEMLEN + 1]; u_char *end, *s_in; TermList *Terms = MakeTermList (0); s_in = (u_char *) QueryLine; end = s_in + strlen ((char *) s_in) - 1; /* find the start of the first word */ if (!INAWORD (*s_in)) PARSE_NON_STEM_WORD (s_in, end); while (s_in <= end) { int j; long word_num; unsigned long count, doc_count, invf_ptr, invf_len; /* Get a word and stem it */ PARSE_STEM_WORD (Word, s_in, end); stemmer (sd->sdh.stem_method, Word); /* Skip over the non word separator */ PARSE_NON_STEM_WORD (s_in, end); /* Look for the word in the already identified terms */ for (j = 0; j < Terms->num; j++) if (compare (Terms->TE[j].Word, Word) == 0) break; /* Increment the weight if the word is in the list */ if (j < Terms->num) Terms->TE[j].Count++; else { /* Look for it in the stemmed dictionary */ if ((word_num = FindWord (sd, Word, &count, &doc_count, &invf_ptr, &invf_len)) != -1) { /* Search the list for the word */ for (j = 0; j < Terms->num; j++) if (Terms->TE[j].WE.word_num == word_num) break; /* Increment the weight if the word is in the list */ if (j < Terms->num) Terms->TE[j].Count++; else /* Create a new entry in the list for the new word */ { /* Create a new entry in the list for the new word */ TermEntry te; te.WE.word_num = word_num; te.WE.count = count; te.WE.doc_count = doc_count; te.WE.invf_ptr = invf_ptr; te.WE.invf_len = invf_len; te.Count = 1; te.Word = copy_string (Word); if (!te.Word) FatalError (1, "Could NOT create memory to add term"); AddTermEntry (&Terms, &te); } } } } if (Sort) /* Sort the terms in ascending order by doc_count */ qsort (Terms->TE, Terms->num, sizeof (TermEntry), doc_count_comp); return (Terms); }
static void test_blur(skiatest::Reporter* reporter) { SkPaint paint; paint.setColor(SK_ColorGRAY); paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(SkIntToScalar(strokeWidth)); SkScalar radius = SkIntToScalar(5); for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) { SkBlurMaskFilter::BlurStyle blurStyle = static_cast<SkBlurMaskFilter::BlurStyle>(style); const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag; for (uint32_t flags = 0; flags < flagPermutations; ++flags) { SkMaskFilter* filter; filter = SkBlurMaskFilter::Create(radius, blurStyle, flags); SkMaskFilter::BlurInfo info; sk_bzero(&info, sizeof(info)); SkMaskFilter::BlurType type = filter->asABlur(&info); REPORTER_ASSERT(reporter, type == static_cast<SkMaskFilter::BlurType>(style + 1)); REPORTER_ASSERT(reporter, info.fRadius == radius); REPORTER_ASSERT(reporter, info.fIgnoreTransform == SkToBool(flags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag)); REPORTER_ASSERT(reporter, info.fHighQuality == SkToBool(flags & SkBlurMaskFilter::kHighQuality_BlurFlag)); paint.setMaskFilter(filter); filter->unref(); for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) { SkPath path; tests[test].addPath(&path); SkPath strokedPath; paint.getFillPath(path, &strokedPath); SkRect refBound = strokedPath.getBounds(); SkIRect iref; refBound.roundOut(&iref); iref.inset(-outset, -outset); SkBitmap refBitmap; create(&refBitmap, iref, SkBitmap::kARGB_8888_Config); SkCanvas refCanvas(refBitmap); refCanvas.translate(SkIntToScalar(-iref.fLeft), SkIntToScalar(-iref.fTop)); drawBG(&refCanvas); refCanvas.drawPath(path, paint); for (int view = 0; view < tests[test].viewLen; ++view) { SkIRect itest = tests[test].views[view]; SkBitmap testBitmap; create(&testBitmap, itest, SkBitmap::kARGB_8888_Config); SkCanvas testCanvas(testBitmap); testCanvas.translate(SkIntToScalar(-itest.fLeft), SkIntToScalar(-itest.fTop)); drawBG(&testCanvas); testCanvas.drawPath(path, paint); REPORTER_ASSERT(reporter, compare(refBitmap, iref, testBitmap, itest)); } } } } }
int compare(const StringRef& ref) const { return compare(ref, IsEqual()); }
static void not_greater(void) { compare(BCODE_NOT_GREATER); }
/* +------------------------------------------------------------------ | FUNCTION : number_gt | INPUT : number : een getal | number : een getal | OUTPUT : | RETURN : boolean object | DATE : | | ABSTRACT : n1 > n2 ? | | CHANGES : +------------------------------------------------------------------ */ DylanObject *number_gt( number *n1, number *n2 ) { return ( compare ( Gt, n1, n2) ) ; }
bool operator<(std::string const& that) const { return compare(that) < 0; }
bool operator>=(std::string const& that) const { return compare(that) >= 0; }
bool operator<=(string const& that) const { return compare(that) <= 0; }
bool operator>(string const& that) const { return compare(that) > 0; }
int searchLocal(IpStruct tmp, unsigned int iplong, FILE * db, char * local) { char buf[80] = {0}; int first = 0; int offset = 0; int countPos= 0; int tmpCount = 0; int pos = BYTE3INT(tmp.local); fseek(db, pos, SEEK_SET); fread(buf, 4, 1, db); int c = compare(buf, iplong); // 获取资料 fread(buf, 1, 1, db); if ( buf[0] == 0x01 ) { // 国家地区均重复, 跳转至新地址 fread(buf, 3, 1, db); pos = BYTE3INT(buf); fseek(db, pos, SEEK_SET); fread(buf, 1, 1, db); } // 获取国家 if ( buf[0] == 0x02 ) { // 获取国家偏移 fread(buf, 3, 1, db); // 保存地区信息 tmpCount = ftell(db); pos = BYTE3INT(buf); fseek(db, pos, SEEK_SET); fread(buf, 1, 1, db); } if ( buf[0] == 0x01 || buf[0] == 0x02 ) { strcat(local, "未知"); return; } if ( buf[0] ) { GetData(buf+1, db, 40); } strcat(local, (char*)buf); strcat(local, " "); // 获取地区 if ( tmpCount ) { fseek(db, tmpCount, SEEK_SET); } fread(buf, 1, 1, db); while ( buf[0] == 0x02 ) { // 获取地区偏移 fread(buf, 3, 1, db); pos = BYTE3INT(buf); fseek(db, pos, SEEK_SET); fread(buf, 1, 1, db); } if ( buf[0] == 0x01 || buf[0] == 0x02 ) { strcat(local, "未知"); return; } if ( buf[0] ) { GetData(buf+1, db, 40); } strcat(local, (char*)buf); return; }
bool operator!=( const PoweredSym & operant ) const { return compare(operant) != 0; };
bool operator> ( const PoweredSym & operant ) const { return compare(operant) > 0; };
static void not_less(void) { compare(BCODE_NOT_LESS); }
void GameConsole::virtualKeyCallBack(USHORT vKey) { if (!showChat && !showConsole) { if (GetAsyncKeyState(VK_TAB) & 0x8000) { return; } if (vKey == VK_RETURN) { displayChat(false); } if (vKey == VK_OEM_3 || vKey == VK_OEM_8) // ` key for US and UK (todo: only use one or the other, since VK_OEM_3 is @ on UK keyboards) { displayChat(true); } // TODO: TEMP: remove if (vKey == VK_F11) { Menu::Instance().menuEnabled = !Menu::Instance().menuEnabled; } return; } switch (vKey) { case VK_RETURN: if (!currentInput.currentInput.empty()) { selectedQueue->unchangingBacklog.push_back(currentInput.currentInput); selectedQueue->pushLineFromKeyboardToGame(currentInput.currentInput); selectedQueue->startIndexForScrolling = 0; } hideConsole(); break; case VK_ESCAPE: hideConsole(); break; case VK_BACK: if (!currentInput.currentInput.empty()) { currentInput.backspace(); } break; case VK_DELETE: if (!currentInput.currentInput.empty()) { currentInput.del(); } break; case VK_CAPITAL: capsLockToggled = !capsLockToggled; break; case VK_PRIOR: // PAGE UP if (selectedQueue->startIndexForScrolling < selectedQueue->numOfLinesBuffer - selectedQueue->numOfLinesToShow) { selectedQueue->startIndexForScrolling++; } break; case VK_NEXT: // PAGE DOWN if (selectedQueue->startIndexForScrolling > 0) { selectedQueue->startIndexForScrolling--; } break; case VK_UP: currentBacklogIndex++; if (currentBacklogIndex > (int)selectedQueue->unchangingBacklog.size() - 1) { currentBacklogIndex--; } if (currentBacklogIndex >= 0) { currentInput.currentInput = selectedQueue->unchangingBacklog.at(selectedQueue->unchangingBacklog.size() - currentBacklogIndex - 1); } break; case VK_DOWN: currentBacklogIndex--; if (currentBacklogIndex < 0) { currentBacklogIndex = -1; currentInput.currentInput = ""; } else { currentInput.currentInput = selectedQueue->unchangingBacklog.at(selectedQueue->unchangingBacklog.size() - currentBacklogIndex - 1); } break; case VK_LEFT: currentInput.left(); break; case VK_RIGHT: currentInput.right(); break; case VK_TAB: if (showChat) { if (selectedQueue == &globalChatQueue) { SwitchToGameChat(); break; } else if (selectedQueue == &gameChatQueue) { SwitchToGlobalChat(); break; } } if (currentInput.currentInput.find_first_of(" ") == std::string::npos && currentInput.currentInput.length() > 0) { if (tabHitLast) { if (currentCommandList.size() > 0) { currentInput.set(currentCommandList.at((++tryCount) % currentCommandList.size())); } } else { tryCount = 0; currentCommandList.clear(); commandPriorComplete = currentInput.currentInput; auto currentLine = currentInput.currentInput; std::transform(currentLine.begin(), currentLine.end(), currentLine.begin(), ::tolower); for (auto cmd : Modules::CommandMap::Instance().Commands) { auto commandName = cmd.Name; std::transform(commandName.begin(), commandName.end(), commandName.begin(), ::tolower); if (commandName.compare(0, currentLine.length(), currentLine) == 0) { currentCommandList.push_back(commandName); } } consoleQueue.pushLineFromGameToUI(std::to_string(currentCommandList.size()) + " commands found starting with \"" + currentLine + ".\""); consoleQueue.pushLineFromGameToUI("Press tab to go through them."); } } break; case 'V': if (GetAsyncKeyState(VK_LCONTROL) & 0x8000 || GetAsyncKeyState(VK_RCONTROL) & 0x8000) // CTRL+V pasting { if (OpenClipboard(nullptr)) { HANDLE hData = GetClipboardData(CF_TEXT); if (hData) { char* textPointer = static_cast<char*>(GlobalLock(hData)); std::string text(textPointer); std::string newInputLine = currentInput.currentInput + text; for(char c : text) { if (currentInput.currentInput.size() <= INPUT_MAX_CHARS) { currentInput.type(c); } } GlobalUnlock(hData); } CloseClipboard(); } } else { handleDefaultKeyInput(vKey); } break; default: handleDefaultKeyInput(vKey); break; } tabHitLast = vKey == VK_TAB; }
static void greater(void) { compare(BCODE_GREATER); }
int string::compare(size_t pos, size_t len, const string& str, size_t subpos, size_t sublen) const { return compare(pos, len, str.substr(subpos, sublen)); }
/* +------------------------------------------------------------------ | FUNCTION : number_eq | INPUT : number : een getal | number : een getal | OUTPUT : | RETURN : boolean object | DATE : | | ABSTRACT : n1 = n2 ? | | CHANGES : +------------------------------------------------------------------ */ DylanObject *number_eq( number *n1, number *n2 ) { return ( compare ( Eq, n1, n2) ) ; }
int string::compare(const char* s) const { return compare(string(s)); }
/* +------------------------------------------------------------------ | FUNCTION : number_le | INPUT : number : een getal | number : een getal | OUTPUT : | RETURN : boolean object | DATE : | | ABSTRACT : n1 <= n2 ? | | CHANGES : +------------------------------------------------------------------ */ DylanObject *number_le( number *n1, number *n2 ) { return ( compare ( Le, n1, n2) ) ; }
int GeometryCollection::compareToSameClass(const Geometry *g) const { const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(g); return compare(*geometries, *(gc->geometries)); }
/** * MPI krok resiciho algoritmu. */ void mpi_solve_step() { assert(t); assert(s); // neni co resit if(stack_empty(s)) return; // puvodni sekvenci zpusob hledani reseni na generickem zasobniku srpdebug("core", node, "zpracovani stavu <d=%d, p=%d>", stack_top(s)->d, stack_top(s)->p); //porovnani if(compare(tf, stack_top(s)->B)) { /* // na zasobniku je reseni ulohy if(solution == NULL) { // prvni reseni ulohy solution = stack_pop(s); srpdebug("core", node, "reseni <prvni, p=%d>", solution->p); } else { if(solution->p >= stack_top(s)->p) { // lepsi reseni ulohy srpdebug("core", node, "reseni <lepsi, p=%d, o=%d>", stack_top(s)->p, solution->p - stack_top(s)->p); stack_item_destroy(solution); solution = stack_pop(s); } else { // horsi reseni ulohy srpdebug("core", node, "reseni <horsi, p=%d, o=+%d>", solution->p, stack_top(s)->p - solution->p); } } */ // mpi_best_p muzu bud ziskat sam, nebo ho dostat od jineho stroje // FIXME tohle lze vylepsit lepsi integraci mpi_best_p // nejdriv si ulozim lokalni nejlepsi reseni if(solution == NULL) { // prvni reseni ulohy solution = stack_pop(s); srpdebug("core", node, "reseni <prvni, p=%d>", solution->p); } else { if(solution->p >= stack_top(s)->p) { // lepsi reseni ulohy srpdebug("core", node, "reseni <lepsi, p=%d, o=%d>", stack_top(s)->p, solution->p - stack_top(s)->p); stack_item_destroy(solution); solution = stack_pop(s); } else { // horsi reseni ulohy srpdebug("core", node, "reseni <horsi, p=%d, o=+%d>", solution->p, stack_top(s)->p - solution->p); } } // ted poresim mpi_best_p if(mpi_best_p < 0 || mpi_best_p > solution->p) { mpi_best_p = solution->p; mpi_best_p_flag = 1; } } // zasobnik mohl byt vyprazdnen, pokud ne, expanze if(!stack_empty(s)) expand(); }
static void equal(void) { compare(BCODE_EQUAL); }
int icompare(const StringRef& ref) const { return compare(ref, IsEqualInsensitive()); }
static void not_equal(void) { compare(BCODE_NOT_EQUAL); }
bool ConnectionFactory::checkRemoteConnection(const enum ngsCatalogObjectType type, const Options &options) { resetError(); switch(type) { case CAT_CONTAINER_NGW: { std::string url = options.asString(KEY_URL); if(url.empty()) { return errorMessage(_("Missing required option 'url'")); } std::string login = options.asString(KEY_LOGIN); if(login.empty()) { login = "******"; } else { std::string oldLogin(login); login = CPLString(login).Trim(); if(!compare(oldLogin, login, true)) { warningMessage("Login was trimmed!"); } } std::string password = options.asString(KEY_PASSWORD); CPLStringList requestOptions; std::string headers = "Accept: */*"; Options authOptions; authOptions.add(KEY_TYPE, "basic"); authOptions.add(KEY_LOGIN, login); authOptions.add(KEY_PASSWORD, password); AuthStore::authAdd(url, authOptions); std::string auth = AuthStore::authHeader(url); AuthStore::authRemove(url); if(!auth.empty()) { headers += "\r\n"; headers += auth; } requestOptions.AddNameValue("HEADERS", headers.c_str()); CPLJSONDocument checkReq; if(!checkReq.LoadUrl(ngw::getCurrentUserUrl(url), requestOptions)) { return errorMessage(CPLGetLastErrorMsg()); } CPLJSONObject root = checkReq.GetRoot(); if(!root.IsValid()) { return errorMessage(_("Response is invalid")); } if(root.GetString("keyname") == login) { return true; } return errorMessage(_("User '%s' failed to connect to %s."), login.c_str(), url.c_str()); } default: return errorMessage(_("Unsupported connection type %d"), type); } }
static void less(void) { compare(BCODE_LESS); }
void TrendReport_float(TrendReport *x, double d) { float f = (float) d; if (x->numSeen == 0) { x->initialValue = x->prevprev = x->prev = f; x->direction = 0; } else if (x->numSeen == 1) { /* Just to start out, use absolute < comparison with no tolerance */ x->direction = ((f < x->initialValue) ? -1 : 1); x->numInTrend = 1; x->lastDeltaWithinTolerance = 0; } else { /* A trend has already been established */ int comparison = compare(f, x->prev, x->tolerance); // post("** compare (%f, %f, %f) = %d", f, x->prev, x->tolerance, comparison); if (comparison == x->direction) { /* Another value in the same trend */ // post("* trend continues..."); ++(x->numInTrend); } else if (comparison + x->direction == 0) { /* This value has broken the trend */ // post("* trend broken: outputting..."); OutputTrend(x); /* Therefore the previous value was a local maximum or minimum and began the current trend */ x->initialValue = x->prev; x->direction = comparison; x->numInTrend = 1; } else { // post("* last two values are within the tolerance..."); /* The current value is not different enough from the previous value to say the direction */ if (!(x->lastDeltaWithinTolerance)) { /* The previous delta was unambiguous, so we'll coast through this round assuming the current trend holds */ ++(x->numInTrend); } else { /* The previous delta value was also not very different, so our tolerance for tolerance has run out. We'll ignore the previous value and make a direct, no-tolerance comparison with the value before that. */ int newComparison = (f < x->prevprev) ? -1 : 1; if (newComparison == x->direction) { /* The trend holds */ ++(x->numInTrend); } else { /* We broke the trend */ OutputTrend(x); x->initialValue = x->prevprev; x->direction = newComparison; x->numInTrend = 2; } } } x->lastDeltaWithinTolerance = (comparison == 0); /* Don't hold it against us if the last delta was within the tolerance as long as the direction was OK. */ if (x->lastDeltaWithinTolerance) { int newComparison = (f < x->prev) ? -1 : 1; if (newComparison == x->direction) x->lastDeltaWithinTolerance = 0; } } x->prevprev = x->prev; x->prev = f; x->numSeen++; #ifdef DEBUG post("TrendReport received %f. numSeen %d, init %f, dir %d, numTrend %d, prev %f, prevprev %f", f, x->numSeen, x->initialValue, x->direction, x->numInTrend, x->prev, x->prevprev); #endif }
bool operator> ( const SymProduct & operant ) const { return compare(operant) > 0; };