NCBI C++ ToolKit
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CBlastDbBlob Class Reference

Search Toolkit Book for CBlastDbBlob

`Blob' Class for SeqDB (and WriteDB). More...

#include <objtools/blast/seqdb_reader/seqdbblob.hpp>

+ Inheritance diagram for CBlastDbBlob:
+ Collaboration diagram for CBlastDbBlob:

Public Types

enum  EStringFormat { eNone , eNUL , eSize4 , eSizeVar }
 String termination style. More...
 
enum  EPadding { eSimple , eString }
 Padding style. More...
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 

Public Member Functions

 CBlastDbBlob (int size=0)
 Create a new object, reserving 'size' bytes for writing. More...
 
 CBlastDbBlob (CTempString data, bool copy)
 Create a readable object containing the specified data. More...
 
CTempString Str () const
 Get blob contents as a CTempString. More...
 
int Size () const
 Get size of blob contents. More...
 
void Clear ()
 Clear all owned data and reference an empty string. More...
 
void ReferTo (CTempString data)
 Refer to an existing memory area. More...
 
void ReferTo (CTempString data, CRef< CObject > lifetime)
 Refer to an existing memory area. More...
 
Int8 ReadVarInt ()
 Read a variable length integer from the blob. More...
 
Int8 ReadVarInt (int offset) const
 Read a variable length integer from the blob. More...
 
int ReadInt1 ()
 Read a 1 byte integer at the pointer (and move the pointer). More...
 
int ReadInt1 (int offset) const
 Read a 1 byte integer from the given offset. More...
 
int ReadInt2 ()
 Read a 2 byte integer at the pointer (and move the pointer). More...
 
int ReadInt2 (int offset) const
 Read a 2 byte integer from the given offset. More...
 
Int4 ReadInt4 ()
 Read a 4 byte integer at the pointer (and move the pointer). More...
 
Int4 ReadInt4 (int offset) const
 Read a 4 byte integer from the given offset. More...
 
Int8 ReadInt8 ()
 Read an 8 byte integer at the pointer (and move the pointer). More...
 
Int8 ReadInt8 (int offset) const
 Read an 8 byte integer from the given offset. More...
 
void SeekRead (int offset)
 Move the read pointer to a specific location. More...
 
int WriteVarInt (Int8 x)
 Write a variable length integer to the blob. More...
 
int WriteVarInt (Int8 x, int offset)
 Write a variable length integer to the blob. More...
 
void WriteInt1 (int x)
 Write a 1 byte integer to the blob. More...
 
void WriteInt1_LE (int x)
 
void WriteInt1 (int x, int offset)
 Write a 1 byte integer to the blob. More...
 
void WriteInt1_LE (int x, int offset)
 
void WriteInt2 (int x)
 Write a 1 byte integer to the blob. More...
 
void WriteInt2_LE (int x)
 
void WriteInt2 (int x, int offset)
 Write a 1 byte integer to the blob. More...
 
void WriteInt2_LE (int x, int offset)
 
void WriteInt4 (Int4 x)
 Write a 4 byte integer to the blob. More...
 
void WriteInt4_LE (Int4 x)
 
void WriteInt4 (Int4 x, int offset)
 Write a 4 byte integer into the blob at a given offset. More...
 
void WriteInt4_LE (Int4 x, int offset)
 
void WriteInt8 (Int8 x)
 Write an 8 byte integer to the blob. More...
 
void WriteInt8_LE (Int8 x)
 
void WriteInt8 (Int8 x, int offset)
 Write an 8 byte integer into the blob at a given offset. More...
 
void WriteInt8_LE (Int8 x, int offset)
 
void SeekWrite (int offset)
 Seek write pointer to a specific location. More...
 
CTempString ReadString (EStringFormat fmt)
 Read string data from the blob (moving the read pointer). More...
 
CTempString ReadString (EStringFormat fmt, int offset) const
 Read string data from the blob at a given offset. More...
 
int WriteString (CTempString str, EStringFormat fmt)
 Write string data to the blob. More...
 
int WriteString (CTempString str, EStringFormat fmt, int offset)
 Write string data to the blob at a specific offset. More...
 
void WritePadBytes (int align, EPadding fmt)
 Align the offset by writing pad bytes. More...
 
void SkipPadBytes (int align, EPadding fmt)
 Align the offset by skipping bytes. More...
 
const char * ReadRaw (int size)
 Read raw data (moving the read pointer). More...
 
void WriteRaw (const char *begin, int size)
 Write raw data to the blob (moving the write pointer). More...
 
void WriteRaw (const char *begin, int size, int offset)
 Write raw data to the blob at the given offset. More...
 
int GetWriteOffset () const
 Get the current write pointer offset. More...
 
int GetReadOffset () const
 Get the current read pointer offset. More...
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (const CObject &src) THROWS_NONE
 Assignment operator. More...
 
bool CanBeDeleted (void) const THROWS_NONE
 Check if object can be deleted. More...
 
bool IsAllocatedInPool (void) const THROWS_NONE
 Check if object is allocated in memory pool (not system heap) More...
 
bool Referenced (void) const THROWS_NONE
 Check if object is referenced. More...
 
bool ReferencedOnlyOnce (void) const THROWS_NONE
 Check if object is referenced only once. More...
 
void AddReference (void) const
 Add reference to object. More...
 
void RemoveReference (void) const
 Remove reference to object. More...
 
void ReleaseReference (void) const
 Remove reference without deleting object. More...
 
virtual void DoNotDeleteThisObject (void)
 Mark this object as not allocated in heap – do not delete this object. More...
 
virtual void DoDeleteThisObject (void)
 Mark this object as allocated in heap – object can be deleted. More...
 
void * operator new (size_t size)
 Define new operator for memory allocation. More...
 
void * operator new[] (size_t size)
 Define new[] operator for 'array' memory allocation. More...
 
void operator delete (void *ptr)
 Define delete operator for memory deallocation. More...
 
void operator delete[] (void *ptr)
 Define delete[] operator for memory deallocation. More...
 
void * operator new (size_t size, void *place)
 Define new operator. More...
 
void operator delete (void *ptr, void *place)
 Define delete operator. More...
 
void * operator new (size_t size, CObjectMemoryPool *place)
 Define new operator using memory pool. More...
 
void operator delete (void *ptr, CObjectMemoryPool *place)
 Define delete operator. More...
 
virtual void DebugDump (CDebugDumpContext ddc, unsigned int depth) const
 Define method for dumping debug information. More...
 
- Public Member Functions inherited from CDebugDumpable
 CDebugDumpable (void)
 
virtual ~CDebugDumpable (void)
 
void DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const
 
void DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const
 
void DumpToConsole (void) const
 

Static Public Member Functions

static int VarIntSize (Int8 x)
 Compute bytes used for a variable length integer. More...
 
- Static Public Member Functions inherited from CObject
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (void)
 Define method to throw null pointer exception. More...
 
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (const type_info &type)
 
static EAllocFillMode GetAllocFillMode (void)
 
static void SetAllocFillMode (EAllocFillMode mode)
 
static void SetAllocFillMode (const string &value)
 Set mode from configuration parameter value. More...
 
- Static Public Member Functions inherited from CDebugDumpable
static void EnableDebugDump (bool on)
 

Private Member Functions

void x_Copy (int total)
 Copy referenced data to owned data. More...
 
void x_Reserve (int size)
 Write raw bytes as a CTempString. More...
 
void x_WriteRaw (const char *ptr, int size, int *offsetp)
 Write raw bytes as ptr + size at a given offset. More...
 
const char * x_ReadRaw (int size, int *offsetp) const
 Read raw bytes from a given offset. More...
 
int x_WriteVarInt (Int8 x, int *offsetp)
 Write a variable length integer into the buffer. More...
 
Int8 x_ReadVarInt (int *offsetp) const
 Read a variable length integer from the buffer. More...
 
int x_WriteString (CTempString str, EStringFormat fmt, int *offsetp)
 Write string data to the blob. More...
 
CTempString x_ReadString (EStringFormat fmt, int *offsetp) const
 Read string data from the blob. More...
 
template<typename TValue , int TBytes>
TValue x_ReadIntFixed (int *offsetp) const
 Read a fixed length integer. More...
 
template<typename TValue , int TBytes>
void x_WriteIntFixed (TValue x, int *offsetp)
 Write a fixed length integer in big endian. More...
 
template<typename TValue , int TBytes>
void x_WriteIntFixed_LE (TValue x, int *offsetp)
 Write a fixed length integer in small endian. More...
 

Private Attributes

bool m_Owner
 True if this object owns the target data. More...
 
int m_ReadOffset
 The `read pointer' for stream-like access. More...
 
int m_WriteOffset
 The `write pointer' for stream-like access. More...
 
vector< char > m_DataHere
 Data owned by this object. More...
 
CTempString m_DataRef
 Non-owned data (only used for `read' streams). More...
 
CRef< CObjectm_Lifetime
 Lifetime maintenance object for referenced data. More...
 

Additional Inherited Members

- Static Public Attributes inherited from CObject
static const TCount eCounterBitsCanBeDeleted = 1 << 0
 Define possible object states. More...
 
static const TCount eCounterBitsInPlainHeap = 1 << 1
 Heap signature was found. More...
 
static const TCount eCounterBitsPlaceMask
 Mask for 'in heap' state flags. More...
 
static const int eCounterStep = 1 << 2
 Skip over the "in heap" bits. More...
 
static const TCount eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2)
 Minimal value for valid objects (reference counter is zero) Must be a single bit value. More...
 
static const TCount eCounterStateMask
 Valid object, and object in heap. More...
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Detailed Description

`Blob' Class for SeqDB (and WriteDB).

This manages serialization and deserialization of binary data of unspecified size and format, known in RDBMS jargon as `blob' data. The primary goals here are to standardize the encoding of data types and to optimize performance. Read and write operations are handled by the same class. For both read and write operations, random and stream access are supported.

Definition at line 56 of file seqdbblob.hpp.

Member Enumeration Documentation

◆ EPadding

Padding style.

Enumerator
eSimple 

Just write NUL bytes until aligned.

eString 

Pad using NUL terminated string of '#' bytes.

Definition at line 270 of file seqdbblob.hpp.

◆ EStringFormat

String termination style.

Enumerator
eNone 

Write the string as-is.

eNUL 

Write a NUL terminated string.

eSize4 

Write string length as Int4, then string data.

eSizeVar 

Write string length as VarInt, then string data.

Definition at line 233 of file seqdbblob.hpp.

Constructor & Destructor Documentation

◆ CBlastDbBlob() [1/2]

CBlastDbBlob::CBlastDbBlob ( int  size = 0)

Create a new object, reserving 'size' bytes for writing.

Parameters
sizeThis many bytes will be reserved for writing.

Definition at line 40 of file seqdbblob.cpp.

References m_DataHere, and ncbi::grid::netcache::search::fields::size.

◆ CBlastDbBlob() [2/2]

CBlastDbBlob::CBlastDbBlob ( CTempString  data,
bool  copy 
)

Create a readable object containing the specified data.

If `copy' is specified as false, only a reference to the data will be kept, and write operations are illegal. If `copy' is specified as true, the data is copied into an internal buffer, and both read and write operations are legal.

Parameters
dataThe data to refer to.
copySpecify true to copy the data to a buffer.

Definition at line 48 of file seqdbblob.cpp.

References data, m_DataHere, m_DataRef, and m_Owner.

Member Function Documentation

◆ Clear()

void CBlastDbBlob::Clear ( void  )

◆ GetReadOffset()

int CBlastDbBlob::GetReadOffset ( ) const

Get the current read pointer offset.

Returns
The offset at which the next read would occur.

Definition at line 557 of file seqdbblob.cpp.

References m_ReadOffset.

Referenced by s_ReadRanges(), CSeqDBColumn::x_ReadFields(), and CSeqDBColumn::x_ReadMetaData().

◆ GetWriteOffset()

int CBlastDbBlob::GetWriteOffset ( ) const

Get the current write pointer offset.

Returns
The offset at which the next write would occur.

Definition at line 552 of file seqdbblob.cpp.

References m_WriteOffset.

Referenced by CWriteDB_GiMaskIndex::x_BuildHeaderFields(), CWriteDB_ColumnIndex::x_BuildHeaderStrings(), and CWriteDB_ColumnIndex::x_BuildMetaData().

◆ ReadInt1() [1/2]

int CBlastDbBlob::ReadInt1 ( )

Read a 1 byte integer at the pointer (and move the pointer).

Definition at line 119 of file seqdbblob.cpp.

References m_ReadOffset.

◆ ReadInt1() [2/2]

int CBlastDbBlob::ReadInt1 ( int  offset) const

Read a 1 byte integer from the given offset.

Parameters
offThe offset from which to read the integer.
Returns
The 1 byte value read from the data.

Definition at line 124 of file seqdbblob.cpp.

References offset.

◆ ReadInt2() [1/2]

int CBlastDbBlob::ReadInt2 ( )

Read a 2 byte integer at the pointer (and move the pointer).

Definition at line 129 of file seqdbblob.cpp.

References m_ReadOffset.

◆ ReadInt2() [2/2]

int CBlastDbBlob::ReadInt2 ( int  offset) const

Read a 2 byte integer from the given offset.

Parameters
offThe offset from which to read the integer.
Returns
The 2 byte value read from the data.

Definition at line 134 of file seqdbblob.cpp.

References offset.

◆ ReadInt4() [1/2]

Int4 CBlastDbBlob::ReadInt4 ( )

Read a 4 byte integer at the pointer (and move the pointer).

Definition at line 139 of file seqdbblob.cpp.

References m_ReadOffset.

Referenced by SReadInt4::Read(), CSeqDBColumn::x_ReadFields(), and CSeqDBGiMask::x_ReadFields().

◆ ReadInt4() [2/2]

Int4 CBlastDbBlob::ReadInt4 ( int  offset) const

Read a 4 byte integer from the given offset.

Parameters
offThe offset from which to read the integer.
Returns
The four byte value read from the data.

Definition at line 144 of file seqdbblob.cpp.

References offset.

◆ ReadInt8() [1/2]

Int8 CBlastDbBlob::ReadInt8 ( )

Read an 8 byte integer at the pointer (and move the pointer).

Definition at line 149 of file seqdbblob.cpp.

References m_ReadOffset.

Referenced by CSeqDBColumn::x_ReadFields().

◆ ReadInt8() [2/2]

Int8 CBlastDbBlob::ReadInt8 ( int  offset) const

Read an 8 byte integer from the given offset.

Parameters
offThe offset from which to read the integer.
Returns
The eight byte value read from the data.

Definition at line 154 of file seqdbblob.cpp.

References offset.

◆ ReadRaw()

const char * CBlastDbBlob::ReadRaw ( int  size)

Read raw data (moving the read pointer).

Parameters
sizeNumber of bytes to move the pointer.

Definition at line 416 of file seqdbblob.cpp.

References m_ReadOffset, ncbi::grid::netcache::search::fields::size, and x_ReadRaw().

Referenced by SReadInt4::Read().

◆ ReadString() [1/2]

CTempString CBlastDbBlob::ReadString ( EStringFormat  fmt)

Read string data from the blob (moving the read pointer).

Parameters
strThe string to read.
fmtString termination criteria.
Returns
The number of bytes read.

Definition at line 159 of file seqdbblob.cpp.

References m_ReadOffset, and x_ReadString().

Referenced by SkipPadBytes(), CSeqDBColumn::x_ReadFields(), CSeqDBGiMask::x_ReadFields(), and CSeqDBColumn::x_ReadMetaData().

◆ ReadString() [2/2]

CTempString CBlastDbBlob::ReadString ( EStringFormat  fmt,
int  offset 
) const

Read string data from the blob at a given offset.

Parameters
strThe string to read.
fmtString termination criteria.
offsetThe offset to read from.
Returns
The number of bytes read.

Definition at line 164 of file seqdbblob.cpp.

References offset, and x_ReadString().

◆ ReadVarInt() [1/2]

Int8 CBlastDbBlob::ReadVarInt ( )

Read a variable length integer from the blob.

Parameters
xThe integer to read.
Returns
The number of bytes read.

Definition at line 82 of file seqdbblob.cpp.

References m_ReadOffset, and x_ReadVarInt().

Referenced by CSeqDBColumn::x_ReadMetaData().

◆ ReadVarInt() [2/2]

Int8 CBlastDbBlob::ReadVarInt ( int  offset) const

Read a variable length integer from the blob.

Parameters
xThe integer to read.
offsetThe offset to read the integer at.
Returns
The number of bytes read.

Definition at line 87 of file seqdbblob.cpp.

References offset, and x_ReadVarInt().

◆ ReferTo() [1/2]

void CBlastDbBlob::ReferTo ( CTempString  data)

Refer to an existing memory area.

This method causes this blob to refer to an existing area of memory without copying it. The caller should guarantee that the referenced data is valid until past the last read of the data. If such a guarantee is not possible, then Clear() and WriteRaw() can be substituted (at the cost of an additional copy operation). Alternately, the two-argument ReferTo() operation can be used to provides `lifetime' management.

Parameters
dataSpecifies the referenced memory region.

Definition at line 68 of file seqdbblob.cpp.

References data, m_DataRef, m_Lifetime, m_Owner, and CRef< C, Locker >::Reset().

Referenced by CSeqDBGiMask::s_GetFileRange(), and CSeqDBColumn::x_GetFileRange().

◆ ReferTo() [2/2]

void CBlastDbBlob::ReferTo ( CTempString  data,
CRef< CObject lifetime 
)

Refer to an existing memory area.

This method causes this blob to refer to an existing area of memory without copying it. This version allows the caller to specify a CObject that maintains the lifetime of the memory region. This object will keep a reference to the CObject as long as it references the specified memory region, after which the CObject should be released. The specified CObject should be allocated on the heap.

Parameters
dataSpecifies the referenced memory region.
lifetimeThe lifetime management object.

Definition at line 75 of file seqdbblob.cpp.

References data, m_DataRef, m_Lifetime, and m_Owner.

◆ SeekRead()

void CBlastDbBlob::SeekRead ( int  offset)

Move the read pointer to a specific location.

Parameters
offsetThe new read offset.

Definition at line 547 of file seqdbblob.cpp.

References m_ReadOffset, and offset.

Referenced by s_ReadRanges().

◆ SeekWrite()

void CBlastDbBlob::SeekWrite ( int  offset)

Seek write pointer to a specific location.

Parameters
offsetThe new write offset.

Definition at line 542 of file seqdbblob.cpp.

References m_WriteOffset, and offset.

Referenced by CWriteDB_ColumnIndex::x_BuildHeaderFields().

◆ Size()

int CBlastDbBlob::Size ( void  ) const

◆ SkipPadBytes()

void CBlastDbBlob::SkipPadBytes ( int  align,
EPadding  fmt 
)

Align the offset by skipping bytes.

This works just like WritePadBytes, but verifies that the pad bytes exist and have the correct values, and skips over them, rather than writing them. If fmt is eString, the alignment value is ignored.

Parameters
alignPad to a multiple of this size.
fmtString termination criteria.

Definition at line 590 of file seqdbblob.cpp.

References _ASSERT, eNUL, eSimple, eString, i, int, m_ReadOffset, ReadString(), SEQDB_FILE_ASSERT, tmp, and x_ReadRaw().

Referenced by CSeqDBColumn::x_ReadMetaData().

◆ Str()

CTempString CBlastDbBlob::Str ( ) const

◆ VarIntSize()

int CBlastDbBlob::VarIntSize ( Int8  x)
static

Compute bytes used for a variable length integer.

Parameters
xThe integer value.
Returns
The number of bytes that would be written.

Definition at line 285 of file seqdbblob.cpp.

Referenced by CWriteDB_ColumnIndex::AddMetaData().

◆ WriteInt1() [1/2]

void CBlastDbBlob::WriteInt1 ( int  x)

Write a 1 byte integer to the blob.

Parameters
xThe integer to write.

Definition at line 303 of file seqdbblob.cpp.

References NULL.

◆ WriteInt1() [2/2]

void CBlastDbBlob::WriteInt1 ( int  x,
int  offset 
)

Write a 1 byte integer to the blob.

Parameters
xThe integer to write.
offsetThe offset to write the integer at.

Definition at line 308 of file seqdbblob.cpp.

References offset.

◆ WriteInt1_LE() [1/2]

void CBlastDbBlob::WriteInt1_LE ( int  x)

Definition at line 343 of file seqdbblob.cpp.

References NULL.

◆ WriteInt1_LE() [2/2]

void CBlastDbBlob::WriteInt1_LE ( int  x,
int  offset 
)

Definition at line 348 of file seqdbblob.cpp.

References offset.

◆ WriteInt2() [1/2]

void CBlastDbBlob::WriteInt2 ( int  x)

Write a 1 byte integer to the blob.

Parameters
xThe integer to write.

Definition at line 313 of file seqdbblob.cpp.

References NULL.

◆ WriteInt2() [2/2]

void CBlastDbBlob::WriteInt2 ( int  x,
int  offset 
)

Write a 1 byte integer to the blob.

Parameters
xThe integer to write.
offsetThe offset to write the integer at.

Definition at line 318 of file seqdbblob.cpp.

References offset.

◆ WriteInt2_LE() [1/2]

void CBlastDbBlob::WriteInt2_LE ( int  x)

Definition at line 353 of file seqdbblob.cpp.

References NULL.

◆ WriteInt2_LE() [2/2]

void CBlastDbBlob::WriteInt2_LE ( int  x,
int  offset 
)

Definition at line 358 of file seqdbblob.cpp.

References offset.

◆ WriteInt4() [1/2]

void CBlastDbBlob::WriteInt4 ( Int4  x)

◆ WriteInt4() [2/2]

void CBlastDbBlob::WriteInt4 ( Int4  x,
int  offset 
)

Write a 4 byte integer into the blob at a given offset.

Parameters
xThe integer to write.
offsetThe offset to write the integer at.

Definition at line 328 of file seqdbblob.cpp.

References offset.

◆ WriteInt4_LE() [1/2]

void CBlastDbBlob::WriteInt4_LE ( Int4  x)

◆ WriteInt4_LE() [2/2]

void CBlastDbBlob::WriteInt4_LE ( Int4  x,
int  offset 
)

Definition at line 368 of file seqdbblob.cpp.

References offset.

◆ WriteInt8() [1/2]

void CBlastDbBlob::WriteInt8 ( Int8  x)

Write an 8 byte integer to the blob.

Parameters
xThe integer to write.

Definition at line 333 of file seqdbblob.cpp.

References NULL.

Referenced by CWriteDB_ColumnIndex::x_BuildHeaderFields().

◆ WriteInt8() [2/2]

void CBlastDbBlob::WriteInt8 ( Int8  x,
int  offset 
)

Write an 8 byte integer into the blob at a given offset.

Parameters
xThe integer to write.
offsetThe offset to write the integer at.

Definition at line 338 of file seqdbblob.cpp.

References offset.

◆ WriteInt8_LE() [1/2]

void CBlastDbBlob::WriteInt8_LE ( Int8  x)

Definition at line 373 of file seqdbblob.cpp.

References NULL.

◆ WriteInt8_LE() [2/2]

void CBlastDbBlob::WriteInt8_LE ( Int8  x,
int  offset 
)

Definition at line 378 of file seqdbblob.cpp.

References offset.

◆ WritePadBytes()

void CBlastDbBlob::WritePadBytes ( int  align,
EPadding  fmt 
)

Align the offset by writing pad bytes.

One of two padding methods is used. If eSimple is specified, zero or more NUL bytes are written. This uses less overhead but readers of the blob need to know the alignment to read fields found after the padding. If eString is specified, a normal string write is used with eNUL termination and a string that will result in the requested alignment. This is self describing but requires at least one byte.

Parameters
alignPad to a multiple of this size.
fmtString termination criteria.

Definition at line 562 of file seqdbblob.cpp.

References _ASSERT, eSimple, i, m_WriteOffset, NULL, pad(), tmp, and x_WriteRaw().

Referenced by CWriteDB_Impl::SetMaskData(), CWriteDB_GiMaskIndex::x_BuildHeaderFields(), and CWriteDB_ColumnIndex::x_BuildHeaderStrings().

◆ WriteRaw() [1/2]

void CBlastDbBlob::WriteRaw ( const char *  begin,
int  size 
)

Write raw data to the blob (moving the write pointer).

Parameters
beginPointer to the start of the data.
sizeNumber of bytes to copy.

Definition at line 421 of file seqdbblob.cpp.

References NULL, ncbi::grid::netcache::search::fields::size, and x_WriteRaw().

Referenced by CBuildDatabase::AddSequences().

◆ WriteRaw() [2/2]

void CBlastDbBlob::WriteRaw ( const char *  begin,
int  size,
int  offset 
)

Write raw data to the blob at the given offset.

Parameters
beginPointer to the start of the data.
sizeNumber of bytes to copy.
offsetLocation to write data at.

Definition at line 426 of file seqdbblob.cpp.

References offset, ncbi::grid::netcache::search::fields::size, and x_WriteRaw().

◆ WriteString() [1/2]

int CBlastDbBlob::WriteString ( CTempString  str,
EStringFormat  fmt 
)

Write string data to the blob.

Parameters
strThe string to write.
fmtString termination criteria.
Returns
The number of bytes written.

Definition at line 383 of file seqdbblob.cpp.

References NULL, str(), and x_WriteString().

Referenced by BOOST_AUTO_TEST_CASE(), CWriteDB_GiMaskIndex::x_BuildHeaderFields(), CWriteDB_ColumnIndex::x_BuildHeaderStrings(), and CWriteDB_ColumnIndex::x_BuildMetaData().

◆ WriteString() [2/2]

int CBlastDbBlob::WriteString ( CTempString  str,
EStringFormat  fmt,
int  offset 
)

Write string data to the blob at a specific offset.

Parameters
strThe string to write.
fmtString termination criteria.
offsetThe offset to write at.
Returns
The number of bytes written.

Definition at line 388 of file seqdbblob.cpp.

References offset, str(), and x_WriteString().

◆ WriteVarInt() [1/2]

int CBlastDbBlob::WriteVarInt ( Int8  x)

Write a variable length integer to the blob.

Parameters
xThe integer to write.
Returns
The number of bytes written.

Definition at line 243 of file seqdbblob.cpp.

References NULL, and x_WriteVarInt().

Referenced by CWriteDB_ColumnIndex::x_BuildMetaData().

◆ WriteVarInt() [2/2]

int CBlastDbBlob::WriteVarInt ( Int8  x,
int  offset 
)

Write a variable length integer to the blob.

Parameters
xThe integer to write.
offsetThe offset to write the integer at.
Returns
The number of bytes written.

Definition at line 248 of file seqdbblob.cpp.

References offset, and x_WriteVarInt().

◆ x_Copy()

void CBlastDbBlob::x_Copy ( int  total)
private

Copy referenced data to owned data.

This handles the Copy part of Copy On Write. To reduce the allocation count, the `total' parameter can be used to request the total number of bytes needed. If `total' is less than the current size, the current size will be used instead.

Parameters
totalTotal space needed.

Definition at line 478 of file seqdbblob.cpp.

References _ASSERT, CTempString::data(), m_DataHere, m_DataRef, m_Lifetime, m_Owner, CRef< C, Locker >::Reset(), and CTempString::size().

Referenced by x_Reserve().

◆ x_ReadIntFixed()

template<typename TValue , int TBytes>
TValue CBlastDbBlob::x_ReadIntFixed ( int offsetp) const
inlineprivate

Read a fixed length integer.

Parameters
offsetpThe offset to read at.
Returns
The value that was read.

Definition at line 389 of file seqdbblob.hpp.

References _ASSERT, buf, and x_ReadRaw().

◆ x_ReadRaw()

const char * CBlastDbBlob::x_ReadRaw ( int  size,
int offsetp 
) const
private

Read raw bytes from a given offset.

This method checks that enough bytes exist, updates the read pointer, and returns a pointer to the given data. Unlike with x_WriteRaw, do not use NULL for the read pointer, instead the internal read pointer should be provided if the user did not provide one. This method will throw an exception if there is not enough data.

Parameters
sizeNumber of bytes needed by caller.
offsetpOffset from which to read (should not be NULL).
Returns
Pointer to beginning of requested data.

Definition at line 209 of file seqdbblob.cpp.

References _ASSERT, CTempString::data(), NCBI_THROW, ncbi::grid::netcache::search::fields::size, CTempString::size(), and Str().

Referenced by ReadRaw(), SkipPadBytes(), x_ReadIntFixed(), and x_ReadString().

◆ x_ReadString()

CTempString CBlastDbBlob::x_ReadString ( EStringFormat  fmt,
int offsetp 
) const
private

Read string data from the blob.

Parameters
fmtString termination criteria.
offsetThe offset to read at (should not be NULL).
Returns
The string that was read.

Definition at line 169 of file seqdbblob.cpp.

References CTempString::data(), eNUL, eSize4, eSizeVar, i, NCBI_THROW, CTempString::size(), Str(), x_ReadRaw(), and x_ReadVarInt().

Referenced by ReadString().

◆ x_ReadVarInt()

Int8 CBlastDbBlob::x_ReadVarInt ( int offsetp) const
private

Read a variable length integer from the buffer.

Parameters
offsetpThe offset to read at (should not be NULL).
Returns
The integer value.

Definition at line 92 of file seqdbblob.cpp.

References all, i, NCBI_THROW, and Str().

Referenced by ReadVarInt(), and x_ReadString().

◆ x_Reserve()

void CBlastDbBlob::x_Reserve ( int  size)
private

Write raw bytes as a CTempString.

Parameters
dataString data to write.

Definition at line 497 of file seqdbblob.cpp.

References m_DataHere, m_Owner, and x_Copy().

Referenced by x_WriteRaw().

◆ x_WriteIntFixed()

template<typename TValue , int TBytes>
void CBlastDbBlob::x_WriteIntFixed ( TValue  x,
int offsetp 
)
inlineprivate

Write a fixed length integer in big endian.

Parameters
xThe value to write.
offsetpThe offset at which to write.

Definition at line 429 of file seqdbblob.hpp.

References _ASSERT, buf, and x_WriteRaw().

◆ x_WriteIntFixed_LE()

template<typename TValue , int TBytes>
void CBlastDbBlob::x_WriteIntFixed_LE ( TValue  x,
int offsetp 
)
inlineprivate

Write a fixed length integer in small endian.

Parameters
xThe value to write.
offsetpThe offset at which to write.

Definition at line 458 of file seqdbblob.hpp.

References _ASSERT, buf, and x_WriteRaw().

◆ x_WriteRaw()

void CBlastDbBlob::x_WriteRaw ( const char *  ptr,
int  size,
int offsetp 
)
private

Write raw bytes as ptr + size at a given offset.

Parameters
dataString data to write.
sizeNumber of bytes to write.
offsetpOffset to write at (NULL means use write pointer).

Definition at line 431 of file seqdbblob.cpp.

References _ASSERT, data, int, len, m_DataHere, m_Owner, m_WriteOffset, min(), NULL, ncbi::grid::netcache::search::fields::size, and x_Reserve().

Referenced by WritePadBytes(), WriteRaw(), x_WriteIntFixed(), x_WriteIntFixed_LE(), x_WriteString(), and x_WriteVarInt().

◆ x_WriteString()

int CBlastDbBlob::x_WriteString ( CTempString  str,
EStringFormat  fmt,
int offsetp 
)
private

Write string data to the blob.

Parameters
strThe string to write.
fmtString termination criteria.
offsetThe offset to write at (NULL to use write pointer.)
Returns
The number of bytes written.

Definition at line 393 of file seqdbblob.cpp.

References buf, eNUL, eSize4, eSizeVar, m_WriteOffset, str(), x_WriteRaw(), and x_WriteVarInt().

Referenced by WriteString().

◆ x_WriteVarInt()

int CBlastDbBlob::x_WriteVarInt ( Int8  x,
int offsetp 
)
private

Write a variable length integer into the buffer.

Parameters
xThe integer to write.
offsetpThe offset to write at (or NULL).
Returns
The number of bytes written.

Definition at line 253 of file seqdbblob.cpp.

References _ASSERT, buf, m_WriteOffset, and x_WriteRaw().

Referenced by WriteVarInt(), and x_WriteString().

Member Data Documentation

◆ m_DataHere

vector<char> CBlastDbBlob::m_DataHere
private

Data owned by this object.

Definition at line 498 of file seqdbblob.hpp.

Referenced by CBlastDbBlob(), Clear(), Size(), Str(), x_Copy(), x_Reserve(), and x_WriteRaw().

◆ m_DataRef

CTempString CBlastDbBlob::m_DataRef
private

Non-owned data (only used for `read' streams).

Definition at line 501 of file seqdbblob.hpp.

Referenced by CBlastDbBlob(), Clear(), ReferTo(), Size(), Str(), and x_Copy().

◆ m_Lifetime

CRef<CObject> CBlastDbBlob::m_Lifetime
private

Lifetime maintenance object for referenced data.

Definition at line 504 of file seqdbblob.hpp.

Referenced by Clear(), ReferTo(), and x_Copy().

◆ m_Owner

bool CBlastDbBlob::m_Owner
private

True if this object owns the target data.

Definition at line 489 of file seqdbblob.hpp.

Referenced by CBlastDbBlob(), Clear(), ReferTo(), Size(), Str(), x_Copy(), x_Reserve(), and x_WriteRaw().

◆ m_ReadOffset

int CBlastDbBlob::m_ReadOffset
private

The `read pointer' for stream-like access.

Definition at line 492 of file seqdbblob.hpp.

Referenced by Clear(), GetReadOffset(), ReadInt1(), ReadInt2(), ReadInt4(), ReadInt8(), ReadRaw(), ReadString(), ReadVarInt(), SeekRead(), and SkipPadBytes().

◆ m_WriteOffset

int CBlastDbBlob::m_WriteOffset
private

The `write pointer' for stream-like access.

Definition at line 495 of file seqdbblob.hpp.

Referenced by Clear(), GetWriteOffset(), SeekWrite(), WritePadBytes(), x_WriteRaw(), x_WriteString(), and x_WriteVarInt().


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:57:21 2024 by modify_doxy.py rev. 669887