NCBI C++ ToolKit
PubmedArticle.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: PubmedArticle.hpp 96985 2022-06-03 16:56:21Z grichenk $
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  */
27 
28 /// @file PubmedArticle.hpp
29 /// User-defined methods of the data storage class.
30 ///
31 /// This file was originally generated by application DATATOOL
32 /// using the following specifications:
33 /// 'efetch.dtd'.
34 ///
35 /// New methods or data members can be added to it if needed.
36 /// See also: PubmedArticle_.hpp
37 
38 
39 #ifndef eutils__OBJTOOLS_EUTILS_EFETCH_PUBMEDARTICLE_HPP
40 #define eutils__OBJTOOLS_EUTILS_EFETCH_PUBMEDARTICLE_HPP
41 
42 #include <locale>
43 #include <serial/iterator.hpp>
44 
45 // generated includes
47 
48 // generated classes
49 
52 class CPubmed_entry;
53 class CDate;
54 class CTitle;
55 class CArticleIdSet;
58 
59 
60 
61 BEGIN_eutils_SCOPE // namespace eutils::
62 
63 /////////////////////////////////////////////////////////////////////////////
65 {
67 public:
68  // constructor
69  CPubmedArticle(void);
70  // destructor
71  ~CPubmedArticle(void);
72 
73  ncbi::CRef<ncbi::objects::CPubmed_entry> ToPubmed_entry(void) const;
74 
75 private:
76  // Prohibit copy constructor and assignment operator
79 
80 };
81 
82 /////////////////// CPubmedArticle inline methods
83 
84 // constructor
85 inline
87 {
88 }
89 
90 
91 /////////////////// end of CPubmedArticle inline methods
92 
93 
94 /////////////////// Helper classes and functions also used by CPubmedBookArticle
95 
96 class CPubDate;
97 class CPubMedPubDate;
98 class CArticleTitle;
99 class CVernacularTitle;
100 class CAuthor;
101 class CPagination;
102 class CArticleIdList;
103 class CArticle;
104 class CGrantList;
105 class CText;
106 
108 ncbi::CRef<ncbi::objects::CDate> s_GetDateFromPubDate(const CPubDate& pub_date);
109 ncbi::CRef<ncbi::objects::CDate> s_GetDateFromPubMedPubDate(const CPubMedPubDate& pdate);
110 std::string s_GetArticleTitleStr(const CArticleTitle& article_title);
111 std::string s_GetVernacularTitleStr(const CVernacularTitle& vernacular_title);
112 ncbi::CRef<ncbi::objects::CTitle> s_MakeTitle(
113  const std::string& title_str,
114  const std::string& vernacular_title_str);
116 std::string s_GetPagination(const CPagination& pagination);
117 ncbi::CRef<ncbi::objects::CArticleIdSet> s_GetArticleIdSet(
118  const CArticleIdList& article_id_list,
119  const CArticle* article);
120 void s_FillGrants(std::list<std::string>& id_nums, const CGrantList& grant_list);
121 
122 
123 template <class CharT>
124 inline auto get_ctype_facet() -> decltype(std::use_facet<std::ctype<CharT>>(std::locale()))
125 {
126  static const std::locale s_Locale("C");
127  static const auto& s_CType = std::use_facet<std::ctype<CharT>>(s_Locale);
128  return s_CType;
129 }
130 
131 
132 template <class CharT>
133 inline auto get_ctype_facet(const std::locale& loc) -> decltype(std::use_facet<std::ctype<CharT>>(std::locale()))
134 {
135  static const auto& s_CType = std::use_facet<std::ctype<CharT>>(loc);
136  return s_CType;
137 }
138 
139 template<class TE>
140 std::string s_TextToString(const TE& text_item)
141 {
142  if (text_item.Is_CharData()) {
143  return text_item.Get_CharData();
144  } else if (text_item.IsText()) {
145  if (text_item.GetText().IsB()) {
146  return s_TextListToString(text_item.GetText().GetB().Get());
147  } else if (text_item.GetText().IsI()) {
148  return s_TextListToString(text_item.GetText().GetI().Get());
149  } else if (text_item.GetText().IsSup()) {
150  return s_TextListToString(text_item.GetText().GetSup().Get());
151  } else if (text_item.GetText().IsSub()) {
152  return s_TextListToString(text_item.GetText().GetSub().Get());
153  } else if (text_item.GetText().IsU()) {
154  return s_TextListToString(text_item.GetText().GetU().Get());
155  }
156  }
157  std::string ret;
158  for (ncbi::CStdTypeConstIterator<std::string> j(Begin(text_item)); j; ++j) {
159  ret.append(*j);
160  }
161  return ret;
162 }
163 
164 template<class TE>
165 std::string s_TextListToString(const std::list<ncbi::CRef<TE>>& text_list)
166 {
167  std::string ret;
168  for (const auto& it : text_list) {
169  ret.append(s_TextToString(*it));
170  }
171  return ret;
172 }
173 
174 
175 template<class D> ncbi::CRef<ncbi::objects::CTitle> s_GetTitle(const D& doc)
176 {
177  std::string title_str;
178  if (doc.IsSetArticleTitle()) title_str = s_GetArticleTitleStr(doc.GetArticleTitle());
179  std::string vernacular_title_str;
180  if (doc.IsSetVernacularTitle()) {
181  vernacular_title_str = s_GetVernacularTitleStr(doc.GetVernacularTitle());
182  }
183  return s_MakeTitle(title_str, vernacular_title_str);
184 }
185 
186 
187 END_eutils_SCOPE // namespace eutils::
188 
189 
190 #endif // eutils__OBJTOOLS_EUTILS_EFETCH_PUBMEDARTICLE_HPP
191 /* Original file checksum: lines: 82, chars: 2477, CRC32: 26408000 */
#define BEGIN_eutils_SCOPE
Definition: Abstract_.hpp:51
#define END_eutils_SCOPE
Definition: Abstract_.hpp:52
ncbi::CRef< ncbi::objects::CArticleIdSet > s_GetArticleIdSet(const CArticleIdList &article_id_list, const CArticle *article)
BEGIN_NAMESPACE(objects)
void s_FillGrants(std::list< std::string > &id_nums, const CGrantList &grant_list)
std::string s_GetPagination(const CPagination &pagination)
std::string s_GetVernacularTitleStr(const CVernacularTitle &vernacular_title)
ncbi::CRef< ncbi::objects::CTitle > s_MakeTitle(const std::string &title_str, const std::string &vernacular_title_str)
ncbi::CRef< ncbi::objects::CDate > s_GetDateFromPubDate(const CPubDate &pub_date)
ncbi::CRef< ncbi::objects::CDate > s_GetDateFromPubMedPubDate(const CPubMedPubDate &pdate)
std::string s_TextListToString(const std::list< ncbi::CRef< TE >> &text_list)
std::string s_TextToString(const TE &text_item)
auto get_ctype_facet() -> decltype(std::use_facet< std::ctype< CharT >>(std::locale()))
ncbi::CRef< ncbi::objects::CTitle > s_GetTitle(const D &doc)
std::string s_CleanupText(std::string str)
std::string s_GetAuthorMedlineName(const CAuthor &author)
END_NAMESPACE(objects)
BEGIN_NCBI_NAMESPACE
std::string s_GetArticleTitleStr(const CArticleTitle &article_title)
Data storage class.
CArticleIdList –.
CArticleIdSet –.
CArticleTitle –.
CArticle –.
Definition: Article.hpp:64
CAuthor –.
Definition: Author.hpp:59
Definition: Date.hpp:53
CGrantList –.
Definition: GrantList.hpp:64
CPagination –.
Definition: Pagination.hpp:64
CPubDate –.
Definition: PubDate.hpp:64
CPubMedPubDate –.
============= Document-level elements ============================
ncbi::CRef< ncbi::objects::CPubmed_entry > ToPubmed_entry(void) const
CPubmedArticle & operator=(const CPubmedArticle &value)
CPubmedArticle(const CPubmedArticle &value)
CPubmedArticle_Base Tparent
CPubmed_entry –.
CText –.
Definition: Text.hpp:64
Definition: Title.hpp:51
CVernacularTitle –.
char value[7]
Definition: config.c:431
string
Definition: cgiapp.hpp:687
CBeginInfo Begin(C &obj)
Get starting point of object hierarchy.
Definition: iterator.hpp:1004
Magic spell ;-) needed for some weird compilers... very empiric.
static char * locale
Definition: pcregrep.c:149
static const char * str(char *buf, int n)
Definition: stats.c:84
Modified on Sat Dec 09 04:48:32 2023 by modify_doxy.py rev. 669887