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

Go to the SVN repository for this file.

1 #ifndef SRA__READER__SRA__VDBREAD__HPP
2 #define SRA__READER__SRA__VDBREAD__HPP
3 /* $Id: vdbread.hpp 102436 2024-05-06 13:19:00Z vasilche $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Eugene Vasilchenko
29  *
30  * File Description:
31  * Access to VDB files
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbiobj.hpp>
38 #include <sra/readers/sra/sdk.hpp>
39 #include <vector>
40 
41 // SRA SDK structures
42 struct KConfig;
43 struct KDBManager;
44 struct KNSManager;
45 struct VFSManager;
46 struct VDBManager;
47 struct VPath;
48 struct VResolver;
49 struct VDatabase;
50 struct VTable;
51 struct VCursor;
52 struct KIndex;
53 
56 
64 DECLARE_SRA_REF_TRAITS(KNSManager, );
65 DECLARE_SRA_REF_TRAITS(VFSManager, );
68 
69 
70 class CVFSManager;
71 class CVPath;
72 class CVResolver;
73 
74 class CVDBMgr;
75 class CVDB;
76 class CVDBTable;
77 class CVDBColumn;
78 class CVDBCursor;
79 class CVDBStringValue;
80 class CSraMgr;
81 
86 
88  : public CSraRef<const KDBManager>
89 {
90 public:
91  explicit CKDBManager(const CVDBMgr& mgr);
92  explicit CKDBManager(ENull /*null*/)
93  {
94  }
95 };
96 
97 
99  : public CSraRef<KNSManager>
100 {
101 public:
102  explicit CKNSManager(const CVFSManager& mgr);
103  explicit CKNSManager(ENull /*null*/)
104  {
105  }
106  enum EMake {
107  eMake
108  };
109  explicit CKNSManager(EMake make);
110 };
111 
112 
114  : public CSraRef<VFSManager>
115 {
116 public:
118  explicit CVFSManager(const CVDBMgr& mgr);
119  enum ECreateNew {
120  eCreateNew
121  };
122  explicit CVFSManager(ECreateNew);
123  explicit CVFSManager(ENull /*null*/)
124  {
125  }
126 
127 private:
128  void x_InitNew(void);
129 };
130 
131 
133  : public CSraRef<const VPath>
134 {
136 public:
137  CVPath(void)
138  {
139  }
140  CVPath(ENull /*null*/)
141  {
142  }
143  explicit
144  CVPath(const VPath* path)
145  : TParent(path)
146  {
147  }
148  enum EType {
149  eSys, // OS native filesystem path
150  eAcc, // VDB accession, needs to be resolved to actual path
151  ePath // VDB path string
152  };
153  CVPath(const CVFSManager& mgr, const string& path, EType type = eSys);
154  NCBI_DEPRECATED_CTOR(explicit CVPath(const string& path, EType type = eSys));
155 
156  bool IsLocalFile() const;
157  string ToString(EType type = eSys) const;
158 
159  // Check if argument string is plain VDB accession,
160  // otherwise it's a system path.
161  static bool IsPlainAccession(const string& acc_or_path);
162 
163  // Convert system path to a POSIX path, accepted by VDB.
164  // Note that only MS Windows requires this conversion.
165  static string ConvertSysPathToPOSIX(const string& sys_path);
166 
167  // Convert system path to a POSIX path, accepted by VDB.
168  // Note that only MS Windows requires this conversion.
169  // Keep plain VDB accession unchanged.
170  static string ConvertAccOrSysPathToPOSIX(const string& acc_or_path);
171 
172 private:
173  void x_Init(const CVFSManager& mgr, const string& path, EType type);
174 };
175 
176 
178  : public CSraRef<KConfig>
179 {
180 public:
182  explicit CKConfig(const CVDBMgr& mgr);
183  explicit CKConfig(ENull /*null*/)
184  {
185  }
186  enum EMake {
187  eMake
188  };
189  explicit CKConfig(EMake make);
190 
191  // Commit changes made into config file
192  void Commit() const;
193 };
194 
195 
197  : public CSraRef<VResolver>
198 {
199 public:
200  explicit CVResolver(const CVFSManager& mgr);
201  NCBI_DEPRECATED_CTOR(CVResolver(const CVFSManager& mgr, const CKConfig& cfg));
202  explicit CVResolver(ENull /*null*/)
203  : m_Mgr(null)
204  {
205  }
206 
207  // Resolve VDB accession to POSIX path.
208  // Keep non plain accession string unchanged.
209  string Resolve(const string& acc) const;
210 
211 private:
213 };
214 
215 
217  : public CSraRef<const VDBManager>
218 {
219 public:
220  CVDBMgr(void);
221 
222  // resolve possible VDB accession
223  string FindAccPath(const string& acc) const;
224  // in addition to FindAccPath() also resolve file symbolic links
225  string FindDereferencedAccPath(const string& acc_or_path) const;
226 
227  void Close(void) {
228  Release();
229  }
230 
231 
232  // Get VDB cache root OS native filesystem path
233  // returns empty string if no cache is set
234  string GetCacheRoot() const;
235 
236  // Set VDB cache root OS native filesystem path
237  void SetCacheRoot(const string& path);
238 
239  // Delete old cache files
240  void DeleteCacheOlderThan(Uint4 days);
241 
242  // Commit configuration changes into config file
243  void CommitConfig() const;
244 
245  // Update VDB request context from Corelib's one
247  public:
251  };
252 
253  // Retrieve timestamp of a file (local or remote)
254  CTime GetTimestamp(const string& path) const;
255  // Get timestamp of a file by URL
256  CTime GetURLTimestamp(const string& url) const;
257 
258 protected:
259  friend class CSraMgr;
260  static void s_VDBInit();
261 
262  void x_Init(void);
263 
264 private:
266 };
267 
268 
270  : public CSraRef<const VDatabase>
271 {
272 public:
273  CVDB(void)
274  {
275  }
276  CVDB(const CVDBMgr& mgr, const string& acc_or_path);
277 
278  const string& GetName(void) const
279  {
280  return m_Name;
281  }
282  const string& GetFullName(void) const
283  {
284  return m_Name;
285  }
286  CNcbiOstream& PrintFullName(CNcbiOstream& out) const;
287 
288  void Close(void) {
289  *this = CVDB();
290  }
291 
292 private:
293  string m_Name;
294 };
295 
296 
298  : public CSraRef<const VTable>
299 {
300 public:
301  enum EMissing {
303  eMissing_Allow
304  };
305 
306  CVDBTable(void)
307  {
308  }
309  CVDBTable(const CVDB& db,
310  const char* table_name,
311  EMissing missing = eMissing_Throw);
312  CVDBTable(const CVDBMgr& mgr,
313  const string& acc_or_path,
314  EMissing missing = eMissing_Throw);
315 
316  const CVDB& GetDb(void) const
317  {
318  return m_Db;
319  }
320  const string& GetName(void) const
321  {
322  return m_Name;
323  }
324  string GetFullName(void) const;
325  CNcbiOstream& PrintFullName(CNcbiOstream& out) const;
326 
327  void Close(void) {
328  *this = CVDBTable();
329  }
330 
331 public:
333  string m_Name;
334 };
335 
336 
338  : public CSraRef<const KIndex>
339 {
340 public:
341  enum EMissing {
343  eMissing_Allow
344  };
345 
347  {
348  }
350  const char* index_name,
351  EMissing missing = eMissing_Throw);
352 
353  const CVDBTable& GetTable(void) const
354  {
355  return m_Table;
356  }
357  const char* GetName(void) const
358  {
359  return m_Name;
360  }
361  string GetFullName(void) const;
362  CNcbiOstream& PrintFullName(CNcbiOstream& out) const;
363 
364  TVDBRowIdRange Find(const string& value) const;
365 
366  void Close(void) {
367  *this = CVDBTableIndex();
368  }
369 
370 private:
372  const char* m_Name;
373 };
374 
375 
377  : public CSraRef<const VCursor>
378 {
379 public:
381  : m_RowOpened(false)
382  {
383  }
384  explicit CVDBCursor(const CVDBTable& table)
385  : m_RowOpened(false)
386  {
387  Init(table);
388  }
389 
390  const CVDBTable& GetTable(void) const
391  {
392  return m_Table;
393  }
394 
395  bool RowIsOpened(void) const
396  {
397  return m_RowOpened;
398  }
399  rc_t OpenRowRc(TVDBRowId row_id);
400  void OpenRow(TVDBRowId row_id);
401  bool TryOpenRow(TVDBRowId row_id)
402  {
403  return OpenRowRc(row_id) == 0;
404  }
405  void CloseRow(void);
406 
407  // returns first id, and count of ids in the range
408  TVDBRowIdRange GetRowIdRange(TVDBColumnIdx column = 0) const;
409 
410  TVDBRowId GetMaxRowId(void) const;
411 
412  void SetParam(const char* name, const CTempString& value) const;
413 
414  uint32_t GetElementCount(TVDBRowId row, const CVDBColumn& column,
415  uint32_t elem_bits) const;
416  void ReadElements(TVDBRowId row, const CVDBColumn& column,
417  uint32_t elem_bits,
418  uint32_t start, uint32_t count,
419  void* buffer) const;
420 
421  void Close(void) {
422  *this = CVDBCursor();
423  }
424 
425 protected:
426  void Init(const CVDBTable& table);
427 
428 private:
431 };
432 
433 
435 {
436 public:
437  CVDBObjectCacheBase(void);
438  ~CVDBObjectCacheBase(void);
439 
440  void Clear(void);
441 
442 protected:
444  void Put(CObject* curs, TVDBRowId row);
445 
446 private:
447  typedef pair<TVDBRowId, CRef<CObject> > TSlot;
448  typedef vector<TSlot> TObjects;
450 
451 private:
454 };
455 
456 
457 template<class Object>
459 {
460 public:
462  Object* obj = static_cast<Object*>(CVDBObjectCacheBase::Get(row));
463  return CRef<Object>(obj);
464  }
465  void Put(CRef<Object>& ref, TVDBRowId row = 0) {
466  if ( Object* obj = ref.ReleaseOrNull() ) {
468  }
469  }
470 };
471 
472 
474 {
475 public:
476  enum EMissing {
478  eMissing_Allow
479  };
480 
481  enum {
482  kInvalidIndex = TVDBColumnIdx(~0)
483  };
484 
486  : m_Name(0),
487  m_Index(kInvalidIndex)
488  {
489  }
490  CVDBColumn(const CVDBCursor& cursor,
491  const char* name,
492  EMissing missing)
493  {
494  Init(cursor, 0, name, NULL, missing);
495  }
496  CVDBColumn(const CVDBCursor& cursor,
497  const char* name,
498  const char* backup_name = NULL,
499  EMissing missing = eMissing_Throw)
500  {
501  Init(cursor, 0, name, backup_name, missing);
502  }
503  CVDBColumn(const CVDBCursor& cursor,
504  size_t element_bit_size,
505  const char* name,
506  const char* backup_name = NULL,
507  EMissing missing = eMissing_Throw)
508  {
509  Init(cursor, element_bit_size, name, backup_name, missing);
510  }
511 
512  bool IsStatic(const CVDBCursor& cursor) const;
513 
514  void Reset(void)
515  {
516  m_Index = kInvalidIndex;
517  }
518  void ResetIfAlwaysEmpty(const CVDBCursor& cursor);
519 
520  const char* GetName(void) const
521  {
522  return m_Name;
523  }
524 
525  DECLARE_OPERATOR_BOOL(m_Index != kInvalidIndex);
526 
528  {
529  return m_Index;
530  }
531 
532  // returns first id, and count of ids in the range
534  {
535  return cursor.GetRowIdRange(GetIndex());
536  }
537 
538 protected:
539  void Init(const CVDBCursor& cursor,
540  size_t element_bit_size,
541  const char* name,
542  const char* backup_name,
543  EMissing missing);
544 
545 private:
546  const char* m_Name;
548 };
549 
550 
551 template<size_t ElementBitSize>
553 {
554 public:
556  {
557  }
558  CVDBColumnBits(const CVDBCursor& cursor,
559  const char* name,
560  const char* backup_name = NULL,
561  EMissing missing = eMissing_Throw)
562  : CVDBColumn(cursor, ElementBitSize, name, backup_name, missing)
563  {
564  }
565 };
566 
567 
568 // DECLARE_VDB_COLUMN is helper macro to declare accessor to VDB column
569 #define DECLARE_VDB_COLUMN(name) \
570  CVDBValue::SRef name(TVDBRowId row, CVDBValue::EMissing missing = CVDBValue::eMissing_Throw) const { \
571  return CVDBValue::SRef(m_Cursor, row, NCBI_NAME2(m_,name), missing); \
572  } \
573  CVDBColumn NCBI_NAME2(m_, name)
574 
575 // DECLARE_VDB_COLUMN is helper macro to declare accessor to VDB column
576 #define DECLARE_VDB_COLUMN_AS(type, name) \
577  CVDBValueFor<type> name(TVDBRowId row, CVDBValue::EMissing missing = CVDBValue::eMissing_Throw) const { \
578  return CVDBValueFor<type>(m_Cursor, row, NCBI_NAME2(m_,name), missing); \
579  } \
580  CVDBColumnBits<sizeof(type)*8> NCBI_NAME2(m_, name)
581 
582 // DECLARE_VDB_COLUMN is helper macro to declare accessor to VDB column
583 #define DECLARE_VDB_COLUMN_AS_STRING(name) \
584  CVDBStringValue name(TVDBRowId row, CVDBValue::EMissing missing = CVDBValue::eMissing_Throw) const { \
585  return CVDBStringValue(m_Cursor, row, NCBI_NAME2(m_,name), missing); \
586  } \
587  CVDBColumnBits<8> NCBI_NAME2(m_, name)
588 
589 // DECLARE_VDB_COLUMN is helper macro to declare accessor to VDB column
590 #define DECLARE_VDB_COLUMN_AS_4BITS(name) \
591  CVDBValueFor4Bits name(TVDBRowId row) const { \
592  return CVDBValueFor4Bits(m_Cursor, row, NCBI_NAME2(m_,name)); \
593  } \
594  CVDBColumnBits<4> NCBI_NAME2(m_, name)
595 
596 // INIT_VDB_COLUMN* are helper macros to initialize VDB column accessors
597 #define INIT_VDB_COLUMN(name) \
598  NCBI_NAME2(m_, name)(m_Cursor, #name)
599 #define INIT_VDB_COLUMN_BACKUP(name, backup_name) \
600  NCBI_NAME2(m_, name)(m_Cursor, #name, #backup_name)
601 #define INIT_VDB_COLUMN_AS(name, type) \
602  NCBI_NAME2(m_, name)(m_Cursor, "("#type")"#name)
603 #define INIT_OPTIONAL_VDB_COLUMN(name) \
604  NCBI_NAME2(m_, name)(m_Cursor, #name, NULL, CVDBColumn::eMissing_Allow)
605 #define INIT_OPTIONAL_VDB_COLUMN_BACKUP(name, backup_name) \
606  NCBI_NAME2(m_, name)(m_Cursor, #name, #backup_name, CVDBColumn::eMissing_Allow)
607 #define INIT_OPTIONAL_VDB_COLUMN_AS(name, type) \
608  NCBI_NAME2(m_, name)(m_Cursor, "("#type")"#name, NULL, CVDBColumn::eMissing_Allow)
609 #define INIT_CONDITIONAL_VDB_COLUMN(name, condition) \
610  NCBI_NAME2(m_, name)(m_Cursor, (condition)? #name: NULL, NULL, CVDBColumn::eMissing_Allow)
611 #define INIT_CONDITIONAL_VDB_COLUMN_AS(name, type, condition) \
612  NCBI_NAME2(m_, name)(m_Cursor, (condition)? "("#type")"#name: NULL, NULL, CVDBColumn::eMissing_Allow)
613 
614 
616 {
617 public:
618  enum EMissing {
620  eMissing_Allow
621  };
622 
623  struct SRef {
624  SRef(const CVDBCursor& cur,
625  TVDBRowId r,
626  const CVDBColumn& col)
627  : cursor(cur), column(col), row(r)
628  {
629  }
630 
634  };
635  struct SSaveRef {
636  SSaveRef(void)
637  : m_Table(0), m_ColumnName(0), m_Row(0)
638  {
639  }
640 
641  void Set(const CVDBCursor& cursor,
642  TVDBRowId row,
643  const CVDBColumn& column)
644  {
645  m_Table = &cursor.GetTable();
646  m_ColumnName = column.GetName();
647  m_Row = row;
648  }
649 
650  CNcbiOstream& PrintFullName(CNcbiOstream& out) const;
651 
653  const char* m_ColumnName;
655  };
656  CVDBValue(void)
657  : m_Data(0),
658  m_ElemCount(0)
659  {
660  }
661  CVDBValue(const CVDBCursor& cursor, const CVDBColumn& column)
662  : m_Data(0),
663  m_ElemCount(0)
664  {
665  x_Get(cursor, column);
666  }
668  const CVDBColumn& column, EMissing missing = eMissing_Throw)
669  : m_Data(0),
670  m_ElemCount(0)
671  {
672  x_Get(cursor, row, column, missing);
673  }
674  explicit CVDBValue(const SRef& ref)
675  : m_Data(0),
676  m_ElemCount(0)
677  {
678  x_Get(ref.cursor, ref.row, ref.column);
679  }
680  CVDBValue(const CVDBCursor& cursor,
681  const char* param_name, const CTempString& param_value,
682  const CVDBColumn& column)
683  : m_Data(0),
684  m_ElemCount(0)
685  {
686  cursor.SetParam(param_name, param_value);
687  x_Get(cursor, column);
688  }
689 
690  bool empty(void) const
691  {
692  return !m_ElemCount;
693  }
694  size_t size(void) const
695  {
696  return m_ElemCount;
697  }
698 
700  {
701  return m_Ref.PrintFullName(out);
702  }
703 
704 protected:
705  void x_Get(const CVDBCursor& cursor,
706  const CVDBColumn& column);
707  void x_Get(const CVDBCursor& cursor,
708  TVDBRowId row,
709  const CVDBColumn& column,
710  EMissing missing = eMissing_Throw);
711 
712  void x_ReportIndexOutOfBounds(size_t index) const;
713  void x_ReportNotOneValue(void) const;
714  void x_CheckIndex(size_t index) const
715  {
716  if ( index >= size() ) {
717  x_ReportIndexOutOfBounds(index);
718  }
719  }
720  void x_CheckRange(size_t pos, size_t len) const;
721  void x_CheckOneValue(void) const
722  {
723  if ( size() != 1 ) {
724  x_ReportNotOneValue();
725  }
726  }
727 
729  const void* m_Data;
731 };
732 
733 
735 {
736 public:
737  typedef unsigned TValue;
738 
740  : m_RawData(0),
741  m_ElemOffset(0),
742  m_ElemCount(0)
743  {
744  }
745  explicit CVDBValueFor4Bits(const CVDBValue::SRef& ref)
746  : m_RawData(0),
747  m_ElemOffset(0),
748  m_ElemCount(0)
749  {
750  x_Get(ref.cursor, ref.row, ref.column);
751  }
753  const CVDBColumn& column)
754  : m_RawData(0),
755  m_ElemOffset(0),
756  m_ElemCount(0)
757  {
758  x_Get(cursor, row, column);
759  }
760 
761  const char* raw_data(void) const
762  {
763  return m_RawData;
764  }
765  uint32_t raw_offset(void) const
766  {
767  return m_ElemOffset;
768  }
769  uint32_t size(void) const
770  {
771  return m_ElemCount;
772  }
773  bool empty(void) const
774  {
775  return !size();
776  }
777 
778  TValue Value(size_t index) const
779  {
780  x_CheckIndex(index);
781  return x_ValueByRawIndex(index+raw_offset());
782  }
783  TValue operator[](size_t index) const
784  {
785  return Value(index);
786  }
787 
788  CVDBValueFor4Bits substr(size_t pos, size_t len) const;
789 
791  {
792  return m_Ref.PrintFullName(out);
793  }
794 
795 protected:
796  void x_Get(const CVDBCursor& cursor,
797  TVDBRowId row,
798  const CVDBColumn& column);
799  static TValue sub_value(uint8_t v, size_t sub_index)
800  {
801  return sub_index? (v&0xf): (v>>4);
802  }
803  TValue x_ValueByRawIndex(size_t raw_index) const
804  {
805  return sub_value(raw_data()[raw_index/2], raw_index%2);
806  }
807 
808  void x_ReportIndexOutOfBounds(size_t index) const;
809  void x_CheckIndex(size_t index) const
810  {
811  if ( index >= size() ) {
812  x_ReportIndexOutOfBounds(index);
813  }
814  }
815  void x_CheckRange(size_t pos, size_t len) const;
816 
818  const char* raw, uint32_t offset, uint32_t sz)
819  : m_Ref(ref),
820  m_RawData(raw),
821  m_ElemOffset(offset),
822  m_ElemCount(sz)
823  {
824  }
825 
827  const char* m_RawData;
830 };
831 
832 
834 {
835 public:
836  typedef unsigned TValue;
837 
839  : m_RawData(0),
840  m_ElemOffset(0),
841  m_ElemCount(0)
842  {
843  }
844  explicit CVDBValueFor2Bits(const CVDBValue::SRef& ref)
845  : m_RawData(0),
846  m_ElemOffset(0),
847  m_ElemCount(0)
848  {
849  x_Get(ref.cursor, ref.row, ref.column);
850  }
852  const CVDBColumn& column)
853  : m_RawData(0),
854  m_ElemOffset(0),
855  m_ElemCount(0)
856  {
857  x_Get(cursor, row, column);
858  }
859 
860  const char* raw_data(void) const
861  {
862  return m_RawData;
863  }
864  uint32_t raw_offset(void) const
865  {
866  return m_ElemOffset;
867  }
868  uint32_t size(void) const
869  {
870  return m_ElemCount;
871  }
872  bool empty(void) const
873  {
874  return !size();
875  }
876 
877  TValue Value(size_t index) const
878  {
879  x_CheckIndex(index);
880  return x_ValueByRawIndex(index+raw_offset());
881  }
882  TValue operator[](size_t index) const
883  {
884  return Value(index);
885  }
886 
887  CVDBValueFor2Bits substr(size_t pos, size_t len) const;
888 
890  {
891  return m_Ref.PrintFullName(out);
892  }
893 
894 protected:
895  void x_Get(const CVDBCursor& cursor,
896  TVDBRowId row,
897  const CVDBColumn& column);
898  static TValue sub_value(uint8_t v, size_t sub_index)
899  {
900  return (v>>(6-2*sub_index))&3;
901  }
902  TValue x_ValueByRawIndex(size_t raw_index) const
903  {
904  return sub_value(raw_data()[raw_index/4], raw_index%4);
905  }
906 
907  void x_ReportIndexOutOfBounds(size_t index) const;
908  void x_CheckIndex(size_t index) const
909  {
910  if ( index >= size() ) {
911  x_ReportIndexOutOfBounds(index);
912  }
913  }
914  void x_CheckRange(size_t pos, size_t len) const;
915 
917  const char* raw, uint32_t offset, uint32_t sz)
918  : m_Ref(ref),
919  m_RawData(raw),
920  m_ElemOffset(offset),
921  m_ElemCount(sz)
922  {
923  }
924 
926  const char* m_RawData;
929 };
930 
931 
932 template<class V>
933 class CVDBValueFor : public CVDBValue
934 {
935 public:
936  typedef V TValue;
938  {
939  }
940  CVDBValueFor(const CVDBCursor& cursor, const CVDBColumn& column)
941  : CVDBValue(cursor, column)
942  {
943  }
945  const CVDBColumn& column, EMissing missing = eMissing_Throw)
946  : CVDBValue(cursor, row, column, missing)
947  {
948  }
949  explicit CVDBValueFor(const CVDBValue::SRef& ref)
950  : CVDBValue(ref)
951  {
952  }
954  const char* param_name, const CTempString& param_value,
955  const CVDBColumn& column)
956  : CVDBValue(cursor, param_name, param_value, column)
957  {
958  }
959 
960  const TValue* data() const
961  {
962  return static_cast<const TValue*>(m_Data);
963  }
964  const TValue& operator[](size_t i) const
965  {
966  x_CheckIndex(i);
967  return data()[i];
968  }
969  const TValue& Value(void) const
970  {
971  x_CheckOneValue();
972  return *data();
973  }
974  const TValue& operator*(void) const
975  {
976  return Value();
977  }
978  const TValue* operator->(void) const
979  {
980  return &Value();
981  }
982 
983  operator const TValue&(void) const
984  {
985  return Value();
986  }
987 
988  typedef const TValue* const_iterator;
990  {
991  return data();
992  }
994  {
995  return begin()+size();
996  }
997 
998  CVDBValueFor<TValue> substr(size_t pos, size_t len) const
999  {
1000  x_CheckRange(pos, len);
1001  return CVDBValueFor<TValue>(data()+pos, uint32_t(len));
1002  }
1003 
1004 private:
1005  // to cause ambiguity if assigned to a wrong type
1006  operator double(void) const;
1007 };
1008 
1009 
1010 class CVDBStringValue : public CVDBValueFor<char>
1011 {
1012 public:
1014  {
1015  }
1017  const CVDBColumn& column)
1018  : CVDBValueFor<char>(cursor, column)
1019  {
1020  }
1022  const CVDBColumn& column,
1023  EMissing missing = eMissing_Throw)
1024  : CVDBValueFor<char>(cursor, row, column, missing)
1025  {
1026  }
1027  explicit CVDBStringValue(const CVDBValue::SRef& ref)
1028  : CVDBValueFor<char>(ref)
1029  {
1030  }
1032  const char* param_name, const CTempString& param_value,
1033  const CVDBColumn& column)
1034  : CVDBValueFor<char>(cursor, param_name, param_value, column)
1035  {
1036  }
1037 
1038  const char* data(void) const
1039  {
1040  return static_cast<const char*>(m_Data);
1041  }
1042 
1043  operator CTempString(void) const
1044  {
1045  return CTempString(data(), size());
1046  }
1047  operator string(void) const
1048  {
1049  return Value();
1050  }
1051  string Value(void) const
1052  {
1053  return string(data(), size());
1054  }
1055 
1057  {
1058  return *this;
1059  }
1060 };
1061 
1062 
1065 
1066 
1067 #ifndef NCBI_OS_MSWIN
1068 // Non-Windows paths are already POSIX
1069 inline
1070 string CVPath::ConvertSysPathToPOSIX(const string& sys_path)
1071 {
1072  return sys_path;
1073 }
1074 
1075 
1076 // Non-Windows paths are already POSIX
1077 inline
1078 string CVPath::ConvertAccOrSysPathToPOSIX(const string& acc_or_path)
1079 {
1080  return acc_or_path;
1081 }
1082 #endif
1083 
1084 
1087 
1088 #endif // SRA__READER__SRA__VDBREAD__HPP
static void s_VDBInit()
Definition: bamread.cpp:725
uint32_t rc_t
CKConfig(ENull)
Definition: vdbread.hpp:183
CKDBManager(ENull)
Definition: vdbread.hpp:92
CKNSManager(ENull)
Definition: vdbread.hpp:103
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
void x_Init(void)
Definition: sraread.cpp:361
Definition: sdk.hpp:85
void Release(void)
Definition: sdk.hpp:136
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
CVDBColumnBits(void)
Definition: vdbread.hpp:555
CVDBColumnBits(const CVDBCursor &cursor, const char *name, const char *backup_name=NULL, EMissing missing=eMissing_Throw)
Definition: vdbread.hpp:558
CVDBColumn(const CVDBCursor &cursor, const char *name, EMissing missing)
Definition: vdbread.hpp:490
@ eMissing_Throw
Definition: vdbread.hpp:477
DECLARE_OPERATOR_BOOL(m_Index !=kInvalidIndex)
CVDBColumn(const CVDBCursor &cursor, size_t element_bit_size, const char *name, const char *backup_name=NULL, EMissing missing=eMissing_Throw)
Definition: vdbread.hpp:503
CVDBColumn(void)
Definition: vdbread.hpp:485
TVDBColumnIdx GetIndex(void) const
Definition: vdbread.hpp:527
const char * GetName(void) const
Definition: vdbread.hpp:520
const char * m_Name
Definition: vdbread.hpp:546
TVDBColumnIdx m_Index
Definition: vdbread.hpp:547
CVDBColumn(const CVDBCursor &cursor, const char *name, const char *backup_name=NULL, EMissing missing=eMissing_Throw)
Definition: vdbread.hpp:496
void Reset(void)
Definition: vdbread.hpp:514
TVDBRowIdRange GetRowIdRange(const CVDBCursor &cursor) const
Definition: vdbread.hpp:533
bool RowIsOpened(void) const
Definition: vdbread.hpp:395
CVDBCursor(const CVDBTable &table)
Definition: vdbread.hpp:384
const CVDBTable & GetTable(void) const
Definition: vdbread.hpp:390
void Close(void)
Definition: vdbread.hpp:421
bool m_RowOpened
Definition: vdbread.hpp:430
void SetParam(const char *name, const CTempString &value) const
Definition: vdbread.cpp:1395
bool TryOpenRow(TVDBRowId row_id)
Definition: vdbread.hpp:401
CVDBTable m_Table
Definition: vdbread.hpp:429
CVDBCursor(void)
Definition: vdbread.hpp:380
TVDBRowIdRange GetRowIdRange(TVDBColumnIdx column=0) const
Definition: vdbread.cpp:1376
CRequestContextUpdater(const CRequestContextUpdater &)=delete
CVResolver m_Resolver
Definition: vdbread.hpp:265
void Close(void)
Definition: vdbread.hpp:227
CObject * Get(TVDBRowId row)
Definition: vdbread.cpp:1483
TObjects m_Objects
Definition: vdbread.hpp:449
CVDBObjectCacheBase(const CVDBObjectCacheBase &)
void Put(CObject *curs, TVDBRowId row)
Definition: vdbread.cpp:1516
pair< TVDBRowId, CRef< CObject > > TSlot
Definition: vdbread.hpp:447
vector< TSlot > TObjects
Definition: vdbread.hpp:448
void operator=(const CVDBObjectCacheBase &)
void Put(CRef< Object > &ref, TVDBRowId row=0)
Definition: vdbread.hpp:465
CRef< Object > Get(TVDBRowId row=0)
Definition: vdbread.hpp:461
CVDBStringValue(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column, EMissing missing=eMissing_Throw)
Definition: vdbread.hpp:1021
CVDBStringValue(const CVDBValue::SRef &ref)
Definition: vdbread.hpp:1027
const char * data(void) const
Definition: vdbread.hpp:1038
CVDBStringValue(CVDBCursor &cursor, const char *param_name, const CTempString &param_value, const CVDBColumn &column)
Definition: vdbread.hpp:1031
CVDBStringValue(void)
Definition: vdbread.hpp:1013
CVDBStringValue(const CVDBCursor &cursor, const CVDBColumn &column)
Definition: vdbread.hpp:1016
CTempString operator*(void) const
Definition: vdbread.hpp:1056
string Value(void) const
Definition: vdbread.hpp:1051
const char * m_Name
Definition: vdbread.hpp:372
void Close(void)
Definition: vdbread.hpp:366
const char * GetName(void) const
Definition: vdbread.hpp:357
const CVDBTable & GetTable(void) const
Definition: vdbread.hpp:353
CVDBTable m_Table
Definition: vdbread.hpp:371
CVDBTableIndex(void)
Definition: vdbread.hpp:346
void Close(void)
Definition: vdbread.hpp:327
@ eMissing_Throw
Definition: vdbread.hpp:302
const CVDB & GetDb(void) const
Definition: vdbread.hpp:316
string m_Name
Definition: vdbread.hpp:333
CVDBTable(void)
Definition: vdbread.hpp:306
CVDB m_Db
Definition: vdbread.hpp:332
const string & GetName(void) const
Definition: vdbread.hpp:320
uint32_t size(void) const
Definition: vdbread.hpp:868
TValue x_ValueByRawIndex(size_t raw_index) const
Definition: vdbread.hpp:902
CVDBValueFor2Bits(void)
Definition: vdbread.hpp:838
CVDBValueFor2Bits(const CVDBValue::SSaveRef &ref, const char *raw, uint32_t offset, uint32_t sz)
Definition: vdbread.hpp:916
uint32_t raw_offset(void) const
Definition: vdbread.hpp:864
const char * raw_data(void) const
Definition: vdbread.hpp:860
const char * m_RawData
Definition: vdbread.hpp:926
CVDBValueFor2Bits(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column)
Definition: vdbread.hpp:851
CVDBValue::SSaveRef m_Ref
Definition: vdbread.hpp:925
unsigned TValue
Definition: vdbread.hpp:836
static TValue sub_value(uint8_t v, size_t sub_index)
Definition: vdbread.hpp:898
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
Definition: vdbread.hpp:889
uint32_t m_ElemOffset
Definition: vdbread.hpp:927
bool empty(void) const
Definition: vdbread.hpp:872
CVDBValueFor2Bits(const CVDBValue::SRef &ref)
Definition: vdbread.hpp:844
TValue operator[](size_t index) const
Definition: vdbread.hpp:882
void x_CheckIndex(size_t index) const
Definition: vdbread.hpp:908
TValue Value(size_t index) const
Definition: vdbread.hpp:877
uint32_t m_ElemCount
Definition: vdbread.hpp:928
CVDBValueFor4Bits(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column)
Definition: vdbread.hpp:752
TValue operator[](size_t index) const
Definition: vdbread.hpp:783
TValue x_ValueByRawIndex(size_t raw_index) const
Definition: vdbread.hpp:803
void x_CheckIndex(size_t index) const
Definition: vdbread.hpp:809
bool empty(void) const
Definition: vdbread.hpp:773
uint32_t raw_offset(void) const
Definition: vdbread.hpp:765
CVDBValueFor4Bits(void)
Definition: vdbread.hpp:739
CVDBValue::SSaveRef m_Ref
Definition: vdbread.hpp:826
const char * m_RawData
Definition: vdbread.hpp:827
unsigned TValue
Definition: vdbread.hpp:737
uint32_t m_ElemOffset
Definition: vdbread.hpp:828
const char * raw_data(void) const
Definition: vdbread.hpp:761
static TValue sub_value(uint8_t v, size_t sub_index)
Definition: vdbread.hpp:799
uint32_t size(void) const
Definition: vdbread.hpp:769
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
Definition: vdbread.hpp:790
TValue Value(size_t index) const
Definition: vdbread.hpp:778
CVDBValueFor4Bits(const CVDBValue::SRef &ref)
Definition: vdbread.hpp:745
CVDBValueFor4Bits(const CVDBValue::SSaveRef &ref, const char *raw, uint32_t offset, uint32_t sz)
Definition: vdbread.hpp:817
uint32_t m_ElemCount
Definition: vdbread.hpp:829
CVDBValueFor(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column, EMissing missing=eMissing_Throw)
Definition: vdbread.hpp:944
const_iterator end() const
Definition: vdbread.hpp:993
const TValue & operator*(void) const
Definition: vdbread.hpp:974
CVDBValueFor< TValue > substr(size_t pos, size_t len) const
Definition: vdbread.hpp:998
CVDBValueFor(CVDBCursor &cursor, const char *param_name, const CTempString &param_value, const CVDBColumn &column)
Definition: vdbread.hpp:953
CVDBValueFor(const CVDBCursor &cursor, const CVDBColumn &column)
Definition: vdbread.hpp:940
const TValue & operator[](size_t i) const
Definition: vdbread.hpp:964
CVDBValueFor(const CVDBValue::SRef &ref)
Definition: vdbread.hpp:949
const TValue * const_iterator
Definition: vdbread.hpp:988
const TValue * data() const
Definition: vdbread.hpp:960
CVDBValueFor(void)
Definition: vdbread.hpp:937
const_iterator begin() const
Definition: vdbread.hpp:989
const TValue * operator->(void) const
Definition: vdbread.hpp:978
const TValue & Value(void) const
Definition: vdbread.hpp:969
void x_CheckRange(size_t pos, size_t len) const
Definition: vdbread.cpp:1791
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
Definition: vdbread.hpp:699
CVDBValue(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column, EMissing missing=eMissing_Throw)
Definition: vdbread.hpp:667
CVDBValue(const CVDBCursor &cursor, const CVDBColumn &column)
Definition: vdbread.hpp:661
CVDBValue(const SRef &ref)
Definition: vdbread.hpp:674
void x_CheckOneValue(void) const
Definition: vdbread.hpp:721
const void * m_Data
Definition: vdbread.hpp:729
bool empty(void) const
Definition: vdbread.hpp:690
uint32_t m_ElemCount
Definition: vdbread.hpp:730
CVDBValue(const CVDBCursor &cursor, const char *param_name, const CTempString &param_value, const CVDBColumn &column)
Definition: vdbread.hpp:680
size_t size(void) const
Definition: vdbread.hpp:694
void x_CheckIndex(size_t index) const
Definition: vdbread.hpp:714
@ eMissing_Throw
Definition: vdbread.hpp:619
CVDBValue(void)
Definition: vdbread.hpp:656
SSaveRef m_Ref
Definition: vdbread.hpp:728
const string & GetFullName(void) const
Definition: vdbread.hpp:282
CVDB(void)
Definition: vdbread.hpp:273
const string & GetName(void) const
Definition: vdbread.hpp:278
string m_Name
Definition: vdbread.hpp:293
void Close(void)
Definition: vdbread.hpp:288
CVFSManager(ENull)
Definition: vdbread.hpp:123
@ eSys
Definition: vdbread.hpp:149
@ eAcc
Definition: vdbread.hpp:150
static string ConvertAccOrSysPathToPOSIX(const string &acc_or_path)
Definition: vdbread.cpp:429
static string ConvertSysPathToPOSIX(const string &sys_path)
Definition: vdbread.cpp:402
CSraRef< const VPath > TParent
Definition: vdbread.hpp:135
CVPath(void)
Definition: vdbread.hpp:137
CVPath(ENull)
Definition: vdbread.hpp:140
CVPath(const VPath *path)
Definition: vdbread.hpp:144
CVFSManager m_Mgr
Definition: vdbread.hpp:212
CVResolver(ENull)
Definition: vdbread.hpp:202
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
#define false
Definition: bool.h:36
static const char table_name[]
Definition: bcp.c:249
static void Init(void)
Definition: cursor6.c:76
static const char * column
Definition: stats.c:23
int offset
Definition: replacements.h:160
Uint8 uint64_t
Int8 int64_t
unsigned char uint8_t
Uint4 uint32_t
#define NCBI_DEPRECATED_CTOR(decl)
Macro used to mark a constructor as deprecated.
Definition: ncbimisc.hpp:1209
ENull
CNullable –.
Definition: ncbimisc.hpp:645
@ null
Definition: ncbimisc.hpp:646
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
TObjectType * ReleaseOrNull(void)
Release a reference to the object and return a pointer to the object.
Definition: ncbiobj.hpp:816
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#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
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
#define NCBI_SRAREAD_EXPORT
Definition: ncbi_export.h:1227
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
int i
int len
const TYPE & Get(const CNamedParameterList *param)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2107
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static pcre_uint8 * buffer
Definition: pcretest.c:1051
@ Resolve
Try to resolve provided seq-ids.
#define uint32_t
Definition: config.h:42
#define row(bind, expected)
Definition: string_bind.c:73
TVDBRowId row
Definition: vdbread.hpp:633
SRef(const CVDBCursor &cur, TVDBRowId r, const CVDBColumn &col)
Definition: vdbread.hpp:624
const CVDBColumn & column
Definition: vdbread.hpp:632
const CVDBCursor & cursor
Definition: vdbread.hpp:631
void Set(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column)
Definition: vdbread.hpp:641
const CVDBTable * m_Table
Definition: vdbread.hpp:652
const char * m_ColumnName
Definition: vdbread.hpp:653
Definition: type.c:6
uint32_t TVDBColumnIdx
Definition: vdbread.hpp:85
uint64_t TVDBRowCount
Definition: vdbread.hpp:83
DECLARE_SRA_REF_TRAITS(VDBManager, const)
CVDBValueFor< uint16_t > CVDBUInt16Value
Definition: vdbread.hpp:1063
pair< TVDBRowId, TVDBRowCount > TVDBRowIdRange
Definition: vdbread.hpp:84
int64_t TVDBRowId
Definition: vdbread.hpp:80
CVDBValueFor< char > CVDBBytesValue
Definition: vdbread.hpp:1064
string ToString(const wxRect &rc)
Definition: wx_utils.cpp:773
#define const
Definition: zconf.h:232
Modified on Mon May 20 04:59:25 2024 by modify_doxy.py rev. 669887