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

Go to the SVN repository for this file.

1 /*
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: Alexey Dobronadezhdin
27  *
28  * File Description:
29  *
30  * ===========================================================================
31  */
32 #include <ncbi_pch.hpp>
33 
34 #include <objects/pub/Pub.hpp>
42 
43 #include "utils.hpp"
44 #include "unpub_report.hpp"
45 #include "unpub_hook.hpp"
46 
49 
50 namespace pub_report
51 {
52 
54  m_report(report)
55 {
56 }
57 
58 static bool IsGenUnpublished(const CCit_gen& cit)
59 {
60  return cit.IsSetCit() && cit.IsSetTitle() &&
61  NStr::EqualNocase(cit.GetCit(), "Unpublished") &&
62  ! NStr::EqualNocase(cit.GetTitle(), "Direct Submission");
63 }
64 
65 static bool IsArtUnpublished(const CCit_art& cit)
66 {
67  bool ret = false;
68 
69  if (cit.IsSetFrom() && cit.GetFrom().IsJournal()) {
70  const CCit_jour& journal = cit.GetFrom().GetJournal();
71  if (journal.IsSetImp()) {
72  const CImprint& imprint = journal.GetImp();
73  ret = (imprint.IsSetPrepub() && imprint.GetPrepub() == CImprint::ePrepub_in_press) ||
74  (imprint.IsSetPubstatus() && imprint.GetPubstatus() == ePubStatus_aheadofprint);
75  }
76  }
77 
78  return ret;
79 }
80 
81 static bool IsUnpublished(const CPub& pub)
82 {
83  bool ret = false;
84 
85  if (pub.IsGen()) {
86  ret = IsGenUnpublished(pub.GetGen());
87  } else if (pub.IsArticle()) {
88  ret = IsArtUnpublished(pub.GetArticle());
89  }
90 
91  return ret;
92 }
93 
95 {
97 }
98 
100 {
101  CPub_equiv pubs;
102  DefaultRead(in, ObjectInfo(pubs));
103 
104  for (const auto& pub : pubs.Get()) {
105  if (pub->IsSub()) {
106  const CCit_sub& sub = pub->GetSub();
107  if (sub.IsSetDate() && sub.GetDate().IsStd()) {
108  const CDate_std& sub_date = sub.GetDate().GetStd();
109  if (m_report.IsSetDate()) {
110  if (m_report.GetDate().Compare(sub_date) == CDate::eCompare_after) {
111  m_report.SetDate(sub_date);
112  }
113  } else {
114  m_report.SetDate(sub_date);
115  }
116  }
117  } else if (IsUnpublished(*pub)) {
118  ProcessUnpublished(*pub);
119  }
120  }
121 }
122 
123 }
User-defined methods of the data storage class.
CDate::ECompare Compare(const CDate_std &date) const
Indicate how *this relates to another date.
Definition: Date_std.cpp:91
@ eCompare_after
*this comes second.
Definition: Date.hpp:76
CImprint –.
Definition: Imprint.hpp:66
CObjectIStream –.
Definition: objistr.hpp:93
CObjectTypeInfo –.
Definition: objectinfo.hpp:94
Definition: Pub.hpp:56
CSkipPubUnpublishedHook(CUnpublishedReport &report)
Definition: unpub_hook.cpp:53
void SkipObject(CObjectIStream &in, const CObjectTypeInfo &info) override
Definition: unpub_hook.cpp:99
void ProcessUnpublished(const CPub &pub)
Definition: unpub_hook.cpp:94
const CDate_std & GetDate() const
void ReportUnpublished(const CPub &pub)
void SetDate(const CDate_std &date)
pair< TObjectPtr, TTypeInfo > ObjectInfo(C &obj)
Definition: objectinfo.hpp:762
void DefaultRead(CObjectIStream &in, const CObjectInfo &object)
Default read.
Definition: objhook.cpp:105
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:5353
const TDate & GetDate(void) const
Get the Date member data.
Definition: Cit_sub_.hpp:455
const TJournal & GetJournal(void) const
Get the variant data.
Definition: Cit_art_.cpp:111
bool IsSetPrepub(void) const
Check if a value has been assigned to Prepub data member.
Definition: Imprint_.hpp:1080
const TFrom & GetFrom(void) const
Get the From member data.
Definition: Cit_art_.hpp:567
const TCit & GetCit(void) const
Get the Cit member data.
Definition: Cit_gen_.hpp:588
bool IsSetFrom(void) const
Check if a value has been assigned to From data member.
Definition: Cit_art_.hpp:555
TPrepub GetPrepub(void) const
Get the Prepub member data.
Definition: Imprint_.hpp:1099
bool IsSetPubstatus(void) const
current status of this publication Check if a value has been assigned to Pubstatus data member.
Definition: Imprint_.hpp:1195
bool IsSetCit(void) const
anything, not parsable Check if a value has been assigned to Cit data member.
Definition: Cit_gen_.hpp:576
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_gen_.hpp:933
bool IsSetDate(void) const
replaces imp, will become required Check if a value has been assigned to Date data member.
Definition: Cit_sub_.hpp:443
bool IsSetTitle(void) const
eg.
Definition: Cit_gen_.hpp:921
bool IsJournal(void) const
Check if variant Journal is selected.
Definition: Cit_art_.hpp:495
TPubstatus GetPubstatus(void) const
Get the Pubstatus member data.
Definition: Imprint_.hpp:1214
@ ePubStatus_aheadofprint
epublish, but will be followed by print
Definition: PubStatus_.hpp:75
@ ePrepub_in_press
accepted, not published
Definition: Imprint_.hpp:96
bool IsStd(void) const
Check if variant Std is selected.
Definition: Date_.hpp:320
const TStd & GetStd(void) const
Get the variant data.
Definition: Date_.cpp:109
const TArticle & GetArticle(void) const
Get the variant data.
Definition: Pub_.cpp:233
const Tdata & Get(void) const
Get the member data.
Definition: Pub_equiv_.hpp:165
const TGen & GetGen(void) const
Get the variant data.
Definition: Pub_.cpp:167
bool IsArticle(void) const
Check if variant Article is selected.
Definition: Pub_.hpp:629
bool IsGen(void) const
Check if variant Gen is selected.
Definition: Pub_.hpp:584
static MDB_envinfo info
Definition: mdb_load.c:37
static bool IsUnpublished(const CPub &pub)
Definition: unpub_hook.cpp:81
static bool IsGenUnpublished(const CCit_gen &cit)
Definition: unpub_hook.cpp:58
static bool IsArtUnpublished(const CCit_art &cit)
Definition: unpub_hook.cpp:65
std::istream & in(std::istream &in_, double &x_)
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:1452
USING_SCOPE(objects)
USING_NCBI_SCOPE
Definition: unpub_hook.cpp:47
Modified on Wed Apr 17 13:10:29 2024 by modify_doxy.py rev. 669887