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


C++ StringTokenizer::count方法代码示例

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


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

示例1: invalidateTiles

bool MasterProcessSession::invalidateTiles(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    int part, tilePosX, tilePosY, tileWidth, tileHeight;

    if (tokens.count() != 6 ||
        !getTokenInteger(tokens[1], "part", part) ||
        !getTokenInteger(tokens[2], "tileposx", tilePosX) ||
        !getTokenInteger(tokens[3], "tileposy", tilePosY) ||
        !getTokenInteger(tokens[4], "tilewidth", tileWidth) ||
        !getTokenInteger(tokens[5], "tileheight", tileHeight))
    {
        sendTextFrame("error: cmd=invalidatetiles kind=syntax");
        return false;
    }

    // FIXME temporarily, set the editing on the 1st invalidate, TODO extend
    // the protocol so that the client can set the editing or view only.
    _tileCache->setEditing(true);

    _tileCache->invalidateTiles(_curPart, tilePosX, tilePosY, tileWidth, tileHeight);
    return true;
}
开发者ID:wanweihua,项目名称:online,代码行数:22,代码来源:MasterProcessSession.cpp

示例2: loadDocument

bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    if (tokens.count() < 2)
    {
        // Failed loading ends connection.
        sendTextFrame("error: cmd=load kind=syntax");
        return false;
    }

    Log::info("Requesting document load from child.");
    try
    {
        std::string timestamp;
        parseDocOptions(tokens, _loadPart, timestamp);

        std::ostringstream oss;
        oss << "load";
        oss << " url=" << _docBroker->getPublicUri().toString();
        oss << " jail=" << _docBroker->getJailedUri().toString();

        if (_loadPart >= 0)
            oss << " part=" + std::to_string(_loadPart);

        if (_haveDocPassword)
            oss << " password=" << _docPassword;

        if (!_docOptions.empty())
            oss << " options=" << _docOptions;

        const auto loadRequest = oss.str();
        return forwardToPeer(_peer, loadRequest.c_str(), loadRequest.size());
    }
    catch (const Poco::SyntaxException&)
    {
        sendTextFrame("error: cmd=load kind=uriinvalid");
    }

    return false;
}
开发者ID:expansio,项目名称:online,代码行数:39,代码来源:ClientSession.cpp

示例3: clientZoom

bool ChildSession::clientZoom(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    int tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight;

    if (tokens.count() != 5 ||
        !getTokenInteger(tokens[1], "tilepixelwidth", tilePixelWidth) ||
        !getTokenInteger(tokens[2], "tilepixelheight", tilePixelHeight) ||
        !getTokenInteger(tokens[3], "tiletwipwidth", tileTwipWidth) ||
        !getTokenInteger(tokens[4], "tiletwipheight", tileTwipHeight))
    {
        sendTextFrame("error: cmd=clientzoom kind=syntax");
        return false;
    }

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (_multiView)
        _loKitDocument->setView(_viewId);

    _loKitDocument->setClientZoom(tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight);
    return true;
}
开发者ID:biostone,项目名称:online,代码行数:22,代码来源:ChildSession.cpp

示例4: setClientPart

bool ChildSession::setClientPart(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    int part;
    if (tokens.count() < 2 ||
        !getTokenInteger(tokens[1], "part", part))
    {
        sendTextFrame("error: cmd=setclientpart kind=invalid");
        return false;
    }

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (part != _loKitDocument->getPart())
    {
        if (_multiView)
            _loKitDocument->setView(_viewId);

        _loKitDocument->setPart(part);
    }

    return true;
}
开发者ID:biostone,项目名称:online,代码行数:22,代码来源:ChildSession.cpp

示例5: keyEvent

bool ChildProcessSession::keyEvent(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    Poco::Mutex::ScopedLock lock(_mutex);

    int type, charcode, keycode;

    if (tokens.count() != 4 ||
        !getTokenKeyword(tokens[1], "type",
                         {{"input", LOK_KEYEVENT_KEYINPUT}, {"up", LOK_KEYEVENT_KEYUP}},
                         type) ||
        !getTokenInteger(tokens[2], "char", charcode) ||
        !getTokenInteger(tokens[3], "key", keycode))
    {
        sendTextFrame("error: cmd=key kind=syntax");
        return false;
    }

    _loKitDocument->pClass->setView(_loKitDocument, _viewId);
    _loKitDocument->pClass->postKeyEvent(_loKitDocument, type, charcode, keycode);

    return true;
}
开发者ID:maloherry,项目名称:online,代码行数:22,代码来源:ChildProcessSession.cpp

示例6: getTextSelection

bool ChildSession::getTextSelection(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    std::string mimeType;

    if (tokens.count() != 2 ||
        !getTokenString(tokens[1], "mimetype", mimeType))
    {
        sendTextFrame("error: cmd=gettextselection kind=syntax");
        return false;
    }

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (_multiView)
        _loKitDocument->setView(_viewId);

    char *textSelection = _loKitDocument->getTextSelection(mimeType.c_str(), nullptr);

    sendTextFrame("textselectioncontent: " + std::string(textSelection));

    free(textSelection);
    return true;
}
开发者ID:biostone,项目名称:online,代码行数:23,代码来源:ChildSession.cpp

示例7: selectGraphic

bool ChildProcessSession::selectGraphic(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    Poco::Mutex::ScopedLock lock(_mutex);

    int type, x, y;

    if (tokens.count() != 4 ||
        !getTokenKeyword(tokens[1], "type",
                         {{"start", LOK_SETGRAPHICSELECTION_START},
                          {"end", LOK_SETGRAPHICSELECTION_END}},
                         type) ||
        !getTokenInteger(tokens[2], "x", x) ||
        !getTokenInteger(tokens[3], "y", y))
    {
        sendTextFrame("error: cmd=selectgraphic kind=syntax");
        return false;
    }

    _loKitDocument->pClass->setView(_loKitDocument, _viewId);
    _loKitDocument->pClass->setGraphicSelection(_loKitDocument, type, x, y);

    return true;
}
开发者ID:maloherry,项目名称:online,代码行数:23,代码来源:ChildProcessSession.cpp

示例8: sendFontRendering

void MasterProcessSession::sendFontRendering(const char *buffer, int length, StringTokenizer& tokens)
{
    std::string font;

    if (tokens.count() < 2 ||
        !getTokenString(tokens[1], "font", font))
    {
        sendTextFrame("error: cmd=renderfont kind=syntax");
        return;
    }

    std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";

    std::vector<char> output;
    output.resize(response.size());
    std::memcpy(output.data(), response.data(), response.size());

    std::unique_ptr<std::fstream> cachedRendering = _tileCache->lookupRendering(font, "font");
    if (cachedRendering && cachedRendering->is_open())
    {
        cachedRendering->seekg(0, std::ios_base::end);
        size_t pos = output.size();
        std::streamsize size = cachedRendering->tellg();
        output.resize(pos + size);
        cachedRendering->seekg(0, std::ios_base::beg);
        cachedRendering->read(output.data() + pos, size);
        cachedRendering->close();

        sendBinaryFrame(output.data(), output.size());
        return;
    }

    if (_peer.expired())
        dispatchChild();
    forwardToPeer(buffer, length);
}
开发者ID:wanweihua,项目名称:online,代码行数:36,代码来源:MasterProcessSession.cpp

示例9: sendCombinedTiles

void MasterProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    int part, pixelWidth, pixelHeight, tileWidth, tileHeight;
    std::string tilePositionsX, tilePositionsY;

    if (tokens.count() < 8 ||
        !getTokenInteger(tokens[1], "part", part) ||
        !getTokenInteger(tokens[2], "width", pixelWidth) ||
        !getTokenInteger(tokens[3], "height", pixelHeight) ||
        !getTokenString (tokens[4], "tileposx", tilePositionsX) ||
        !getTokenString (tokens[5], "tileposy", tilePositionsY) ||
        !getTokenInteger(tokens[6], "tilewidth", tileWidth) ||
        !getTokenInteger(tokens[7], "tileheight", tileHeight))
    {
        sendTextFrame("error: cmd=tilecombine kind=syntax");
        return;
    }

    if (part < 0 || pixelWidth <= 0 || pixelHeight <= 0
       || tileWidth <= 0 || tileHeight <= 0
       || tilePositionsX.empty() || tilePositionsY.empty())
    {
        sendTextFrame("error: cmd=tilecombine kind=invalid");
        return;
    }

    Util::Rectangle renderArea;

    StringTokenizer positionXtokens(tilePositionsX, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
    StringTokenizer positionYtokens(tilePositionsY, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);

    size_t numberOfPositions = positionYtokens.count();

    // check that number of positions for X and Y is the same
    if (numberOfPositions != positionYtokens.count())
    {
        sendTextFrame("error: cmd=tilecombine kind=invalid");
        return;
    }

    std::string forwardTileX;
    std::string forwardTileY;

    for (size_t i = 0; i < numberOfPositions; i++)
    {
        int x, y;

        if (!stringToInteger(positionXtokens[i], x))
        {
            sendTextFrame("error: cmd=tilecombine kind=syntax");
            return;
        }
        if (!stringToInteger(positionYtokens[i], y))
        {
            sendTextFrame("error: cmd=tilecombine kind=syntax");
            return;
        }

        std::unique_ptr<std::fstream> cachedTile = _tileCache->lookupTile(part, pixelWidth, pixelHeight, x, y, tileWidth, tileHeight);

        if (cachedTile && cachedTile->is_open())
        {
            std::string response = "tile: part=" + std::to_string(part) +
                               " width=" + std::to_string(pixelWidth) +
                               " height=" + std::to_string(pixelHeight) +
                               " tileposx=" + std::to_string(x) +
                               " tileposy=" + std::to_string(y) +
                               " tilewidth=" + std::to_string(tileWidth) +
                               " tileheight=" + std::to_string(tileHeight) + "\n";

            std::vector<char> output;
            output.reserve(4 * pixelWidth * pixelHeight);
            output.resize(response.size());
            std::memcpy(output.data(), response.data(), response.size());
            cachedTile->seekg(0, std::ios_base::end);
            size_t pos = output.size();
            std::streamsize size = cachedTile->tellg();
            output.resize(pos + size);
            cachedTile->seekg(0, std::ios_base::beg);
            cachedTile->read(output.data() + pos, size);
            cachedTile->close();

            sendBinaryFrame(output.data(), output.size());
        }
        else
        {
            if (!forwardTileX.empty())
                forwardTileX += ",";
            forwardTileX += std::to_string(x);

            if (!forwardTileY.empty())
                forwardTileY += ",";
            forwardTileY += std::to_string(y);
        }
    }

    if (forwardTileX.empty() && forwardTileY.empty())
        return;

    if (_peer.expired())
//.........这里部分代码省略.........
开发者ID:wanweihua,项目名称:online,代码行数:101,代码来源:MasterProcessSession.cpp

示例10: sendTile

void ChildProcessSession::sendTile(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    Poco::Mutex::ScopedLock lock(_mutex);

    int part, width, height, tilePosX, tilePosY, tileWidth, tileHeight;

    if (tokens.count() < 8 ||
        !getTokenInteger(tokens[1], "part", part) ||
        !getTokenInteger(tokens[2], "width", width) ||
        !getTokenInteger(tokens[3], "height", height) ||
        !getTokenInteger(tokens[4], "tileposx", tilePosX) ||
        !getTokenInteger(tokens[5], "tileposy", tilePosY) ||
        !getTokenInteger(tokens[6], "tilewidth", tileWidth) ||
        !getTokenInteger(tokens[7], "tileheight", tileHeight))
    {
        sendTextFrame("error: cmd=tile kind=syntax");
        return;
    }

    if (part < 0 ||
        width <= 0 ||
        height <= 0 ||
        tilePosX < 0 ||
        tilePosY < 0 ||
        tileWidth <= 0 ||
        tileHeight <= 0)
    {
        sendTextFrame("error: cmd=tile kind=invalid");
        return;
    }

    _loKitDocument->pClass->setView(_loKitDocument, _viewId);

    std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";

    std::vector<char> output;
    output.reserve(4 * width * height);
    output.resize(response.size());
    std::memcpy(output.data(), response.data(), response.size());

    unsigned char *pixmap = new unsigned char[4 * width * height];
    memset(pixmap, 0, 4 * width * height);

    if (_docType != "text" && part != _loKitDocument->pClass->getPart(_loKitDocument))
    {
        _loKitDocument->pClass->setPart(_loKitDocument, part);
    }

    Poco::Timestamp timestamp;
    _loKitDocument->pClass->paintTile(_loKitDocument, pixmap, width, height, tilePosX, tilePosY, tileWidth, tileHeight);
    Log::trace() << "paintTile at [" << tilePosX << ", " << tilePosY
                 << "] rendered in " << (timestamp.elapsed()/1000.) << " ms" << Log::end;

    LibreOfficeKitTileMode mode = static_cast<LibreOfficeKitTileMode>(_loKitDocument->pClass->getTileMode(_loKitDocument));
    if (!Util::encodePNGAndAppendToBuffer(pixmap, width, height, output, mode))
    {
        sendTextFrame("error: cmd=tile kind=failure");
        return;
    }

    delete[] pixmap;

    sendBinaryFrame(output.data(), output.size());
}
开发者ID:maloherry,项目名称:online,代码行数:64,代码来源:ChildProcessSession.cpp

示例11: loadDocument

bool ChildProcessSession::loadDocument(const char *buffer, int length, StringTokenizer& tokens)
{
    Poco::Mutex::ScopedLock lock(_mutex);

    int part = -1;
    if (tokens.count() < 2)
    {
        sendTextFrame("error: cmd=load kind=syntax");
        return false;
    }

    std::string timestamp;
    parseDocOptions(tokens, part, timestamp);

    assert(!_docURL.empty());
    assert(!_jailedFilePath.empty());

    if (_loKitDocument == nullptr)
        Log::info("Loading new document from URI: [" + _jailedFilePath + "].");
    else
        Log::info("Loading view to document from URI: [" + _jailedFilePath + "].");

    if (_loKitDocument != nullptr)
    {
        _viewId = _loKitDocument->pClass->createView(_loKitDocument);
    }
    else
    {
        if ( LIBREOFFICEKIT_HAS(_loKit, registerCallback))
            _loKit->pClass->registerCallback(_loKit, myCallback, this);

        if ((_loKitDocument = _loKit->pClass->documentLoad(_loKit, _jailedFilePath.c_str())) == nullptr)
        {
            Log::error("Failed to load: " + _jailedFilePath + ", error: " + _loKit->pClass->getError(_loKit));
            sendTextFrame("error: cmd=load kind=failed");
            return false;
        }
    }

    _loKitDocument->pClass->setView(_loKitDocument, _viewId);

    std::string renderingOptions;
    if (!_docOptions.empty())
    {
        Poco::JSON::Parser parser;
        Poco::Dynamic::Var var = parser.parse(_docOptions);
        Poco::JSON::Object::Ptr object = var.extract<Poco::JSON::Object::Ptr>();
        renderingOptions = object->get("rendering").toString();
    }

    _loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderingOptions.empty() ? nullptr : renderingOptions.c_str()));

    if (_docType != "text" && part != -1)
    {
        _clientPart = part;
        _loKitDocument->pClass->setPart(_loKitDocument, part);
    }

    _loKitDocument->pClass->registerCallback(_loKitDocument, myCallback, this);

    if (!getStatus(buffer, length))
        return false;

    _onLoad(_loKitDocument, _viewId);

    return true;
}
开发者ID:maloherry,项目名称:online,代码行数:67,代码来源:ChildProcessSession.cpp


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