1 /* @include ajquerydata ******************************************************* 2 ** 3 ** AJAX Query data structures 4 ** 5 ** @author Copyright (C) 2011 Peter Rice 6 ** @version $Revision: 1.22 $ 7 ** @modified Jul 15 pmr First version with code from all datatypes merged 8 ** @modified $Date: 2012/09/03 14:26:04 $ by $Author: rice $ 9 ** @@ 10 ** 11 ** This library is free software; you can redistribute it and/or 12 ** modify it under the terms of the GNU Lesser General Public 13 ** License as published by the Free Software Foundation; either 14 ** version 2.1 of the License, or (at your option) any later version. 15 ** 16 ** This library is distributed in the hope that it will be useful, 17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 ** Lesser General Public License for more details. 20 ** 21 ** You should have received a copy of the GNU Lesser General Public 22 ** License along with this library; if not, write to the Free Software 23 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 24 ** MA 02110-1301, USA. 25 ** 26 ******************************************************************************/ 27 28 #ifndef AJQUERYDATA_H 29 #define AJQUERYDATA_H 30 31 /* ========================================================================= */ 32 /* ============================= include files ============================= */ 33 /* ========================================================================= */ 34 35 #include "ajdefine.h" 36 #include "ajlist.h" 37 #include "ajtable.h" 38 39 AJ_BEGIN_DECLS 40 41 42 43 44 /* ========================================================================= */ 45 /* =============================== constants =============================== */ 46 /* ========================================================================= */ 47 48 49 50 51 #define NULLFPOS -1 52 53 54 55 56 /* ========================================================================= */ 57 /* ============================== public data ============================== */ 58 /* ========================================================================= */ 59 60 61 62 63 /* @enum AjEQryType *********************************************************** 64 ** 65 ** Query type or scope (one, some or all entries) 66 ** 67 ** @value AJQUERY_UNKNOWN Unknown 68 ** @value AJQUERY_ENTRY Single entry 69 ** @value AJQUERY_QUERY Query for one or more entries 70 ** @value AJQUERY_ALL All entries 71 ******************************************************************************/ 72 73 typedef enum AjOQryType 74 { 75 AJQUERY_UNKNOWN, AJQUERY_ENTRY, 76 AJQUERY_QUERY, AJQUERY_ALL 77 } AjEQryType; 78 79 80 81 82 /* @enum AjEQryLink *********************************************************** 83 ** 84 ** Query link operators 85 ** 86 ** @value AJQLINK_INIT Initial query 87 ** @value AJQLINK_OR Current OR next 88 ** @value AJQLINK_AND Current AND next 89 ** @value AJQLINK_EOR Current EOR next 90 ** @value AJQLINK_NOT Current but NOT next 91 ** @value AJQLINK_ELSE Current if it exists, else next 92 ** @value AJQLINK_MAX Above last defined value 93 ******************************************************************************/ 94 95 typedef enum AjOQryLink 96 { 97 AJQLINK_INIT, 98 AJQLINK_OR, 99 AJQLINK_AND, 100 AJQLINK_EOR, 101 AJQLINK_NOT, 102 AJQLINK_ELSE, 103 AJQLINK_MAX 104 } AjEQryLink; 105 106 107 108 109 /* @enum AjEDataType ********************************************************** 110 ** 111 ** AJAX data type 112 ** 113 ** @value AJDATATYPE_UNKNOWN Undefined type 114 ** @value AJDATATYPE_SEQUENCE Sequence data 115 ** @value AJDATATYPE_FEATURES Feature data 116 ** @value AJDATATYPE_ASSEMBLY Assembly data 117 ** @value AJDATATYPE_OBO OBO ontology term data 118 ** @value AJDATATYPE_REFSEQ Reference sequence data 119 ** @value AJDATATYPE_RESOURCE Data resource data 120 ** @value AJDATATYPE_TAXON Taxonomy data 121 ** @value AJDATATYPE_TEXT Text data 122 ** @value AJDATATYPE_URL URL data 123 ** @value AJDATATYPE_VARIATION Variation data 124 ** @value AJDATATYPE_XML XML data 125 ** @value AJDATATYPE_MAX Above last defined value 126 ******************************************************************************/ 127 128 typedef enum AjODataType 129 { 130 AJDATATYPE_UNKNOWN, 131 AJDATATYPE_SEQUENCE, 132 AJDATATYPE_FEATURES, 133 AJDATATYPE_ASSEMBLY, 134 AJDATATYPE_OBO, 135 AJDATATYPE_REFSEQ, 136 AJDATATYPE_RESOURCE, 137 AJDATATYPE_TAXON, 138 AJDATATYPE_TEXT, 139 AJDATATYPE_URL, 140 AJDATATYPE_VARIATION, 141 AJDATATYPE_XML, 142 AJDATATYPE_MAX 143 } AjEDataType; 144 145 146 147 148 /* @data AjPQueryField ******************************************************** 149 ** 150 ** Ajax Query Field object. 151 ** 152 ** Holds data needed for a specific field query 153 ** This must refer to an field name (id, acc or any other queriable field) 154 ** and the query string including wildcards specified by the user 155 ** 156 ** @alias AjSQueryField 157 ** @alias AjOQueryField 158 ** 159 ** @attr Field [AjPStr] Field name 160 ** @attr Wildquery [AjPStr] Query Wildcard 161 ** @attr Link [AjEQryLink] Link to previous queries 162 ** @attr Padding [ajuint] Padding to alignment boundary 163 ******************************************************************************/ 164 165 typedef struct AjSQueryField 166 { 167 AjPStr Field; 168 AjPStr Wildquery; 169 AjEQryLink Link; 170 ajuint Padding; 171 } AjOQueryField; 172 173 #define AjPQueryField AjOQueryField* 174 175 176 177 178 /* @data AjPQuery ************************************************************* 179 ** 180 ** Ajax Query object. 181 ** 182 ** Holds data needed to interpret an entry specification 183 ** This can refer to an entry name (or "id"), and accession number or 184 ** other queriable items. 185 ** 186 ** AjPQuery is created with the entry specification part of a USA 187 ** (Uniform Sequence Address) or euivalent for other data types. 188 ** The syntax is currently related to that 189 ** used by SRS release 5.1. 190 ** 191 ** @alias AjSQuery 192 ** @alias AjOQuery 193 ** 194 ** @attr SvrName [AjPStr] Server name used by EMBOSS 195 ** @attr DbName [AjPStr] Database name used by EMBOSS 196 ** @attr DbAlias [AjPStr] Database name used by access method 197 ** @attr DbType [AjPStr] Database type 198 ** @attr QueryFields [AjPList] Query field list 199 ** @attr ResultsList [AjPList] Query results list 200 ** @attr ResultsTable [AjPTable] Query results table 201 ** @attr Method [AjPStr] Name of access method 202 ** @attr Qlinks [AjPStr] Supported query link operators 203 ** @attr Formatstr [AjPStr] Name of input format for parser 204 ** @attr IndexDir [AjPStr] Index directory 205 ** @attr Directory [AjPStr] Data directory 206 ** @attr Filename [AjPStr] Individual filename 207 ** @attr Exclude [AjPStr] File wildcards to exclude (spaced) 208 ** @attr Namespace [AjPStr] Ontology namespace query to include 209 ** @attr Organisms [AjPStr] Organism/taxonomy query to include 210 ** @attr DbFields [AjPStr] Query fields (plus id and acc) 211 ** @attr DbFilter [AjPStr] Database filter (query) fields 212 ** @attr DbReturn [AjPStr] Database attribute (returned data) fields 213 ** @attr DbIdentifier [AjPStr] Database primary identifier field 214 ** @attr DbAccession [AjPStr] Database secondary identifier field 215 ** @attr DbUrl [AjPStr] Query URL 216 ** @attr DbProxy [AjPStr] Proxy host 217 ** @attr DbHttpVer [AjPStr] HTTP version 218 ** @attr ServerVer [AjPStr] Server version 219 ** @attr SingleField [AjPStr] Query single field from end of query string 220 ** @attr QryString [AjPStr] Query term 221 ** @attr QryFields [AjPStr] Query fields or ID list 222 ** @attr Application [AjPStr] External application command 223 ** @attr Fpos [ajlong] File position from fseek 224 ** @attr TextAccess [void*] Text access function : see ajtextdb.h 225 ** @attr Access [void*] Datatype-specific access function : see ajseqdb.h 226 ** ajobodb.h and others 227 ** @attr QryData [void*] Private data for access function 228 ** @attr QueryType [AjEQryType] Enumerated query type 229 ** @attr DataType [AjEDataType] Enumerated datatype general scope 230 ** @attr QryDone [AjBool] Has the query been done yet 231 ** @attr SetServer [AjBool] True if server data has been set 232 ** @attr SetDatabase [AjBool] True if database data has been set 233 ** @attr SetQuery [AjBool] True if query data has been set 234 ** @attr InDrcat [AjBool] True if database is defined in DRCAT 235 ** @attr Wild [AjBool] True if query contains '*' or '?' 236 ** @attr CaseId [AjBool] True if ID match is case-sensitive 237 ** @attr HasAcc [AjBool] True if entries have acc field 238 ** @attr CountEntries [ajuint] Number of entries processed 239 ** @attr TotalEntries [ajuint] Number of entries found 240 ** @@ 241 ******************************************************************************/ 242 243 typedef struct AjSQuery 244 { 245 AjPStr SvrName; 246 AjPStr DbName; 247 AjPStr DbAlias; 248 AjPStr DbType; 249 AjPList QueryFields; 250 AjPList ResultsList; 251 AjPTable ResultsTable; 252 AjPStr Method; 253 AjPStr Qlinks; 254 AjPStr Formatstr; 255 AjPStr IndexDir; 256 AjPStr Directory; 257 AjPStr Filename; 258 AjPStr Exclude; 259 AjPStr Namespace; 260 AjPStr Organisms; 261 AjPStr DbFields; 262 AjPStr DbFilter; 263 AjPStr DbReturn; 264 AjPStr DbIdentifier; 265 AjPStr DbAccession; 266 AjPStr DbUrl; 267 AjPStr DbProxy; 268 AjPStr DbHttpVer; 269 AjPStr ServerVer; 270 AjPStr SingleField; 271 AjPStr QryString; 272 AjPStr QryFields; 273 AjPStr Application; 274 ajlong Fpos; 275 void* TextAccess; 276 void* Access; 277 void* QryData; 278 AjEQryType QueryType; 279 AjEDataType DataType; 280 AjBool QryDone; 281 AjBool SetServer; 282 AjBool SetDatabase; 283 AjBool SetQuery; 284 AjBool InDrcat; 285 AjBool Wild; 286 AjBool CaseId; 287 AjBool HasAcc; 288 ajuint CountEntries; 289 ajuint TotalEntries; 290 } AjOQuery; 291 292 #define AjPQuery AjOQuery* 293 294 295 296 297 /* @data AjPQueryList ********************************************************* 298 ** 299 ** Query processing list of queries from a list file. 300 ** 301 ** Includes data from the original query (@listfile) 302 ** 303 ** @alias AjSQueryList 304 ** @alias AjOQueryList 305 ** 306 ** @attr Qry [AjPStr] Current query 307 ** @attr Formatstr [AjPStr] Format name from original query 308 ** @attr QryFields [AjPStr] Query fields or ID list 309 ** @attr Fpos [ajlong] File position 310 ** @attr Format [ajuint] Format enumeration 311 ** @attr Padding [char[4]] Padding to alignment boundary 312 ** @@ 313 ******************************************************************************/ 314 315 typedef struct AjSQueryList 316 { 317 AjPStr Qry; 318 AjPStr Formatstr; 319 AjPStr QryFields; 320 ajlong Fpos; 321 ajuint Format; 322 char Padding[4]; 323 } AjOQueryList; 324 325 #define AjPQueryList AjOQueryList* 326 327 328 329 330 /* @enum AjEQueryFmtcode ****************************************************** 331 ** 332 ** Format code. 333 ** 334 ** @value FMT_OK OK 335 ** @value FMT_NOMATCH No match 336 ** @value FMT_BADTYPE Bad datatype 337 ** @value FMT_FAIL Failed 338 ** @value FMT_EOF End of file reached 339 ** @value FMT_EMPTY Data object empty 340 ******************************************************************************/ 341 342 typedef enum AjOQueryFmtcode 343 { 344 FMT_OK, 345 FMT_NOMATCH, 346 FMT_BADTYPE, 347 FMT_FAIL, 348 FMT_EOF, 349 FMT_EMPTY 350 } AjEQueryFmtcode; 351 352 353 354 355 /* ========================================================================= */ 356 /* =========================== public functions ============================ */ 357 /* ========================================================================= */ 358 359 360 361 362 /* 363 ** Prototype definitions 364 */ 365 366 /* 367 ** End of prototype definitions 368 */ 369 370 371 372 373 AJ_END_DECLS 374 375 #endif /* !AJQUERYDATA_H */ 376