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

Go to the SVN repository for this file.

1 /* $Id: Cit_gen.cpp 72031 2016-04-12 18:56:44Z grichenk $
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 data definition file
34  * 'biblio.asn'.
35  */
36 
37 // standard includes
38 
39 // generated includes
40 #include <ncbi_pch.hpp>
42 #include <objects/general/Date.hpp>
43 
44 // generated classes
45 
47 
48 BEGIN_objects_SCOPE // namespace ncbi::objects::
49 
50 // destructor
52 {
53 }
54 
55 
57 {
58  bool unique = (flags & fLabel_Unique) != 0;
59 
60  if (IsSetSerial_number()) {
61  *label += "[" + NStr::IntToString(GetSerial_number()) + "]";
62  }
63  if (IsSetMuid()) {
64  *label += "NLM" + NStr::NumericToString(GetMuid());
65  }
66 
67  string date;
68  string* date_ptr = 0;
69  if ( IsSetDate() ) {
70  date_ptr = &date;
71  GetDate().GetDate(date_ptr, true);
72  }
73 
74  const string* title2 = 0;
75  const string* titleunique = 0;
76  bool unpublished = false;
77  const CTitle* title = IsSetJournal() ? &GetJournal() : 0;
78  const CAuth_list* authors = IsSetAuthors() ? &GetAuthors() : 0;
79  const string* volume = IsSetVolume() ? &GetVolume() : 0;
80  const string* issue = IsSetIssue() ? &GetIssue() : 0;
81  const string* pages = IsSetPages() ? &GetPages() : 0;
82 
83  if (IsSetCit()) {
84  if ( NStr::EqualNocase( GetCit(), "Unpublished") ) {
85  unpublished = true;
86  } else if (!title) {
87  title2 = &GetCit();
88  }
89  }
90  if (IsSetTitle()) {
91  titleunique = &GetTitle();
92  } else if (title2) {
93  titleunique = title2;
94  } else if (!title && IsSetCit()) {
95  titleunique = &GetCit();
96  }
97  if (!title && !authors && !IsSetTitle() && !volume &&
98  !pages && !issue) {
99  titleunique = 0;
100  if (IsSetCit()) {
101  string cit(GetCit());
102  if (!unique) {
103  try {
104  cit.resize(cit.find_last_of('|'));
105  } catch(length_error&) {}
106  }
107  *label += cit;
108  }
109  return true;
110  }
111 
112  return x_GetLabelV1(label, unique,
113  authors, 0, title, 0, 0, 0, title2, titleunique,
114  date_ptr, volume, issue, pages, unpublished);
115 }
116 
117 
118 // Based on FormatCitGen from the C Toolkit's api/asn2gnb5.c.
120 {
121  if ( !CanGetCit() && !CanGetJournal() && !CanGetDate()
122  && CanGetSerial_number() ) {
123  return false;
124  }
125 
126  if ( !CanGetJournal() && CanGetCit() && SWNC(GetCit(), "unpublished")) {
127  if ((flags & fLabel_NoUnpubAffil) != 0) {
129  *label += "Unpublished";
130  return true;
131  }
132 
133  if (CanGetAuthors() && GetAuthors().CanGetAffil()) {
135  *label += "Unpublished ";
138  return true;
139  }
140 
141  if (CanGetCit() && HasText(GetCit())) {
144  return true;
145  } else {
146  return false;
147  }
148  }
149 
150  string year = CanGetDate() ? GetParenthesizedYear(GetDate()) : kEmptyStr;
151  string pages = CanGetPages() ? FixPages(GetPages()) : kEmptyStr;
152  string journal, inpress;
153  SIZE_TYPE pos;
154 
155  if (CanGetJournal()) {
157  }
158 
159  if (CanGetCit()) {
160  pos = GetCit().find("Journal=\"");
161  if (pos != NPOS) {
162  journal = GetCit().substr(pos + 9);
163  } else if (SWNC(GetCit(), "submitted")
164  || SWNC(GetCit(), "unpublished")) {
165  if ((flags & fLabel_NoBadCitGen) == 0 || !journal.empty()) {
166  inpress = GetCit();
167  } else {
168  inpress = "Unpublished";
169  }
170  } else if (SWNC(GetCit(), "Online Publication")
171  || SWNC(GetCit(), "Published Only in DataBase")
172  || SWNC(GetCit(), "In press")) {
173  inpress = GetCit();
174  } else if (SWNC(GetCit(), "(er) ")) {
175  journal = GetCit();
176  } else if ((flags & fLabel_NoBadCitGen) == 0 && journal.empty()) {
177  journal = GetCit();
178  }
179  }
180 
181  if ((!HasText(pages) || (flags & (fLabel_FlatNCBI | fLabel_FlatEMBL)) == 0)
182  && journal.empty() && !HasText(inpress) && !HasText(year)
183  && (!CanGetVolume() || !HasText(GetVolume()))) {
184  return false;
185  }
186 
187  string prefix;
189 
190  if ( !journal.empty() ) {
191  pos = journal.find_first_of("=\"");
192  if (pos != NPOS) {
193  journal.resize(pos);
194  }
195  *label += journal;
196  prefix = " ";
197  }
198 
199  if (HasText(inpress)) {
200  *label += prefix + inpress;
201  prefix = " ";
202  }
203 
204  if (CanGetVolume() && HasText(GetVolume())) {
205  *label += prefix + GetVolume();
206  }
207 
208  if (HasText(pages)) {
209  if ((flags & fLabel_FlatNCBI) != 0) {
210  *label += ", " + pages;
211  } else if ((flags & fLabel_FlatEMBL) != 0) {
212  *label += ':' + pages;
213  }
214  }
215 
216  if (HasText(year)) {
217  *label += ' ' + year;
218  }
219 
220  return true;
221 }
222 
223 
224 END_objects_SCOPE // namespace ncbi::objects::
225 
227 
228 /* Original file checksum: lines: 64, chars: 1875, CRC32: 5ca91cd9 */
@Auth_list.hpp User-defined methods of the data storage class.
Definition: Auth_list.hpp:57
bool GetLabelV1(string *label, TLabelFlags flags) const override
Definition: Cit_gen.cpp:56
~CCit_gen(void)
Definition: Cit_gen.cpp:51
bool GetLabelV2(string *label, TLabelFlags flags) const override
Definition: Cit_gen.cpp:119
void GetDate(string *label, bool year_only=false) const
Append a standardized string representation of the date to the label.
Definition: Date.hpp:149
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_V2
New implementation, in line with GenBank/GenPept REFERENCE JOURNAL fields and the like.
int TLabelFlags
binary OR of ELabelFlags
@ fLabel_FlatEMBL
For EMBL or EMBLPept [V2].
@ fLabel_NoUnpubAffil
No affil on unpublished Cit-gen [V2].
@ fLabel_NoBadCitGen
Ignore "bad" Cit-gen data [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 bool SWNC(const string &str, const string &pfx)
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 END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NPOS
Definition: ncbistr.hpp:133
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3197
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5083
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5352
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
Definition: ncbistr.cpp:3182
@ eTrunc_End
Truncate trailing spaces only.
Definition: ncbistr.hpp:2241
static const char label[]
bool IsSetPages(void) const
Check if a value has been assigned to Pages data member.
Definition: Cit_gen_.hpp:806
const TIssue & GetIssue(void) const
Get the Issue member data.
Definition: Cit_gen_.hpp:771
bool IsSetDate(void) const
Check if a value has been assigned to Date data member.
Definition: Cit_gen_.hpp:853
TSerial_number GetSerial_number(void) const
Get the Serial_number member data.
Definition: Cit_gen_.hpp:893
bool CanGetJournal(void) const
Check if it is safe to call GetJournal method.
Definition: Cit_gen_.hpp:697
bool IsSetAuthors(void) const
Check if a value has been assigned to Authors data member.
Definition: Cit_gen_.hpp:623
bool IsSetVolume(void) const
Check if a value has been assigned to Volume data member.
Definition: Cit_gen_.hpp:712
const TPages & GetPages(void) const
Get the Pages member data.
Definition: Cit_gen_.hpp:818
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_gen_.hpp:635
const TCit & GetCit(void) const
Get the Cit member data.
Definition: Cit_gen_.hpp:588
bool IsSetSerial_number(void) const
for GenBank style references Check if a value has been assigned to Serial_number data member.
Definition: Cit_gen_.hpp:874
const TAffil & GetAffil(void) const
Get the Affil member data.
Definition: Auth_list_.hpp:510
const TDate & GetDate(void) const
Get the Date member data.
Definition: Cit_gen_.hpp:865
bool CanGetPages(void) const
Check if it is safe to call GetPages method.
Definition: Cit_gen_.hpp:812
bool IsSetCit(void) const
anything, not parsable Check if a value has been assigned to Cit data member.
Definition: Cit_gen_.hpp:576
bool CanGetDate(void) const
Check if it is safe to call GetDate method.
Definition: Cit_gen_.hpp:859
const TVolume & GetVolume(void) const
Get the Volume member data.
Definition: Cit_gen_.hpp:724
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_gen_.hpp:933
const TJournal & GetJournal(void) const
Get the Journal member data.
Definition: Cit_gen_.hpp:703
bool IsSetTitle(void) const
eg.
Definition: Cit_gen_.hpp:921
bool IsSetJournal(void) const
Check if a value has been assigned to Journal data member.
Definition: Cit_gen_.hpp:691
bool CanGetVolume(void) const
Check if it is safe to call GetVolume method.
Definition: Cit_gen_.hpp:718
bool CanGetAuthors(void) const
Check if it is safe to call GetAuthors method.
Definition: Cit_gen_.hpp:629
bool IsSetIssue(void) const
Check if a value has been assigned to Issue data member.
Definition: Cit_gen_.hpp:759
TMuid GetMuid(void) const
Get the Muid member data.
Definition: Cit_gen_.hpp:663
bool IsSetMuid(void) const
medline uid Check if a value has been assigned to Muid data member.
Definition: Cit_gen_.hpp:644
bool CanGetSerial_number(void) const
Check if it is safe to call GetSerial_number method.
Definition: Cit_gen_.hpp:880
bool CanGetCit(void) const
Check if it is safe to call GetCit method.
Definition: Cit_gen_.hpp:582
static const char * prefix[]
Definition: pcregrep.c:405
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:1468
Modified on Sat Dec 02 09:22:49 2023 by modify_doxy.py rev. 669887