本文整理汇总了C++中ustring::find方法的典型用法代码示例。如果您正苦于以下问题:C++ ustring::find方法的具体用法?C++ ustring::find怎么用?C++ ustring::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ustring
的用法示例。
在下文中一共展示了ustring::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bibleworks_clipboard_file_line_get_extract_book_id
unsigned int bibleworks_clipboard_file_line_get_extract_book_id (ustring& line)
// Gets the id of a book from a line of a BibleWorks database copied through the clipboard.
// The amount of text that make up the book is removed from the line.
// Normally a line of text would look like this:
// SCR Matthew 1:1 Βίβλος γενέσεως Ἰησοῦ Χριστοῦ, υἱοῦ Δαβὶδ, υἱοῦ Ἀβραάμ.
// or:
// SCR 1 Corinthians 1:1 Παῦλος κλητὸς ἀπόστολος Ἰησοῦ Χριστοῦ διὰ θελήματος Θεοῦ, καὶ Σωσθένης ὁ ἀδελφός,
{
// Remove whitespace from the start of the line.
while (line.substr (0, 1) == " ")
line.erase (0, 1);
// Remove the module abbreviation.
size_t pos = line.find (" ");
if (pos == string::npos)
return 0;
line.erase (0, ++pos);
// Get the name of the book.
vector <unsigned int> ids = books_type_to_ids (btUnknown);
for (unsigned int i = 0; i < ids.size(); i++) {
ustring english_name = books_id_to_english (ids[i]);
if (line.find (english_name) == 0) {
line.erase (0, english_name.length());
return ids[i];
}
}
return 0;
}
示例2: replace_text
bool replace_text(ustring & line, const ustring & look_for, const ustring & replace_with)
// Replaces some text. Returns true if any replacement was done.
{
bool replacements_done = false;
size_t offposition = line.find (look_for);
while (offposition != string::npos) {
line.replace (offposition, look_for.length (), replace_with);
offposition = line.find (look_for, offposition + replace_with.length ());
replacements_done = true;
}
return replacements_done;
}
示例3: notes_handle_vcs_feedback
void notes_handle_vcs_feedback (const ustring& directory, const ustring& feedback)
// This handles the feedback that comes from the version control system.
{
if (directory == notes_shared_storage_folder ()) {
unsigned int note_id = 0;
// The following feedback indicates that somebody created a new note:
// create mode 100644 27185458
if (feedback.find ("create mode") != string::npos) {
ustring s (feedback);
s.erase (12);
Parse parse (s);
if (parse.words.size () == 2) {
note_id = convert_to_int (parse.words[1]);
}
}
// The following feedback indicates that somebody modified a note:
// # modified: 27185458
if (feedback.find ("modified:") != string::npos) {
ustring s (feedback);
s.erase (12);
note_id = convert_to_int (number_in_string (feedback));
}
// The following feedback indicates that somebody deleted a note:
// # deleted: 46473236
if (feedback.find ("deleted:") != string::npos) {
ustring s (feedback);
s.erase (11);
note_id = convert_to_int (number_in_string (feedback));
}
// See the following:
// 95935882 | 9 +++++++++
// It means that this note was edited.
if (feedback.find (" | ") != string::npos) {
note_id = convert_to_int (number_in_string (feedback));
}
if (note_id != 0) {
gw_message (_("Change detected for note ") + convert_to_string (note_id));
// Update the index.
sqlite3 *db;
sqlite3_open(notes_index_filename ().c_str(), &db);
sqlite3_busy_timeout(db, 1000);
notes_store_index_entry (db, note_id);
sqlite3_close(db);
}
}
}
示例4: store_expanded_verse
void CheckChaptersVerses::store_expanded_verse(const ustring & verse, unsigned int verses_pointer, vector < unsigned int >&expanded_verses, vector < unsigned int >&verses_pointers)
{
int expanded_verse;
expanded_verse = 2 * (convert_to_int(verse));
if (verse.find("b") == string::npos) {
expanded_verses.push_back(expanded_verse);
verses_pointers.push_back(verses_pointer);
}
if (verse.find("a") == string::npos) {
expanded_verses.push_back(++expanded_verse);
verses_pointers.push_back(verses_pointer);
}
}
示例5: replace_text_between
bool replace_text_between(ustring & line, const ustring & start, const ustring & end, const ustring & replacement)
// Replaces text that starts with "start" and ends with "end" with "replacement".
// Returns true if replacement was done.
{
bool replacements_done = false;
size_t beginpos = line.find(start);
size_t endpos = line.find(end);
while ((beginpos != string::npos) && (endpos != string::npos) && (endpos > beginpos)) {
line.replace(beginpos, endpos - beginpos + end.length(), replacement);
beginpos = line.find(start, beginpos + replacement.length());
endpos = line.find(end, beginpos + replacement.length());
replacements_done = true;
}
return replacements_done;
}
示例6: makeIMFromString
InputMethodT makeIMFromString (ustring imStr) {
InputMethodT im;
_size_t_ eolPos;
ustring transPortion;
ustring specialToken = (imStr.find (" -> ") != ustring::npos) ?
_(" -> ") : _(" ");
while (imStr.length () > 1) {
eolPos = imStr.find ("\n");
transPortion = imStr.substr (0, eolPos);
imStr = imStr.replace (0, eolPos + 1, "");
im = addTransformation
(im, transPortion.replace (1, specialToken.length (), ""));
}
return standardizeIM (im);
}
示例7: parseArray
void DataValue::parseArray(const ustring &text, void *value) {
ArrayValue *arr = (ArrayValue*)value;
int i = 1; // skip [
while (text[i] != ']') {
i++; // skip '
int p = text.find('\'', i);
void *v = arr->add(ustring(text, i, p - i));
i = p + 2; // skip =
p = text.find(',', i);
if(p == -1)
p = text.length() - 1;
parse(ustring(text, i, p - i), arr->type, v);
i = p;
if(text[i] == ',') i++;
}
}
示例8: processAllMessages
/*
* Extracts and processes all messages inside the specified buffer.
* @throw CDCReading Exception
*/
void CDCImplPrivate::processAllMessages(ustring& msgBuffer) {
if (msgBuffer.empty()) {
return;
}
ParsedMessage parsedMessage = parseNextMessage(msgBuffer);
while ( parsedMessage.parseResult.resultType != PARSE_NOT_COMPLETE ) {
if ( parsedMessage.parseResult.resultType == PARSE_BAD_FORMAT ) {
// throw all bytes from the buffer up to next 0x0D
size_t endMsgPos = msgBuffer.find(0x0D, parsedMessage.parseResult.lastPosition);
if (endMsgPos == string::npos) {
msgBuffer.clear();
} else {
msgBuffer.erase(0, endMsgPos+1);
}
setLastReceptionError("Bad message format");
} else {
msgBuffer.erase(0, parsedMessage.parseResult.lastPosition+1);
processMessage(parsedMessage);
}
if (msgBuffer.empty()) {
return;
}
parsedMessage = parseNextMessage(msgBuffer);
}
}
示例9: process_line
void Wordlist::process_line(ustring & line, set <ustring> §ion_entries)
// Processes one line of text:
// - deals with entries.
// - deals with asterisks.
// section_entries - has the entries already made in this section.
{
// Handle section restart.
{
ustring s (line);
ustring marker = usfm_extract_marker (s);
if (section_markers.find (marker) != section_markers.end()) {
section_entries.clear();
}
}
// Remove the asterisk before and the asterisk after the closer, e.g.:
// \w entry*\w* -> \w entry\w*
// \w entry\w** -> \w entry\w*
replace_text(line, "*" + entry_closer, entry_closer);
replace_text(line, entry_closer + "*", entry_closer);
// Go through the line looking for the opener.
size_t startpos = line.find(entry_opener);
while (startpos != string::npos) {
// Look for the closer too, after the opener, not before.
size_t endpos = line.find(entry_closer, startpos);
if (endpos == string::npos)
break;
// Get the word.
ustring word = line.substr(startpos + entry_opener.length(), endpos - startpos - entry_closer.length());
if (!word.empty()) {
// Store the word.
words.insert(word);
wordcount++;
// Handle asterisks.
if (use_asterisk) {
bool insert_asterisk = true;
if (first_in_chapter)
if (section_entries.find(word) != section_entries.end())
insert_asterisk = false;
if (insert_asterisk) {
line.insert(endpos + entry_closer.length(), "*");
}
section_entries.insert(word);
}
}
startpos = line.find(entry_opener, endpos);
}
}
示例10: clear_out_any_marker
void CategorizeLine::clear_out_any_marker(ustring & line)
{
size_t startpos = 0;
startpos = line.find("\\", startpos);
while (startpos != string::npos) {
ustring marker;
size_t endpos = line.find_first_of(" *", startpos);
if (endpos == string::npos) {
marker = line.substr(startpos + 1, line.length() - startpos);
} else {
marker = line.substr(startpos + 1, endpos - startpos - 1);
}
line.erase(startpos, marker.length() + 2);
startpos++;
startpos = line.find("\\", startpos);
}
}
示例11:
PaletteItemGroup::PaletteItemGroup(Palette *parent, const ustring &name):PaletteItem(parent, name, "") {
int p = name.find('_');
if(p != -1)
caption = name.substr(p+1, -1);
minHeight = 14;
height = minHeight;
fullWidth = true;
}
示例12: de_byte_order_mark
void de_byte_order_mark (ustring& line)
// Some textfiles start with a byte order mark.
// This function remove it.
{
if (line.find ("") == 0) { // Note that there's text between the quotation marks.
line.erase (0, 1);
}
}
示例13: replace
ustring replace(ustring source, ustring fromStr, ustring toStr, int offset, int times)
{
int total = 0;
ustring::size_type pos=offset;
while ( ( (pos = source.find(fromStr, pos)) < Glib::ustring::npos) && ( (times==0) || (total++<times) ) )
{
source.replace(pos, fromStr.length(), toStr);
pos+=toStr.size();
}
return source;
}
示例14: xml_handle_entities
void xml_handle_entities(ustring & line, vector < size_t > *positions)
/*
Changes the < and the > in the text to the xml entities < and >
Changes the ampersand (&) to &
Any positions affected by this will be adjusted.
*/
{
size_t offposition;
// Deal with &. This one is done first,
// else the ampersands inserted later will get changed too.
offposition = line.find("&");
while (offposition != string::npos) {
line.replace(offposition, 1, "&");
if (positions)
xml_positions_push_up(offposition, 4, *positions);
// Do not repeat on the & just removed and inserted, but start searching after it.
offposition = line.find("&", offposition + 3);
}
// Deal with <
offposition = line.find("<");
while (offposition != string::npos) {
line.replace(offposition, 1, "<");
if (positions)
xml_positions_push_up(offposition, 3, *positions);
offposition = line.find("<", offposition);
}
// Deal with >
offposition = line.find(">");
while (offposition != string::npos) {
line.replace(offposition, 1, ">");
if (positions)
xml_positions_push_up(offposition, 3, *positions);
offposition = line.find(">", offposition);
}
}
示例15: set_lyrics
void set_lyrics(DB_playItem_t *track, ustring lyrics) {
signal_idle().connect_once([track, lyrics = move(lyrics)]() -> void {
const char *artist, *title;
{
pl_lock_guard guard;
if (!is_playing(track))
return;
artist = deadbeef->pl_find_meta(track, "artist");
title = deadbeef->pl_find_meta(track, "title");
}
if (!artist)
artist = _("Unknown Artist");
if (!title)
title = _("Unknown Title");
refBuffer->erase(refBuffer->begin(), refBuffer->end());
refBuffer->insert_with_tags(refBuffer->begin(), title, tagsTitle);
refBuffer->insert_with_tags(refBuffer->end(), ustring("\n") + artist + "\n\n", tagsArtist);
bool italic = false;
bool bold = false;
size_t prev_mark = 0;
vector<RefPtr<TextTag>> tags;
while (prev_mark != ustring::npos) {
size_t italic_mark = lyrics.find("''", prev_mark);
if (italic_mark == ustring::npos)
break;
size_t bold_mark = ustring::npos;
if (italic_mark < lyrics.size() - 2 && lyrics[italic_mark + 2] == '\'')
bold_mark = italic_mark;
tags.clear();
if (italic) tags.push_back(tagItalic);
if (bold) tags.push_back(tagBold);
refBuffer->insert_with_tags(refBuffer->end(),
lyrics.substr(prev_mark, min(bold_mark, italic_mark) - prev_mark), tags);
if (bold_mark == ustring::npos) {
prev_mark = italic_mark + 2;
italic = !italic;
} else {
prev_mark = bold_mark + 3;
bold = !bold;
}
}
refBuffer->insert(refBuffer->end(), lyrics.substr(prev_mark)); // in case if no formatting found
last = track;
});
}