1 /* $Id: Cit_art.cpp 272611 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>
41 #include <objects/biblio/Cit_art.hpp>
42 #include <objects/biblio/Imprint.hpp>
43 #include <objects/biblio/Title.hpp>
44 #include <objects/biblio/Cit_jour.hpp>
45 #include <objects/biblio/Cit_book.hpp>
46 #include <objects/biblio/Cit_proc.hpp>
47 #include <objects/general/Date.hpp>
48 
49 // generated classes
50 
51 BEGIN_NCBI_SCOPE
52 
53 BEGIN_objects_SCOPE // namespace ncbi::objects::
54 
55 // destructor
~CCit_art(void)56 CCit_art::~CCit_art(void)
57 {
58 }
59 
60 
GetLabelV1(string * label,TLabelFlags flags) const61 bool CCit_art::GetLabelV1(string* label, TLabelFlags flags) const
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.
GetLabelV2(string * label,TLabelFlags flags) const103 bool CCit_art::GetLabelV2(string* label, TLabelFlags flags) const
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()
110             .GetLabel(label, flags | fLabel_ISO_JTA, eLabel_V2);
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 
x_GetLabelV2(string * label,TLabelFlags flags,const CCit_book & book)121 bool CCit_art::x_GetLabelV2(string* label, TLabelFlags flags,
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 
128     MaybeAddSpace(label);
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 
188 END_NCBI_SCOPE
189 
190 /* Original file checksum: lines: 61, chars: 1880, CRC32: 30f0bfed */
191