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


C++ StringBuffer::ensureCapacity方法代码示例

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


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

示例1: getMangledTag

static void getMangledTag(StringBuffer & path, const char * name)
{
    path.append("Dll");
    unsigned len = strlen(name);
    path.ensureCapacity(len);
    for (unsigned i=0; i < len; i++)
    {
        char next = name[i];
        if (isalnum((byte)next))
            path.append(next);
        else
            path.append("_");
    }
}
开发者ID:lrenn,项目名称:HPCC-Platform,代码行数:14,代码来源:dllserver.cpp

示例2: gunzip

void gunzip(const byte* compressed, unsigned int comprLen, StringBuffer& sOutput)
{
    if (comprLen == 0)
        return;

    const int CHUNK_OUT = 16384;
    z_stream d_stream; // decompression stream
    memset( &d_stream, 0, sizeof(z_stream));
    d_stream.next_in = (byte*) compressed;
    d_stream.avail_in = comprLen;

    int ret = inflateInit2(&d_stream, (15+16));
    if (ret != Z_OK)
        throwGZipException("initialization", ret);

    unsigned int outLen = 0;

    do
    {
        sOutput.ensureCapacity( outLen + CHUNK_OUT );
        d_stream.avail_out = CHUNK_OUT; //free space in the output buffer
        d_stream.next_out = (byte*)sOutput.str() + outLen;

        ret = inflate(&d_stream, Z_NO_FLUSH);
        if (ret < Z_OK)
            break;

        outLen += CHUNK_OUT - d_stream.avail_out;
        sOutput.setLength( outLen );

    } while (d_stream.avail_out == 0 || ret != Z_STREAM_END);

    inflateEnd(&d_stream);
    if (ret != Z_STREAM_END)
    {
        sOutput.clear();
        throwGZipException("decompression", ret);
    }
}
开发者ID:elahehrashedi,项目名称:HPCC-Platform,代码行数:39,代码来源:zcrypt.cpp

示例3: determineInstallFiles

//---------------------------------------------------------------------------
//  determineInstallFiles
//---------------------------------------------------------------------------
int CConfigGenEngine::determineInstallFiles(IPropertyTree& processNode, CInstallFiles& installFiles) const
{
    try
    {
        m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, 
            "Determining files to install for %s", processNode.queryProp("@name"));

        StringBuffer compListPath(CONFIGGEN_COMP_LIST);
        if (m_inDir.length())
            compListPath.clear().append(m_inDir).append(PATHSEPCHAR).append(CONFIGGEN_COMP_LIST);

        Owned<IPropertyTree> deployNode = createPTreeFromXMLFile(compListPath.str(), ipt_caseInsensitive);
        StringBuffer srcFilePath;
        srcFilePath.ensureCapacity(_MAX_PATH);
        const bool bFindStartable = &m_process == &processNode && m_startable == unknown;
        const bool bFindStoppable = &m_process == &processNode && m_stoppable == unknown;

        StringBuffer xpath;
        xpath.appendf("Component[@name=\"%s\"]",processNode.queryProp("@buildSet"));
        IPropertyTree* pComponent = deployNode->queryPropTree(xpath.str());

        if (!pComponent)
        {
            m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, 
                "Cannot find files to install for %s", processNode.queryProp("@buildSet"));
            return 0;
        }

        Owned<IPropertyTreeIterator> iter = pComponent->getElements("File");
        ForEach(*iter)
        {
            IPropertyTree* pFile = &iter->query();
            const char* name = pFile->queryProp("@name");

            if (!stricmp(name, "deploy_map.xml"))
                continue;

            if (bFindStartable && !strnicmp(name, "startup", sizeof("startup")-1))
                m_startable = yes;

            if (bFindStoppable && !strnicmp(name, "stop", sizeof("stop")-1))
                m_stoppable = yes;

            const char* method  = pFile->queryProp("@method");
            if (method && !stricmp(method, "schema"))
                continue;

            //if we are not deploying build files and method is copy then ignore this file
            if (!(m_deployFlags & DEFLAGS_BUILDFILES) && (!method || !stricmp(method, "copy")))
                continue;

            const char* srcPath = pFile->queryProp("@srcPath");
            const char* destPath= pFile->queryProp("@destPath");
            const char* destName= pFile->queryProp("@destName");
            bool bCacheable     = pFile->getPropBool("@cache", false);

            // Get source filespec
            if (srcPath && !strcmp(srcPath, "@temp"))
            {
                char tempfile[_MAX_PATH];
                getTempPath(tempfile, sizeof(tempfile), m_name);
                srcFilePath.clear().append(tempfile).append(name);
            }
            else
            {
                srcFilePath.clear().append(m_inDir);

        //adjust source paths
                if (srcPath && 0!=strcmp(srcPath, "."))
                {
                    if (!strncmp(srcPath, "..", 2) && (*(srcPath+2)=='/' || *(srcPath+2)=='\\'))
                    {
                        StringBuffer reldir(srcPath);
                        reldir.replace('/', '\\');

                        while (!strncmp(reldir.str(), "..\\", 3))
                        {
                            srcFilePath.setLength( srcFilePath.length() - 1 ); //remove last char PATHSEPCHAR
                            const char* tail = pathTail(srcFilePath.str());
                            srcFilePath.setLength( tail - srcFilePath.str() );
                            reldir.remove(0, 3);
                        }
                        srcFilePath.append(reldir).append(PATHSEPCHAR);
                    }
                    else
                        srcFilePath.append(srcPath).append(PATHSEPCHAR);
                }
                srcFilePath.append(name);
            }

            std::string sDestName;
            if (method && (!stricmp(method, "esp_service_module") || !stricmp(method, "esp_plugin")))
            {
                //if this is xsl transformation and we are not generating config files then ignore
                //
                if (!(m_deployFlags & DEFLAGS_CONFIGFILES) && !stricmp(method, "esp_service_module"))
                    continue;
//.........这里部分代码省略.........
开发者ID:EwokVillage,项目名称:HPCC-Platform,代码行数:101,代码来源:configgenengine.cpp


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