1 #ifndef OBJECTS_GENERAL___GENERAL_MACROS__HPP 2 #define OBJECTS_GENERAL___GENERAL_MACROS__HPP 3 4 /* $Id: general_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 general_macros.hpp 34 /// Utility macros and typedefs for exploring NCBI objects from general.asn. 35 36 37 #include <objects/misc/sequence_util_macros.hpp> 38 #include <objects/general/general__.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 /// CUser_field definitions 54 55 #define NCBI_USERFIELD(Type) CUser_field::TData::e_##Type 56 typedef CUser_field::C_Data::E_Choice TUSERFIELD_CHOICE; 57 58 // Str Int Real Bool Os 59 // Object Strs Ints Reals Oss 60 // Fields Objects 61 62 63 /// CPerson_id definitions 64 65 #define NCBI_PERSONID(Type) CPerson_id::e_##Type 66 typedef CPerson_id::E_Choice TPERSONID_TYPE; 67 68 // Dbtag Name Ml Str Consortium 69 70 71 72 // "FOR_EACH_XXX_ON_YYY" does a linear const traversal of STL containers 73 // "EDIT_EACH_XXX_ON_YYY" does a linear non-const traversal of STL containers 74 75 // "SWITCH_ON_XXX_CHOICE" switches on the item subtype 76 77 // "ADD_XXX_TO_YYY" adds an element to a specified object 78 // "ERASE_XXX_ON_YYY" deletes a specified object within an iterator 79 80 // Miscellaneous macros for testing objects include 81 // "XXX_IS_YYY" or "XXX_HAS_YYY" 82 // "XXX_CHOICE_IS" 83 84 /// 85 /// CUser_object macros 86 87 /// USERFIELD_ON_USEROBJECT macros 88 89 #define USERFIELD_ON_USEROBJECT_Type CUser_object::TData 90 #define USERFIELD_ON_USEROBJECT_Test(Var) (Var).IsSetData() 91 #define USERFIELD_ON_USEROBJECT_Get(Var) (Var).GetData() 92 #define USERFIELD_ON_USEROBJECT_Set(Var) (Var).SetData() 93 94 /// USEROBJECT_HAS_USERFIELD 95 96 #define USEROBJECT_HAS_USERFIELD(Var) \ 97 ITEM_HAS (USERFIELD_ON_USEROBJECT, Var) 98 99 /// FOR_EACH_USERFIELD_ON_USEROBJECT 100 /// EDIT_EACH_USERFIELD_ON_USEROBJECT 101 // CUser_object& as input, dereference with [const] CUser_field& fld = **itr; 102 103 #define FOR_EACH_USERFIELD_ON_USEROBJECT(Itr, Var) \ 104 FOR_EACH (USERFIELD_ON_USEROBJECT, Itr, Var) 105 106 #define EDIT_EACH_USERFIELD_ON_USEROBJECT(Itr, Var) \ 107 EDIT_EACH (USERFIELD_ON_USEROBJECT, Itr, Var) 108 109 /// ADD_USERFIELD_TO_USEROBJECT 110 111 #define ADD_USERFIELD_TO_USEROBJECT(Var, Ref) \ 112 ADD_ITEM (USERFIELD_ON_USEROBJECT, Var, Ref) 113 114 /// ERASE_USERFIELD_ON_USEROBJECT 115 116 #define ERASE_USERFIELD_ON_USEROBJECT(Itr, Var) \ 117 VECTOR_ERASE_ITEM (USERFIELD_ON_USEROBJECT, Itr, Var) 118 119 #define USERFIELD_ON_USEROBJECT_IS_SORTED(Var, Func) \ 120 IS_SORTED (USERFIELD_ON_USEROBJECT, Var, Func) 121 122 #define SORT_USERFIELD_ON_USEROBJECT(Var, Func) \ 123 DO_VECTOR_SORT (USERFIELD_ON_USEROBJECT, Var, Func) 124 125 /// 126 /// CUser_field macros 127 128 /// USERFIELD_CHOICE macros 129 130 #define USERFIELD_CHOICE_Test(Var) (Var).IsSetData() && Var.GetData().Which() != CUser_field::TData::e_not_set 131 #define USERFIELD_CHOICE_Chs(Var) (Var).GetData().Which() 132 133 /// USERFIELD_CHOICE_IS 134 135 #define USERFIELD_CHOICE_IS(Var, Chs) \ 136 CHOICE_IS (USERFIELD_CHOICE, Var, Chs) 137 138 /// SWITCH_ON_USERFIELD_CHOICE 139 140 #define SWITCH_ON_USERFIELD_CHOICE(Var) \ 141 SWITCH_ON (USERFIELD_CHOICE, Var) 142 143 144 END_SCOPE(objects) 145 END_NCBI_SCOPE 146 147 148 /* @} */ 149 150 #endif /* OBJECTS_GENERAL___GENERAL_MACROS__HPP */ 151