NCBI C++ ToolKit
Classes | Macros | Functions | Variables
compound_id_v0.cpp File Reference

A simple implementation of CompoundID packing/unpacking procedures. More...

#include <ncbi_pch.hpp>
#include "compound_id_impl.hpp"
#include <connect/ncbi_socket.hpp>
+ Include dependency graph for compound_id_v0.cpp:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  SCodeRec
 
struct  SIDPackingBuffer
 
struct  SIDUnpacking
 

Macros

#define CIT_ID_FIELD_CODE   '!'
 
#define CIT_INTEGER_FIELD_CODE   '+' or '-'
 
#define CIT_SERVICE_NAME_FIELD_CODE   'S'
 
#define CIT_DATABASE_NAME_FIELD_CODE   'D'
 
#define CIT_TIMESTAMP_FIELD_CODE   '@'
 
#define CIT_RANDOM_FIELD_CODE   'R'
 
#define CIT_IPV4_ADDRESS_FIELD_CODE   'A'
 
#define CIT_HOST_FIELD_CODE   'H'
 
#define CIT_PORT_FIELD_CODE   ':'
 
#define CIT_IPV4_SOCK_ADDR_FIELD_CODE   '&'
 
#define CIT_OBJECTREF_FIELD_CODE   '/'
 
#define CIT_STRING_FIELD_CODE   '"'
 
#define CIT_BOOLEAN_FIELD_CODE   'Y' or 'N'
 
#define CIT_FLAGS_FIELD_CODE   '|'
 
#define CIT_LABEL_FIELD_CODE   '$'
 
#define CIT_CUE_FIELD_CODE   '#'
 
#define CIT_SEQ_ID_FIELD_CODE   'Q'
 
#define CIT_TAX_ID_FIELD_CODE   'X'
 
#define CIT_NESTED_CID_FIELD_CODE   '{' and '}'
 
#define REC_DATA
 
#define REC(length, bits)   {length, (bits << 8)}
 

Functions

unsigned g_PackInteger (void *dst, size_t dst_size, Uint8 number)
 Save a 8-byte unsigned integer to a variable-length array of up to 9 bytes. More...
 
unsigned g_UnpackInteger (const void *src, size_t src_size, Uint8 *number)
 Unpack an unsigned integer from a byte array prepared by g_PackInteger(). More...
 

Variables

static const char s_TypePrefix [eCIT_NumberOfTypes]
 
struct SCodeRec s_CodeRec [128] = { { 2 , ( 0x00 << 8)}, { 2 , ( 0x01 << 8)}, { 2 , ( 0x02 << 8)}, { 2 , ( 0x03 << 8)}, { 2 , ( 0x04 << 8)}, { 2 , ( 0x05 << 8)}, { 2 , ( 0x06 << 8)}, { 2 , ( 0x07 << 8)}, { 2 , ( 0x08 << 8)}, { 2 , ( 0x09 << 8)}, { 2 , ( 0x0A << 8)}, { 2 , ( 0x0B << 8)}, { 2 , ( 0x0C << 8)}, { 2 , ( 0x0D << 8)}, { 2 , ( 0x0E << 8)}, { 2 , ( 0x0F << 8)}, { 2 , ( 0x10 << 8)}, { 2 , ( 0x11 << 8)}, { 2 , ( 0x12 << 8)}, { 2 , ( 0x13 << 8)}, { 2 , ( 0x14 << 8)}, { 2 , ( 0x15 << 8)}, { 2 , ( 0x16 << 8)}, { 2 , ( 0x17 << 8)}, { 2 , ( 0x18 << 8)}, { 2 , ( 0x19 << 8)}, { 2 , ( 0x1A << 8)}, { 2 , ( 0x1B << 8)}, { 2 , ( 0x1C << 8)}, { 2 , ( 0x1D << 8)}, { 2 , ( 0x1E << 8)}, { 2 , ( 0x1F << 8)}, { 2 , ( 0x20 << 8)}, { 2 , ( 0x21 << 8)}, { 2 , ( 0x22 << 8)}, { 2 , ( 0x23 << 8)}, { 2 , ( 0x24 << 8)}, { 2 , ( 0x25 << 8)}, { 2 , ( 0x26 << 8)}, { 2 , ( 0x27 << 8)}, { 2 , ( 0x28 << 8)}, { 2 , ( 0x29 << 8)}, { 2 , ( 0x2A << 8)}, { 2 , ( 0x2B << 8)}, { 2 , ( 0x2C << 8)}, { 2 , ( 0x2D << 8)}, { 2 , ( 0x2E << 8)}, { 2 , ( 0x2F << 8)}, { 2 , ( 0x30 << 8)}, { 2 , ( 0x31 << 8)}, { 2 , ( 0x32 << 8)}, { 2 , ( 0x33 << 8)}, { 2 , ( 0x34 << 8)}, { 2 , ( 0x35 << 8)}, { 2 , ( 0x36 << 8)}, { 2 , ( 0x37 << 8)}, { 2 , ( 0x38 << 8)}, { 2 , ( 0x39 << 8)}, { 2 , ( 0x3A << 8)}, { 2 , ( 0x3B << 8)}, { 2 , ( 0x3C << 8)}, { 2 , ( 0x3D << 8)}, { 2 , ( 0x3E << 8)}, { 2 , ( 0x3F << 8)}, { 3 , ( 0x00 << 8)}, { 3 , ( 0x01 << 8)}, { 3 , ( 0x02 << 8)}, { 3 , ( 0x03 << 8)}, { 3 , ( 0x04 << 8)}, { 3 , ( 0x05 << 8)}, { 3 , ( 0x06 << 8)}, { 3 , ( 0x07 << 8)}, { 3 , ( 0x08 << 8)}, { 3 , ( 0x09 << 8)}, { 3 , ( 0x0A << 8)}, { 3 , ( 0x0B << 8)}, { 3 , ( 0x0C << 8)}, { 3 , ( 0x0D << 8)}, { 3 , ( 0x0E << 8)}, { 3 , ( 0x0F << 8)}, { 3 , ( 0x10 << 8)}, { 3 , ( 0x11 << 8)}, { 3 , ( 0x12 << 8)}, { 3 , ( 0x13 << 8)}, { 3 , ( 0x14 << 8)}, { 3 , ( 0x15 << 8)}, { 3 , ( 0x16 << 8)}, { 3 , ( 0x17 << 8)}, { 3 , ( 0x18 << 8)}, { 3 , ( 0x19 << 8)}, { 3 , ( 0x1A << 8)}, { 3 , ( 0x1B << 8)}, { 3 , ( 0x1C << 8)}, { 3 , ( 0x1D << 8)}, { 3 , ( 0x1E << 8)}, { 3 , ( 0x1F << 8)}, { 4 , ( 0x00 << 8)}, { 4 , ( 0x01 << 8)}, { 4 , ( 0x02 << 8)}, { 4 , ( 0x03 << 8)}, { 4 , ( 0x04 << 8)}, { 4 , ( 0x05 << 8)}, { 4 , ( 0x06 << 8)}, { 4 , ( 0x07 << 8)}, { 4 , ( 0x08 << 8)}, { 4 , ( 0x09 << 8)}, { 4 , ( 0x0A << 8)}, { 4 , ( 0x0B << 8)}, { 4 , ( 0x0C << 8)}, { 4 , ( 0x0D << 8)}, { 4 , ( 0x0E << 8)}, { 4 , ( 0x0F << 8)}, { 5 , ( 0x00 << 8)}, { 5 , ( 0x01 << 8)}, { 5 , ( 0x02 << 8)}, { 5 , ( 0x03 << 8)}, { 5 , ( 0x04 << 8)}, { 5 , ( 0x05 << 8)}, { 5 , ( 0x06 << 8)}, { 5 , ( 0x07 << 8)}, { 6 , ( 0x00 << 8)}, { 6 , ( 0x01 << 8)}, { 6 , ( 0x02 << 8)}, { 6 , ( 0x03 << 8)}, { 7 , ( 0x00 << 8)}, { 7 , ( 0x01 << 8)}, { 8 , ( 0x00 << 8)}, { 9 , ( 0x00 << 8)} }
 

Detailed Description

A simple implementation of CompoundID packing/unpacking procedures.

Definition in file compound_id_v0.cpp.

Macro Definition Documentation

◆ CIT_BOOLEAN_FIELD_CODE

#define CIT_BOOLEAN_FIELD_CODE   'Y' or 'N'

Definition at line 57 of file compound_id_v0.cpp.

◆ CIT_CUE_FIELD_CODE

#define CIT_CUE_FIELD_CODE   '#'

Definition at line 60 of file compound_id_v0.cpp.

◆ CIT_DATABASE_NAME_FIELD_CODE

#define CIT_DATABASE_NAME_FIELD_CODE   'D'

Definition at line 48 of file compound_id_v0.cpp.

◆ CIT_FLAGS_FIELD_CODE

#define CIT_FLAGS_FIELD_CODE   '|'

Definition at line 58 of file compound_id_v0.cpp.

◆ CIT_HOST_FIELD_CODE

#define CIT_HOST_FIELD_CODE   'H'

Definition at line 52 of file compound_id_v0.cpp.

◆ CIT_ID_FIELD_CODE

#define CIT_ID_FIELD_CODE   '!'

Definition at line 45 of file compound_id_v0.cpp.

◆ CIT_INTEGER_FIELD_CODE

#define CIT_INTEGER_FIELD_CODE   '+' or '-'

Definition at line 46 of file compound_id_v0.cpp.

◆ CIT_IPV4_ADDRESS_FIELD_CODE

#define CIT_IPV4_ADDRESS_FIELD_CODE   'A'

Definition at line 51 of file compound_id_v0.cpp.

◆ CIT_IPV4_SOCK_ADDR_FIELD_CODE

#define CIT_IPV4_SOCK_ADDR_FIELD_CODE   '&'

Definition at line 54 of file compound_id_v0.cpp.

◆ CIT_LABEL_FIELD_CODE

#define CIT_LABEL_FIELD_CODE   '$'

Definition at line 59 of file compound_id_v0.cpp.

◆ CIT_NESTED_CID_FIELD_CODE

#define CIT_NESTED_CID_FIELD_CODE   '{' and '}'

Definition at line 63 of file compound_id_v0.cpp.

◆ CIT_OBJECTREF_FIELD_CODE

#define CIT_OBJECTREF_FIELD_CODE   '/'

Definition at line 55 of file compound_id_v0.cpp.

◆ CIT_PORT_FIELD_CODE

#define CIT_PORT_FIELD_CODE   ':'

Definition at line 53 of file compound_id_v0.cpp.

◆ CIT_RANDOM_FIELD_CODE

#define CIT_RANDOM_FIELD_CODE   'R'

Definition at line 50 of file compound_id_v0.cpp.

◆ CIT_SEQ_ID_FIELD_CODE

#define CIT_SEQ_ID_FIELD_CODE   'Q'

Definition at line 61 of file compound_id_v0.cpp.

◆ CIT_SERVICE_NAME_FIELD_CODE

#define CIT_SERVICE_NAME_FIELD_CODE   'S'

Definition at line 47 of file compound_id_v0.cpp.

◆ CIT_STRING_FIELD_CODE

#define CIT_STRING_FIELD_CODE   '"'

Definition at line 56 of file compound_id_v0.cpp.

◆ CIT_TAX_ID_FIELD_CODE

#define CIT_TAX_ID_FIELD_CODE   'X'

Definition at line 62 of file compound_id_v0.cpp.

◆ CIT_TIMESTAMP_FIELD_CODE

#define CIT_TIMESTAMP_FIELD_CODE   '@'

Definition at line 49 of file compound_id_v0.cpp.

◆ REC

#define REC (   length,
  bits 
)    {length, (bits << 8)}

Definition at line 173 of file compound_id_v0.cpp.

◆ REC_DATA

#define REC_DATA
Value:
{ \
REC(2, 0x00), REC(2, 0x01), REC(2, 0x02), REC(2, 0x03), REC(2, 0x04), \
REC(2, 0x05), REC(2, 0x06), REC(2, 0x07), REC(2, 0x08), REC(2, 0x09), \
REC(2, 0x0A), REC(2, 0x0B), REC(2, 0x0C), REC(2, 0x0D), REC(2, 0x0E), \
REC(2, 0x0F), REC(2, 0x10), REC(2, 0x11), REC(2, 0x12), REC(2, 0x13), \
REC(2, 0x14), REC(2, 0x15), REC(2, 0x16), REC(2, 0x17), REC(2, 0x18), \
REC(2, 0x19), REC(2, 0x1A), REC(2, 0x1B), REC(2, 0x1C), REC(2, 0x1D), \
REC(2, 0x1E), REC(2, 0x1F), REC(2, 0x20), REC(2, 0x21), REC(2, 0x22), \
REC(2, 0x23), REC(2, 0x24), REC(2, 0x25), REC(2, 0x26), REC(2, 0x27), \
REC(2, 0x28), REC(2, 0x29), REC(2, 0x2A), REC(2, 0x2B), REC(2, 0x2C), \
REC(2, 0x2D), REC(2, 0x2E), REC(2, 0x2F), REC(2, 0x30), REC(2, 0x31), \
REC(2, 0x32), REC(2, 0x33), REC(2, 0x34), REC(2, 0x35), REC(2, 0x36), \
REC(2, 0x37), REC(2, 0x38), REC(2, 0x39), REC(2, 0x3A), REC(2, 0x3B), \
REC(2, 0x3C), REC(2, 0x3D), REC(2, 0x3E), REC(2, 0x3F), REC(3, 0x00), \
REC(3, 0x01), REC(3, 0x02), REC(3, 0x03), REC(3, 0x04), REC(3, 0x05), \
REC(3, 0x06), REC(3, 0x07), REC(3, 0x08), REC(3, 0x09), REC(3, 0x0A), \
REC(3, 0x0B), REC(3, 0x0C), REC(3, 0x0D), REC(3, 0x0E), REC(3, 0x0F), \
REC(3, 0x10), REC(3, 0x11), REC(3, 0x12), REC(3, 0x13), REC(3, 0x14), \
REC(3, 0x15), REC(3, 0x16), REC(3, 0x17), REC(3, 0x18), REC(3, 0x19), \
REC(3, 0x1A), REC(3, 0x1B), REC(3, 0x1C), REC(3, 0x1D), REC(3, 0x1E), \
REC(3, 0x1F), REC(4, 0x00), REC(4, 0x01), REC(4, 0x02), REC(4, 0x03), \
REC(4, 0x04), REC(4, 0x05), REC(4, 0x06), REC(4, 0x07), REC(4, 0x08), \
REC(4, 0x09), REC(4, 0x0A), REC(4, 0x0B), REC(4, 0x0C), REC(4, 0x0D), \
REC(4, 0x0E), REC(4, 0x0F), REC(5, 0x00), REC(5, 0x01), REC(5, 0x02), \
REC(5, 0x03), REC(5, 0x04), REC(5, 0x05), REC(5, 0x06), REC(5, 0x07), \
REC(6, 0x00), REC(6, 0x01), REC(6, 0x02), REC(6, 0x03), REC(7, 0x00), \
REC(7, 0x01), REC(8, 0x00), REC(9, 0x00) \
}
#define REC(length, bits)

Definition at line 143 of file compound_id_v0.cpp.

Function Documentation

◆ g_PackInteger()

unsigned g_PackInteger ( void *  dst,
size_t  dst_size,
Uint8  number 
)

Save a 8-byte unsigned integer to a variable-length array of up to 9 bytes.

Parameters
dstPointer to the receiving buffer.
dst_sizeSize of the receiving buffer in bytes. If the buffer is too small to store a particular number, the buffer will not be changed, but the function will return the value that would have been returned if the buffer was big enough. The caller must check whether the returned value is greater than 'dst_size'. This, of course, is not necessary if 'dst_size' is guaranteed to be at least 9 bytes long, which is the maximum possible packed length of an 8-byte number.
numberThe integer to pack.
Returns
The number of bytes stored in the 'dst' buffer. Or the number of bytes that would have been stored if the buffer was big enough (see the dscription of 'dst_size').
See also
g_UnpackInteger

Definition at line 111 of file compound_id_v0.cpp.

◆ g_UnpackInteger()

unsigned g_UnpackInteger ( const void *  src,
size_t  src_size,
Uint8 number 
)

Unpack an unsigned integer from a byte array prepared by g_PackInteger().

Parameters
srcThe source byte array.
src_sizeNumber of bytes available in 'src'.
numberPointer to a variable where the integer originally passed to g_PackInteger() will be stored. If 'src_size' bytes is not enough to reconstitute the integer, the variable will not be changed.
Returns
The length of the packed integer stored in 'src' regardless of whether the integer was actually unpacked or not (in case if 'src_size' was less that the value that g_PackInteger() originally returned, see the description of the 'number' argument).
See also
g_PackInteger

Definition at line 203 of file compound_id_v0.cpp.

Variable Documentation

◆ s_CodeRec

struct SCodeRec s_CodeRec[128] = { { 2 , ( 0x00 << 8)}, { 2 , ( 0x01 << 8)}, { 2 , ( 0x02 << 8)}, { 2 , ( 0x03 << 8)}, { 2 , ( 0x04 << 8)}, { 2 , ( 0x05 << 8)}, { 2 , ( 0x06 << 8)}, { 2 , ( 0x07 << 8)}, { 2 , ( 0x08 << 8)}, { 2 , ( 0x09 << 8)}, { 2 , ( 0x0A << 8)}, { 2 , ( 0x0B << 8)}, { 2 , ( 0x0C << 8)}, { 2 , ( 0x0D << 8)}, { 2 , ( 0x0E << 8)}, { 2 , ( 0x0F << 8)}, { 2 , ( 0x10 << 8)}, { 2 , ( 0x11 << 8)}, { 2 , ( 0x12 << 8)}, { 2 , ( 0x13 << 8)}, { 2 , ( 0x14 << 8)}, { 2 , ( 0x15 << 8)}, { 2 , ( 0x16 << 8)}, { 2 , ( 0x17 << 8)}, { 2 , ( 0x18 << 8)}, { 2 , ( 0x19 << 8)}, { 2 , ( 0x1A << 8)}, { 2 , ( 0x1B << 8)}, { 2 , ( 0x1C << 8)}, { 2 , ( 0x1D << 8)}, { 2 , ( 0x1E << 8)}, { 2 , ( 0x1F << 8)}, { 2 , ( 0x20 << 8)}, { 2 , ( 0x21 << 8)}, { 2 , ( 0x22 << 8)}, { 2 , ( 0x23 << 8)}, { 2 , ( 0x24 << 8)}, { 2 , ( 0x25 << 8)}, { 2 , ( 0x26 << 8)}, { 2 , ( 0x27 << 8)}, { 2 , ( 0x28 << 8)}, { 2 , ( 0x29 << 8)}, { 2 , ( 0x2A << 8)}, { 2 , ( 0x2B << 8)}, { 2 , ( 0x2C << 8)}, { 2 , ( 0x2D << 8)}, { 2 , ( 0x2E << 8)}, { 2 , ( 0x2F << 8)}, { 2 , ( 0x30 << 8)}, { 2 , ( 0x31 << 8)}, { 2 , ( 0x32 << 8)}, { 2 , ( 0x33 << 8)}, { 2 , ( 0x34 << 8)}, { 2 , ( 0x35 << 8)}, { 2 , ( 0x36 << 8)}, { 2 , ( 0x37 << 8)}, { 2 , ( 0x38 << 8)}, { 2 , ( 0x39 << 8)}, { 2 , ( 0x3A << 8)}, { 2 , ( 0x3B << 8)}, { 2 , ( 0x3C << 8)}, { 2 , ( 0x3D << 8)}, { 2 , ( 0x3E << 8)}, { 2 , ( 0x3F << 8)}, { 3 , ( 0x00 << 8)}, { 3 , ( 0x01 << 8)}, { 3 , ( 0x02 << 8)}, { 3 , ( 0x03 << 8)}, { 3 , ( 0x04 << 8)}, { 3 , ( 0x05 << 8)}, { 3 , ( 0x06 << 8)}, { 3 , ( 0x07 << 8)}, { 3 , ( 0x08 << 8)}, { 3 , ( 0x09 << 8)}, { 3 , ( 0x0A << 8)}, { 3 , ( 0x0B << 8)}, { 3 , ( 0x0C << 8)}, { 3 , ( 0x0D << 8)}, { 3 , ( 0x0E << 8)}, { 3 , ( 0x0F << 8)}, { 3 , ( 0x10 << 8)}, { 3 , ( 0x11 << 8)}, { 3 , ( 0x12 << 8)}, { 3 , ( 0x13 << 8)}, { 3 , ( 0x14 << 8)}, { 3 , ( 0x15 << 8)}, { 3 , ( 0x16 << 8)}, { 3 , ( 0x17 << 8)}, { 3 , ( 0x18 << 8)}, { 3 , ( 0x19 << 8)}, { 3 , ( 0x1A << 8)}, { 3 , ( 0x1B << 8)}, { 3 , ( 0x1C << 8)}, { 3 , ( 0x1D << 8)}, { 3 , ( 0x1E << 8)}, { 3 , ( 0x1F << 8)}, { 4 , ( 0x00 << 8)}, { 4 , ( 0x01 << 8)}, { 4 , ( 0x02 << 8)}, { 4 , ( 0x03 << 8)}, { 4 , ( 0x04 << 8)}, { 4 , ( 0x05 << 8)}, { 4 , ( 0x06 << 8)}, { 4 , ( 0x07 << 8)}, { 4 , ( 0x08 << 8)}, { 4 , ( 0x09 << 8)}, { 4 , ( 0x0A << 8)}, { 4 , ( 0x0B << 8)}, { 4 , ( 0x0C << 8)}, { 4 , ( 0x0D << 8)}, { 4 , ( 0x0E << 8)}, { 4 , ( 0x0F << 8)}, { 5 , ( 0x00 << 8)}, { 5 , ( 0x01 << 8)}, { 5 , ( 0x02 << 8)}, { 5 , ( 0x03 << 8)}, { 5 , ( 0x04 << 8)}, { 5 , ( 0x05 << 8)}, { 5 , ( 0x06 << 8)}, { 5 , ( 0x07 << 8)}, { 6 , ( 0x00 << 8)}, { 6 , ( 0x01 << 8)}, { 6 , ( 0x02 << 8)}, { 6 , ( 0x03 << 8)}, { 7 , ( 0x00 << 8)}, { 7 , ( 0x01 << 8)}, { 8 , ( 0x00 << 8)}, { 9 , ( 0x00 << 8)} }

◆ s_TypePrefix

const char s_TypePrefix[eCIT_NumberOfTypes]
static
Initial value:
= {
'!' ,
0,
'S' ,
'D' ,
'@' ,
'R' ,
'A' ,
'H' ,
':' ,
'&' ,
'/' ,
'"' ,
0,
'|' ,
'$' ,
'#' ,
'Q' ,
'X' ,
0
}

Definition at line 65 of file compound_id_v0.cpp.

Modified on Sat Apr 20 12:21:51 2024 by modify_doxy.py rev. 669887