Ejemplo n.º 1
0
void ReactionPickler::pickleReaction(const ChemicalReaction *rxn,
                                     std::ostream &ss) {
  PRECONDITION(rxn, "empty reaction");
  streamWrite(ss, endianId);
  streamWrite(ss, VERSION);
  streamWrite(ss, versionMajor);
  streamWrite(ss, versionMinor);
  streamWrite(ss, versionPatch);
  _pickle(rxn, ss);
}
Ejemplo n.º 2
0
void TransformCatalogEntry::toStream(std::ostream &ss) const {
  ReactionPickler::pickleReaction(*dp_transform, ss);

  std::int32_t tmpInt;
  tmpInt = getBitId();
  streamWrite(ss, tmpInt);

  tmpInt = d_descrip.size();
  streamWrite(ss, tmpInt);
  ss.write(d_descrip.c_str(), tmpInt * sizeof(char));
}
Ejemplo n.º 3
0
void FragmentCatalogEntry::toStream(std::ostream &ss) const {
  MolPickler::pickleMol(*dp_mol, ss);

  boost::int32_t tmpInt;
  tmpInt = getBitId();
  streamWrite(ss, tmpInt);

  tmpInt = d_descrip.size();
  streamWrite(ss, tmpInt);
  ss.write(d_descrip.c_str(), tmpInt * sizeof(char));
}
Ejemplo n.º 4
0
void MolCatalogEntry::toStream(std::ostream &ss) const {
  PRECONDITION(dp_mol, "bad mol");
  MolPickler::pickleMol(*dp_mol, ss);

  boost::int32_t tmpInt;
  tmpInt = getBitId();
  streamWrite(ss, tmpInt);

  tmpInt = getOrder();
  streamWrite(ss, tmpInt);

  tmpInt = d_descrip.size();
  streamWrite(ss, tmpInt);
  ss.write(d_descrip.c_str(), tmpInt * sizeof(char));
}
Ejemplo n.º 5
0
static void print_line(void) {
  unsigned i;

  for (i = 0; i < 76; i++)
    streamPut(test_chp, '-');
  streamWrite(test_chp, (const uint8_t *)"\r\n", 2);
}
Ejemplo n.º 6
0
DWORD SimPlanet::packUpdate(Net::GhostManager *, DWORD, BitStream *stream)
{
   streamWrite(*stream);
   stream->write(planet.size);
   stream->write(planet.distance);
   return 0;
}
Ejemplo n.º 7
0
bool CipherFileIO::writeOneBlock(const IORequest &req) {

  if (haveHeader && fsConfig->reverseEncryption) {
    VLOG(1)
        << "writing to a reverse mount with per-file IVs is not implemented";
    return false;
  }

  int bs = blockSize();
  off_t blockNum = req.offset / bs;

  if (haveHeader && fileIV == 0) initHeader();

  bool ok;
  if (req.dataLen != bs) {
    ok = streamWrite(req.data, (int)req.dataLen, blockNum ^ fileIV);
  } else {
    ok = blockWrite(req.data, (int)req.dataLen, blockNum ^ fileIV);
  }

  if (ok) {
    if (haveHeader) {
      IORequest tmpReq = req;
      tmpReq.offset += HEADER_SIZE;
      ok = base->write(tmpReq);
    } else
      ok = base->write(req);
  } else {
    VLOG(1) << "encodeBlock failed for block " << blockNum << ", size "
            << req.dataLen;
    ok = false;
  }
  return ok;
}
Ejemplo n.º 8
0
void FragCatalogEntry::toStream(std::ostream &ss) const {
  MolPickler::pickleMol(*dp_mol, ss);

  std::int32_t tmpInt;
  tmpInt = getBitId();
  streamWrite(ss, tmpInt);

  tmpInt = d_descrip.size();
  streamWrite(ss, tmpInt);
  ss.write(d_descrip.c_str(), tmpInt * sizeof(char));

  tmpInt = d_order;
  streamWrite(ss, tmpInt);

  tmpInt = d_aToFmap.size();
  streamWrite(ss, tmpInt);
  for (const auto &iivmci : d_aToFmap) {
    tmpInt = iivmci.first;
    streamWrite(ss, tmpInt);
    INT_VECT tmpVect = iivmci.second;
    tmpInt = tmpVect.size();
    streamWrite(ss, tmpInt);
    for (INT_VECT_CI ivci = tmpVect.begin(); ivci != tmpVect.end(); ivci++) {
      tmpInt = *ivci;
      streamWrite(ss, tmpInt);
    }
  }
}
Ejemplo n.º 9
0
Persistent::Base::Error SimPlanet::write(StreamIO &sio, int a, int b)
{
   Persistent::Base::Error error = SimNetObject::write(sio, a, b);
   if (error != Persistent::Base::Ok) 
      return error;
   streamWrite(sio);
   sio.write(planet.size);
   sio.write(planet.distance);
	return (sio.getStatus() == STRM_OK) ? Ok : WriteError;
}
Ejemplo n.º 10
0
			void streamWrite(
				uint8_t const * in,
				uint8_t const * out,
				BgzfDeflateZStreamBaseFlushInfo const & BDZSBFI)
			{
				assert ( BDZSBFI.blocks == 1 || BDZSBFI.blocks == 2 );
				
				if ( BDZSBFI.blocks == 1 )
				{
					/* write data to stream, one block */
					streamWrite(in, BDZSBFI.block_a_u, out, BDZSBFI.block_a_c);
				}
				else
				{
					assert ( BDZSBFI.blocks == 2 );
					/* write data to stream, two blocks */
					streamWrite(in                    , BDZSBFI.block_a_u, out                    , BDZSBFI.block_a_c);
					streamWrite(in + BDZSBFI.block_a_u, BDZSBFI.block_b_u, out + BDZSBFI.block_a_c, BDZSBFI.block_b_c);
				}
			}
Ejemplo n.º 11
0
  std::string DiscreteValueVect::toString() const {
    std::stringstream ss(std::ios_base::binary|std::ios_base::out|std::ios_base::in);

    boost::int32_t tVers=ci_DISCRETEVALUEVECTPICKLE_VERSION*-1;
    streamWrite(ss,tVers);
    boost::uint32_t tInt;
    tInt=d_type;
    streamWrite(ss,tInt);
    tInt=d_bitsPerVal;
    streamWrite(ss,tInt);
    tInt=d_mask;
    streamWrite(ss,tInt);
    tInt=d_length;
    streamWrite(ss,tInt);
    tInt=d_numInts;
    streamWrite(ss,tInt);

#if defined(BOOST_BIG_ENDIAN)
    boost::uint32_t *td = new boost::uint32_t[d_numInts];
    for(unsigned int i=0;i<d_numInts;++i) td[i]=EndianSwapBytes<HOST_ENDIAN_ORDER,LITTLE_ENDIAN_ORDER>(d_data.get()[i]);
    ss.write((const char *)td,d_numInts*sizeof(tInt));
    delete [] td;
#else    
    ss.write((const char *)d_data.get(),d_numInts*sizeof(tInt));
#endif    
    std::string res(ss.str());
    return res;
  };
Ejemplo n.º 12
0
void serial_if_tx(void *arg, const char *frame, size_t len, uint8_t prio, uint8_t dest)
{
    (void)prio;
    (void)dest;
    if (arg == NULL) {
        return;
    }

    chprintf((BaseSequentialStream *)&SD3, "[debug] sending to %x, if %x\n", dest, arg);

    char send_buf[2*NET_MTU];
    size_t send_len = serial_datagram_buffer_wrap((uint8_t*)frame, len, (uint8_t*)send_buf, sizeof(send_buf));
    streamWrite((BaseSequentialStream*)arg, (uint8_t*)send_buf, send_len);
}
Ejemplo n.º 13
0
ssize_t streamWritev(int nSockFd,  const struct iovec *pVector, int nCount, int nTimeoutMs)
{
    ssize_t nWritten = 0;
    int i;
    for (i = 0; i < nCount; i++) {
        ssize_t nSent = streamWrite(nSockFd, pVector[i].iov_base, pVector[i].iov_len, nTimeoutMs);
        if (nSent <= 0) break;
        nWritten += nSent;
    }

    /*
    ssize_t nWritten = writev(nSockFd, pVector, nCount);
    */

    DEBUG("[TX] (binary, written=%zd bytes, %d vectors)", nWritten, nCount);

    return nWritten;
}
Ejemplo n.º 14
0
  std::string UniformGrid3D::toString() const {
    std::stringstream ss(std::ios_base::binary|std::ios_base::out|std::ios_base::in);
    boost::int32_t tVers = ci_GRIDPICKLE_VERSION*-1;
    streamWrite(ss,tVers);
    boost::uint32_t tInt;
    tInt=d_numX;
    streamWrite(ss,tInt);
    tInt=d_numY;
    streamWrite(ss,tInt);
    tInt=d_numZ;
    streamWrite(ss,tInt);
    streamWrite(ss,d_spacing);
    streamWrite(ss,d_offSet.x);
    streamWrite(ss,d_offSet.y);
    streamWrite(ss,d_offSet.z);

    std::string storePkl=dp_storage->toString();
    boost::uint32_t pklSz=storePkl.size();
    streamWrite(ss,pklSz);
    ss.write(storePkl.c_str(),pklSz*sizeof(char));

    std::string res(ss.str());
    return(res);
  }
Ejemplo n.º 15
0
/*============================================================================
  Description:  (API Call) Writes an entire stream in one pass.
  Arguments: 
   io_pStorage - pointer to parent storage in which to create the new stream
   in_wszStreamName - name of new stream
   in_pvBuf - data to write into stream
   in_pcbBufSize - number of bytes in in_pvBuf
  Return:
   Status code
  ==========================================================================*/
int
flushStream(Storage* io_pStorage,
            const wchar_t* in_wszStreamName,
            const void* in_pvBuf,
            unsigned long* in_pcbBufSize)
{
    int     iRet =          SSTG_OK;
    Stream* pNewStream =    NULL;

    ASSERT ((io_pStorage != NULL) &&
            (in_wszStreamName != NULL) &&
            (*in_wszStreamName != 0) &&
            (in_pvBuf != NULL));
    if ((io_pStorage == NULL) ||
        (in_wszStreamName == NULL) ||
        (*in_wszStreamName == 0) ||
        (in_pvBuf == NULL))
    {
        return SSTG_ERROR_ILLEGAL_CALL;
    }

    _KABOOM1;

    iRet = createStream(io_pStorage, in_wszStreamName, &pNewStream);
    if (iRet != SSTG_OK)
    {
        return iRet;
    }

    iRet = streamWrite(pNewStream, in_pvBuf, in_pcbBufSize);
    if (iRet != SSTG_OK)
    {
        return iRet;
    }

    iRet = closeStream(&pNewStream);

    return iRet;
}
Ejemplo n.º 16
0
			uint64_t flush()
			{
				/* flush, compress */
				BgzfDeflateZStreamBaseFlushInfo BDZSBFI = base_type::flush(flushmode);
								
				/* write blocks */
				streamWrite(inbuf.begin(), outbuf.begin(), BDZSBFI);

				if ( flushmode )
				{
					assert ( ! BDZSBFI.movesize );
				}
				else
				{
					if ( BDZSBFI.movesize )
						BgzfDeflateInputBufferBase::pc = BDZSBFI.moveUncompressedRest();
					else
						BgzfDeflateInputBufferBase::pc = BgzfDeflateInputBufferBase::pa;
				}

				/* return number of compressed bytes written */
				return BDZSBFI.getCompressedSize();
			}
Ejemplo n.º 17
0
static void log_handler_stdout_cb(log_level_t lvl, const char *msg, size_t len)
{
    (void)lvl;
    streamWrite(stdout, (uint8_t*)msg, len);
}
Ejemplo n.º 18
0
/**
 * @brief   Prints a line.
 *
 * @param[in] msgp      the message
 *
 * @api
 */
void test_println(const char *msgp) {

  test_print(msgp);
  streamWrite(test_chp, (const uint8_t *)"\r\n", 2);
}
Ejemplo n.º 19
0
void streamWrite(std::ostream &ss, ReactionPickler::Tags tag, const T &what) {
  streamWrite(ss, tag);
  streamWrite(ss, what);
};
Ejemplo n.º 20
0
inline void FileUtils::streamWrite<std::string>(OutputStreamHandle &out, const std::string &src)
{
    streamWrite(out, &src[0], src.size() + 1);
}
Ejemplo n.º 21
0
 static inline void streamWrite(OutputStreamHandle &out, const T *src, size_t numElements)
 {
     streamWrite(*out, src, numElements);
 }
Ejemplo n.º 22
0
 static inline void streamWrite(OutputStreamHandle &out, const std::vector<T> &src)
 {
     streamWrite(*out, src);
 }
Ejemplo n.º 23
0
 static inline void streamWrite(OutputStreamHandle &out, const T &src)
 {
     streamWrite(*out, src);
 }
Ejemplo n.º 24
0
int OutputStream::streamWrite(VoidBuffer buffer)
{
    return streamWrite(buffer, buffer.size());
}
Ejemplo n.º 25
0
void streamWrite(std::ostream &ss, ReactionPickler::Tags tag) {
  int32_t tmp = tag;
  streamWrite(ss, tmp);
}
Ejemplo n.º 26
0
void ReactionPickler::_pickle(const ChemicalReaction *rxn, std::ostream &ss) {
  PRECONDITION(rxn, "empty reaction");
  uint32_t tmpInt;

  tmpInt = static_cast<int32_t>(rxn->getNumReactantTemplates());
  streamWrite(ss, tmpInt);
  tmpInt = static_cast<int32_t>(rxn->getNumProductTemplates());
  streamWrite(ss, tmpInt);
  tmpInt = static_cast<int32_t>(rxn->getNumAgentTemplates());
  streamWrite(ss, tmpInt);

  uint32_t flag = 0;
  if (rxn->getImplicitPropertiesFlag()) flag |= 0x1;
  if (rxn->df_needsInit) flag |= 0x2;
  streamWrite(ss, flag);

  // -------------------
  //
  // Write Reactants
  //
  // -------------------
  streamWrite(ss, BEGINREACTANTS);
  for (MOL_SPTR_VECT::const_iterator tmpl = rxn->beginReactantTemplates();
       tmpl != rxn->endReactantTemplates(); ++tmpl) {
    MolPickler::pickleMol(tmpl->get(), ss);
  }
  streamWrite(ss, ENDREACTANTS);

  streamWrite(ss, BEGINPRODUCTS);
  for (MOL_SPTR_VECT::const_iterator tmpl = rxn->beginProductTemplates();
       tmpl != rxn->endProductTemplates(); ++tmpl) {
    MolPickler::pickleMol(tmpl->get(), ss, PicklerOps::AllProps);
  }
  streamWrite(ss, ENDPRODUCTS);

  if (rxn->getNumAgentTemplates()) {
    streamWrite(ss, BEGINAGENTS);
    for (MOL_SPTR_VECT::const_iterator tmpl = rxn->beginAgentTemplates();
         tmpl != rxn->endAgentTemplates(); ++tmpl) {
      MolPickler::pickleMol(tmpl->get(), ss);
    }
    streamWrite(ss, ENDAGENTS);
  }
  streamWrite(ss, ENDREACTION);
}  // end of _pickle