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


C++ XString::substr方法代码示例

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


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

示例1: XSimpleTimeZone

XIRef<XTimeZone> XSimpleTimeZone::FromISOString(const XString& isoString)
{
    if(isoString[0] != '-' && isoString[0] != '+')
        X_THROW(("Invalid ISO Extended String: %s", isoString.c_str()));

    const int sign = isoString[0] == '-' ? -1 : 1;
    const XString str = isoString.substr(1);

    if(str.empty())
        X_THROW(("Invalid ISO Extended String: %s", isoString.c_str()));

    const size_t colonDex = str.find(':');
    XString hoursStr;
    XString minutesStr;

    if(colonDex != string::npos)
    {
        hoursStr = str.substr(0, colonDex);
        minutesStr = str.substr(colonDex + 1);

        if(minutesStr.size() != 2)
            X_THROW(("Invalid ISO Extended String: %s", isoString.c_str()));
    }
    else
        hoursStr = str;

    if(count_if(hoursStr.begin(), hoursStr.end(), verifyDigit) != (int)hoursStr.size() ||
       count_if(minutesStr.begin(), minutesStr.end(), verifyDigit) != (int)minutesStr.size())
    {
        X_THROW(("Invalid ISO Extended String: %s", isoString.c_str()));
    }

    const int hours = hoursStr.ToInt();
    const int minutes = minutesStr.empty() ? 0 : minutesStr.ToInt();

    return new XSimpleTimeZone(sign * (int)(convert(HOURS, MINUTES, hours) + minutes));
}
开发者ID:MultiSight,项目名称:xsdk,代码行数:37,代码来源:XTimeZone.cpp

示例2: _GetTMPName

XString TranscodeExport::_GetTMPName( const XString& fileName ) const
{
    if( !fileName.Contains(".") )
        X_THROW(("No extension in file name!"));

    if( !fileName.Contains(PATH_SLASH) )
        X_THROW(("Need full path to file for export."));

    vector<XString> parts;
    fileName.Split( PATH_SLASH, parts );

    if( parts.size() < 2 )
        X_THROW(("Invalid export path: %s",fileName.c_str()));;

    XString path;

    for( int i = 0; i < ((int)parts.size() - 1); i++ )
        path += XString::Format( "%s%s", PATH_SLASH, parts[i].c_str() );

    XString mediaFileName = parts[parts.size()-1];

    XString fileBaseName = mediaFileName.substr(0, mediaFileName.find("."));
    XString extension = mediaFileName.substr(mediaFileName.find(".")+1);

    XMD5 hash;
    hash.Update( (uint8_t*)fileBaseName.c_str(), fileBaseName.length() );
    hash.Finalize();

    XString fileBaseNameHash = hash.GetAsString();

    return XString::Format( "%s%sexport-tmp-%s.%s",
                            path.c_str(),
                            PATH_SLASH,
                            fileBaseNameHash.c_str(),
                            extension.c_str() );
}
开发者ID:MultiSight,项目名称:exporty,代码行数:36,代码来源:TranscodeExport.cpp

示例3: _GetNode

XIRef<XDomParserNode> SoapArgs::_GetNode( const XString& path, XIRef<XDomParserNode> parent )
{
    const size_t dot = path.find('.');
    XString front = path.substr(0, dot);
    XString rest = dot == string::npos ? "" : path.substr(dot + 1);

    const list<XIRef<XDomParserNode> >::const_iterator end = parent->GetChildren().end();
    list<XIRef<XDomParserNode> >::const_iterator found = end;

    for(list<XIRef<XDomParserNode> >::const_iterator iter = parent->GetChildren().begin();
        iter != end;
        ++iter)
    {
        if((*iter)->GetTagName() == front)
        {
            found = iter;
            break;
        }
    }

    if(found != end)
        return rest.empty() ? *found : _GetNode(rest, *found);

    XIRef<XDomParserNode> node(new XDomParserNode(XString::Format("<%s>", front.c_str())));
    parent->AppendChild(node);

    if(!rest.empty())
        return _GetNode(rest, node);

    return node;


    /*
    // Key - "foo.bar.alpha"
    // In this case, foo and bar are CONTAINER_TYPE and alpha is a VALUE_TYPE

    SoapArgs* existingNode = current->Find( path);

    if(existingNode)
    {
    }

    vector<XString> parts;
    key.Split( ".", parts );

    XHash<SoapArgsNode>* current = &_complex;


    if( !parts.empty() )
    {
        XString currPath = parts[0];
        size_t limit = parts.size() - 1;

        // Loop over all the CONTAINER_TYPE parts of the path...
        for( size_t i = 0; i < limit; ++i )
        {
            SoapArgsNode* found = current->Find( currPath );

            if( found )
            {
                current = &found->_children;
            }
            else
            {
                SoapArgsNode node;
                node._nodeType = CONTAINER_TYPE;
                node._name = parts[i];
                current->Add( currPath, node );
                SoapArgsNode* foundNode = current->Find( currPath );
                current = &foundNode->_children;
            }

            currPath += "." + parts[i];
        }

        SoapArgsNode* found == current->Find( path );

        if(found)
        {
            SoapArgs node = *found;
            current->Remove( parts[i] );

            return found;
        }
    }

    SoapArgsNode node;
    node._nodeType = VALUE_TYPE;
    node._name = !parts.empty() ? parts[i] : key;
    */
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:91,代码来源:SoapArgs.cpp

示例4: Root

	XString Root(const XString& path)
	{
		size_t index = path.find_last_of("/\\");
		return (XString::npos == index) ? XString() : path.substr(0,index+1);
	}
开发者ID:yuechuanbingzhi163,项目名称:myduilib,代码行数:5,代码来源:CXString.cpp


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