/** Tries to read a string from a file. Uses a buffering to achieve it. If the * current file mode is unbuffered then this function enables buffering, makes * requested operation and disables buffering. If the buffer is too small to * contain all the line read then the rest of line is lost. * \param[out] pszStr - ptr to a buffer to receive a string * \param[in] uiMaxLen - size of the string buffer * \return If the line has been succesfully read. */ bool file::read_line(tchar_t* pszStr, uint_t uiMaxLen) { // for unbuffered operations enable buffering for this op if (m_bBuffered) return _read_string(pszStr, uiMaxLen); else { uint_t uiSize=m_uiBufferSize; set_buffering(true, 4096); bool bRet=_read_string(pszStr, uiMaxLen); set_buffering(false, uiSize); return bRet; } }
void _read_tag(pTHX_ srl_splitter_t * splitter, char tag) { /* first, self-contained tags*/ if ( tag <= SRL_HDR_POS_HIGH ) { SRL_SPLITTER_TRACE(" * POS INTEGER %d", (int)tag); } else if ( tag <= SRL_HDR_NEG_HIGH) { SRL_SPLITTER_TRACE(" * NEG INTEGER %d", (int)tag - 32); } else if ( IS_SRL_HDR_SHORT_BINARY(tag) ) { UV len = SRL_HDR_SHORT_BINARY_LEN_FROM_TAG(tag); SRL_SPLITTER_TRACE(" * SHORT BINARY of length %lu", len); char *binary_start_pos = splitter->pos - 1; _check_for_duplicates(aTHX_ splitter, binary_start_pos, len, 0); } else if ( IS_SRL_HDR_HASHREF(tag) ) { int len = tag & 0xF; SRL_SPLITTER_TRACE(" * SHORT HASHREF of length %d", len); splitter->deepness++; stack_push(splitter->status_stack, ST_DEEPNESS_UP); while (len-- > 0) { stack_push(splitter->status_stack, ST_VALUE); stack_push(splitter->status_stack, ST_VALUE); } } else if ( IS_SRL_HDR_ARRAYREF(tag) ) { int len = tag & 0xF; SRL_SPLITTER_TRACE(" * SHORT ARRAY of length %d", len); splitter->deepness++; stack_push(splitter->status_stack, ST_DEEPNESS_UP); while (len-- > 0) { stack_push(splitter->status_stack, ST_VALUE); } } else { switch (tag) { case SRL_HDR_VARINT: _read_varint(splitter); break; case SRL_HDR_ZIGZAG: _read_zigzag(splitter); break; case SRL_HDR_FLOAT: _read_float(splitter); break; case SRL_HDR_DOUBLE: _read_double(splitter); break; case SRL_HDR_LONG_DOUBLE: _read_long_double(splitter); break; case SRL_HDR_TRUE: /* no op */ break; case SRL_HDR_FALSE: /* no op */ break; case SRL_HDR_CANONICAL_UNDEF: case SRL_HDR_UNDEF: /* no op */ break; case SRL_HDR_BINARY: _read_string(aTHX_ splitter, 0); break; case SRL_HDR_STR_UTF8: _read_string(aTHX_ splitter, 1); break; case SRL_HDR_WEAKEN: _read_weaken(splitter); break; case SRL_HDR_REFN: _read_refn(splitter); break; case SRL_HDR_REFP: _read_refp(aTHX_ splitter); break; case SRL_HDR_HASH: _read_hash(splitter); break; case SRL_HDR_ARRAY: _read_array(splitter); break; case SRL_HDR_OBJECT: _read_object(splitter, 0); break; case SRL_HDR_OBJECT_FREEZE: _read_object(splitter, 1); break; case SRL_HDR_OBJECTV: _read_objectv(aTHX_ splitter, 0); break; case SRL_HDR_OBJECTV_FREEZE: _read_objectv(aTHX_ splitter, 1); break; case SRL_HDR_ALIAS: _read_alias(aTHX_ splitter); break; case SRL_HDR_COPY: _read_copy(aTHX_ splitter); break; case SRL_HDR_EXTEND: /* no op */ break; case SRL_HDR_REGEXP: _read_regexp(splitter); break; case SRL_HDR_PAD: /* no op */ break; default: croak("Unexpected tag value"); break; } } }