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