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

Go to the SVN repository for this file.

1 #ifndef ESEARCH__HPP
2 #define ESEARCH__HPP
3 
4 /* $Id: esearch.hpp 65828 2015-01-05 18:47:52Z grichenk $
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 * Author: Aleksey Grichenko
30 *
31 * File Description:
32 * ESearch request
33 *
34 */
35 
36 #include <corelib/ncbistd.hpp>
37 #include <corelib/ncbitime.hpp>
40 
42 
43 
44 /** @addtogroup EUtils
45  *
46  * @{
47  */
48 
49 
50 /////////////////////////////////////////////////////////////////////////////
51 ///
52 /// CESearch_Request
53 ///
54 /// Searches and retrieves primary ids and term translations.
55 ///
56 
57 
59 {
60 public:
61  /// Create ESearch request for the given database.
63  virtual ~CESearch_Request(void);
64 
65  /// Get CGI script query string.
66  virtual string GetQueryString(void) const;
67 
68  /// Get serial stream format for reading data.
69  virtual ESerialDataFormat GetSerialDataFormat(void) const;
70 
71  /// Get search results. If WebEnv and query_key values are
72  /// persent in the results, they are stored in the context.
73  CRef<esearch::CESearchResult> GetESearchResult(void);
74 
75  /// History update flag, on by default. If set, WebEnv and query_key
76  /// are updated to include the results in the history.
77  bool GetUseHistory(void) const { return m_UseHistory; }
78  void SetUseHistory(bool value) { Disconnect(); m_UseHistory = value; }
79 
80  /// Search term.
81  const string& GetTerm(void) const { return m_Term; }
82  void SetTerm(const string& term) { Disconnect(); m_Term = term; }
83 
84  /// Search field.
85  const string& GetField(void) const { return m_Field; }
86  void SetField(const string& field) { Disconnect(); m_Field = field; }
87 
88  /// Relative date to start search with, in days.
89  /// 0 = not set
90  int GetRelDate(void) const { return m_RelDate; }
91  void SetRelDate(int days) { Disconnect(); m_RelDate = days; }
92 
93  /// Min date. Both min and max date must be set.
94  const CTime& GetMinDate(void) const { return m_MinDate; }
95  void SetMinDate(const CTime& date) { Disconnect(); m_MinDate = date; }
96 
97  /// Max date. Both min and max date must be set.
98  const CTime& GetMaxDate(void) const { return m_MaxDate; }
99  void SetMaxDate(const CTime& date) { Disconnect(); m_MaxDate = date; }
100 
101  /// Limit dates to a specific date field (e.g. edat, mdat).
102  const string& GetDateType(void) const { return m_DateType; }
103  void SetDateType(const string& type) { Disconnect(); m_DateType = type; }
104 
105  /// Sequential number of the first id retrieved. Default is 0 which
106  /// will retrieve the first record.
107  int GetRetStart(void) const { return m_RetStart; }
108  void SetRetStart(int retstart) { Disconnect(); m_RetStart = retstart; }
109 
110  /// Number of items retrieved.
111  int GetRetMax(void) const { return m_RetMax; }
112  void SetRetMax(int retmax) { Disconnect(); m_RetMax = retmax; }
113 
114  /// Output data types.
115  enum ERetType {
118  eRetType_uilist
119  };
120  /// Output data type.
121  ERetType GetRetType(void) const { return m_RetType; }
122  void SetRetType(ERetType rettype) { Disconnect(); m_RetType = rettype; }
123 
124  /// Sort orders.
125  /// @deprecated Use string sort orders instead.
126  enum ESort {
127  eSort_none, // no sorting or sort order set by string
128  eSort_author, // author
129  eSort_last_author, // last+author
130  eSort_journal, // journal
131  eSort_pub_date, // pub+date
132  };
133  /// Get sort order. @deprecated Use GetSortOrderName().
134  NCBI_DEPRECATED ESort GetSort(void) const { return m_Sort; }
135  /// Set sort order. @deprecated Use SetSortOrderName().
136  NCBI_DEPRECATED void SetSort(ESort order);
137 
138  /// Get sort order. Empty string indicates no sorting (or the default one).
139  const string& GetSortOrderName(void) const { return m_SortName; }
140  /// Set sort order. Empty string indicates no sorting (or the default one).
141  void SetSortOrderName(CTempString name);
142 
143 private:
145 
146  const char* x_GetRetTypeName(void) const;
147 
149  string m_Term;
150  string m_Field;
154  string m_DateType; // ???
156  int m_RetMax;
159  string m_SortName;
160 };
161 
162 
163 /* @} */
164 
165 
167 
168 #endif // ESEARCH__HPP
User-defined methods of the data storage class.
CESearch_Request.
Definition: esearch.hpp:59
CEUtils_Request.
Definition: eutils.hpp:119
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
CTime –.
Definition: ncbitime.hpp:296
Include a standard set of the NCBI C++ Toolkit most basic headers.
CS_CONTEXT * ctx
Definition: t0006.c:12
static int type
Definition: getdata.c:31
string m_SortName
Definition: esearch.hpp:159
void SetMinDate(const CTime &date)
Definition: esearch.hpp:95
const string & GetField(void) const
Search field.
Definition: esearch.hpp:85
CEUtils_Request TParent
Definition: esearch.hpp:144
ERetType
Output data types.
Definition: esearch.hpp:115
virtual string GetQueryString(void) const
Get CGI script query string.
Definition: eutils.cpp:199
int GetRetStart(void) const
Sequential number of the first id retrieved.
Definition: esearch.hpp:107
const CTime & GetMaxDate(void) const
Max date. Both min and max date must be set.
Definition: esearch.hpp:98
void SetDateType(const string &type)
Definition: esearch.hpp:103
void SetMaxDate(const CTime &date)
Definition: esearch.hpp:99
const string & GetTerm(void) const
Search term.
Definition: esearch.hpp:81
void SetRetStart(int retstart)
Definition: esearch.hpp:108
const string & GetDateType(void) const
Limit dates to a specific date field (e.g. edat, mdat).
Definition: esearch.hpp:102
void SetTerm(const string &term)
Definition: esearch.hpp:82
int GetRetMax(void) const
Number of items retrieved.
Definition: esearch.hpp:111
virtual ESerialDataFormat GetSerialDataFormat(void) const
Get serial stream format for reading data.
Definition: eutils.hpp:134
int GetRelDate(void) const
Relative date to start search with, in days.
Definition: esearch.hpp:90
void SetRelDate(int days)
Definition: esearch.hpp:91
const string & GetSortOrderName(void) const
Get sort order. Empty string indicates no sorting (or the default one).
Definition: esearch.hpp:139
ERetType GetRetType(void) const
Output data type.
Definition: esearch.hpp:121
bool GetUseHistory(void) const
History update flag, on by default.
Definition: esearch.hpp:77
void SetRetType(ERetType rettype)
Definition: esearch.hpp:122
ESort
Sort orders.
Definition: esearch.hpp:126
void SetUseHistory(bool value)
Definition: esearch.hpp:78
const CTime & GetMinDate(void) const
Min date. Both min and max date must be set.
Definition: esearch.hpp:94
void SetRetMax(int retmax)
Definition: esearch.hpp:112
void SetField(const string &field)
Definition: esearch.hpp:86
void Disconnect(void)
Close connection, destroy the stream.
Definition: eutils.hpp:149
ERetType m_RetType
Definition: esearch.hpp:157
ESort GetSort(void) const
Get sort order.
Definition: esearch.hpp:134
string m_DateType
Definition: esearch.hpp:154
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
#define NCBI_DEPRECATED
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_EUTILS_EXPORT
Definition: ncbi_export.h:1460
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Defines: CTimeFormat - storage class for time format.
Definition: type.c:6
Modified on Mon Jul 15 05:33:33 2024 by modify_doxy.py rev. 669887