NCBI C++ ToolKit
reader_pubseq2.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: reader_pubseq2.cpp 101122 2023-11-01 22:41:46Z vasilche $
2 * ===========================================================================
3 * PUBLIC DOMAIN NOTICE
4 * National Center for Biotechnology Information
5 *
6 * This software/database is a "United States Government Work" under the
7 * terms of the United States Copyright Act. It was written as part of
8 * the author's official duties as a United States Government employee and
9 * thus cannot be copyrighted. This software/database is freely available
10 * to the public for use. The National Library of Medicine and the U.S.
11 * Government have not placed any restriction on its use or reproduction.
12 *
13 * Although all reasonable efforts have been taken to ensure the accuracy
14 * and reliability of the software and data, the NLM and the U.S.
15 * Government do not and cannot warrant the performance or results that
16 * may be obtained by using this software or data. The NLM and the U.S.
17 * Government disclaim all warranties, express or implied, including
18 * warranties of performance, merchantability or fitness for any particular
19 * purpose.
20 *
21 * Please cite the author in any work or product based on this material.
22 * ===========================================================================
23 *
24 * Author: Eugene Vasilchenko
25 *
26 * File Description: ID2 Data reader via PubSeqOS
27 *
28 */
29 
30 #include <ncbi_pch.hpp>
31 #include <corelib/ncbi_param.hpp>
35 #include <objtools/data_loaders/genbank/readers.hpp> // for entry point
38 #include <objtools/error_codes.hpp>
39 
41 #include <objmgr/impl/tse_info.hpp>
42 
45 #include <dbapi/driver/drivers.hpp>
47 
50 
51 #include <corelib/ncbicntr.hpp>
54 #include <corelib/rwstream.hpp>
55 
56 #include <serial/objistrasnb.hpp>
57 #include <serial/serial.hpp>
58 
59 #include <objects/id2/id2__.hpp>
60 
63 #include <strstream>
64 
65 #define BINARY_REQUESTS 1
66 #define LONG_REQUESTS 1
67 
68 #if BINARY_REQUESTS
69 # include <serial/objostrasnb.hpp>
70 #define CRequestSerializer CObjectOStreamAsnBinary
71 #else
72 # include <serial/objostrasn.hpp>
73 #define CRequestSerializer CObjectOStreamAsn
74 #endif
75 #if LONG_REQUESTS
76 # define MAX_ASN_IN (20*1024)
77 #else
78 # define MAX_ASN_IN 255
79 #endif
80 
81 #define DEFAULT_DB_SERVER "PUBSEQ_OS_PUBLIC_GI64"
82 #define DEFAULT_DB_USER "anyone"
83 #define DEFAULT_DB_PASSWORD "allowed"
84 #define DEFAULT_DB_DRIVER "ftds;ctlib"
85 #define DEFAULT_NUM_CONN 2
86 #define MAX_MT_CONN 256
87 #define DEFAULT_EXCL_WGS_MASTER false
88 #define DEFAULT_TIMEOUT 40
89 #define DEFAULT_OPEN_TIMEOUT 20
90 
91 #define NCBI_USE_ERRCODE_X Objtools_Rd_Pubseq2
92 
95 
96 
97 CPubseq2Reader::CPubseq2Reader(int max_connections,
98  const string& server,
99  const string& user,
100  const string& pswd,
101  const string& dbapi_driver)
102  : m_Server(server) , m_User(user), m_Password(pswd),
103  m_DbapiDriver(dbapi_driver),
104  m_Context(nullptr),
105  m_ExclWGSMaster(DEFAULT_EXCL_WGS_MASTER),
106  m_SetCubbyUser(false)
107 {
108  if ( m_Server.empty() ) {
109  m_Server = DEFAULT_DB_SERVER;
110  }
111  if ( m_User.empty() ) {
112  m_User = DEFAULT_DB_USER;
113  }
114  if ( m_Password.empty() ) {
115  m_Password = DEFAULT_DB_PASSWORD;
116  }
117  if ( m_DbapiDriver.empty() ) {
118  m_DbapiDriver = DEFAULT_DB_DRIVER;
119  }
120 
121  SetMaximumConnections(max_connections, DEFAULT_NUM_CONN);
122 }
123 
124 
126  const string& driver_name)
127  : m_Context(nullptr),
128  m_ExclWGSMaster(DEFAULT_EXCL_WGS_MASTER),
129  m_SetCubbyUser(false)
130 {
131  CConfig conf(params);
132  m_Server = conf.GetString(
133  driver_name,
137  m_User = conf.GetString(
138  driver_name,
142  m_Password = conf.GetString(
143  driver_name,
147  m_DbapiDriver = conf.GetString(
148  driver_name,
152  m_ExclWGSMaster = conf.GetBool(
153  driver_name,
157  /*
158  bool set_cubby_user = conf.GetBool(
159  driver_name,
160  NCBI_GBLOADER_READER_PUBSEQ2_PARAM_SET_CUBBY_USER,
161  CConfig::eErr_NoThrow,
162  false);
163  if ( set_cubby_user ) {
164  SetIncludeHUP(set_cubby_user);
165  }
166  */
167  m_Timeout = conf.GetInt(
168  driver_name,
172  m_OpenTimeout = conf.GetInt(
173  driver_name,
177 
178  CReader::InitParams(conf, driver_name, DEFAULT_NUM_CONN);
179 }
180 
181 
183 {
184  delete m_Context.exchange(nullptr);
185 }
186 
187 
189 {
190 #if defined(NCBI_THREADS)
191  return MAX_MT_CONN;
192 #else
193  return 1;
194 #endif
195 }
196 
197 
199 {
200  _ASSERT(!m_Connections.count(conn));
202 }
203 
204 
206 {
208 }
209 
210 
212 {
213  _ASSERT(m_Connections.count(conn));
215  if ( c.m_Connection ) {
216  x_ReportDisconnect("CPubseq2Reader", "PubSeqOS2", conn, failed);
217  c.m_Result.reset();
218  c.m_Connection.reset();
219  }
220 }
221 
222 
224 {
225  return "";
226 }
227 
228 
230 {
231  _ASSERT(m_Connections.count(conn));
233  if ( c.m_Connection.get() ) {
234  c.m_Result.reset();
235  return *c.m_Connection;
236  }
239  c2.m_Result.reset();
240  return *c2.m_Connection;
241 }
242 
243 
245 {
246  _ASSERT(m_Connections.count(conn));
248  if ( iter == m_Connections.end() || !iter->second.m_Result ) {
249  NCBI_THROW(CLoaderException, eOtherError,
250  "CPubseq2Reader: no active command");
251  }
252  return *iter->second.m_Result;
253 }
254 
255 
258 {
259  _ASSERT(m_Connections.count(conn));
261  if ( iter == m_Connections.end() ) {
262  NCBI_THROW(CLoaderException, eOtherError,
263  "CPubseq2Reader: no active connection");
264  }
265  iter->second.m_Result = result;
266 }
267 
268 
269 namespace {
270  class CPubseq2Validator : public IConnValidator
271  {
272  public:
273  typedef CPubseq2Reader::TConn TConn;
274 
275  CPubseq2Validator(CPubseq2Reader* reader,
276  TConn conn,
277  bool excl_wgs_master)
278  : m_Reader(reader),
279  m_Conn(conn),
280  m_ExclWGSMaster(excl_wgs_master)
281  {
282  }
283 
284  virtual EConnStatus Validate(CDB_Connection& conn) {
285  if ( m_ExclWGSMaster ) {
287  (conn.LangCmd("set exclude_wgs_master on"));
288  cmd->Send();
289  cmd->DumpResults();
290  }
291  m_Reader->x_InitConnection(conn, m_Conn);
292  return eValidConn;
293  }
294 
295  virtual string GetName(void) const {
296  return "CPubseq2Validator";
297  }
298 
299  private:
300  CPubseq2Reader* m_Reader;
301  TConn m_Conn;
302  bool m_ExclWGSMaster;
303  };
304 
305  bool sx_FetchNextItem(CDB_Result& result, const CTempString& name)
306  {
307  while ( result.Fetch() ) {
308  for ( unsigned pos = 0; pos < result.NofItems(); ++pos ) {
309  if ( result.ItemName(pos) == name ) {
310  return true;
311  }
312  result.SkipItem();
313  }
314  }
315  return false;
316  }
317 
318  class CDB_Result_Reader : public CObject, public IReader
319  {
320  public:
322  AutoPtr<CDB_Result> db_result)
323  : m_DB_RPCCmd(cmd), m_DB_Result(db_result)
324  {
325  }
326 
327  ERW_Result Read(void* buf,
328  size_t count,
329  size_t* bytes_read)
330  {
331  if ( !count ) {
332  if ( bytes_read ) {
333  *bytes_read = 0;
334  }
335  return eRW_Success;
336  }
337  size_t ret;
338  while ( (ret = m_DB_Result->ReadItem(buf, count)) == 0 ) {
339  if ( !sx_FetchNextItem(*m_DB_Result, "asnout") ) {
340  m_DB_RPCCmd->DumpResults();
341  break;
342  }
343  }
344  if ( bytes_read ) {
345  *bytes_read = ret;
346  }
347  return ret? eRW_Success: eRW_Eof;
348  }
349  ERW_Result PendingCount(size_t* /*count*/)
350  {
351  return eRW_NotImplemented;
352  }
353 
354  private:
355  AutoPtr<CDB_RPCCmd> m_DB_RPCCmd;
357  };
358 }
359 
360 static string s_GetCubbyUserName(const string& web_cookie)
361 {
362  static const char* kEMyNCBIURL =
363  "https://www.ncbi.nlm.nih.gov/entrez/eutils/emyncbi.cgi?cmd=whoami&WebCubbyUser=";
364  string cubby_user;
365  if (!web_cookie.empty()) {
366  CHttpSession session;
367  int response_timeout = 40;
368  CHttpResponse response =
369  session.Get(CUrl(kEMyNCBIURL + web_cookie), CTimeout(response_timeout), 0);
370  if (response.GetStatusCode() == 200) {
372  try {
373  response.ContentStream()
374  >> MSerial_Xml
375  >> result;
376  if (result.GetUE().IsUU() && result.GetUE().GetUU().IsSetUserName())
377  cubby_user = result.GetUE().GetUU().GetUserName();
378  } catch(CException& e) {
379  string msg = e.what();
380  ERR_POST_X(1, Warning << "s_GetCubbyUserName: unable to read MyNCBI XML: "<< msg);
381  }
382  }
383  }
384 
385  if (cubby_user.empty())
386  cubby_user = CSystemInfo::GetUserName();
387 
388  return cubby_user;
389 }
390 
392 {
393  auto context = m_Context.load(memory_order_acquire);
394  if ( !context ) {
395  DEFINE_STATIC_FAST_MUTEX(s_Mutex);
396  CFastMutexGuard guard(s_Mutex);
397  context = m_Context.load(memory_order_acquire);
398  if ( !context ) {
400  C_DriverMgr drvMgr;
401  map<string,string> args;
402  args["packet"]="3584"; // 7*512
403  args["version"]="125"; // for correct connection to OpenServer
404  vector<string> driver_list;
405  NStr::Split(m_DbapiDriver, ";", driver_list);
406  size_t driver_count = driver_list.size();
407  vector<string> errmsg(driver_count);
408  for ( size_t i = 0; i < driver_count; ++i ) {
409  try {
410  context = drvMgr.GetDriverContext(driver_list[i],
411  &errmsg[i], &args);
412  if ( context ) {
413  break;
414  }
415  }
416  catch ( CException& exc ) {
417  errmsg[i] = exc.what();
418  }
419  }
420  if ( !context ) {
421  for ( size_t i = 0; i < driver_count; ++i ) {
422  ERR_POST_X(2, "Failed to create dbapi context with driver '"
423  <<driver_list[i]<<"': "<<errmsg[i]);
424  }
425  NCBI_THROW(CLoaderException, eNoConnection,
426  "Cannot create dbapi context with driver '"+
427  m_DbapiDriver+"'");
428  }
429 
430  if ( m_Timeout > 0 ) {
431  context->SetTimeout(m_Timeout);
432  }
433  }
434  m_Context.store(context, memory_order_release);
435  }
436 
437  CPubseq2Validator validator(this, conn_, m_ExclWGSMaster);
439  (context->ConnectValidated(m_Server, m_User, m_Password, validator));
440 
441  if ( !conn.get() ) {
442  NCBI_THROW(CLoaderException, eConnectionFailed, "connection failed");
443  }
444 
445  if ( m_SetCubbyUser ) {
446  // Using a formal parameter is typically better practice, but
447  // likely won't work here (a custom Open Server).
450  AutoPtr<CDB_LangCmd> cmd(conn->LangCmd("set cubby_user " + encoded));
451  cmd->Send();
452  cmd->DumpResults();
453  }
454 
455  if ( GetDebugLevel() >= 2 ) {
456  NcbiCout << "CPubseq2Reader::Connected to " << conn->ServerName()
457  << NcbiEndl;
458  }
459 
460  m_Connections[conn_].m_Connection.reset(conn.release());
461 }
462 
463 
465 {
466  // prepare init request
467  CID2_Request req;
468  req.SetRequest().SetInit();
469  x_SetContextData(req);
470  CID2_Request_Packet packet;
471  packet.Set().push_back(Ref(&req));
472  // that's it for now
473  // TODO: add params
474 
475  if ( m_OpenTimeout > 0 ) {
476  db_conn.SetTimeout(m_OpenTimeout);
477  }
478 
480  // send init request
481  {{
482  if ( GetDebugLevel() >= eTraceConn ) {
483  CDebugPrinter s(conn, "CPubseq2Reader");
484  s << "Sending";
485  if ( GetDebugLevel() >= eTraceASN ) {
486  s << ": " << MSerial_AsnText << packet;
487  }
488  else {
489  s << " ID2-Request-Packet";
490  }
491  s << "...";
492  }
493  try {
494  result = x_SendPacket(db_conn, conn, packet);
495  }
496  catch ( CException& exc ) {
497  NCBI_RETHROW(exc, CLoaderException, eConnectionFailed,
498  "failed to send init request");
499  }
500  if ( GetDebugLevel() >= eTraceConn ) {
501  CDebugPrinter s(conn, "CPubseq2Reader");
502  s << "Sent ID2-Request-Packet.";
503  }
504  }}
505 
506  // receive init reply
507  CID2_Reply reply;
508  {{
509  if ( GetDebugLevel() >= eTraceConn ) {
510  CDebugPrinter s(conn, "CPubseq2Reader");
511  s << "Receiving ID2-Reply...";
512  }
514  if ( GetDebugLevel() >= eTraceConn ) {
515  CDebugPrinter s(conn, "CPubseq2Reader");
516  s << "Received";
517  if ( GetDebugLevel() >= eTraceASN ) {
518  s << ": " << MSerial_AsnText << reply;
519  }
520  else {
521  s << " ID2-Reply.";
522  }
523  }
524  }}
525 
526  // check init reply
527  if ( reply.IsSetDiscard() ) {
528  NCBI_THROW(CLoaderException, eLoaderFailed,
529  "bad init reply: 'discard' is set");
530  }
531  if ( reply.IsSetError() ) {
532  NCBI_THROW(CLoaderException, eLoaderFailed,
533  "bad init reply: 'error' is set");
534  }
535  if ( !reply.IsSetEnd_of_reply() ) {
536  NCBI_THROW(CLoaderException, eLoaderFailed,
537  "bad init reply: 'end-of-reply' is not set");
538  }
539  if ( reply.GetReply().Which() != CID2_Reply::TReply::e_Init ) {
540  NCBI_THROW(CLoaderException, eLoaderFailed,
541  "bad init reply: 'reply' is not 'init'");
542  }
543  if ( result->HaveMoreData() ) {
544  ERR_POST_X(1, "More data in reply");
545  }
546 
547  if ( m_Timeout > 0 ) {
548  db_conn.SetTimeout(m_Timeout);
549  }
550  // that's it for now
551  // TODO: process params
552 }
553 
554 
556  const CID2_Request_Packet& packet)
557 {
560 }
561 
562 
564  CID2_Reply& reply)
565 {
567 }
568 
569 
571 {
573  if ( stream.HaveMoreData() ) {
574  ERR_POST_X(4, "CPubseq2Reader: extra blob data");
575  }
577 }
578 
579 
582  TConn conn,
583  const CID2_Request_Packet& packet)
584 {
585  char buffer[MAX_ASN_IN];
586  size_t size;
587  {{
588  // NOT CNcbiOstrstream, because that can be ostringstream, which
589  // doesn't support setting up a fixed-length buffer in this manner.
590  ostrstream mem_str(buffer, sizeof(buffer));
591  {{
592  CRequestSerializer obj_str(mem_str);
593  obj_str << packet;
594  }}
595  if ( !mem_str ) {
596  NCBI_THROW(CLoaderException, eOtherError,
597  "CPubseq2Reader: packet size overflow");
598  }
599  size = mem_str.pcount();
600  }}
601  CDB_VarChar service("ID2");
602  CDB_VarChar short_asn;
603  CDB_LongBinary long_asn(size);
604  if ( LONG_REQUESTS ) {
605  long_asn.SetValue(buffer, size);
606  }
607  else {
608  short_asn.SetValue(buffer, size);
609  }
610  CDB_TinyInt text_in(!BINARY_REQUESTS);
611  CDB_TinyInt text_out(0);
612 
613  AutoPtr<CDB_RPCCmd> cmd(db_conn.RPC("os_asn_request"));
614  cmd->SetParam("@service", &service);
615  cmd->SetParam("@asnin", &short_asn);
616  cmd->SetParam("@text", &text_in);
617  cmd->SetParam("@out_text", &text_out);
618  cmd->SetParam("@asnin_long", &long_asn);
619  cmd->Send();
620 
622  while( cmd->HasMoreResults() ) {
623  if ( cmd->HasFailed() ) {
624  NCBI_THROW(CLoaderException, eOtherError,
625  "CPubseq2Reader: failed RPC");
626  }
627  dbr = cmd->Result();
628  if ( !dbr.get() ) {
629  continue;
630  }
631 
632  if ( dbr->ResultType() != eDB_RowResult ) {
633  while ( dbr->Fetch() )
634  ;
635  continue;
636  }
637  if ( sx_FetchNextItem(*dbr, "asnout") ) {
639  (new CDB_Result_Reader(cmd, dbr));
640  AutoPtr<CRStream> stream
641  (new CRStream(reader.release(), 0, 0, CRWStreambuf::fOwnAll));
644  return obj_str;
645  }
646  }
647  NCBI_THROW(CLoaderException, eOtherError,
648  "CPubseq2Reader: no more results");
649 }
650 
651 
652 void CPubseq2Reader::SetIncludeHUP(bool include_hup,
653  const string& web_cookie)
654 {
655  x_SetIncludeHUP(include_hup);
656  m_SetCubbyUser = include_hup;
657  m_WebCookie = web_cookie;
658  if ( include_hup ) {
660  }
661 }
662 
663 
665 
667 {
668  RegisterEntryPoint<objects::CReader>(NCBI_EntryPoint_ReaderPubseqos2);
669 }
670 
671 
672 /// Class factory for Pubseq reader
673 ///
674 /// @internal
675 ///
677  public CSimpleClassFactoryImpl<objects::CReader,
678  objects::CPubseq2Reader>
679 {
680 public:
681  typedef CSimpleClassFactoryImpl<objects::CReader,
682  objects::CPubseq2Reader> TParent;
683 public:
686 
688 
689  objects::CReader*
690  CreateInstance(const string& driver = kEmptyStr,
692  NCBI_INTERFACE_VERSION(objects::CReader),
693  const TPluginManagerParamTree* params = 0) const
694  {
695  objects::CReader* drv = 0;
696  if ( !driver.empty() && driver != m_DriverName ) {
697  return 0;
698  }
699  if (version.Match(NCBI_INTERFACE_VERSION(objects::CReader))
701  drv = new objects::CPubseq2Reader(params, driver);
702  }
703  return drv;
704  }
705 };
706 
707 
711 {
713  NCBI_EntryPointImpl(info_list, method);
714 }
715 
716 
720 {
721  NCBI_EntryPoint_ReaderPubseqos2(info_list, method);
722 }
723 
724 
User-defined methods of the data storage class.
ERW_Result PendingCount(size_t *)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
Definition: asn2asn.cpp:746
ERW_Result Read(void *buf, size_t count, size_t *bytes_read)
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
Definition: asn2asn.cpp:727
CDB_Result * m_DB_Result
Definition: asn2asn.cpp:751
CDB_Result_Reader(CDB_Result *db_result)
Definition: asn2asn.cpp:723
CEMyNCBIResult –.
HTTP response.
CID2_Reply –.
Definition: ID2_Reply.hpp:66
CID2_Request_Packet –.
CID2_Request –.
Definition: ID2_Request.hpp:66
virtual void x_ReceiveReply(TConn conn, CID2_Reply &reply)=0
void x_SetContextData(CID2_Request &request)
static int GetDebugLevel(void)
Data loader exceptions, used by GenBank loader.
CObjectIStreamAsnBinary –.
Definition: objistrasnb.hpp:59
CObjectIStream –.
Definition: objistr.hpp:93
CObject –.
Definition: ncbiobj.hpp:180
Class factory for Pubseq reader.
CSimpleClassFactoryImpl< objects::CReader, objects::CPubseq2Reader > TParent
objects::CReader * CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=NCBI_INTERFACE_VERSION(objects::CReader), const TPluginManagerParamTree *params=0) const
Create instance of TDriver.
virtual void x_ReceiveReply(TConn conn, CID2_Reply &reply) override
virtual void x_AddConnectionSlot(TConn conn) override
virtual void x_RemoveConnectionSlot(TConn conn) override
void x_InitConnection(CDB_Connection &db_conn, TConn conn)
CPubseq2Reader(int max_connections=0, const string &server=kEmptyStr, const string &user=kEmptyStr, const string &pswd=kEmptyStr, const string &dbapi_driver=kEmptyStr)
virtual void SetIncludeHUP(bool include_hup=true, const string &web_cookie=NcbiEmptyString) override
void x_SetCurrentResult(TConn conn, AutoPtr< CObjectIStream > result)
TConnections m_Connections
atomic< I_DriverContext * > m_Context
virtual string x_ConnDescription(TConn conn) const override
virtual void x_DisconnectAtSlot(TConn conn, bool failed) override
virtual void x_EndOfPacket(TConn conn) override
CObjectIStream & x_GetCurrentResult(TConn conn)
virtual int GetMaximumConnectionsLimit(void) const override
CDB_Connection & x_GetConnection(TConn conn)
virtual void x_ConnectAtSlot(TConn conn) override
virtual void x_SendPacket(TConn conn, const CID2_Request_Packet &packet) override
virtual ~CPubseq2Reader() override
Note about the "buf_size" parameter for streams in this API.
Definition: rwstream.hpp:122
void x_SetIncludeHUP(bool include_hup)
Definition: reader.hpp:368
unsigned TConn
Definition: reader.hpp:87
void x_ReportDisconnect(const char *reader, const char *server, TConn conn, bool failed) const
Definition: reader.cpp:444
virtual void OpenConnection(TConn conn)
Definition: reader.cpp:326
void InitParams(CConfig &conf, const string &driver_name, int default_max_conn)
Definition: reader.cpp:131
Template class helps to implement one driver class factory.
static string GetUserName(void)
Get actual user name for the current process.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
CTimeout – Timeout interval.
Definition: ncbitime.hpp:1693
definition of a Culling tree
Definition: ncbi_tree.hpp:100
CUrl –.
Definition: ncbi_url.hpp:353
CVersionInfo –.
A very basic data-read interface.
void erase(iterator pos)
Definition: map.hpp:167
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
#define DBLB_INSTALL_DEFAULT()
Easy-to-use macro to install the default DBAPI service mapper.
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
int failed
Definition: dbmorecmds.c:10
#define false
Definition: bool.h:36
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
Definition: ncbimisc.hpp:480
element_type * get(void) const
Get pointer.
Definition: ncbimisc.hpp:469
element_type * release(void)
Release will release ownership of pointer to caller.
Definition: ncbimisc.hpp:472
@ eTakeOwnership
An object can take ownership of another.
Definition: ncbi_types.h:136
I_DriverContext * GetDriverContext(const string &driver_name, string *err_msg=0, const map< string, string > *attr=0)
Definition: driver_mgr.cpp:308
@ eDB_RowResult
Definition: interfaces.hpp:387
virtual EDB_ResType ResultType() const
Get type of the result.
Definition: public.cpp:609
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)
Read a result item body (for BLOB columns, mostly).
Definition: public.cpp:684
virtual CDB_RPCCmd * RPC(const string &rpc_name)
Make remote procedure call command.
Definition: public.cpp:362
virtual void SetTimeout(size_t nof_secs)
Set connection timeout.
Definition: public.cpp:544
virtual bool Fetch()
Fetch next row.
Definition: public.cpp:655
void SetValue(const void *v, size_t v_size)
Definition: types.cpp:1759
CDB_VarChar & SetValue(const string &s, EEncoding enc=eEncoding_Unknown)
Definition: types.cpp:1189
#define _VERIFY(expr)
Definition: ncbidbg.hpp:161
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
Definition: ncbiexpt.hpp:737
#define MSerial_Xml
Definition: serialbase.hpp:698
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
CHttpResponse Get(const CUrl &url, const CTimeout &timeout=CTimeout(CTimeout::eDefault), THttpRetries retries=null)
Shortcut for GET requests.
CNcbiIstream & ContentStream(void) const
Get input stream.
int GetStatusCode(void) const
Get response status code.
int GetInt(const string &driver_name, const string &param_name, EErrAction on_error, int default_value, const list< string > *synonyms=NULL)
Utility function to get an integer element of parameter tree Throws an exception when mandatory param...
string GetString(const string &driver_name, const string &param_name, EErrAction on_error, const string &default_value, const list< string > *synonyms=NULL)
Utility function to get an element of parameter tree Throws an exception when mandatory parameter is ...
bool GetBool(const string &driver_name, const string &param_name, EErrAction on_error, bool default_value, const list< string > *synonyms=NULL)
Utility function to get an integer element of parameter tree Throws an exception when mandatory param...
@ eErr_NoThrow
Return default value on error.
bool HaveMoreData(void)
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
static void NCBI_EntryPointImpl(TDriverInfoList &info_list, EEntryPointRequest method)
Entry point implementation.
#define NCBI_INTERFACE_VERSION(iface)
Macro to construct CVersionInfo class using interface name (relies on CInterfaceVersion class)
list< SDriverInfo > TDriverInfoList
List of driver information.
EEntryPointRequest
Actions performed by the entry point.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
ERW_Result
Result codes for I/O operations.
#define NcbiEndl
Definition: ncbistre.hpp:548
#define NcbiCout
Definition: ncbistre.hpp:543
@ eRW_NotImplemented
Action / information is not available.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Success
Everything is okay, I/O completed.
#define kEmptyStr
Definition: ncbistr.hpp:123
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3452
static CStringUTF8 SQLEncode(const CStringUTF8 &str, ESqlEncode flag)
SQL-encode string.
Definition: ncbistr.cpp:6131
@ eSqlEnc_TagNonASCII
Produce N'...' when input's not pure ASCII.
Definition: ncbistr.hpp:3170
#define DEFINE_STATIC_FAST_MUTEX(id)
Define static fast mutex and initialize it.
Definition: ncbimtx.hpp:496
@ eNonCompatible
major, minor does not match
E_Choice Which(void) const
Which variant is currently selected.
Definition: ID2_Reply_.hpp:710
bool IsSetDiscard(void) const
Check if a value has been assigned to Discard data member.
Definition: ID2_Reply_.hpp:958
const TReply & GetReply(void) const
Get the Reply member data.
Definition: ID2_Reply_.hpp:940
Tdata & Set(void)
Assign a value to data member.
bool IsSetError(void) const
Check if a value has been assigned to Error data member.
Definition: ID2_Reply_.hpp:879
void SetRequest(TRequest &value)
Assign a value to Request data member.
bool IsSetEnd_of_reply(void) const
true if this reply is the last one for the request false if more replies will follow Check if a value...
Definition: ID2_Reply_.hpp:904
Definition of all error codes used in objtools libraries.
char * buf
int i
const string version
version string
Definition: variables.hpp:66
const struct ncbi::grid::netcache::search::fields::SIZE size
#define nullptr
Definition: ncbimisc.hpp:45
#define count
static uint8_t * buffer
Definition: pcre2test.c:1016
Helper classes and templates to implement plugins.
#define DEFAULT_DB_PASSWORD
#define MAX_MT_CONN
#define DEFAULT_DB_DRIVER
void GenBankReaders_Register_Pubseq2(void)
#define MAX_ASN_IN
#define BINARY_REQUESTS
#define DEFAULT_NUM_CONN
#define DEFAULT_DB_USER
void NCBI_EntryPoint_xreader_pubseqos2(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
#define DEFAULT_EXCL_WGS_MASTER
#define DEFAULT_DB_SERVER
#define LONG_REQUESTS
void NCBI_EntryPoint_ReaderPubseqos2(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
#define CRequestSerializer
#define DEFAULT_OPEN_TIMEOUT
#define DEFAULT_TIMEOUT
static string s_GetCubbyUserName(const string &web_cookie)
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_OPEN_TIMEOUT
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_EXCL_WGS_MASTER
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_SERVER
#define NCBI_GBLOADER_READER_PUBSEQ2_DRIVER_NAME
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_DRIVER
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_TIMEOUT
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_PASSWORD
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_USER
Reader-writer based streams.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
AutoPtr< CDB_Connection > m_Connection
AutoPtr< CObjectIStream > m_Result
#define _ASSERT
else result
Definition: token2.c:20
static CS_CONTEXT * context
Definition: will_convert.c:21
#define const
Definition: zconf.h:232
Modified on Fri Sep 20 14:58:21 2024 by modify_doxy.py rev. 669887