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

Go to the SVN repository for this file.

1 /* $Id: Cit_pat.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>
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  string date;
59  string* date_ptr = &date;
60  if ( IsSetDate_issue() ) {
61  GetDate_issue().GetDate(&date, true);
62  }
63  else if ( IsSetApp_date() ) {
64  GetApp_date().GetDate(&date, true);
65  }
66  else {
67  date_ptr = 0;
68  }
69 
70  return x_GetLabelV1(label, false, &GetAuthors(), 0, 0, 0, 0,
71  &GetCountry(),
72  IsSetNumber() ? &GetNumber() :
73  (IsSetApp_number() ? &GetApp_number() : 0),
74  0, date_ptr);
75 }
76 
77 
79 {
80  // The C equivalent (FormatCitPat from asn2gnb5.c) additionally
81  // consults Patent-seq-id objects, which are neither available nor
82  // usable here. This implementation necessarily treats them as
83  // absent. :-/
85 
86  if ((flags & fLabel_FlatNCBI) != 0) {
87  *label += "Patent: ";
88  } else if ((flags & fLabel_FlatEMBL) != 0) {
89  *label += "Patent number ";
90  }
91 
92  if (HasText(GetCountry())) {
93  *label += GetCountry();
94  if ((flags & (fLabel_FlatNCBI | fLabel_FlatEMBL)) != 0) {
95  *label += ' ';
96  }
97  }
98 
99  if (CanGetNumber() && HasText(GetNumber())) {
100  *label += GetNumber();
101  } else if (CanGetApp_number() && HasText(GetApp_number())) {
102  *label += '(' + GetApp_number() + ')';
103  }
104 
105  if (HasText(GetDoc_type())) {
106  *label += '-' + GetDoc_type();
107  }
108 
109  *label += ' ';
110  {{
111  string date;
112  if (CanGetDate_issue()) {
113  GetDate_issue().GetDate(&date, "%{%2D%|01%}-%{%3N%|JAN%}-%Y");
114  } else if (CanGetApp_date()) {
115  GetApp_date().GetDate(&date, "%{%2D%|01%}-%{%3N%|JAN%}-%Y");
116  }
117  *label += date;
118  }}
119 
120  if ((flags & fLabel_FlatNCBI) != 0) {
121  *label += ';';
122  } else if ((flags & fLabel_FlatEMBL) != 0) {
123  *label += '.';
124  }
125 
126  x_GetLabelV2(label, GetAuthors(), "\n");
127 
128  if (CanGetAssignees()) {
129  string assignees, consortia, prefix = "\n";
130  GetAssignees().GetLabel(&assignees, flags, eLabel_V2);
132  eLabel_V2);
133  if (HasText(assignees)) {
134  *label += prefix + assignees + ';';
135  prefix = HasText(consortia) ? kEmptyStr : " ";
136  }
137  if (HasText(consortia)) {
138  *label += prefix + consortia + ';';
139  prefix = " ";
140  }
142  }
143 
144  return true;
145 }
146 
147 
148 // Based on FormatCitPat from the C Toolkit's api/asn2gnb5.c.
149 bool CCit_pat::x_GetLabelV2(string* label, const CAuth_list& authors,
150  string prefix)
151 {
152  if ( !authors.CanGetAffil() ) {
153  return false;
154  }
155 
156  switch (authors.GetAffil().Which()) {
157  case CAffil::e_Str:
158  if (HasText(authors.GetAffil().GetStr())) {
159  if (prefix == "\n") {
160  *label += prefix;
161  }
162  *label += authors.GetAffil().GetStr();
163  }
164  return true;
165 
166  case CAffil::e_Std:
167  {
168  const CAffil::TStd& std = authors.GetAffil().GetStd();
169  if (std.CanGetAffil() && HasText(std.GetAffil())) {
170  if (prefix == "\n") {
171  *label += prefix;
172  }
173  *label += std.GetAffil() + ';';
174  prefix = " ";
175  }
176  if (std.CanGetStreet() && HasText(std.GetStreet())) {
177  *label += prefix + std.GetStreet() + ';';
178  prefix = " ";
179  }
180  if (std.CanGetDiv() && HasText(std.GetDiv())) {
181  *label += prefix + std.GetDiv() + ';';
182  prefix = " ";
183  }
184  if (std.CanGetCity() && HasText(std.GetCity())) {
185  *label += prefix + std.GetCity();
186  prefix = ", ";
187  }
188  if (std.CanGetSub() && HasText(std.GetSub())) {
189  *label += prefix + std.GetSub();
190  }
191  if (std.CanGetCountry() && HasText(std.GetCountry())) {
192  if (prefix == "\n") {
193  *label += prefix;
194  }
195  *label += ";\n" + std.GetCountry() + ';';
196  }
197  return true;
198  }
199 
200  default:
201  return false;
202  }
203 
204  return false;
205 }
206 
207 
208 END_objects_SCOPE // namespace ncbi::objects::
209 
211 
212 /* Original file checksum: lines: 61, chars: 1880, CRC32: 6bbed461 */
std representation
Definition: Affil_.hpp:91
@Auth_list.hpp User-defined methods of the data storage class.
Definition: Auth_list.hpp:57
~CCit_pat(void)
Definition: Cit_pat.cpp:51
static bool x_GetLabelV2(string *label, const CAuth_list &authors, string prefix)
Definition: Cit_pat.cpp:149
bool GetLabelV1(string *label, TLabelFlags flags) const override
Definition: Cit_pat.cpp:56
bool GetLabelV2(string *label, TLabelFlags flags) const override
Definition: Cit_pat.cpp:78
void GetDate(string *label, bool year_only=false) const
Append a standardized string representation of the date to the label.
Definition: Date.hpp:149
@ 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_Consortia
Consortia, not authors [internal].
@ fLabel_FlatNCBI
For GenBank or GenPept [V2].
static bool HasText(const string &s)
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
#define kEmptyStr
Definition: ncbistr.hpp:123
static const char label[]
bool CanGetAffil(void) const
Check if it is safe to call GetAffil method.
Definition: Auth_list_.hpp:504
const TDoc_type & GetDoc_type(void) const
Get the Doc_type member data.
Definition: Cit_pat_.hpp:792
bool IsSetNumber(void) const
Patent Document Number Check if a value has been assigned to Number data member.
Definition: Cit_pat_.hpp:827
bool CanGetCity(void) const
Check if it is safe to call GetCity method.
Definition: Affil_.hpp:788
const TAffil & GetAffil(void) const
Get the Affil member data.
Definition: Auth_list_.hpp:510
bool CanGetSub(void) const
Check if it is safe to call GetSub method.
Definition: Affil_.hpp:835
const TStr & GetStr(void) const
Get the variant data.
Definition: Affil_.hpp:1193
bool CanGetCountry(void) const
Check if it is safe to call GetCountry method.
Definition: Affil_.hpp:882
const TApp_date & GetApp_date(void) const
Get the App_date member data.
Definition: Cit_pat_.hpp:979
const TDate_issue & GetDate_issue(void) const
Get the Date_issue member data.
Definition: Cit_pat_.hpp:886
const TStreet & GetStreet(void) const
Get the Street member data.
Definition: Affil_.hpp:935
const TAffil & GetAffil(void) const
Get the Affil member data.
Definition: Affil_.hpp:700
const TSub & GetSub(void) const
Get the Sub member data.
Definition: Affil_.hpp:841
bool CanGetDate_issue(void) const
Check if it is safe to call GetDate_issue method.
Definition: Cit_pat_.hpp:880
bool CanGetApp_number(void) const
Check if it is safe to call GetApp_number method.
Definition: Cit_pat_.hpp:926
bool CanGetNumber(void) const
Check if it is safe to call GetNumber method.
Definition: Cit_pat_.hpp:833
E_Choice Which(void) const
Which variant is currently selected.
Definition: Affil_.hpp:1158
const TNumber & GetNumber(void) const
Get the Number member data.
Definition: Cit_pat_.hpp:839
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_pat_.hpp:715
const TCountry & GetCountry(void) const
Get the Country member data.
Definition: Affil_.hpp:888
const TStd & GetStd(void) const
Get the variant data.
Definition: Affil_.cpp:214
bool CanGetAssignees(void) const
Check if it is safe to call GetAssignees method.
Definition: Cit_pat_.hpp:1015
bool IsSetApp_date(void) const
Patent Appl File Date Check if a value has been assigned to App_date data member.
Definition: Cit_pat_.hpp:967
bool IsSetApp_number(void) const
Patent Doc Appl Number Check if a value has been assigned to App_number data member.
Definition: Cit_pat_.hpp:920
bool CanGetApp_date(void) const
Check if it is safe to call GetApp_date method.
Definition: Cit_pat_.hpp:973
const TApp_number & GetApp_number(void) const
Get the App_number member data.
Definition: Cit_pat_.hpp:932
bool CanGetStreet(void) const
Check if it is safe to call GetStreet method.
Definition: Affil_.hpp:929
bool CanGetDiv(void) const
Check if it is safe to call GetDiv method.
Definition: Affil_.hpp:741
const TAssignees & GetAssignees(void) const
Get the Assignees member data.
Definition: Cit_pat_.hpp:1021
bool CanGetAffil(void) const
Check if it is safe to call GetAffil method.
Definition: Affil_.hpp:694
const TCity & GetCity(void) const
Get the City member data.
Definition: Affil_.hpp:794
const TDiv & GetDiv(void) const
Get the Div member data.
Definition: Affil_.hpp:747
bool IsSetDate_issue(void) const
Patent Issue/Pub Date Check if a value has been assigned to Date_issue data member.
Definition: Cit_pat_.hpp:874
const TCountry & GetCountry(void) const
Get the Country member data.
Definition: Cit_pat_.hpp:745
@ e_Str
unparsed string
Definition: Affil_.hpp:545
static const char * prefix[]
Definition: pcregrep.c:405
Modified on Wed Apr 17 13:10:02 2024 by modify_doxy.py rev. 669887