Ejemplo n.º 1
0
// Based on FormatCitGen from the C Toolkit's api/asn2gnb5.c.
bool CCit_gen::GetLabelV2(string* label, TLabelFlags flags) const
{
    if ( !CanGetCit()  &&  !CanGetJournal()  &&  !CanGetDate()
        &&  CanGetSerial_number() ) {
        return false;
    }

    if ( !CanGetJournal()  &&  CanGetCit()  &&  SWNC(GetCit(), "unpublished")) {
        if ((flags & fLabel_NoUnpubAffil) != 0) {
            MaybeAddSpace(label);
            *label += "Unpublished";
            return true;
        }

        if (CanGetAuthors()  &&  GetAuthors().CanGetAffil()) {
            MaybeAddSpace(label);
            *label += "Unpublished ";
            GetAuthors().GetAffil().GetLabel(label, flags, eLabel_V2);
            NStr::TruncateSpacesInPlace(*label, NStr::eTrunc_End);
            return true;
        }

        if (CanGetCit()  &&  HasText(GetCit())) {
            MaybeAddSpace(label);
            *label += NStr::TruncateSpaces(GetCit());
            return true;
        } else {
            return false;
        }
    }

    string year  = CanGetDate()  ? GetParenthesizedYear(GetDate()) : kEmptyStr;
    string pages = CanGetPages() ? FixPages(GetPages())            : kEmptyStr;
    string journal, inpress;
    SIZE_TYPE pos;

    if (CanGetJournal()) {
        journal = GetJournal().GetTitle();
    }

    if (CanGetCit()) {
        pos = GetCit().find("Journal=\"");
        if (pos != NPOS) {
            journal = GetCit().substr(pos + 9);
        } else if (SWNC(GetCit(), "submitted")
                   ||  SWNC(GetCit(), "unpublished")) {
            if ((flags & fLabel_NoBadCitGen) == 0  ||  !journal.empty()) {
                inpress = GetCit();
            } else {
                inpress = "Unpublished";
            }
        } else if (SWNC(GetCit(), "Online Publication")
                   ||  SWNC(GetCit(), "Published Only in DataBase")
                   ||  SWNC(GetCit(), "In press")) {
            inpress = GetCit();
        } else if (SWNC(GetCit(), "(er) ")) {
            journal = GetCit();
        } else if ((flags & fLabel_NoBadCitGen) == 0  &&  journal.empty()) {
            journal = GetCit();
        }
    }

    if ((!HasText(pages) || (flags & (fLabel_FlatNCBI | fLabel_FlatEMBL)) == 0)
        &&  journal.empty()  &&  !HasText(inpress)  &&  !HasText(year)
        &&  (!CanGetVolume() || !HasText(GetVolume()))) {
        return false;
    }

    string prefix;
    MaybeAddSpace(label);

    if ( !journal.empty() ) {
        pos = journal.find_first_of("=\"");
        if (pos != NPOS) {
            journal.resize(pos);
        }
        *label += journal;
        prefix = " ";
    }

    if (HasText(inpress)) {
        *label += prefix + inpress;
        prefix = " ";
    }

    if (CanGetVolume()  &&  HasText(GetVolume())) {
        *label += prefix + GetVolume();
    }

    if (HasText(pages)) {
        if ((flags & fLabel_FlatNCBI) != 0) {
            *label += ", " + pages;
        } else if ((flags & fLabel_FlatEMBL) != 0) {
            *label += ':' + pages;
        }
    }

    if (HasText(year)) {
        *label += ' ' + year;
    }

    return true;
}
Ejemplo n.º 2
0
bool CCit_art::x_GetLabelV2(string* label, TLabelFlags flags,
                            const CCit_book& book)
{
    const CImprint& imp    = book.GetImp();
    int             prepub = imp.CanGetPrepub() ? imp.GetPrepub() : 0;
    string          year   = GetParenthesizedYear(imp.GetDate());

    MaybeAddSpace(label);

    if (prepub == CImprint::ePrepub_submitted
        ||  prepub == CImprint::ePrepub_other) {
        *label += "Unpublished " + year;
        return true;
    }

    string title = book.GetTitle().GetTitle();
    if (title.size() < 3) {
        *label += '.';
        return false;
    }

    *label += "(in) ";
    if (book.GetAuthors().GetLabel(label, flags, eLabel_V2)) {
        size_t n = book.GetAuthors().GetNameCount();
        if (n > 1) {
            *label += " (Eds.);";
        } else if (n == 1) {
            *label += " (Ed.);";
        }
        *label += '\n';
    }

    *label += NStr::ToUpper(title);

    const string* volume = imp.CanGetVolume() ? &imp.GetVolume() : NULL;
    if (HasText(volume)  &&  *volume != "0") {
        *label += ", Vol. " + *volume;
        if ((flags & fLabel_FlatNCBI) != 0) {
            NoteSup(label, imp);
        }
    }
    if (imp.CanGetPages()) {
        string pages = FixPages(imp.GetPages());
        if (HasText(pages)) {
            *label += ": " + pages;
        }
    }
    *label += ";\n";

    if (imp.CanGetPub()
        &&  imp.GetPub().GetLabel(label, flags, eLabel_V1)) { // sic
        // "V1" taken over by MakeAffilStr translation
        *label += ' ';
    }
    *label += year;

    if ((flags & fLabel_FlatNCBI) != 0
        &&  prepub == CImprint::ePrepub_in_press) {
        *label += " In press";
    }

    return true;
}
Ejemplo n.º 3
0
// Based on FormatCitJour from the C Toolkit's api/asn2gnb5.c.
bool CCit_jour::GetLabelV2(string* label, TLabelFlags flags) const
{
    const CImprint& imp = GetImp();

    int prepub = imp.CanGetPrepub()    ? imp.GetPrepub()    : 0;
    int status = imp.CanGetPubstatus() ? imp.GetPubstatus() : 0;

    bool is_electronic = (status == ePubStatus_epublish
                          ||  status == ePubStatus_aheadofprint);

    const string* jtitle;
    try {
        jtitle = &GetTitle().GetTitle(CTitle::C_E::e_Iso_jta);
    } catch (CException&) {
        try {
            jtitle = &GetTitle().GetTitle();
            if (NStr::StartsWith(*jtitle, "(er)")) {
                is_electronic = true;
            }
            if ((flags & fLabel_ISO_JTA) != 0  &&  !is_electronic) {
                return false;
            }
        } catch (CException&) {
            jtitle = NULL;
        }
    }

    string year = GetParenthesizedYear(imp.GetDate());

    MaybeAddSpace(label);

    if (prepub == CImprint::ePrepub_submitted
        ||  prepub == CImprint::ePrepub_other) {
        *label += "Unpublished " + year;
        return true;
    }

    if (jtitle == NULL  ||  jtitle->size() < 3) {
        *label += '.';
        return false;
    }

    *label += *jtitle;

    const string* volume = imp.CanGetVolume() ? &imp.GetVolume() : NULL;
    string        pages  = imp.CanGetPages()  ? imp.GetPages()   : kEmptyStr;
    if ( !pages.empty()  &&  !is_electronic ) {
        pages = FixPages(pages);
    }

    if (HasText(volume)) {
        MaybeAddSpace(label);
        *label += *volume;
    }

    if ((flags & fLabel_FlatNCBI) != 0
        &&  (HasText(volume)  ||  HasText(pages))) {
        NoteSup(label, imp);
    }

    if ((flags & fLabel_FlatNCBI) != 0) {
        if (HasText(pages)) {
            *label += ", " + pages;
        }
    } else if ((flags & fLabel_FlatEMBL) != 0) {
        if (HasText(pages)) {
            *label += ':' + pages;
        } else if (prepub == CImprint::ePrepub_in_press  ||  !HasText(volume)) {
            MaybeAddSpace(label);
            *label += "0:0-0";
        }
    }

    *label += ' ' + year;
    
    if ((flags & fLabel_FlatNCBI) != 0) {
        if (prepub == CImprint::ePrepub_in_press
            ||  (status == ePubStatus_aheadofprint  &&  !HasText(pages))) {
            MaybeAddSpace(label);
            *label += "In press";
        }
    }

    return true;
}