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

Go to the SVN repository for this file.

1 /* $Id: Pub_equiv.cpp 73686 2016-07-20 12:15:43Z bollin $
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  * 'pub.asn'.
35  */
36 
37 // standard includes
38 
39 // generated includes
40 #include <ncbi_pch.hpp>
42 #include <objects/pub/Pub.hpp>
43 
44 // generated classes
45 
47 
48 BEGIN_objects_SCOPE // namespace ncbi::objects::
49 
50 // destructor
52 {
53 }
54 
55 // Appends a label to "label" based on content
57  ELabelVersion version) const
58 {
59  bool found = false;
60  const CPub* pubs[5];
61  int i;
62  for(i = 0; i < 5; i++) {
63  pubs[i] = 0;
64  }
65  i = 1;
66 
67  // Get five pubs in the set of pubs, giving preference to e_Muid,
68  // e_Pmid, and e_Gen.
69  ITERATE (list<CRef<CPub> >, it, Get()) {
70  switch ((**it).Which()) {
71  case CPub::e_Muid:
72  pubs[3] = *it;
73  break;
74  case CPub::e_Pmid:
75  pubs[0] = *it;
76  break;
77  case CPub::e_Gen:
78  if ((**it).GetGen().IsSetSerial_number()) {
79  pubs[4] = *it;
80  break;
81  }
82  // otherwise fall through
83  default:
84  if (i < 5) {
85  if (!pubs[i]) {
86  pubs[i] = *it;
87  }
88  i++;
89  }
90  break;
91  }
92  }
93 
94  bool first = true;
95  // Loop thru 5 pubs, ensuring each one exists
96  for (i = 0; i < 5; i++) {
97  if (!pubs[i]) {
98  continue;
99  }
100 
101  if (first) {
102  first = false;
103  } else {
104  *label += " ";
105  }
106  // Append a label to "label"
107  found |= pubs[i]->GetLabel(label, flags, version);
108  }
109 
110  return found;
111 }
112 
113 
114 bool CPub_equiv::SameCitation(const CPub& pub) const
115 {
116  ITERATE(CPub_equiv::Tdata, it1, Get()) {
117  if ((*it1)->SameCitation(pub)) {
118  return true;
119  } else if ((*it1)->Which() == pub.Which()) {
120  return false;
121  }
122  }
123  return false;
124 }
125 
126 
127 bool CPub_equiv::SameCitation(const CPub_equiv& other) const
128 {
129  ITERATE(CPub_equiv::Tdata, it1, Get()) {
130  ITERATE(CPub_equiv::Tdata, it2, other.Get()) {
131  if ((*it1)->SameCitation(**it2)) {
132  return true;
133  } else if ((*it1)->Which() == (*it2)->Which()) {
134  return false;
135  }
136  }
137  }
138  return false;
139 }
140 
141 
142 
143 
144 END_objects_SCOPE // namespace ncbi::objects::
145 
147 
148 /* Original file checksum: lines: 61, chars: 1880, CRC32: 176db75f */
bool SameCitation(const CPub_equiv &other) const
Definition: Pub_equiv.cpp:127
~CPub_equiv(void)
Definition: Pub_equiv.cpp:51
bool GetLabel(string *label, TLabelFlags flags=0, ELabelVersion version=eLabel_DefaultVersion) const override
Append a label to "label" based on content.
Definition: Pub_equiv.cpp:56
Definition: Pub.hpp:56
bool GetLabel(string *label, ELabelType type=eContent, TLabelFlags flags=0, ELabelVersion version=eLabel_DefaultVersion) const
Concatenate a label for this pub to label.
Definition: Pub.cpp:76
int TLabelFlags
binary OR of ELabelFlags
static uch flags
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#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 const char label[]
list< CRef< CPub > > Tdata
Definition: Pub_equiv_.hpp:90
const Tdata & Get(void) const
Get the member data.
Definition: Pub_equiv_.hpp:165
E_Choice Which(void) const
Which variant is currently selected.
Definition: Pub_.hpp:555
@ e_Pmid
PubMedId.
Definition: Pub_.hpp:114
@ e_Gen
general or generic unparsed
Definition: Pub_.hpp:102
@ e_Muid
medline uid
Definition: Pub_.hpp:105
int i
static int version
Definition: mdb_load.c:29
Modified on Thu Apr 11 15:20:18 2024 by modify_doxy.py rev. 669887