⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdrmemorystream.cc

📁 编译工具
💻 CC
📖 第 1 页 / 共 2 页
字号:
CORBA::ULongcdrMemoryStream::currentInputPtr() const{  void* begin = (pd_readonly_and_external_buffer) ?                    pd_bufp : ensure_align_8(pd_bufp);  return ((omni::ptr_arith_t)pd_inb_mkr - (omni::ptr_arith_t)begin);}CORBA::ULongcdrMemoryStream::currentOutputPtr() const{  void* begin = (pd_readonly_and_external_buffer) ?                    pd_bufp : ensure_align_8(pd_bufp);  return ((omni::ptr_arith_t)pd_outb_mkr - (omni::ptr_arith_t)begin);}cdrMemoryStream::cdrMemoryStream(void* databuffer){  pd_tcs_c = orbParameters::anyCharCodeSet;  pd_tcs_w = orbParameters::anyWCharCodeSet;  pd_readonly_and_external_buffer = 1;  pd_bufp = databuffer;#if (SIZEOF_LONG == SIZEOF_PTR)  pd_inb_end = (void *) ULONG_MAX;#elif (SIZEOF_INT == SIZEOF_PTR)  pd_inb_end = (void *) UINT_MAX;#elif defined (_WIN64)  pd_inb_end = (void *) _UI64_MAX;#else#error "No suitable integer type available to calculate maximum" \  " pointer value from"#endif  rewindPtrs();}cdrMemoryStream::cdrMemoryStream(void* databuffer, size_t maxLen){  pd_tcs_c = orbParameters::anyCharCodeSet;  pd_tcs_w = orbParameters::anyWCharCodeSet;  pd_readonly_and_external_buffer = 1;  pd_bufp = databuffer;  pd_inb_end = (void*)((omni::ptr_arith_t)pd_bufp + maxLen);  rewindPtrs();}cdrMemoryStream::cdrMemoryStream(const cdrMemoryStream& s,				 _CORBA_Boolean read_only){  pd_tcs_c = s.pd_tcs_c;  pd_tcs_w = s.pd_tcs_w;  pd_readonly_and_external_buffer = (read_only ||				     s.pd_readonly_and_external_buffer);  pd_marshal_byte_swap = pd_unmarshal_byte_swap = s.pd_marshal_byte_swap;  if (s.pd_readonly_and_external_buffer) {    // For an external buffer the storage is managed elsewhere. We    // assume that it will continue to exist for the lifetime of this    // buffered stream, and just use the buffer directly.    pd_bufp    = s.pd_bufp;    pd_inb_end = s.pd_inb_end;    rewindPtrs();  }  else if (read_only) {    // Original MemoryStream is read/write.  We assume that the    // original stream will exist at least as long as us, intact, so    // that we can safely refer to its buffer directly.    pd_bufp = s.bufPtr();    pd_inb_end = (void*)((omni::ptr_arith_t)pd_bufp + s.bufSize());    rewindPtrs();  }  else {    // Copy the contents of the original stream    pd_bufp     = pd_inline_buffer;    pd_outb_end = (pd_inline_buffer + sizeof(pd_inline_buffer));    rewindPtrs();    if (s.bufSize()) {      reserveOutputSpace(omni::ALIGN_8,s.bufSize());      memcpy(pd_outb_mkr,s.bufPtr(),s.bufSize());      pd_outb_mkr = (void*)((omni::ptr_arith_t)pd_outb_mkr + s.bufSize());    }  }}cdrMemoryStream& cdrMemoryStream::operator=(const cdrMemoryStream& s){  pd_tcs_c = s.pd_tcs_c;  pd_tcs_w = s.pd_tcs_w;  pd_marshal_byte_swap = pd_unmarshal_byte_swap = s.pd_marshal_byte_swap;  if (!s.pd_readonly_and_external_buffer) {    if (pd_readonly_and_external_buffer) {      pd_readonly_and_external_buffer = 0;      pd_bufp     = pd_inline_buffer;      pd_outb_end = (pd_inline_buffer + sizeof(pd_inline_buffer));    }    rewindPtrs();    if (s.bufSize()) {      reserveOutputSpace(omni::ALIGN_8,s.bufSize());      memcpy(pd_outb_mkr,s.bufPtr(),s.bufSize());      pd_outb_mkr = (void*)((omni::ptr_arith_t)pd_outb_mkr + s.bufSize());    }  }  else {    // For an external buffer the storage is managed elsewhere. We assume    // that it will continue to exist for the lifetime of this buffered    // stream also - so just copy the pointer.        if (!pd_readonly_and_external_buffer) {      pd_readonly_and_external_buffer = 1;      if (pd_bufp != pd_inline_buffer) {	delete [] (char*)pd_bufp;      }    }    pd_bufp     = s.pd_bufp;    pd_inb_end  = s.pd_inb_end;    rewindPtrs();  }  return *this;}cdrEncapsulationStream::cdrEncapsulationStream(CORBA::ULong initialBufsize,					       CORBA::Boolean clearMemory)  : cdrMemoryStream(initialBufsize,clearMemory){  marshalOctet(omni::myByteOrder);}cdrEncapsulationStream::cdrEncapsulationStream(const CORBA::Octet* databuffer,					       CORBA::ULong bufsize,					       CORBA::Boolean useAlign4)   : cdrMemoryStream((void*)databuffer, bufsize){  if (bufsize < 1)     OMNIORB_THROW(BAD_PARAM,BAD_PARAM_InvalidInitialSize,		  (CORBA::CompletionStatus)completion());  // We have to check the alignment of start of the the octet sequence buffer.  // It should be <initialAlign>. This is normally the case but  // is dependent on the implementation of the new operator. The following  // deal with both cases.  omni::alignment_t initialAlign = (useAlign4) ? omni::ALIGN_4 : omni::ALIGN_8;  if ((omni::ptr_arith_t)databuffer !=       omni::align_to((omni::ptr_arith_t)databuffer,initialAlign))     {      // This is the rare case. The sequence buffer does not start with      // initialAlign. Create a local copy.      pd_readonly_and_external_buffer = 0;      pd_clear_memory = 0;      pd_bufp     = pd_inline_buffer;      pd_outb_end = (pd_inline_buffer + sizeof(pd_inline_buffer));      rewindPtrs();      put_octet_array((const CORBA::Char*)databuffer,bufsize);    }  {    CORBA::Boolean endian = unmarshalBoolean();    setByteSwapFlag(endian);  }}cdrEncapsulationStream::cdrEncapsulationStream(cdrStream& s,					       CORBA::ULong fetchsize)  : cdrMemoryStream(fetchsize){  pd_tcs_c = s.TCS_C();  pd_tcs_w = s.TCS_W();  s.get_octet_array((CORBA::Octet*)pd_outb_mkr,(int)fetchsize);  pd_outb_mkr = (void*)((omni::ptr_arith_t)pd_outb_mkr + fetchsize);  rewindInputPtr();  {    CORBA::Boolean endian = unmarshalBoolean();    setByteSwapFlag(endian);  }}void*cdrEncapsulationStream::ptrToClass(int* cptr){  if (cptr == &cdrEncapsulationStream::_classid)    return (cdrEncapsulationStream*)this;  if (cptr == &cdrMemoryStream::_classid)    return (cdrMemoryStream*)this;  if (cptr == &cdrStream::_classid)    return (cdrStream*)this;  return 0;}int cdrEncapsulationStream::_classid;voidcdrEncapsulationStream::getOctetStream(CORBA::Octet*& databuffer,				       CORBA::ULong& max,				       CORBA::ULong& len){  if (pd_readonly_and_external_buffer)     OMNIORB_THROW(MARSHAL,MARSHAL_AttemptToWriteToReadOnlyBuf,		  (CORBA::CompletionStatus)completion());  void* begin = ensure_align_8(pd_bufp);    max = ((omni::ptr_arith_t) pd_outb_end - (omni::ptr_arith_t) begin);  len = ((omni::ptr_arith_t) pd_outb_mkr - (omni::ptr_arith_t) begin);  if (begin == pd_bufp && pd_bufp != pd_inline_buffer) {    databuffer = (CORBA::Octet*) pd_bufp;    pd_readonly_and_external_buffer = 1;  }  else {    databuffer = new CORBA::Octet[max];    memcpy((void*)databuffer,(void*)begin,len);  }}/////////////////////////////////////////////////////////////////////////////void*cdrCountingStream::ptrToClass(int* cptr){  if (cptr == &cdrCountingStream::_classid) return (cdrCountingStream*)this;  if (cptr == &cdrStream        ::_classid) return (cdrStream*)        this;  return 0;}int cdrCountingStream::_classid;voidcdrCountingStream::put_octet_array(const CORBA::Octet* b, int size,				  omni::alignment_t align){  omni::ptr_arith_t p1 = omni::align_to((omni::ptr_arith_t)pd_total,align);  pd_total = p1 + size;}CORBA::BooleancdrCountingStream::maybeReserveOutputSpace(omni::alignment_t align,					   size_t required){  omni::ptr_arith_t p1 = omni::align_to((omni::ptr_arith_t)pd_total,align);  pd_total = p1 + required;  return 0;}CORBA::BooleancdrCountingStream::reserveOutputSpaceForPrimitiveType(omni::alignment_t align,						      size_t required){  return maybeReserveOutputSpace(align,required);}CORBA::BooleancdrCountingStream::checkOutputOverrun(CORBA::ULong,				      CORBA::ULong,				      omni::alignment_t){  return 0;}voidcdrCountingStream::copy_to(cdrStream&, int, omni::alignment_t) {}voidcdrCountingStream::get_octet_array(CORBA::Octet*,int,omni::alignment_t){}voidcdrCountingStream::skipInput(CORBA::ULong) {}CORBA::BooleancdrCountingStream::checkInputOverrun(CORBA::ULong,CORBA::ULong,				     omni::alignment_t){  return 0;}voidcdrCountingStream::fetchInputData(omni::alignment_t,size_t) {}CORBA::ULongcdrCountingStream::currentInputPtr() const {  return (CORBA::ULong) pd_total;}CORBA::ULongcdrCountingStream::currentOutputPtr() const {   return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -