Ejemplo n.º 1
0
// comparison function
bool CTextseq_id::Match(const CTextseq_id& tsip2) const
{
    // Check Accessions first
    if (IsSetAccession()  &&  tsip2.IsSetAccession()) {
        if ( PNocase().Equals(GetAccession(), tsip2.GetAccession()) ) {
            if (IsSetVersion()  &&  tsip2.IsSetVersion()) {
                return GetVersion() == tsip2.GetVersion();
            } else {
                return true;
            }
        } else {
            return false;
        }
    }

    // then try name
    if (IsSetName()  &&  tsip2.IsSetName()) {
        if ( PNocase().Equals(GetName(), tsip2.GetName()) ) {
            if (IsSetVersion()  &&  tsip2.IsSetVersion()) {
                return GetVersion() == tsip2.GetVersion();
            }
            else {
                return true;
            }
        } else {
            return false;
        }
    }

    //nothing to compare
    return false;
}
Ejemplo n.º 2
0
bool CNcbiCommand::IsRequested( const CCgiContext& ctx ) const
{ 
    const string value = GetName();
  
    TCgiEntries& entries =
        const_cast<TCgiEntries&>(ctx.GetRequest().GetEntries());

    pair<TCgiEntriesI,TCgiEntriesI> p = entries.equal_range( GetEntry() );
    for ( TCgiEntriesI itEntr = p.first; itEntr != p.second; ++itEntr ) {
        if( AStrEquiv( value, itEntr->second, PNocase() ) ) {
            return true;
        } // if
    } // for

    // if there is no 'cmd' entry
    // check the same for IMAGE value
    p = entries.equal_range( NcbiEmptyString );
    for ( TCgiEntriesI iti = p.first; iti != p.second; ++iti ) {
        if( AStrEquiv( value, iti->second, PNocase() ) ) {
            return true;
        } // if
    }
    
    return false;
}
Ejemplo n.º 3
0
// comparison function
int CTextseq_id::Compare(const CTextseq_id& tsip2) const
{
    // Check Accessions first
    // no-accession before accession
    if ( int diff = IsSetAccession() - tsip2.IsSetAccession() ) {
        return diff;
    }
    if ( IsSetAccession() ) {
        _ASSERT(tsip2.IsSetAccession());
        // sort by accession
        if ( int diff = PNocase().Compare(GetAccession(),
                                          tsip2.GetAccession()) ) {
            return diff;
        }
    }

    // Check version
    // no-version before version
    if ( int diff = IsSetVersion() - tsip2.IsSetVersion() ) {
        return diff;
    }
    if ( IsSetVersion() ) {
        _ASSERT(tsip2.IsSetVersion());
        // smaller version first
        if ( int diff = GetVersion() - tsip2.GetVersion() ) {
            return diff;
        }
    }
    if ( IsSetAccession() && IsSetVersion() ) {
        // acc.ver are the same -> equal Seq-ids
        return 0;
    }

    // Check name
    // no-name before name
    if ( int diff = IsSetName() - tsip2.IsSetName() ) {
        return diff;
    }
    if ( IsSetName() ) {
        _ASSERT(tsip2.IsSetName());
        if ( int diff = PNocase().Compare(GetName(), tsip2.GetName()) ) {
            return diff;
        }
    }
    
    // All checks failed to distinguish Seq-ids.
    return 0;
}
Ejemplo n.º 4
0
bool CId_pat::Id_Match(const C_Id& id1, const C_Id& id2)
{
	C_Id::E_Choice type1 = id1.Which();
	C_Id::E_Choice type2 = id2.Which();

	if (type1 != type2)
		return false;

    switch ( type1 ) {
    case C_Id::e_Number:
        return AStrEquiv(id1.GetNumber(), id2.GetNumber(), PNocase());
    case C_Id::e_App_number:
        return AStrEquiv(id1.GetApp_number(), id2.GetApp_number(), PNocase());
    default:
        return false;
    }
}
Ejemplo n.º 5
0
const string& CCgiContext::GetSelfURL(void) const
{
    if ( !m_SelfURL.empty() )
        return m_SelfURL;

    // First check forwarded URLs
    string caf_url = GetRequest().GetRandomProperty("CAF_URL");
    if ( !caf_url.empty() ) {
        m_SelfURL = caf_url;
        return m_SelfURL;
    }

    // Compose self URL
    string server(GetRequest().GetProperty(eCgi_ServerName));
    if ( server.empty() ) {
        return kEmptyStr;
    }

    bool secure = AStrEquiv(GetRequest().GetRandomProperty("HTTPS",
        false), "on", PNocase());
    m_SelfURL = secure ? "https://" : "http://";
    m_SelfURL += server;
    string port = GetRequest().GetProperty(eCgi_ServerPort);
    // Skip port if it's default for the selected scheme
    if ((secure  &&  port == "443")  ||  (!secure  &&  port == "80")
	||  (server.size() >= port.size() + 2  &&  NStr::EndsWith(server, port)
	     &&  server[server.size() - port.size() - 1] == ':')) {
        port = kEmptyStr;
    }
    if ( !port.empty() ) {
        m_SelfURL += ':';
        m_SelfURL += port;
    }
    // (replace adjacent '//' to work around a bug in the "www.ncbi" proxy;
    //  it should not hurt, and may help with similar proxies outside NCBI)
    string script_uri;
    script_uri = GetRequest().GetRandomProperty("SCRIPT_URL", false);
    if ( script_uri.empty() ) {
        script_uri = GetRequest().GetProperty(eCgi_ScriptName);
    }
    // Remove args if any
    size_t arg_pos = script_uri.find('?');
    if (arg_pos != NPOS) {
        script_uri = script_uri.substr(0, arg_pos);
    }
    m_SelfURL += NStr::Replace(script_uri, "//", "/");

    return m_SelfURL;
}
Ejemplo n.º 6
0
// match for identity
bool CObject_id::Match(const CObject_id& oid2) const
{
    E_Choice type = Which();

    if ( type != oid2.Which() )
        return false;

    switch ( type ) {
    case e_Id:
        return GetId() == oid2.GetId();
    case e_Str:
        return PNocase().Equals(GetStr(), oid2.GetStr());
    default:
        return this == &oid2;
    }
}
Ejemplo n.º 7
0
// match for identity
int CObject_id::Compare(const CObject_id& oid2) const
{
    Int8 value, value2;
    E_Choice type = s_GetInteger(*this, value);
    E_Choice type2 = s_GetInteger(oid2, value2);
    if ( int diff = type - type2 ) {
        return diff;
    }
    switch ( type ) {
    case e_Id:
        return value < value2? -1: value > value2? 1: 0;
    case e_Str:
        return PNocase().Compare(GetStr(), oid2.GetStr());
    default:
        return 0;
    }
}
Ejemplo n.º 8
0
// comparison function
bool CId_pat::Match(const CId_pat& idp2) const
{
    return AStrEquiv(GetCountry(), idp2.GetCountry(), PNocase()) &&
        Id_Match(GetId(), idp2.GetId());
}