std::ds_wstring  xOperationSys::getAbsPath(const wchar_t* _relPath , const wchar_t* pRootPath)
{
    size_t nLen = wcslen(_relPath);
    if(nLen >= 2)
    {
        if(_relPath[1] == '\\' && _relPath[0] == '\\')
        {
            m_LastRet = _relPath;
            convertToSystem(m_LastRet);
            return m_LastRet.c_str();
        }
        if(_relPath[1] == ':' || _relPath[0] == '/'  || _relPath[0] == '\\') //[C:\....]  [/mnt/....]  [\program files\]
        {
            m_LastRet = _relPath;
            convertToSystem(m_LastRet);
            return m_LastRet.c_str();
        }
        else if(_relPath[0] == '.' &&( _relPath[1] == '/' ||  _relPath[1] == '\\' ) ) // ["./xxxxx"]
        {
            m_LastRet = std::ds_wstring( pRootPath ) + &_relPath[2];
            convertToSystem(m_LastRet);
            return m_LastRet.c_str();
        }
        else if( bIsUpLevelDir(_relPath)  ) // ["../xxxxx"]
        {
            m_LastRet = GetUpLevelAbsPath(_relPath , pRootPath);
            convertToSystem(m_LastRet);
            return m_LastRet.c_str();
        }
        else
        {
            m_LastRet = std::ds_wstring( pRootPath ) + _relPath;
            convertToSystem(m_LastRet);
            return m_LastRet.c_str();
        }
    }
    if(nLen == 0 || _relPath[0] == '.')
    {
        m_LastRet = pRootPath;
        convertToSystem(m_LastRet);
        return m_LastRet.c_str();
    }
    m_LastRet = std::ds_wstring( pRootPath ) + _relPath;
    convertToSystem(m_LastRet);
    return m_LastRet.c_str();
}
Beispiel #2
0
PatternCompiler::MatchRepr PatternCompiler::convertMatch(lspl::text::MatchRef ref,PatternType patternType)
{
    QString text = convertToSystem(ref->getRangeString());
    QString transform;
    QString params;
    uint vars = ref->getVariantCount();
    lspl::text::Match::AttributesMap attrMap = ref->getAttributes();
    for(std::map<lspl::text::attributes::AttributeKey,lspl::text::attributes::AttributeValue>::iterator itr = attrMap.begin();
        itr != attrMap.end();++itr)
    {
        QString title = convertToSystem(itr->first.getTitle());
        QString value = convertToSystem(itr->second.getTitle());
        QString otherValue;
        if(value == "неопределено"){
            otherValue = convertToSystem(itr->second.getString());
        }
        if(otherValue != ""){
            value = otherValue;
        }
        if(!title.isEmpty() && ! value.isEmpty()){
            params += title+" : " + value + ", ";
        }
    }
    params.resize(params.length()-2);
    switch(patternType){
    case RIGHT_PART_PATTERN:
    {
        lspl::patterns::PatternRef p = ref->getVariant(0)->getTransformResult<lspl::patterns::PatternRef>();
        transform = convertToSystem(p->getName().c_str()) + " = " + convertToSystem(p->getSource().c_str());
        break;
    }
    case RIGHT_PART_TEXT:
    {
        transform = convertToSystem(ref->getVariant(0)->getTransformResult<std::string>().c_str());
        break;
    }
    default:
        transform = "";
        break;
    }
    return {text, params, transform, ref->getRangeStart(),ref->getRangeEnd(),vars};
}