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

Go to the SVN repository for this file.

1 /* $Id: Cit_jour.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 
43 // generated classes
44 
46 
47 BEGIN_objects_SCOPE // namespace ncbi::objects::
48 
49 // destructor
51 {
52 }
53 
54 
56 {
57  return x_GetLabelV1(label, false, 0, &GetImp(), &GetTitle(), 0, this);
58 }
59 
60 
61 // Based on FormatCitJour from the C Toolkit's api/asn2gnb5.c.
63 {
64  const CImprint& imp = GetImp();
65 
66  int prepub = imp.CanGetPrepub() ? imp.GetPrepub() : 0;
67  int status = imp.CanGetPubstatus() ? imp.GetPubstatus() : 0;
68 
69  bool is_electronic = (status == ePubStatus_epublish
70  || status == ePubStatus_aheadofprint);
71 
72  const string* jtitle;
73  try {
75  } catch (CException&) {
76  try {
77  jtitle = &GetTitle().GetTitle();
78  if (NStr::StartsWith(*jtitle, "(er)")) {
79  is_electronic = true;
80  }
81  if ((flags & fLabel_ISO_JTA) != 0 && !is_electronic) {
82  return false;
83  }
84  } catch (CException&) {
85  jtitle = NULL;
86  }
87  }
88 
89  string year = GetParenthesizedYear(imp.GetDate());
90 
92 
93  if (prepub == CImprint::ePrepub_submitted
94  || prepub == CImprint::ePrepub_other) {
95  *label += "Unpublished " + year;
96  return true;
97  }
98 
99  if (jtitle == NULL || jtitle->size() < 3) {
100  *label += '.';
101  return false;
102  }
103 
104  *label += *jtitle;
105 
106  const string* volume = imp.CanGetVolume() ? &imp.GetVolume() : NULL;
107  string pages = imp.CanGetPages() ? imp.GetPages() : kEmptyStr;
108  if ( !pages.empty() && !is_electronic ) {
109  pages = FixPages(pages);
110  }
111 
112  if (HasText(volume)) {
114  *label += *volume;
115  }
116 
117  if ((flags & fLabel_FlatNCBI) != 0
118  && (HasText(volume) || HasText(pages))) {
119  NoteSup(label, imp);
120  }
121 
122  if ((flags & fLabel_FlatNCBI) != 0) {
123  if (HasText(pages)) {
124  *label += ", " + pages;
125  }
126  } else if ((flags & fLabel_FlatEMBL) != 0) {
127  if (HasText(pages)) {
128  *label += ':' + pages;
129  } else if (prepub == CImprint::ePrepub_in_press || !HasText(volume)) {
131  *label += "0:0-0";
132  }
133  }
134 
135  *label += ' ' + year;
136 
137  if ((flags & fLabel_FlatNCBI) != 0) {
138  if (prepub == CImprint::ePrepub_in_press
139  || (status == ePubStatus_aheadofprint && !HasText(pages))) {
141  *label += "In press";
142  }
143  }
144 
145  return true;
146 }
147 
148 
149 END_objects_SCOPE // namespace ncbi::objects::
150 
152 
153 /* Original file checksum: lines: 61, chars: 1883, CRC32: 93da792e */
~CCit_jour(void)
Definition: Cit_jour.cpp:50
bool GetLabelV1(string *label, TLabelFlags flags) const override
Definition: Cit_jour.cpp:55
bool GetLabelV2(string *label, TLabelFlags flags) const override
Definition: Cit_jour.cpp:62
CImprint –.
Definition: Imprint.hpp:66
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
int TLabelFlags
binary OR of ELabelFlags
@ fLabel_FlatEMBL
For EMBL or EMBLPept [V2].
@ fLabel_ISO_JTA
Only ISO jnl. title abbrevs. OK [V2].
@ fLabel_FlatNCBI
For GenBank or GenPept [V2].
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)
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
#define kEmptyStr
Definition: ncbistr.hpp:123
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5406
static const char label[]
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
bool CanGetPubstatus(void) const
Check if it is safe to call GetPubstatus method.
Definition: Imprint_.hpp:1201
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
bool CanGetVolume(void) const
Check if it is safe to call GetVolume method.
Definition: Imprint_.hpp:752
const TImp & GetImp(void) const
Get the Imp member data.
Definition: Cit_jour_.hpp:243
const TDate & GetDate(void) const
Get the Date member data.
Definition: Imprint_.hpp:728
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_jour_.hpp:213
TPubstatus GetPubstatus(void) const
Get the Pubstatus member data.
Definition: Imprint_.hpp:1214
@ e_Iso_jta
specifically ISO jta J
Definition: Title_.hpp:115
@ ePubStatus_aheadofprint
epublish, but will be followed by print
Definition: PubStatus_.hpp:75
@ ePubStatus_epublish
published electronically by publisher
Definition: PubStatus_.hpp:68
@ ePrepub_in_press
accepted, not published
Definition: Imprint_.hpp:96
@ ePrepub_submitted
submitted, not accepted
Definition: Imprint_.hpp:95
Modified on Fri Sep 20 14:57:24 2024 by modify_doxy.py rev. 669887