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


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

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


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

示例1: xml_handle_entities

void xml_handle_entities(ustring & line, vector < size_t > *positions)
/*
  Changes the < and the > in the text to the xml entities &lt; and &gt
  Changes the ampersand (&) to &amp;
  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, "&amp;");
    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, "&lt;");
    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, "&gt;");
    if (positions)
      xml_positions_push_up(offposition, 3, *positions);
    offposition = line.find(">", offposition);
  }
}
开发者ID:alerque,项目名称:bibledit,代码行数:35,代码来源:xmlutils.cpp

示例2: analyseWord

    ustringArrayT analyseWord (ustring str) {
        typedef bool (*_TrivialPointerToFunctions_) (ustring);

        ustringArrayT res(3);
        _TrivialPointerToFunctions_ testFuncs[3] =
            { isConsonant, isVowel, isConsonant };

        // First part: Consonant 1
        // Second part: Vowel
        // Third part: Consonant 2

        for (int part = 0; part < 3; part++) {
            res[part] = "";
            // This is safe due to short-circuit logic
            while (str.length () > 0 && testFuncs[part] (_(str[0]))) {
                res[part] += _(str[0]);
                str.replace (0, 1, "");
            }
        }

        // Special case: "qu" and "gi" are considered consonants
        if (analyseWordCheckSpecialConsonants (res, "qu") ||
            analyseWordCheckSpecialConsonants (res, "gi")) {
            res[0] += _(res[1][0]);
            res[1] = res[1].replace (0, 1, "");
        }

        return res;
    }
开发者ID:ano-qml,项目名称:BoGoEngine,代码行数:29,代码来源:utils.cpp

示例3: 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;
  }
开发者ID:gasparfm,项目名称:glibutils,代码行数:11,代码来源:gutils_string.cpp

示例4: 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;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:12,代码来源:utilities.cpp

示例5: xml_html_insert_emphasis

void xml_html_insert_emphasis(ustring & line, vector < size_t > &positions, vector < size_t > &lengths)
// This inserts the <b> tag to get the text bold.
{
  for (unsigned int i = 0; i < positions.size(); i++) {
    // Text to insert to highlight it.
    ustring taggedtext = "<b>" + line.substr(positions[i], lengths[i]) + "</b>";
    // Insert tag.
    line.replace(positions[i], lengths[i], taggedtext);
    // Push any following positions up.
    for (unsigned int i2 = i + 1; i2 < positions.size(); i2++) {
      positions[i2] = positions[i2] + 7;
    }
  }
}
开发者ID:alerque,项目名称:bibledit,代码行数:14,代码来源:xmlutils.cpp

示例6: 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;
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:15,代码来源:utilities.cpp

示例7: 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);
    }
开发者ID:ano-qml,项目名称:BoGoEngine,代码行数:16,代码来源:utils.cpp

示例8: removeMarkFromWord

 ustring removeMarkFromWord (ustring word, _size_t_ pos) {
     ustring ch = _(word[pos]);
     return word.replace (pos, 1, removeMarkFromChar (ch));
 }
开发者ID:ano-qml,项目名称:BoGoEngine,代码行数:4,代码来源:utils.cpp


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