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


C++ u16string::erase方法代码示例

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


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

示例1:

void LineEdit::Validator::erase(std::u16string &string, size_t &scursor, size_t &ecursor) const {
  if( scursor < ecursor )
    string.erase( scursor, ecursor-scursor ); else
  if( scursor > 0 ){
    string.erase( ecursor-1, 1 );
    --scursor;
    }

  ecursor = scursor;
  }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例2: mapToDimension

bool mapToDimension(std::u16string& value)
{
    if (stripLeadingWhitespace(value).empty())
        return false;
    if (value[0] == '+') {
        if (value.erase(0, 1).empty())
            return false;
    }
    size_t pos = 0;
    while (value[pos] == '0')
        ++pos;
    if (0 < pos) {
        if (value.erase(0, pos).empty())
            return false;
    }
    pos = 0;
    while (isDigit(value[pos]))
        ++pos;
    if (value.length() <= pos) {
        value += u"px";
        return true;
    }
    size_t end = pos;
    if (value[pos] == '.') {
        ++pos;
        if (value.length() <= pos || !isDigit(value[pos])) {
            value.replace(end, std::u16string::npos, u"px");
            return true;
        }
        ++pos;
        while (isDigit(value[pos]))
            ++pos;
    }
    if (pos < value.length() && value[pos] == '%') {
        value.erase(++pos);
        return true;
    }
    value.replace(pos, std::u16string::npos, u"px");    // TODO: Check whether floating point length should be allowed
    return true;
}
开发者ID:UIKit0,项目名称:escudo,代码行数:40,代码来源:HTMLUtil.cpp

示例3: mapToInteger

bool mapToInteger(std::u16string& value)
{
    if (stripLeadingWhitespace(value).empty())
        return false;
    const char16_t* input = value.c_str();
    const char16_t* end = input + value.length();
    int u;
    end = parseInt(input, end, u);
    if (!end)
        return false;
    value.erase(end - input);
    return true;
}
开发者ID:UIKit0,项目名称:escudo,代码行数:13,代码来源:HTMLUtil.cpp

示例4: mapToPixelLength

bool mapToPixelLength(std::u16string& value)
{
    if (stripLeadingWhitespace(value).empty())
        return false;
    const char16_t* input = value.c_str();
    const char16_t* end = input + value.length();
    int u;
    end = parseInt(input, end, u);
    if (!end || u < 0)
        return false;
    if (0 < u)
        value.replace(end - input, std::u16string::npos, u"px");
    else
        value.erase(end - input);
    return true;
}
开发者ID:UIKit0,项目名称:escudo,代码行数:16,代码来源:HTMLUtil.cpp

示例5: specialCalculateMesh

    void TextFlow::specialCalculateMesh(
            std::u16string streamlinedContent,
            float lineHeight, std::vector<glm::vec3>& rVertices,
            std::vector<glm::vec2>& rTextureCoordinates)
    {
		// Reset flow width to get longest line's width of this computation
		mFlowWidth = 0;

        // OpenGL setup done in calling method

        // Get size of space character
        float pixelOfSpace = 0;

        Glyph const * pGlyph = mpFont->getGlyph(mFontSize, u' ');
        if (pGlyph == NULL)
        {
            throwWarning(
                OperationNotifier::Operation::RUNTIME,
                "TextFlow creation does not find space sign in font");
        }
        else
        {
            pixelOfSpace = mScale * pGlyph->advance.x;
        }

        // Create mark for overflow
        Word overflowMark = calculateWord(TEXT_FLOW_OVERFLOW_MARK, mScale);

        // Get pararaphs separated by \n
        std::vector<std::u16string> paragraphs;
        std::u16string paragraphDelimiter = u"\n";

        // Seperate into paragraphs
        size_t pos = 0;
        std::u16string token;
        while ((pos = streamlinedContent.find(paragraphDelimiter)) != std::u16string::npos)
        {
            token = streamlinedContent.substr(0, pos);
            paragraphs.push_back(token);
            streamlinedContent.erase(0, pos + paragraphDelimiter.length());
        }
        paragraphs.push_back(streamlinedContent); // Last paragraph (paragraphs never empty)

        // Do not generate text flow mesh when there is a failure
        bool failure = false;

        // Go over paragraphs (pens are in local pixel coordinate system with origin in lower left corner of element)
        float yPixelPen = -lineHeight; // First line should be also inside flow
        for (std::u16string& rPargraph : paragraphs)
        {
            // Get words out of paragraph
            std::vector<Word> words;
            std::u16string wordDelimiter = u" ";
            while ((pos = rPargraph.find(wordDelimiter)) != std::u16string::npos)
            {
                token = rPargraph.substr(0, pos);
                rPargraph.erase(0, pos + wordDelimiter.length());
                failure |= !insertFitWord(words, token, mWidth, mScale);
            }

            // Add last token from paragraph as well
            failure |= !insertFitWord(words, rPargraph, mWidth, mScale);

            // Failure appeared, forget it
            if (!failure)
            {
                // Prepare some values
                uint wordIndex = 0;
                bool hasNext = !words.empty();

                // Go over lines to write paragraph
                while (hasNext && abs(yPixelPen) <= mHeight)
                {
                    // Collect words in one line
                    std::vector<Word const *> line;
                    float wordsPixelWidth = 0;
                    float newWordsWithSpacesPixelWidth = 0;

                    // Still words in the paragraph and enough space? Fill into line!
                    while (hasNext && newWordsWithSpacesPixelWidth <= mWidth)
                    {
                        // First word should always fit into width because of previous checks
                        wordsPixelWidth += words[wordIndex].pixelWidth;
                        line.push_back(&words[wordIndex]);
                        wordIndex++;

                        if (wordIndex >= words.size())
                        {
                            // No words in paragraph left
                            hasNext = false;
                        }
                        else
                        {
                            // Calculate next width of line
                            newWordsWithSpacesPixelWidth = std::ceil(
                                (wordsPixelWidth + (float)words[wordIndex].pixelWidth) // Words size (old ones and new one)
                                + (((float)line.size()) - 1.0f) * pixelOfSpace); // Spaces between words
                        }
                    }

//.........这里部分代码省略.........
开发者ID:Institute-Web-Science-and-Technologies,项目名称:GazeTheWeb,代码行数:101,代码来源:TextFlow.cpp


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