Example #1
0
void CNamespace::Set(const CNamespace& ns, CNcbiOstream& out, bool mainHeader)
{
    size_t equal = EqualLevels(ns);
    CloseAllAbove(equal, out);
    for ( size_t i = equal, end = ns.GetNamespaceLevel(); i < end; ++i )
        Open(ns.GetNamespaces()[i], out, mainHeader);
}
Example #2
0
size_t CNamespace::EqualLevels(const CNamespace& ns) const
{
    size_t end = min(GetNamespaceLevel(), ns.GetNamespaceLevel());
    for ( size_t i = 0; i < end; ++i ) {
        if ( GetNamespaces()[i] != ns.GetNamespaces()[i] )
            return i;
    }
    return end;
}
Example #3
0
string CStdTypeStrings::GetCType(const CNamespace& ns) const
{
    if ( m_Namespace )
        return ns.GetNamespaceRef(m_Namespace)+m_CType;
    else
        return m_CType;
}
Example #4
0
string CNamespace::GetNamespaceRef(const CNamespace& ns) const
{
    size_t equal = EqualLevels(ns);
    string s;
    if ( equal == GetNamespaceLevel() ) {
        // internal namespace
    }
    else {
        // reference from root
        equal = 0;
        if ( ns.InNCBI() ) {
            s = KNCBINamespaceDefine;
            equal = 1;
        }
        else if ( ns.InSTD() ) {
            s = KSTDNamespaceDefine;
            equal = 1;
        }
        if ( equal == 1 ) {
            // std or ncbi
            if ( InNCBI() )
                s.erase();
            else
                s += "::";
        }
        else {
            // from root
            s = "::";
        }
    }
    for ( size_t i = equal, end = ns.GetNamespaceLevel(); i < end; ++i ) {
        s += ns.GetNamespaces()[i];
        s += "::";
    }
    return s;
}
Example #5
0
 bool operator==(const CNamespace& ns) const
     {
         size_t myLevel = GetNamespaceLevel();
         return ns.GetNamespaceLevel() == myLevel &&
             EqualLevels(ns) == myLevel;
     }