Exemplo n.º 1
0
// Determines the type of set and calls the appropriately instantiated
// s_GetLabel
bool CPub_set::GetLabel(string* label, TLabelFlags flags,
                        ELabelVersion version) const
{
    // Ensure label exists
    if (!label) {
        return false;
    }
    
    switch (Which()) {
    case e_Pub:
        return s_GetLabel<CPub>(label, GetPub(), flags, version);
    case e_Medline:
        return s_GetLabel<CMedline_entry>(label, GetMedline(), flags, version);
    case e_Article:
        return s_GetLabel<CCit_art>(label, GetArticle(), flags, version);
    case e_Journal:
        return s_GetLabel<CCit_jour>(label, GetJournal(), flags, version);
    case e_Book:
        return s_GetLabel<CCit_book>(label, GetBook(), flags, version);
    case e_Proc:
        return s_GetLabel<CCit_proc>(label, GetProc(), flags, version);
    case e_Patent:
        return s_GetLabel<CCit_pat>(label, GetPatent(), flags, version);
    default:
        return false;
    }
}
Exemplo n.º 2
0
// Appends a label to "label"
bool CPub::GetLabel(string*        label,
                    ELabelType     type,
                    TLabelFlags    flags,
                    ELabelVersion  version) const
{
    static const char* s_PubTypes[14] = {
        "Unknown",
        "Generic",
        "Submit",
        "Medline",
        "MUID",
        "Article",
        "Journal",
        "Book",
        "Proceedings",
        "Patent",
        "PatID",
        "Manuscript",
        "Equiv",
        "PMID" };

    // Check that label exists
    if (!label) {
        return false;
    }

    // Get the index into the s_PubTypes array corresponding to pub type
    int idx = static_cast<int>(Which());
    idx = idx >= 0 && idx < 14 ? idx : 0;

    if (type == eType) {
        // Append pub type to label and return
        *label += s_PubTypes[idx];
        return true;
    }

    if (type == eBoth) {
        // Append pub type to label
        *label += string(s_PubTypes[idx]) + ": ";
    }

    switch (Which()) {
    case e_Muid:
        *label += "NLM" + NStr::IntToString(GetMuid());
        return true;
    case e_Pmid:
        *label += "PM" + NStr::IntToString(GetPmid().Get());
        return true;
    case e_Equiv:
        return GetEquiv().GetLabel(label, flags, version);
    case e_Medline:
        return GetMedline().GetLabel(label, flags, version);
    case e_Article:
        return GetArticle().GetLabel(label, flags, version);
    case e_Journal:
        return GetJournal().GetLabel(label, flags, version);
    case e_Book:
        return GetBook().GetLabel(label, flags, version);
    case e_Proc:
        return GetProc().GetLabel(label, flags, version);
    case e_Man:
        return GetMan().GetLabel(label, flags, version);
    case e_Sub:
        return GetSub().GetLabel(label, flags, version);
    case e_Patent:
        return GetPatent().GetLabel(label, flags, version);
    case e_Pat_id:
        return GetPat_id().GetLabel(label, flags, version);
    case e_Gen:
        return GetGen().GetLabel(label, flags, version);
    default:
        return false;
    }
}