NCBI C++ ToolKit
Cit_art.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: Cit_art.cpp 49240 2011-04-08 18:57:08Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using specifications from the ASN data definition file
34  * 'biblio.asn'.
35  */
36 
37 // standard includes
38 
39 // generated includes
40 #include <ncbi_pch.hpp>
43 #include <objects/biblio/Title.hpp>
47 #include <objects/general/Date.hpp>
48 
49 // generated classes
50 
52 
53 BEGIN_objects_SCOPE // namespace ncbi::objects::
54 
55 // destructor
57 {
58 }
59 
60 
62 {
63  const CCit_jour* journal = 0;
64  const CCit_book* book = 0;
65  const CImprint* imprint = 0;
66  const CAuth_list* authors = 0;
67  const CTitle* title = 0;
68  const string* titleunique = 0;
69  if ( IsSetAuthors() ) {
70  authors = &GetAuthors();
71  }
72  if ( IsSetTitle() ) {
73  titleunique = &GetTitle().GetTitle();
74  }
75  switch ( GetFrom().Which() ) {
76  case C_From::e_Journal:
77  journal = &GetFrom().GetJournal();
78  imprint = &journal->GetImp();
79  title = &journal->GetTitle();
80  break;
81  case C_From::e_Book:
82  book = &GetFrom().GetBook();
83  imprint = &book->GetImp();
84  if (!authors) {
85  authors = &book->GetAuthors();
86  }
87  break;
88  case C_From::e_Proc:
89  book = &GetFrom().GetProc().GetBook();
90  imprint = &book->GetImp();
91  if (!authors) {
92  authors = &book->GetAuthors();
93  }
94  default:
95  break;
96  }
97  return x_GetLabelV1(label, (flags & fLabel_Unique) != 0, authors, imprint,
98  title, book, journal, 0, 0, titleunique);
99 }
100 
101 
102 // Based on FormatCit(Book)Art from the C Toolkit's api/asn2gnb5.c.
104 {
105  switch (GetFrom().Which()) {
106  case C_From::e_not_set:
107  return false;
108  case C_From::e_Journal:
109  return GetFrom().GetJournal()
111  case C_From::e_Book:
112  return x_GetLabelV2(label, flags, GetFrom().GetBook());
113  case C_From::e_Proc:
114  return x_GetLabelV2(label, flags, GetFrom().GetProc().GetBook());
115  }
116 
117  return false;
118 }
119 
120 
122  const CCit_book& book)
123 {
124  const CImprint& imp = book.GetImp();
125  int prepub = imp.CanGetPrepub() ? imp.GetPrepub() : 0;
126  string year = GetParenthesizedYear(imp.GetDate());
127 
129 
130  if (prepub == CImprint::ePrepub_submitted
131  || prepub == CImprint::ePrepub_other) {
132  *label += "Unpublished " + year;
133  return true;
134  }
135 
136  string title = book.GetTitle().GetTitle();
137  if (title.size() < 3) {
138  *label += '.';
139  return false;
140  }
141 
142  *label += "(in) ";
143  if (book.GetAuthors().GetLabel(label, flags, eLabel_V2)) {
144  size_t n = book.GetAuthors().GetNameCount();
145  if (n > 1) {
146  *label += " (Eds.);";
147  } else if (n == 1) {
148  *label += " (Ed.);";
149  }
150  *label += '\n';
151  }
152 
153  *label += NStr::ToUpper(title);
154 
155  const string* volume = imp.CanGetVolume() ? &imp.GetVolume() : NULL;
156  if (HasText(volume) && *volume != "0") {
157  *label += ", Vol. " + *volume;
158  if ((flags & fLabel_FlatNCBI) != 0) {
159  NoteSup(label, imp);
160  }
161  }
162  if (imp.CanGetPages()) {
163  string pages = FixPages(imp.GetPages());
164  if (HasText(pages)) {
165  *label += ": " + pages;
166  }
167  }
168  *label += ";\n";
169 
170  if (imp.CanGetPub()
171  && imp.GetPub().GetLabel(label, flags, eLabel_V1)) { // sic
172  // "V1" taken over by MakeAffilStr translation
173  *label += ' ';
174  }
175  *label += year;
176 
177  if ((flags & fLabel_FlatNCBI) != 0
178  && prepub == CImprint::ePrepub_in_press) {
179  *label += " In press";
180  }
181 
182  return true;
183 }
184 
185 
186 END_objects_SCOPE // namespace ncbi::objects::
187 
189 
190 /* Original file checksum: lines: 61, chars: 1880, CRC32: 30f0bfed */
User-defined methods of the data storage class.
@Auth_list.hpp User-defined methods of the data storage class.
Definition: Auth_list.hpp:57
size_t GetNameCount() const
Definition: Auth_list.cpp:58
bool GetLabelV2(string *label, TLabelFlags flags) const override
Definition: Cit_art.cpp:103
static bool x_GetLabelV2(string *label, TLabelFlags flags, const CCit_book &book)
Definition: Cit_art.cpp:121
bool GetLabelV1(string *label, TLabelFlags flags) const override
Definition: Cit_art.cpp:61
~CCit_art(void)
Definition: Cit_art.cpp:56
CImprint –.
Definition: Imprint.hpp:66
Definition: Title.hpp:51
const string & GetTitle(C_E::E_Choice type=C_E::e_not_set) const
If the internal list contains a title (of the specified type, if given), returns the corresponding st...
Definition: Title.cpp:56
@ eLabel_V1
Traditional GetLabel semantics, modeled on the C Toolkit's PubLabelUnique.
@ eLabel_V2
New implementation, in line with GenBank/GenPept REFERENCE JOURNAL fields and the like.
int TLabelFlags
binary OR of ELabelFlags
@ fLabel_ISO_JTA
Only ISO jnl. title abbrevs. OK [V2].
@ fLabel_FlatNCBI
For GenBank or GenPept [V2].
@ fLabel_Unique
Append a unique tag [V1].
static string GetParenthesizedYear(const CDate &date)
static string FixPages(const string &orig_pages)
Canonicalize a range of page numbers, expanding Medline-style 125-35 -> 125-135, F124-34 -> F124-F134...
static bool HasText(const string &s)
static void NoteSup(string *label, const CImprint &imp)
static bool 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=0, const string *title2=0, const string *titleunique=0, const string *date=0, const string *volume=0, const string *issue=0, const string *pages=0, bool unpublished=false)
bool GetLabel(string *label, TLabelFlags flags=0, ELabelVersion version=eLabel_DefaultVersion) const override
Append a label to the specified string per the specified flags.
static void MaybeAddSpace(string *label)
static uch flags
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string & ToUpper(string &str)
Convert string to upper case – string& version.
Definition: ncbistr.cpp:424
static const char label[]
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_book_.hpp:296
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_book_.hpp:347
const TBook & GetBook(void) const
Get the Book member data.
Definition: Cit_proc_.hpp:214
bool IsSetAuthors(void) const
authors (ANSI requires) Check if a value has been assigned to Authors data member.
Definition: Cit_art_.hpp:534
const TJournal & GetJournal(void) const
Get the variant data.
Definition: Cit_art_.cpp:111
const TVolume & GetVolume(void) const
Get the Volume member data.
Definition: Imprint_.hpp:758
const TPages & GetPages(void) const
Get the Pages member data.
Definition: Imprint_.hpp:852
const TFrom & GetFrom(void) const
Get the From member data.
Definition: Cit_art_.hpp:567
bool IsSetTitle(void) const
title of paper (ANSI requires) Check if a value has been assigned to Title data member.
Definition: Cit_art_.hpp:513
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_art_.hpp:525
bool CanGetPrepub(void) const
Check if it is safe to call GetPrepub method.
Definition: Imprint_.hpp:1086
bool CanGetPages(void) const
Check if it is safe to call GetPages method.
Definition: Imprint_.hpp:846
TPrepub GetPrepub(void) const
Get the Prepub member data.
Definition: Imprint_.hpp:1099
const TPub & GetPub(void) const
Get the Pub member data.
Definition: Imprint_.hpp:946
const TProc & GetProc(void) const
Get the variant data.
Definition: Cit_art_.cpp:155
bool CanGetVolume(void) const
Check if it is safe to call GetVolume method.
Definition: Imprint_.hpp:752
bool CanGetPub(void) const
Check if it is safe to call GetPub method.
Definition: Imprint_.hpp:940
const TDate & GetDate(void) const
Get the Date member data.
Definition: Imprint_.hpp:728
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_art_.hpp:546
const TImp & GetImp(void) const
Get the Imp member data.
Definition: Cit_book_.hpp:377
const TBook & GetBook(void) const
Get the variant data.
Definition: Cit_art_.cpp:133
@ e_not_set
No variant selected.
Definition: Cit_art_.hpp:112
@ ePrepub_in_press
accepted, not published
Definition: Imprint_.hpp:96
@ ePrepub_submitted
submitted, not accepted
Definition: Imprint_.hpp:95
yy_size_t n
CRef< CPub > journal(ParserPtr pp, char *bptr, char *eptr, CRef< CAuth_list > &auth_list, CRef< CTitle::C_E > &title, bool has_muid, CRef< CCit_art > &cit_art, Int4 er)
Definition: ref.cpp:1457
Modified on Mon May 06 04:49:28 2024 by modify_doxy.py rev. 669887