55 #define NCBI_USE_ERRCODE_X Serial_OStream
73 m_PreserveKeys(
false),
87 m_PreserveKeys(
false),
145 if (!
type->GetName().empty()) {
254 in.ReadStringStore(s);
301 string obj_name = obj.
GetName();
302 if (obj_name.empty()) {
306 if (obj_name.empty()) {
311 const vector<CSerialAttribInfoItem>& attlist = obj.
GetAttributes();
312 if (attlist.empty()) {
317 vector<CSerialAttribInfoItem>::const_iterator it;
318 for ( it = attlist.begin(); it != attlist.end(); ++it) {
331 in.ReadAnyContentObject(obj);
339 #if BITSTRING_AS_VECTOR
340 static const char ToHex[] =
"0123456789ABCDEF";
343 for ( CBitString::const_iterator
i = obj.begin(); !
done; ) {
355 CBitString::statistics st;
357 char*
buf = (
char*)
malloc(st.max_serialize_mem);
366 for (;
i < ilast; ++
i) {
495 if (
id.HasNotag() ||
id.IsAttlist()) {
497 if (
id.HasAnyContent()) {
508 auto tn = [
this]()->
const string& {
517 if (
id.HasAnyContent()) {
552 if (
id.HasNotag() ||
id.IsAttlist()) {
570 static const char*
const HEX =
"0123456789ABCDEF";
586 const char* bytes,
size_t length)
617 const size_t chunk_in = 57;
618 const size_t chunk_out = 80;
619 if (length > chunk_in &&
m_WrapAt != 0) {
622 char dst_buf[chunk_out];
623 size_t bytes_left = length;
624 size_t src_read=0, dst_written=0, line_len=0;
625 while (bytes_left > 0 && bytes_left <= length) {
627 dst_buf, chunk_out, &dst_written, &line_len);
629 bytes_left -= src_read;
631 if (bytes_left > 0 &&
m_WrapAt != 0) {
635 if (length > chunk_in &&
m_WrapAt != 0) {
642 while ( length-- > 0 ) {
664 while ( length-- > 0 ) {
705 const char* ,
size_t )
741 if ( (
unsigned int)c < 0x20 ||
745 unsigned hi = ch >> 4;
746 unsigned lo = ch & 0xF;
765 for ( string::const_iterator
t =
tmp.begin();
t !=
tmp.end(); ++
t ) {
774 for (
const char* src =
value.c_str(); *src; ++src) {
Serializable object that stores any combination of parsable data.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
size_type size() const noexcept
Returns bvector's capacity (number of bits it can store)
bvector_size_type size_type
enumerator first() const
Returns enumerator pointing on the first non-zero bit.
enumerator end() const
Returns enumerator pointing on the next bit after the last.
void calc_stat(struct bm::bvector< Alloc >::statistics *st) const noexcept
Calculates bitvector statistics.
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
static const char * str(char *buf, int n)
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
#define finite
Define value of finite (Is Finite).
const string & GetName(void) const
const string & FindNameEx(TEnumValueType value, bool allowBadValue) const
bool IsInteger(void) const
Check whether the type is defined as INTEGER in ASN.1 spec.
const CStringUTF8 & GetValue(void) const
Get normalized value.
const void * TConstObjectPtr
const string & GetName(void) const
Get local name.
const vector< CSerialAttribInfoItem > & GetAttributes(void) const
Get object attributes.
@ eStringTypeUTF8
UTF8-encoded string.
virtual void WriteString(const string &s, EStringType type=eStringTypeVisible) override
virtual void CopyStringStore(CObjectIStream &in) override
virtual void WriteFileHeader(TTypeInfo type) override
EBinaryDataFormat
formatting of binary data ('OCTET STRING', 'hexBinary', 'base64Binary')
void GetJsonpPadding(string *prefix, string *suffix) const
Get JSONP padding (prefix and suffix)
virtual void BeginContainerElement(TTypeInfo elementType) override
MLIOVIR void WriteClassMemberSpecialCase(const CMemberId &memberId, TTypeInfo memberType, TConstObjectPtr memberPtr, ESpecialCaseWrite how)
void WriteClassMember(const CConstObjectInfoMI &member)
void WriteDouble2(double data, unsigned digits)
virtual void WriteSeparator(void) override
virtual void EndContainer(void) override
EBinaryDataFormat GetBinaryDataFormat(void) const
Get formatting of binary data.
virtual void CopyAnyContentObject(CObjectIStream &in) override
virtual void WriteOtherEnd(TTypeInfo typeInfo) override
static TTypeInfo GetRealTypeInfo(TTypeInfo typeInfo)
virtual string GetPosition(void) const override
Get current stream position as string.
virtual void WriteAnyContentObject(const CAnyContentObject &obj) override
void WriteEscapedChar(char c, EEncoding enc_in)
virtual void EndBytes(const ByteBlock &block) override
#define ThrowError(flag, mess)
void SetJsonpMode(const string &function_name)
Set JSONP mode JSONP prefix will become "function_name(" JSONP suffix will become ");".
void WriteCustomBytes(const char *bytes, size_t length)
virtual void EndClass(void) override
virtual void EndChoice(void) override
bool IsCompressed(void) const
virtual ~CObjectOStreamJson(void)
Destructor.
virtual void WriteInt4(Int4 data) override
virtual void WriteNull(void) override
virtual void WriteUint8(Uint8 data) override
void x_WriteString(const string &value, EStringType type=eStringTypeVisible)
void WriteKeywordValue(const string &value)
EEncoding m_StringEncoding
virtual void BeginNamedType(TTypeInfo namedTypeInfo)
virtual void EndNamedType(void) override
void SetNotag(bool set=true)
void WriteEncodedChar(const char *&src, EStringType type)
void WriteMemberId(const CMemberId &id)
TFrame & FetchFrameFromTop(size_t index)
virtual void EndOfWrite(void) override
virtual void BeginChoiceVariant(const CChoiceTypeInfo *choiceType, const CMemberId &id) override
virtual void BeginContainer(const CContainerTypeInfo *containerType) override
virtual void WriteOther(TConstObjectPtr object, TTypeInfo typeInfo) override
void WriteKey(const string &key)
size_t GetStackDepth(void) const
virtual void BeginChoice(const CChoiceTypeInfo *choiceType) override
virtual void WriteFloat(float data) override
void WriteValue(const string &value, EStringType type=eStringTypeVisible)
const TFrame & TopFrame(void) const
static CObjectOStream * OpenObjectOStreamJson(CNcbiOstream &out, EOwnership deleteOut)
virtual void WriteStringStore(const string &s) override
virtual void WriteBool(bool data) override
virtual void EndOfWrite(void)
virtual void WriteChar(char data) override
virtual void WriteEnum(const CEnumeratedTypeValues &values, TEnumValueType value) override
virtual void CopyBitString(CObjectIStream &in) override
EBinaryDataFormat m_BinaryFormat
CObjectOStreamJson(CNcbiOstream &out, bool deleteOut)
Constructor.
bool GetWriteNamedIntegersByValue(void) const
Get writing named integers by value parameter.
bool StackIsEmpty(void) const
const CMemberId & GetMemberId(void) const
virtual void EndContainerElement(void) override
virtual void BeginClassMember(const CMemberId &id) override
virtual void WriteBytes(const ByteBlock &block, const char *bytes, size_t length) override
virtual void BeginNamedType(TTypeInfo namedTypeInfo) override
virtual void EndClassMember(void) override
virtual void WriteCString(const char *str) override
EEncoding GetDefaultStringEncoding(void) const
Get default encoding of 'string' objects.
virtual void WriteChars(const CharBlock &block, const char *chars, size_t length) override
virtual void WriteBitString(const CBitString &obj) override
EFrameType GetFrameType(void) const
void SetBinaryDataFormat(EBinaryDataFormat fmt)
Set formatting of binary data.
bool m_WriteNamedIntegersByValue
void WriteSkippedMember(void)
virtual void CopyString(CObjectIStream &in, EStringType type=eStringTypeVisible) override
virtual void EndChoiceVariant(void) override
virtual void CopyEnum(const CEnumeratedTypeValues &values, CObjectIStream &in) override
virtual void WriteInt8(Int8 data) override
virtual void WriteNullPointer(void) override
virtual void WriteUint4(Uint4 data) override
virtual void EndNamedType(void)
virtual void BeginBytes(const ByteBlock &block) override
virtual void WriteObjectReference(TObjectIndex index) override
virtual void WriteDouble(double data) override
virtual void WriteOtherBegin(TTypeInfo typeInfo) override
void WriteBase64Bytes(const char *bytes, size_t length)
bool m_EnforceWritingDefaults
void SetDefaultStringEncoding(EEncoding enc)
Set default encoding of 'string' objects.
virtual void BeginClass(const CClassTypeInfo *classInfo) override
@ eString_01B
string of 0 and 1, plus 'B' at the end
@ eArray_Uint
array of unsigned integers
@ eArray_Bool
array of 'true' and 'false'
@ eArray_01
array of 1 and 0
@ eString_Base64
Base64Binary string.
@ eString_01
string of 0 and 1
@ fInvalidData
Output data is incorrect.
@ fNotImplemented
Method is not implemented.
uint8_t Uint1
1-byte (8-bit) unsigned integer
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void IncIndentLevel(size_t step=2)
bool GetUseIndentation(void) const
size_t GetLine(void) const
void PutString(const char *str, size_t length)
void PutEol(bool indent=true)
void WrapAt(size_t lineLength, bool keepWord)
void DecIndentLevel(size_t step=2)
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)
Convert Int8 to string.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static SIZE_TYPE DoubleToStringPosix(double value, unsigned int precision, char *buf, SIZE_TYPE buf_size)
Convert double to string with specified precision and put the result into a character buffer,...
static CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static string UInt8ToString(Uint8 value, TNumToStringFlags flags=0, int base=10)
Convert UInt8 to string.
@ fDoublePosix
DoubleToString*(): Use C locale for double conversions.
const string & GetName(void) const
Get name of this type.
TTypeInfo GetElementType(void) const
enum ENcbiOwnership EOwnership
Ownership relations between objects.
size_t serialize(const BV &bv, unsigned char *buf, bm::word_t *temp_block=0, unsigned serialization_flags=0)
Saves bitvector into memory.
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
void aligned_free(void *ptr) BMNOEXCEPT
Aligned free.
void * aligned_new_malloc(size_t size)
Aligned malloc (unlike classic malloc it throws bad_alloc exception)
const unsigned set_block_alloc_size
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static const char *const HEX
static const char * suffix[]
static const char * prefix[]
static pcre_uint8 * buffer