46 #if !defined(DBL_MAX_10_EXP) || !defined(FLT_MAX)
120 return isalpha((
unsigned char) c) || c ==
'_';
126 return isalnum((
unsigned char) c) || c ==
'_' || c ==
'.';
190 char c =
GetChar(skipWhiteSpace);
191 if ( c == choiceTrue ) {
194 else if ( c == choiceFalse ) {
279 for (
size_t i = 1; ; ++
i ) {
295 for (
size_t i = 1; ; ++
i ) {
318 if ( c !=
'-' && c !=
'+' && !
isdigit((
unsigned char) c) )
320 for (
size_t i = 1; ; ++
i ) {
322 if ( !
isdigit((
unsigned char) c) ) {
346 for (
size_t i = 1; ; ++
i ) {
374 string id_alt =
string(
id);
375 id_alt[0] = (char)
toupper((
unsigned char)id_alt[0]);
382 !
info.GetItemInfo(idx)->GetId().HaveNoPrefix()) {
461 const size_t maxpos=128;
467 }
else if (to ==
'\"') {
475 if (to !=
'}' && c ==
'\n') {
479 if (
isspace((
unsigned char) c)) {
489 if (to !=
'}' && (c ==
',' || c ==
'}')) {
492 }
else if (c ==
'\"' || c ==
'{') {
509 if (c ==
'\"' || c ==
'{') {
538 }
else if (to ==
'\"') {
539 }
else if (to ==
'\'') {
546 if (!ap && to !=
'\"') {
547 if (to !=
'}' && (c ==
'\n' || c ==
',' || c ==
'}')) {
549 }
else if (c ==
'\"' || c ==
'{') {
558 if (c ==
'\"' || (c ==
'{' && to !=
'\"')) {
562 if (c ==
'\'' && to !=
'\"') {
580 #if BITSTRING_AS_VECTOR
585 const size_t step=128;
586 data.reserve(reserve=step);
589 for ( ; !
hex;
hex= c > 0x1) {
594 data.append(1,
char(c));
595 if (--reserve == 0) {
596 data.reserve(
data.size() + (reserve=step));
603 obj.reserve(
data.size() * 4 );
608 obj.push_back( (
byte &
mask) != 0 );
612 obj.reserve(obj.
size() + (reserve=step));
616 obj.push_back( (
byte &
mask) != 0 );
617 if (--reserve == 0) {
618 obj.reserve(obj.
size() + (reserve=step));
625 obj.reserve(
data.size() );
627 obj.push_back( *
i != 0 );
631 obj.reserve(obj.
size());
641 const size_t step=128;
642 data.reserve(reserve=step);
645 for ( ; !
hex;
hex= c > 0x1) {
650 data.append(1,
char(c));
651 if (--reserve == 0) {
652 data.reserve(
data.size() + (reserve=step));
666 if ((
byte &
mask) != 0) {
680 if ((
byte &
mask) != 0) {
770 if ( s.size() != 1 ) {
772 "\"" + s +
"\": one char string expected");
811 return HUGE_VAL/HUGE_VAL;
817 bool is_negative =
PeekChar(
true) ==
'-';
819 size_t mantissaLength = mantissaStr.
size();
821 if ( mantissaLength >=
sizeof(
buffer) - 1 )
823 memcpy(
buffer, mantissaStr.
data(), mantissaLength);
824 buffer[mantissaLength] =
'\0';
835 if ( base != 2 && base != 10 ) {
838 if (mantissa == 0.) {
842 mantissa = -mantissa;
846 result = mantissa * pow((
double)10.0, exp);
848 result = ldexp( mantissa, exp);
862 "bad char in string starting at line "+
870 "unclosed string starts at line "+
883 size_t done = 0, valid = 0;
884 for (
size_t i = 0;
i <
count; ++
i ) {
887 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
931 else if ( s.capacity() <
double(s.size()+1)*1.1 ) {
932 s.reserve(s.size()*2);
958 s.reserve(s.size() +
i);
1041 if ( c < '0' || c >
'9' ) {
1066 if ( c < '0' || c >
'9' ) {
1089 if ( base != 2 && base != 10 )
1097 size_t i = 0, valid = 0;
1125 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
1175 if ( c >=
'0' && c <=
'9' ) {
1178 else if ( c >=
'A' && c <=
'F' ) {
1181 else if ( c >=
'a' && c <=
'f' ) {
1184 else if ( c ==
'\'' ) {
1187 else if ( c ==
'\r' || c ==
'\n' ) {
1219 else if ( c !=
'}' )
1245 #ifdef VIRTUAL_MID_LEVEL_IO
1255 bool old_element = contType->
InitIterator(iter, contPtr);
1258 if ( old_element ) {
1266 if ( old_element ) {
1309 "\""+
string(
id)+
"\": unexpected member, should be one of: ";
1360 #ifdef VIRTUAL_MID_LEVEL_IO
1486 if ( c >=
'0' && c <=
'9' ) {
1489 else if ( c >=
'A' && c <=
'F' ) {
1490 return c -
'A' + 10;
1492 else if ( c >=
'a' && c <=
'f' ) {
1493 return c -
'a' + 10;
1511 char* dst,
size_t length)
1514 while ( length-- > 0 ) {
1522 *dst++ = char(c1 << 4);
1528 *dst++ = char((c1 << 4) | c2);
1546 char* dst,
size_t length)
1548 size_t count = 0, valid = 0;
1550 while (length-- > 0) {
1566 for (
size_t i = 0;
i <
count;
i++) {
1568 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
1577 dst[
i] = c ==
'\0' ?
'#' : c;
1639 " must be either sizeof(Int4) or sizeof(Int8)");
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...
void resize(size_type new_size)
Change size of the bvector.
size_type size() const noexcept
Returns bvector's capacity (number of bits it can store)
bool set_bit(size_type n, bool val=true)
Sets bit n.
bvector_size_type size_type
void clear(const size_type *ids, size_type ids_size, bm::sort_order so=bm::BM_UNKNOWN)
clear list of bits in this bitset
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const char * expect
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
#define finite
Define value of finite (Is Finite).
const string & FindName(TEnumValueType value, bool allowBadValue) const
Find name of the enum by its numeric value.
const CMemberId & GetId(void) const
bool IsAttlist(void) const
TMemberIndex Find(const CTempString &name) const
CAsnBinaryDefs::TLongTag TTag
const CItemInfo * GetItemInfo(TMemberIndex index) const
bool HasNotag(void) const
TEnumValueType FindValue(const CTempString &name) const
Find numeric value by the name of the enum.
bool IsInteger(void) const
Check whether the type is defined as INTEGER in ASN.1 spec.
string ToString(void) const
EFixNonPrint
How to process non-printing character in the ASN VisibleString.
size_t TMemberIndex
Type used for indexing class members and choice variants.
const TMemberIndex kFirstMemberIndex
Start if member indexing.
const TMemberIndex kInvalidMember
Special value returned from FindMember.
void SetName(const string &name)
Set local name.
void SetValue(const CStringUTF8 &value)
Set normalized value.
@ eFNP_Allow
pass through unchanged, post no error message
@ eStringTypeUTF8
UTF8-encoded string.
@ eStringTypeVisible
VisibleString (in ASN.1 sense)
@ eSerial_AsnText
ASN.1 text.
void AppendStringData(string &s, size_t count, EFixNonPrint fix_method, size_t line)
virtual void SkipChar(void) override
void SkipEndOfLine(char c)
char ReplaceVisibleChar(char c, EFixNonPrint fix_method, const CObjectStack *io, const CTempString &str, char subst)
virtual void SkipSNumber(void) override
virtual void StartDelayBuffer(void) override
CTempString ScanEndOfId(bool isId)
virtual void ReadBitString(CBitString &obj) override
CObjectIStreamAsn(EFixNonPrint how=eFNP_Default)
Constructor.
MLIOVIR void ReadClassSequential(const CClassTypeInfo *classType, TObjectPtr classPtr)
virtual bool BeginContainerElement(TTypeInfo elementType) override
virtual Int8 ReadInt8(void) override
virtual bool EndOfData(void) override
Check if there is still some meaningful data that can be read; this function will skip white spaces a...
virtual size_t ReadBytes(ByteBlock &block, char *dst, size_t length) override
bool GoodVisibleChar(char c)
void ReadStringValue(string &s, EFixNonPrint fix_method)
virtual void BeginClass(const CClassTypeInfo *classInfo) override
virtual void SkipNull(void) override
#define BEGIN_OBJECT_FRAME(Type)
char SkipWhiteSpaceAndGetChar(void)
#define ThrowError(flag, mess)
virtual bool ReadBool(void) override
virtual Uint8 ReadUint8(void) override
virtual void SkipUNumber(void) override
static bool IdChar(char c)
virtual void EndContainer(void) override
void BadStringChar(size_t startLine, char c)
void Expect(char c, bool skipWhiteSpace=false)
virtual EPointerType ReadPointerType(void) override
EFixNonPrint FixNonPrint(EFixNonPrint how)
virtual bool EndOfData(void)
Check if there is still some meaningful data that can be read; in text streams this function will ski...
CTempString ReadLCaseId(char firstChar)
bool IsCompressed(void) const
void UnexpectedMember(const CTempString &id, const CItemsInfo &items)
virtual Int4 ReadInt4(void) override
#define BEGIN_OBJECT_FRAME2(Type, Arg)
virtual void SkipFNumber(void) override
static CObjectIStream * CreateObjectIStreamAsn(void)
MLIOVIR void ReadContainer(const CContainerTypeInfo *containerType, TObjectPtr containerPtr)
virtual void Location(string &, size_t &) const override
Get current stream location as tuple (positiontype:string, size_t).
void SkipObject(const CObjectTypeInfo &objectType)
Skip child object.
virtual char ReadChar(void) override
virtual void SkipAnyContentObject(void) override
virtual void SkipString(EStringType type=eStringTypeVisible) override
virtual void ReadAnyContentObject(CAnyContentObject &obj) override
virtual double ReadDouble(void) override
void SetNotag(bool set=true)
virtual TObjectIndex ReadObjectPointer(void) override
bool CanSkipUnknownMembers(void)
Simple check if it's allowed to skip unknown members.
static bool FirstIdChar(char c)
virtual void SkipBitString(void) override
virtual void BeginChars(CharBlock &block) override
virtual void SkipByteBlock(void) override
virtual size_t ReadChars(CharBlock &block, char *dst, size_t length) override
virtual void ReadNull(void) override
virtual void SkipBool(void) override
#define END_OBJECT_FRAME()
size_t GetStackDepth(void) const
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
char SkipWhiteSpace(void)
const TFrame & TopFrame(void) const
CTempString ReadMemberId(char firstChar)
EFixNonPrint x_FixCharsMethod(void) const
virtual void ReadString(string &s, EStringType type=eStringTypeVisible) override
TFailFlags SetFailFlags(TFailFlags flags, const char *message=0)
Set fail flags.
TMemberIndex GetAltItemIndex(const CClassTypeInfoBase *classType, const CTempString &id, const TMemberIndex pos=kInvalidMember)
void UnendedString(size_t startLine)
CTempString ReadUCaseId(char firstChar)
void AppendLongStringData(string &s, size_t count, EFixNonPrint fix_method, size_t line)
virtual void BeginChoice(const CChoiceTypeInfo *choiceType) override
CTempString ReadTypeId(char firstChar)
virtual TMemberIndex BeginClassMember(const CClassTypeInfo *classType) override
TMemberIndex GetMemberIndex(const CClassTypeInfo *classType, const CTempString &id)
MLIOVIR void SkipContainer(const CContainerTypeInfo *containerType)
MLIOVIR void SkipClassSequential(const CClassTypeInfo *classType)
virtual TMemberIndex BeginChoiceVariant(const CChoiceTypeInfo *choiceType) override
virtual void EndClass(void) override
virtual void BeginContainer(const CContainerTypeInfo *containerType) override
bool CanSkipUnknownVariants(void)
Simple check if it's allowed to skip unknown variants.
#define BEGIN_OBJECT_FRAME3(Type, Arg1, Arg2)
virtual void EndChoice(void) override
virtual void StartDelayBuffer(void)
virtual void EndBytes(const ByteBlock &block) override
void ReadAnyContent(string &value)
char x_FixCharsSubst(void) const
virtual Uint4 ReadUint4(void) override
virtual void BeginBytes(ByteBlock &block) override
virtual string ReadFileHeader(void) override
Read file header.
void OpenFromBuffer(const char *buffer, size_t size)
Attach reader to a data source.
MLIOVIR void SkipClassRandom(const CClassTypeInfo *classType)
virtual TEnumValueType ReadEnum(const CEnumeratedTypeValues &values) override
TMemberIndex GetChoiceIndex(const CChoiceTypeInfo *choiceType, const CTempString &id)
virtual string ReadOtherPointer(void) override
void ReadCompressedBitString(CBitString &data)
CTempString ReadNumber(void)
MLIOVIR void ReadClassRandom(const CClassTypeInfo *classType, TObjectPtr classPtr)
void SkipAnyContent(void)
@ fEOF
End of file in the middle of reading an object.
@ fOverflow
Data read is beyond the allowed limits.
@ fIllegalCall
Illegal in a given context function call.
@ fUnknownValue
Unknown value was present in the input.
@ fFormatError
Input file formatting does not conform with specification.
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.
char PeekChar(size_t offset=0)
void SkipEndOfLine(char lastChar)
size_t GetLine(void) const
void SkipChars(size_t count)
const char * GetCurrentPos(void) const
char PeekCharNoEOF(size_t offset=0)
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static int strncasecmp(const char *s1, const char *s2, size_t n)
Case-insensitive comparison of two zero-terminated strings, narrowed to the specified number of chara...
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
const char * data(void) const
Return a pointer to the array represented.
static double StringToDoublePosix(const char *str, char **endptr=0, TStringToNumFlags flags=0)
Convert string to double-precision value (analog of strtod function)
static CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
size_type size(void) const
Return the length of the represented array.
static bool EvaluateFirst(char ch, SIZE_TYPE &more)
Check that the character is valid first byte of an UTF8 byte sequence.
@ fDecimalPosixFinite
StringToDouble*(): Keep result finite and normalized: if DBL_MAX < result < INF, result becomes DBL_M...
const CItemsInfo & GetItems(void) const
TObjectPtr AddElement(TObjectPtr containerPtr, TConstObjectPtr elementPtr, ESerialRecursionMode how=eRecursive) const
const CItemsInfo & GetVariants(void) const
const CVariantInfo * GetVariantInfo(TMemberIndex index) const
void ReadData(CObjectIStream &in, TObjectPtr object) const
TConstObjectPtr GetElementPtr(const CConstIterator &it) const
bool InitIterator(CConstIterator &it, TConstObjectPtr containerPtr) const
bool NextElement(CConstIterator &it) const
void EraseAllElements(CIterator &it) const
const CItemsInfo & GetMembers(void) const
TTypeInfo GetElementType(void) const
enum ENcbiOwnership EOwnership
Ownership relations between objects.
static void hex(unsigned char c)
static void byte(MDB_val *v)
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Floating-point support routines.
Useful/utility classes and methods.
std::istream & in(std::istream &in_, double &x_)
#define SkipClassSequentialContentsEnd()
#define SkipClassRandomContentsMember()
#define ReadClassSequentialContentsEnd(classPtr)
#define SkipClassSequentialContentsBegin(classType)
#define ReadClassRandomContentsBegin(classType)
#define ReadClassSequentialContentsMember(classPtr)
#define ReadClassSequentialContentsBegin(classType)
#define ReadClassRandomContentsMember(classPtr)
#define SkipClassSequentialContentsMember()
#define SkipClassRandomContentsEnd()
#define SkipClassRandomContentsBegin(classType)
#define ReadClassRandomContentsEnd()
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)