예제 #1
0
bool CCit_gen::GetLabelV1(string* label, TLabelFlags flags) const
{
    bool unique = (flags & fLabel_Unique) != 0;

    if (IsSetSerial_number()) {
        *label += "[" + NStr::IntToString(GetSerial_number()) + "]";
    }
    if (IsSetMuid()) {
        *label += "NLM" + NStr::IntToString(GetMuid());
    }

    string date;
    string* date_ptr = 0;
    if ( IsSetDate() ) {
        date_ptr = &date;
        GetDate().GetDate(date_ptr, true);
    }

    const string* title2 = 0;
    const string* titleunique = 0;
    bool unpublished = false;
    const CTitle* title = IsSetJournal() ? &GetJournal() : 0;
    const CAuth_list* authors = IsSetAuthors() ? &GetAuthors() : 0;
    const string* volume = IsSetVolume() ? &GetVolume() : 0;
    const string* issue = IsSetIssue() ? &GetIssue() : 0;
    const string* pages = IsSetPages() ? &GetPages() : 0;

    if (IsSetCit()) {
        if ( NStr::EqualNocase( GetCit(), "Unpublished") ) {
            unpublished = true;
        } else if (!title) {
            title2 = &GetCit();
        }
    }
    if (IsSetTitle()) {
        titleunique = &GetTitle();
    } else if (title2) {
        titleunique = title2;
    } else if (!title && IsSetCit()) {
        titleunique = &GetCit();
    }
    if (!title && !authors && !IsSetTitle() && !volume &&
        !pages && !issue) {
        titleunique = 0;
        if (IsSetCit()) {
            string cit(GetCit());
            if (!unique) {
                try {
                    cit.resize(cit.find_last_of('|'));
                } catch(length_error&) {}
            }   
            *label += cit;
        }
        return true;
    }

    return x_GetLabelV1(label, unique,
        authors, 0, title, 0, 0, 0, title2, titleunique,
        date_ptr, volume, issue, pages, unpublished);
}
예제 #2
0
파일: Pub.cpp 프로젝트: swuecho/igblast
// 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;
    }
}