当前位置: 首页>>代码示例>>C++>>正文


C++ ustring::insert方法代码示例

本文整理汇总了C++中ustring::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ ustring::insert方法的具体用法?C++ ustring::insert怎么用?C++ ustring::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ustring的用法示例。


在下文中一共展示了ustring::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process_line

void Wordlist::process_line(ustring & line, set <ustring> &section_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);
  }
}
开发者ID:alerque,项目名称:bibledit,代码行数:47,代码来源:wordlist.cpp

示例2: CategorizeOneLine

void CategorizeLine::CategorizeOneLine(ustring &line)
{
    // Extract the marker for this line.
    ustring marker = usfm_extract_marker(line);
    
    // Marker to work with for this line.
    ustring actual_marker;
    if (marker.empty())
        actual_marker = previous_marker;
    else
        actual_marker = marker;
    
    // Re-insert bible note markers.
    if (marker == footnote_opener(false)) {
        line.insert(0, footnote_opener(true));
    }
    if (marker == endnote_opener(false)) {
        line.insert(0, endnote_opener(true));
    }
    if (marker == xref_opener(false)) {
        line.insert(0, xref_opener(true));
    }
    // Subdivide the line into categories.
    // Each category removes something from this content, until it is empty.
    
    // Footnotes, endnotes.
    if (!line.empty()) {
        size_t beginposition, endposition;
        ustring opening_marker = footnote_opener(true);
        ustring closing_marker = footnote_closer();
        beginposition = line.find(opening_marker);
        endposition = line.find(closing_marker);
        if (endposition == string::npos) {
            // BUG: In main editor, the chapter lines are all combined into a single long ustring.
            // This means that footnotes that are split across lines are "fixed." But that is not
            // the case when just looking at a single verse \\v line that has a footnote started
            // but not finished. Fixed 2/15/2018
            endposition = line.length() - 1;
        }
        while (beginposition != string::npos) {
            assert(beginposition <= endposition); // this cannot be above the while stmt...beginposition == string::npos if no marker is found
            ustring notetext;
            notetext = line.substr(beginposition + opening_marker.length(), endposition - beginposition - closing_marker.length());
            line.erase(beginposition, endposition - beginposition + closing_marker.length());
            clear_out_any_marker(notetext);
            append_text(note, notetext);
            beginposition = line.find(opening_marker);
            endposition = line.find(closing_marker);
        }
        opening_marker = endnote_opener(true);
        closing_marker = endnote_closer();
        beginposition = line.find(opening_marker);
        endposition = line.find(closing_marker);
        while ((beginposition != string::npos) && (endposition != string::npos)) {
            ustring notetext;
            notetext = line.substr(beginposition + opening_marker.length(), endposition - beginposition - closing_marker.length());
            line.erase(beginposition, endposition - beginposition + closing_marker.length());
            clear_out_any_marker(notetext);
            append_text(note, notetext);
            beginposition = line.find(opening_marker);
            endposition = line.find(closing_marker);
        }
    }
    // Crossreferences.
    if (!line.empty()) {
        size_t beginposition, endposition;
        ustring opening_marker = xref_opener(true);
        ustring closing_marker = xref_closer();
        beginposition = line.find(opening_marker);
        endposition = line.find(closing_marker);
        while ((beginposition != string::npos) && (endposition != string::npos)) {
            ustring referencetext;
            referencetext = line.substr(beginposition + opening_marker.length(), endposition - beginposition - closing_marker.length());
            line.erase(beginposition, endposition - beginposition + closing_marker.length());
            clear_out_any_marker(referencetext);
            append_text(ref, referencetext);
            beginposition = line.find(opening_marker);
            endposition = line.find(closing_marker);
        }
    }
    // Identifiers.
    if (!line.empty()) {
        if (is_id_marker(actual_marker)) {
            clear_out_any_marker(line);
            append_text(id, line);
            line.clear();
        }
    }
    // Introduction elements.
    if (!line.empty()) {
        if (is_intro_marker(actual_marker)) {
            clear_out_any_marker(line);
            append_text(intro, line);
            line.clear();
        }
    }
    // Headings, titles, labels.
    if (!line.empty()) {
        if (is_head_marker(actual_marker)) {
            clear_out_any_marker(line);
//.........这里部分代码省略.........
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:101,代码来源:categorize.cpp


注:本文中的ustring::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。