/*-------------------------------------------------------parseEntityReference-+ | Effects: | | Parse an entity reference, indicates how much was parsed. | | Returns: | | Pointer to the dereferenced entity, or 0 if failed. | +----------------------------------------------------------------------------*/ Entity const * Yasp3::parseEntityReference(bool isGeneral, int & iLen) { UCS_2 entName[1+NAMELEN_MAX]; iLen = peekRefc(peekName(entName, sdcl.charset().isCaseEntity())); if (isGeneral) { return entMgr.inqEntityGeneralOrExtend(entName, true); }else { return entMgr.inqEntityParameter(entName, true); } }
bool PeekProcessor::process(boost::shared_ptr<TProtocol> in, boost::shared_ptr<TProtocol> out, void* connectionContext) { std::string fname; TMessageType mtype; int32_t seqid; in->readMessageBegin(fname, mtype, seqid); if (mtype != T_CALL) { throw TException("Unexpected message type"); } // Peek at the name peekName(fname); TType ftype; int16_t fid; while (true) { in->readFieldBegin(fname, ftype, fid); if (ftype == T_STOP) { break; } // Peek at the variable peek(in, ftype, fid); in->readFieldEnd(); } in->readMessageEnd(); in->getTransport()->readEnd(); // // All the data is now in memoryBuffer_ and ready to be processed // // Let's first take a peek at the full data in memory uint8_t* buffer; uint32_t size; memoryBuffer_->getBuffer(&buffer, &size); peekBuffer(buffer, size); // Done peeking at variables peekEnd(); bool ret = actualProcessor_->process(pipedProtocol_, out, connectionContext); memoryBuffer_->resetBuffer(); return ret; }
/*----------------------------------------------------------dereferRegCharRef-+ | Effects: | | Peek at a character reference, after Delimiter::IX_CRO has been found. | | Returns: | | the actual single character represented by the reference | | Sets: | | - the length parsed | | - its type (TYPE_NON_SGML if invalid NAMED reference. | | This is non ambiguous, because a numeric char ref cannot be non-sgml | +----------------------------------------------------------------------------*/ UCS_2 Yasp3::dereferRegCharRef(Charset::e_CharType & ct, int & iLen) { UCS_2 ucValue; iLen = 0; OpenEntityCache_Extractor extract(oec, iLen); extract >> ucValue; if (extract.good()) { // Numeric Character Reference? ct = Charset::TYPE_REGULAR; }else { // Named Character Reference? UCS_2 buf[1+NAMELEN_MAX]; iLen = peekName(buf, sdcl.charset().isCaseGeneral()); if (iLen && (ucValue = sdcl.charset().funchar(buf), ucValue)) { ct = sdcl.charset().charType(ucValue); }else { erh << ECE__ERROR << _YSP__INVNAMCREF << buf << endm; ct = Charset::TYPE_NON_SGML; ucValue = 0; } } iLen = peekRefc(iLen); return ucValue; }