1 #ifndef OBJECTS_PUB___PUB_MACROS__HPP
2 #define OBJECTS_PUB___PUB_MACROS__HPP
3 
4 /*  $Id: pub_macros.hpp 394538 2013-04-03 19:01:36Z ucko $
5  * ===========================================================================
6  *
7  *                            PUBLIC DOMAIN NOTICE
8  *               National Center for Biotechnology Information
9  *
10  *  This software/database is a "United States Government Work" under the
11  *  terms of the United States Copyright Act.  It was written as part of
12  *  the author's official duties as a United States Government employee and
13  *  thus cannot be copyrighted.  This software/database is freely available
14  *  to the public for use. The National Library of Medicine and the U.S.
15  *  Government have not placed any restriction on its use or reproduction.
16  *
17  *  Although all reasonable efforts have been taken to ensure the accuracy
18  *  and reliability of the software and data, the NLM and the U.S.
19  *  Government do not and cannot warrant the performance or results that
20  *  may be obtained by using this software or data. The NLM and the U.S.
21  *  Government disclaim all warranties, express or implied, including
22  *  warranties of performance, merchantability or fitness for any particular
23  *  purpose.
24  *
25  *  Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors:  Jonathan Kans, Michael Kornbluh, Colleen Bollin
30  *
31  */
32 
33 /// @file pub_macros.hpp
34 /// Utility macros and typedefs for exploring NCBI objects from pub.asn.
35 
36 
37 #include <objects/misc/sequence_util_macros.hpp>
38 #include <objects/pub/pub__.hpp>
39 
40 
41 /// @NAME Convenience macros for NCBI objects
42 /// @{
43 
44 
45 BEGIN_NCBI_SCOPE
46 BEGIN_SCOPE(objects)
47 
48 /////////////////////////////////////////////////////////////////////////////
49 /// Macros and typedefs for object subtypes
50 /////////////////////////////////////////////////////////////////////////////
51 
52 
53 /// CPub definitions
54 
55 #define NCBI_PUB(Type) CPub::e_##Type
56 typedef CPub::E_Choice TPUB_CHOICE;
57 
58 //   Gen         Sub       Medline     Muid       Article
59 //   Journal     Book      Proc        Patent     Pat_id
60 //   Man         Equiv     Pmid
61 
62 
63 // "FOR_EACH_XXX_ON_YYY" does a linear const traversal of STL containers
64 // "EDIT_EACH_XXX_ON_YYY" does a linear non-const traversal of STL containers
65 
66 // "SWITCH_ON_XXX_CHOICE" switches on the item subtype
67 
68 // "ADD_XXX_TO_YYY" adds an element to a specified object
69 // "ERASE_XXX_ON_YYY" deletes a specified object within an iterator
70 
71 // Miscellaneous macros for testing objects include
72 // "XXX_IS_YYY" or "XXX_HAS_YYY"
73 // "XXX_CHOICE_IS"
74 
75 
76 ///
77 /// CPubequiv macros
78 
79 /// PUB_ON_PUBEQUIV macros
80 
81 #define PUB_ON_PUBEQUIV_Type      CPub_equiv::Tdata
82 #define PUB_ON_PUBEQUIV_Test(Var) (Var).IsSet()
83 #define PUB_ON_PUBEQUIV_Get(Var)  (Var).Get()
84 #define PUB_ON_PUBEQUIV_Set(Var)  (Var).Set()
85 
86 #define FOR_EACH_PUB_ON_PUBEQUIV(Itr, Var) \
87 FOR_EACH (PUB_ON_PUBEQUIV, Itr, Var)
88 
89 #define EDIT_EACH_PUB_ON_PUBEQUIV(Itr, Var) \
90 EDIT_EACH (PUB_ON_PUBEQUIV, Itr, Var)
91 
92 /// ADD_PUB_TO_PUBEQUIV
93 
94 #define ADD_PUB_TO_PUBEQUIV(Var, Ref) \
95 ADD_ITEM (PUB_ON_PUBEQUIV, Var, Ref)
96 
97 /// ERASE_PUB_ON_PUBEQUIV
98 
99 #define ERASE_PUB_ON_PUBEQUIV(Itr, Var) \
100 LIST_ERASE_ITEM (PUB_ON_PUBEQUIV, Itr, Var)
101 
102 
103 ///
104 /// CPubdesc macros
105 
106 /// PUB_ON_PUBDESC macros
107 
108 #define PUB_ON_PUBDESC_Type      CPub_equiv::Tdata
109 #define PUB_ON_PUBDESC_Test(Var) (Var).IsSetPub() && (Var).GetPub().IsSet()
110 #define PUB_ON_PUBDESC_Get(Var)  (Var).GetPub().Get()
111 #define PUB_ON_PUBDESC_Set(Var)  (Var).SetPub().Set()
112 
113 /// PUBDESC_HAS_PUB
114 
115 #define PUBDESC_HAS_PUB(Var) \
116 ITEM_HAS (PUB_ON_PUBDESC, Var)
117 
118 /*
119 #define PUBDESC_HAS_PUB(Pbd) \
120 ((Pbd).IsSetPub())
121 */
122 
123 /// FOR_EACH_PUB_ON_PUBDESC
124 /// EDIT_EACH_PUB_ON_PUBDESC
125 // CPubdesc& as input, dereference with [const] CPub& pub = **itr;
126 
127 #define FOR_EACH_PUB_ON_PUBDESC(Itr, Var) \
128 FOR_EACH (PUB_ON_PUBDESC, Itr, Var)
129 
130 #define EDIT_EACH_PUB_ON_PUBDESC(Itr, Var) \
131 EDIT_EACH (PUB_ON_PUBDESC, Itr, Var)
132 
133 /// ADD_PUB_TO_PUBDESC
134 
135 #define ADD_PUB_TO_PUBDESC(Var, Ref) \
136 ADD_ITEM (PUB_ON_PUBDESC, Var, Ref)
137 
138 /// ERASE_PUB_ON_PUBDESC
139 
140 #define ERASE_PUB_ON_PUBDESC(Itr, Var) \
141 LIST_ERASE_ITEM (PUB_ON_PUBDESC, Itr, Var)
142 
143 
144 ///
145 /// CPub macros
146 
147 /// AUTHOR_ON_PUB macros
148 
149 #define AUTHOR_ON_PUB_Type      CAuth_list::C_Names::TStd
150 #define AUTHOR_ON_PUB_Test(Var) (Var).IsSetAuthors() && \
151                                     (Var).GetAuthors().IsSetNames() && \
152                                     (Var).GetAuthors().GetNames().IsStd()
153 #define AUTHOR_ON_PUB_Get(Var)  (Var).GetAuthors().GetNames().GetStd()
154 #define AUTHOR_ON_PUB_Set(Var)  (Var).SetAuthors().SetNames().SetStd()
155 
156 /// PUB_HAS_AUTHOR
157 
158 #define PUB_HAS_AUTHOR(Var) \
159 ITEM_HAS (AUTHOR_ON_PUB, Var)
160 
161 /// FOR_EACH_AUTHOR_ON_PUB
162 /// EDIT_EACH_AUTHOR_ON_PUB
163 // CPub& as input, dereference with [const] CAuthor& auth = **itr;
164 
165 #define FOR_EACH_AUTHOR_ON_PUB(Itr, Var) \
166 FOR_EACH (AUTHOR_ON_PUB, Itr, Var)
167 
168 #define EDIT_EACH_AUTHOR_ON_PUB(Itr, Var) \
169 EDIT_EACH (AUTHOR_ON_PUB, Itr, Var)
170 
171 /// ADD_AUTHOR_TO_PUB
172 
173 #define ADD_AUTHOR_TO_PUB(Var, Ref) \
174 ADD_ITEM (AUTHOR_ON_PUB, Var, Ref)
175 
176 /// ERASE_AUTHOR_ON_PUB
177 
178 #define ERASE_AUTHOR_ON_PUB(Itr, Var) \
179 LIST_ERASE_ITEM (AUTHOR_ON_PUB, Itr, Var)
180 
181 
182 END_SCOPE(objects)
183 END_NCBI_SCOPE
184 
185 
186 /* @} */
187 
188 #endif  /* OBJECTS_PUB___PUB_MACROS__HPP */
189