void ICitationBase::NoteSup(string* label, const CImprint& ip) { _ASSERT(label != NULL); const string* issue = ip.CanGetIssue() ? &ip.GetIssue() : NULL; const string* part_sup = ip.CanGetPart_sup() ? &ip.GetPart_sup() : NULL; const string* part_supi = ip.CanGetPart_supi() ? &ip.GetPart_supi() : NULL; if (HasText(part_sup)) { MaybeAddSpace(label); *label += *part_sup; } if (HasText(issue) || HasText(part_supi)) { MaybeAddSpace(label); *label += '('; if (HasText(issue)) { *label += *issue; } if (HasText(part_sup)) { *label += ' ' + *part_supi; } *label += ')'; } }
bool ICitationBase::x_GetLabelV1(string* label, bool unique, const CAuth_list* authors, const CImprint* imprint, const CTitle* title, const CCit_book* book, const CCit_jour* /* journal */, const string* title1, const string* title2, const string* titleunique, const string* date, const string* volume, const string* issue, const string* pages, bool unpublished) { const string* part_sup = 0; const string* part_supi = 0; string subst_date; if (imprint) { if ( !date ) { imprint->GetDate().GetDate(&subst_date); date = &subst_date; } volume = !volume && imprint->IsSetVolume() ? &imprint->GetVolume() : volume; issue = !issue && imprint->IsSetIssue() ? &imprint->GetIssue() : issue; pages = !pages && imprint->IsSetPages() ? &imprint->GetPages() : pages; part_sup = imprint->IsSetPart_sup() ? &imprint->GetPart_sup() : 0; part_supi = imprint->IsSetPart_supi() ? &imprint->GetPart_supi() : 0; } if (authors) { authors->GetLabel(label, 0, eLabel_V1); } if (date) { MaybeAddSpace(label); *label += '(' + *date + ") "; } if (title && !titleunique) { try { titleunique = &title->GetTitle(); } catch (exception&) {} } if (title && !title2) { try { title2 = &title->GetTitle(); } catch (exception&) {} } if (title2) { if (book) { *label += "(in) " + *title2 + " "; } else if (title1) { *label += *title1 + *title2 + " "; } else { *label += *title2 + " "; } } if (volume) { if (part_sup) { *label += *volume + *part_sup + ":"; } else { *label += *volume + ":"; } } if (issue) { if (part_supi) { *label += "(" + *issue + *part_supi + ")"; } else { *label += "(" + *issue + ")"; } } if (pages) { *label += *pages; } if (unpublished) { *label += "Unpublished"; } // If unique parameter true, then add unique tag to end of label // constructed from the first character of each whitespace separated // word in titleunique if (unique) { string tag; if (titleunique && !titleunique->empty()) { CNcbiIstrstream is(titleunique->c_str(), titleunique->size()); string word; int cnt = 0; while ( (is >> word) && (cnt++ < 40) ) { tag += word[0]; } } // NB: add '|' even if tag is empty to maintain backward compatibility. *label += "|" + tag; }
// 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; }
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; }
// 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; }