StringView &StringView::trimLeft() noexcept { for (; begin_ < end_; ++begin_) if (!firstChar().isSpace()) break; return *this; }
Rect CRtfWord::charsBRect() const { if (chars_.empty()) return Rect(); // uliss TODO only first and last char are counted, is it better to // unite all character bboxes* return firstChar()->realRect().united(lastChar()->realRect()); }
QChar StringView::takeFirstLetter() noexcept(false) { mustNotBeEmpty(); const auto c = firstChar(); if (c.isSpace()) throw std::runtime_error("space"); ++begin_; return c; }
static QString doTagReplace(QString str, const Song &song) { if (str.contains(QLatin1Char('{'))) { QString artistFixed=song.basicArtist(); str.replace(constArtistArg, artistFixed); str.replace(constArtistFirstCharArg, firstChar(artistFixed)); str.replace(constAlbumArg, song.album); str.replace(constTitleArg, song.title); str.replace(constYearArg, QString::number(song.year)); str.replace(constTrackNoArg, QString::number(song.track)); } return str; }
bool isPalindrome(char word[], int length) { printWord(word, length); if (length == 0 || length == 1) { return true; } else { if (firstChar(word) != lastChar(word, length)) { return false; } else { return isPalindrome(middle(word), length - 2); } } }
StringView StringView::takeFirstWord() noexcept(false) { trimLeft(); mustNotBeEmpty(); assert(!lastChar().isSpace()); const auto it = begin_; for (; begin_ != end_; ++begin_) if (firstChar().isSpace()) break; const auto result = StringView{it, begin_}; trimLeft(); return result; }
std::pair< std::vector<std::string>,std::vector<std::string> > decomposeCompoundUnitString( const std::string& s) { if (!isCompoundUnit(s)) { LOG_FREE_AND_THROW("openstudio.QuantityRegex","Cannot decompose " << s << " into AtomicUnits in the numerator and denominator because it is not a compound unit."); } std::pair< std::vector<std::string>,std::vector<std::string> > result; boost::match_results<std::string::const_iterator> match; std::string ws(s); // remove leading 1, if applicable std::string::iterator firstCharEnd = ws.begin(); ++firstCharEnd; std::string::const_iterator tempStrConstIter; // for gcc std::string firstChar(ws.begin(),firstCharEnd); if (firstChar == "1") { ws = std::string(firstCharEnd,ws.end()); firstCharEnd = ws.begin(); ++firstCharEnd; firstChar = std::string(ws.begin(),firstCharEnd); } while (!ws.empty() && (firstChar != "/")) { // populate numerator boost::regex_search(ws,match,regexAtomicUnit()); result.first.push_back(std::string(match[0].first,match[0].second)); tempStrConstIter = ws.end(); // for gcc ws = std::string(match[0].second,tempStrConstIter); if (!ws.empty()) { firstCharEnd = ws.begin(); ++firstCharEnd; firstChar = std::string(ws.begin(),firstCharEnd); } } if (firstChar == "/") { ws = std::string(firstCharEnd,ws.end()); while (!ws.empty()) { // populate denominator boost::regex_search(ws,match,regexAtomicUnit()); result.second.push_back(std::string(match[0].first,match[0].second)); tempStrConstIter = ws.end(); // for gcc ws = std::string(match[0].second,tempStrConstIter); } } return result; }
void Main(void) { char bitmap, bitmapL, bitmapH; char row, rowmask; char firstP1,firstP2,secondP1,secondP2,chr1; int charCount=0; functionSet(); IRWRITE(0x06);//entryModeSet(1, 0); // increment and no shift IRWRITE(0x0F);//displayOnOffControl(1, 1, 1); // display on, cursor on and blinking on //IRWRITE(0x80); setDdRamAddress(0x00); while (1) { // for (row=bitmapL=bitmapH=0, rowmask = 0xf7; row < 4; row++, rowmask >>= 1) { bitmap=colScan(rowmask); if (row==2) { bitmapH = (bitmapL >> 2); } bitmapL = (bitmapL<<3) | bitmap; } //P1 = bitmapL; //P2 = bitmapH; if(bitmapL==0x00 && bitmapH==0x00){ ; }else if(charCount==0){//first char charCount=1; firstP1=P2= bitmapL; firstP2=P3= bitmapH; delay(); }else if(charCount==1){//second char charCount=0; secondP1=P2= bitmapL; secondP2=P3= bitmapH; chr1=firstChar(firstP1,firstP2); secondChar(chr1,secondP1,secondP2);//secondChar() returns the input of this time delay(); } }
int ApplicationBinder::get(lua_State *L) { Binder binder(L); (void)binder.getInstance("Application", 1); const char* what = luaL_checkstring(L, 2); extern const char* g_getProperty(const char* what); const char* propertyGet = g_getProperty(what); std::string stringProp = propertyGet; char *returnedProperty = (char*)malloc((stringProp.length() + 1)*sizeof(char)); // char returnedProperty[stringProp.length()+1]; strcpy(returnedProperty, propertyGet); const char* arrayProperty[10] = {""}; unsigned int index = 0; arrayProperty[index] = strtok(returnedProperty,"|"); while(arrayProperty[index] != NULL) { std::string firstChar(arrayProperty[index],arrayProperty[index]+1); if (strcmp(firstChar.c_str(), "s") == 0){ std::string resultChar(arrayProperty[index] + 1); lua_pushstring(L, resultChar.c_str()); }else{ lua_pushnumber(L, atoi(arrayProperty[index])); } ++index; arrayProperty[index] = strtok(NULL, "|"); } free(returnedProperty); return index; }
LOCAL_C TBool CheckValidTextHost(const TDesCType& aHost) { TInt len = aHost.Length(); if (len == 0) return EFalse; // host name can't start with a dot or dash TChar firstChar(aHost[0]); if (firstChar == '-' || firstChar == '.') return EFalse; TChar prev = '\0'; TInt ii; for (ii=0; ii < len; ii++) { TChar ch(aHost[ii]); // Valid characters are a-z, 0-9, '-' and '.' if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z') && (ch < '0' || ch > '9') && ch != '-' && ch != '.') { return EFalse; } // dot is the section separator. Check the previous section is not empty if (ch == '.' && prev == '.') { // can't have an empty section return EFalse; } prev = ch; } // host name can't end with a dot or dash if (prev == '-' || prev == '.') return EFalse; return ETrue; }
std::size_t ZLUnicodeUtil::firstChar(Ucs4Char &ch, const std::string &utf8String) { return firstChar(ch, utf8String.c_str()); }
void UltimateLyricsProvider::fetchInfo(int id, const Song &metadata) { #if QT_VERSION < 0x050000 const QTextCodec *codec = QTextCodec::codecForName(charset.toAscii().constData()); #else const QTextCodec *codec = QTextCodec::codecForName(charset.toLatin1().constData()); #endif if (!codec) { emit lyricsReady(id, QString()); return; } QString artistFixed=metadata.basicArtist(); QString urlText(url); if (QLatin1String("lyrics.wikia.com")==name) { QUrl url(urlText); #if QT_VERSION < 0x050000 QUrl &query=url; #else QUrlQuery query; #endif query.addQueryItem(QLatin1String("artist"), artistFixed); query.addQueryItem(QLatin1String("song"), metadata.title); query.addQueryItem(QLatin1String("func"), QLatin1String("getSong")); query.addQueryItem(QLatin1String("fmt"), QLatin1String("xml")); #if QT_VERSION >= 0x050000 url.setQuery(query); #endif NetworkJob *reply = NetworkAccessManager::self()->get(url); requests[reply] = id; connect(reply, SIGNAL(finished()), this, SLOT(wikiMediaSearchResponse())); return; } songs.insert(id, metadata); // Fill in fields in the URL bool urlContainsDetails=urlText.contains(QLatin1Char('{')); if (urlContainsDetails) { doUrlReplace(constArtistArg, artistFixed, urlText); doUrlReplace(constArtistLowerArg, artistFixed.toLower(), urlText); doUrlReplace(constArtistLowerNoSpaceArg, noSpace(artistFixed.toLower()), urlText); doUrlReplace(constArtistFirstCharArg, firstChar(artistFixed), urlText); doUrlReplace(constAlbumArg, metadata.album, urlText); doUrlReplace(constAlbumLowerArg, metadata.album.toLower(), urlText); doUrlReplace(constAlbumLowerNoSpaceArg, noSpace(metadata.album.toLower()), urlText); doUrlReplace(constTitleArg, metadata.title, urlText); doUrlReplace(constTitleLowerArg, metadata.title.toLower(), urlText); doUrlReplace(constTitleCaseArg, titleCase(metadata.title), urlText); doUrlReplace(constYearArg, QString::number(metadata.year), urlText); doUrlReplace(constTrackNoArg, QString::number(metadata.track), urlText); } // For some reason Qt messes up the ? -> %3F and & -> %26 conversions - by placing 25 after the % // So, try and revert this... QUrl url(urlText); if (urlContainsDetails) { QByteArray data=url.toEncoded(); data.replace("%253F", "%3F"); data.replace("%253f", "%3f"); data.replace("%2526", "%26"); url=QUrl::fromEncoded(data, QUrl::StrictMode); } QNetworkRequest req(url); req.setRawHeader("User-Agent", "Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20100101 Firefox/6.0"); NetworkJob *reply = NetworkAccessManager::self()->get(req); requests[reply] = id; connect(reply, SIGNAL(finished()), this, SLOT(lyricsFetched())); }
std::string stripws(const std::string& s) { int ifirst = firstChar(s); int ilast = lastChar(s); return s.substr(ifirst, ilast - ifirst + 1); }
bool analyseWordCheckSpecialConsonants (ustringArrayT word, ustring consonant) { return lastChar (word[0]).lowercase () == _(consonant[0]) && firstChar (word[1]).lowercase () == _(consonant[1]); }
ustring firstChar (const gchar *s) { return firstChar (_(s)); }
ustring firstChar (string s) { return firstChar (_(s)); }