#include <CDR_Stream.h>
Collaboration diagram for ACE_InputCDR:
This class is based on the the CORBA spec for Java (98-02-29), java class omg.org.CORBA.portable.InputStream. It diverts in a few ways: + Operations to retrieve basic types take parameters by reference. + Operations taking arrays don't have offsets, because in C++ it is easier to describe an array starting from x+offset. + Operations return an error status, because exceptions are not widely available in C++ (yet).
Definition at line 533 of file CDR_Stream.h.
|
Create an input stream from an arbitrary buffer. The buffer must be properly aligned because this contructor will *not* work if the buffer is aligned unproperly.See ACE_ptr_align_binary() for instructions on how to align a pointer properly and use ACE_CDR::MAX_ALIGNMENT for the correct alignment. Definition at line 679 of file CDR_Stream.cpp. References ACE_CDR_BYTE_ORDER, ACE_CDR::Octet, and ACE_Message_Block::wr_ptr().
00684 : start_ (buf, bufsiz), 00685 do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), 00686 good_bit_ (1), 00687 major_version_ (major_version), 00688 minor_version_ (minor_version), 00689 char_translator_ (0), 00690 wchar_translator_ (0) 00691 { 00692 this->start_.wr_ptr (bufsiz); 00693 } |
|
Create an empty input stream. The caller is responsible for putting the right data and providing the right alignment. Definition at line 695 of file CDR_Stream.cpp. References ACE_CDR_BYTE_ORDER, and ACE_CDR::Octet.
00699 : start_ (bufsiz), 00700 do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), 00701 good_bit_ (1), 00702 major_version_ (major_version), 00703 minor_version_ (minor_version), 00704 char_translator_ (0), 00705 wchar_translator_ (0) 00706 { 00707 } |
|
Create an input stream from an ACE_Message_Block. The alignment of the
Definition at line 709 of file CDR_Stream.cpp. References ACE_CDR::Octet, and reset().
00714 : start_ (0, ACE_Message_Block::MB_DATA, 0, 0, 0, lock), 00715 good_bit_ (1), 00716 major_version_ (major_version), 00717 minor_version_ (minor_version), 00718 char_translator_ (0), 00719 wchar_translator_ (0) 00720 00721 { 00722 this->reset (data, byte_order); 00723 } |
|
Create an input stream from an ACE_Data_Block. The indicates whether the can be deleted by the CDR stream or not Definition at line 725 of file CDR_Stream.cpp. References ACE_CDR_BYTE_ORDER, ACE_Message_Block::Message_Flags, and ACE_CDR::Octet.
00730 : start_ (data, flag), 00731 do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), 00732 good_bit_ (1), 00733 major_version_ (major_version), 00734 minor_version_ (minor_version), 00735 char_translator_ (0), 00736 wchar_translator_ (0) 00737 00738 { 00739 } |
|
Create an input stream from an ACE_Data_Block. It also sets the read and write pointers at the desired positions. This would be helpful if the applications desires to create a new CDR stream from a semi-processed datablock. Definition at line 741 of file CDR_Stream.cpp. References ACE_CDR_BYTE_ORDER, ACE_Message_Block::base(), ACE_Message_Block::end(), ACE_Message_Block::Message_Flags, ACE_CDR::Octet, ACE_Message_Block::rd_ptr(), and ACE_Message_Block::wr_ptr().
00748 : start_ (data, flag), 00749 do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), 00750 good_bit_ (1), 00751 major_version_ (major_version), 00752 minor_version_ (minor_version), 00753 char_translator_ (0), 00754 wchar_translator_ (0) 00755 00756 { 00757 // Set the read pointer 00758 this->start_.rd_ptr (rd_pos); 00759 00760 // Set the write pointer after doing a sanity check. 00761 char* wrpos = this->start_.base () + wr_pos; 00762 00763 if (this->start_.end () >= wrpos) 00764 { 00765 this->start_.wr_ptr (wr_pos); 00766 } 00767 } |
|
These make a copy of the current stream state, but do not copy the internal buffer, so the same stream can be read multiple times efficiently. Definition at line 845 of file CDR_Stream.cpp. References ACE_ptr_align_binary, ACE_Message_Block::base(), ACE_Message_Block::rd_ptr(), start_, and ACE_Message_Block::wr_ptr().
00846 : start_ (rhs.start_, 00847 ACE_CDR::MAX_ALIGNMENT), 00848 do_byte_swap_ (rhs.do_byte_swap_), 00849 good_bit_ (1), 00850 major_version_ (rhs.major_version_), 00851 minor_version_ (rhs.minor_version_), 00852 char_translator_ (rhs.char_translator_), 00853 wchar_translator_ (rhs.wchar_translator_) 00854 { 00855 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00856 char *buf = ACE_ptr_align_binary (rhs.start_.base (), 00857 ACE_CDR::MAX_ALIGNMENT); 00858 #else 00859 char *buf = rhs.start_.base (); 00860 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00861 00862 size_t rd_offset = rhs.start_.rd_ptr () - buf; 00863 size_t wr_offset = rhs.start_.wr_ptr () - buf; 00864 this->start_.rd_ptr (rd_offset); 00865 this->start_.wr_ptr (wr_offset); 00866 } |
|
When interpreting indirected TypeCodes it is useful to make a "copy" of the stream starting in the new position. Definition at line 770 of file CDR_Stream.cpp. References ACE_ptr_align_binary, ACE_Message_Block::base(), ACE_CDR::Long, ACE_Message_Block::rd_ptr(), ACE_Message_Block::space(), start_, and ACE_Message_Block::wr_ptr().
00773 : start_ (rhs.start_, 00774 ACE_CDR::MAX_ALIGNMENT), 00775 do_byte_swap_ (rhs.do_byte_swap_), 00776 good_bit_ (1), 00777 major_version_ (rhs.major_version_), 00778 minor_version_ (rhs.minor_version_), 00779 char_translator_ (rhs.char_translator_), 00780 wchar_translator_ (rhs.wchar_translator_) 00781 00782 { 00783 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00784 // Align the base pointer assuming that the incoming stream is also 00785 // aligned the way we are aligned 00786 char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (), 00787 ACE_CDR::MAX_ALIGNMENT); 00788 #else 00789 char *incoming_start = rhs.start_.base (); 00790 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00791 00792 const size_t newpos = 00793 (rhs.start_.rd_ptr() - incoming_start) + offset; 00794 00795 if (newpos <= this->start_.space () 00796 && newpos + size <= this->start_.space ()) 00797 { 00798 this->start_.rd_ptr (newpos); 00799 this->start_.wr_ptr (newpos + size); 00800 } 00801 else 00802 this->good_bit_ = false; 00803 } |
|
This creates an encapsulated stream, the first byte must be (per the spec) the byte order of the encapsulation. Definition at line 805 of file CDR_Stream.cpp. References ACE_CDR_BYTE_ORDER, ACE_ptr_align_binary, ACE_Message_Block::base(), ACE_CDR::Octet, ACE_Message_Block::rd_ptr(), read_octet(), ACE_Message_Block::space(), start_, and ACE_Message_Block::wr_ptr().
00807 : start_ (rhs.start_, 00808 ACE_CDR::MAX_ALIGNMENT), 00809 do_byte_swap_ (rhs.do_byte_swap_), 00810 good_bit_ (1), 00811 major_version_ (rhs.major_version_), 00812 minor_version_ (rhs.minor_version_), 00813 char_translator_ (rhs.char_translator_), 00814 wchar_translator_ (rhs.wchar_translator_) 00815 00816 { 00817 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00818 // Align the base pointer assuming that the incoming stream is also 00819 // aligned the way we are aligned 00820 char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (), 00821 ACE_CDR::MAX_ALIGNMENT); 00822 #else 00823 char *incoming_start = rhs.start_.base (); 00824 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00825 00826 const size_t newpos = 00827 rhs.start_.rd_ptr() - incoming_start; 00828 00829 if (newpos <= this->start_.space () 00830 && newpos + size <= this->start_.space ()) 00831 { 00832 // Notice that ACE_Message_Block::duplicate may leave the 00833 // wr_ptr() with a higher value than what we actually want. 00834 this->start_.rd_ptr (newpos); 00835 this->start_.wr_ptr (newpos + size); 00836 00837 ACE_CDR::Octet byte_order = 0; 00838 this->read_octet (byte_order); 00839 this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); 00840 } 00841 else 00842 this->good_bit_ = false; 00843 } |
|
|
Transfer the contents from to a new CDR.
Definition at line 868 of file CDR_Stream.cpp. References ACE_Data_Block::clone_nocopy(), ACE_Message_Block::data_block(), ACE_Message_Block::rd_ptr(), ACE_Message_Block::replace_data_block(), ACE_InputCDR::Transfer_Contents::rhs_, start_, and ACE_Message_Block::wr_ptr().
00869 : start_ (x.rhs_.start_.data_block ()), 00870 do_byte_swap_ (x.rhs_.do_byte_swap_), 00871 good_bit_ (1), 00872 major_version_ (x.rhs_.major_version_), 00873 minor_version_ (x.rhs_.minor_version_), 00874 char_translator_ (x.rhs_.char_translator_), 00875 wchar_translator_ (x.rhs_.wchar_translator_) 00876 { 00877 00878 this->start_.rd_ptr (x.rhs_.start_.rd_ptr ()); 00879 this->start_.wr_ptr (x.rhs_.start_.wr_ptr ()); 00880 00881 ACE_Data_Block* db = this->start_.data_block ()->clone_nocopy (); 00882 (void) x.rhs_.start_.replace_data_block (db); 00883 } |
|
Destructor.
Definition at line 594 of file CDR_Stream.inl.
00595 { 00596 } |
|
As above, but now the size and alignment requirements may be different. Definition at line 1043 of file CDR_Stream.inl. References ACE_ptr_align_binary, ACE_Message_Block::rd_ptr(), rd_ptr(), and wr_ptr().
01046 { 01047 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 01048 buf = ACE_ptr_align_binary (this->rd_ptr (), align); 01049 #else 01050 buf = this->rd_ptr (); 01051 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 01052 01053 char *end = buf + size; 01054 if (end <= this->wr_ptr ()) 01055 { 01056 this->start_.rd_ptr (end); 01057 return 0; 01058 } 01059 01060 this->good_bit_ = false; 01061 return -1; 01062 #if defined (ACE_LACKS_CDR_ALIGNMENT) 01063 ACE_UNUSED_ARG (align); 01064 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 01065 } |
|
Returns (in buf) the next position in the buffer aligned to size. It advances the Message_Block Definition at line 1068 of file CDR_Stream.inl. Referenced by read_16(), read_2(), read_4(), read_8(), read_array(), and read_wchar_array_i().
01070 { 01071 return this->adjust (size, size, buf); 01072 } |
|
Utility function to allow the user more flexibility. Skips up to the nearest alignment-byte boundary. Argument MUST be a power of 2.
Definition at line 1503 of file CDR_Stream.inl. References ACE_ptr_align_binary, ACE_Message_Block::rd_ptr(), rd_ptr(), and wr_ptr().
01504 { 01505 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 01506 char *buf = ACE_ptr_align_binary (this->rd_ptr (), 01507 alignment); 01508 #else 01509 char *buf = this->rd_ptr (); 01510 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 01511 01512 if (buf <= this->wr_ptr ()) 01513 { 01514 this->start_.rd_ptr (buf); 01515 return 0; 01516 } 01517 01518 this->good_bit_ = false; 01519 return -1; 01520 } |
|
If Definition at line 1497 of file CDR_Stream.inl. References ACE_CDR_BYTE_ORDER, and do_byte_swap().
01498 { 01499 return this->do_byte_swap () ? !ACE_CDR_BYTE_ORDER : ACE_CDR_BYTE_ORDER; 01500 } |
|
Set the codeset translators.
Definition at line 1554 of file CDR_Stream.inl.
01555 { 01556 this->char_translator_ = ctran; 01557 } |
|
Access the codeset translators. They can be nil!
Definition at line 1541 of file CDR_Stream.inl.
01542 { 01543 return this->char_translator_; 01544 } |
|
Definition at line 1572 of file CDR_Stream.cpp. References ACE_Data_Block::clone_nocopy(), ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), do_byte_swap_, major_version_, ACE_CDR::mb_align(), ACE_OS::memcpy(), minor_version_, ACE_Message_Block::rd_ptr(), rd_ptr(), ACE_Message_Block::replace_data_block(), ACE_Message_Block::reset(), ACE_Data_Block::size(), ACE_Message_Block::size(), start_, ACE_Message_Block::wr_ptr(), and wr_ptr().
01573 { 01574 this->do_byte_swap_ = cdr.do_byte_swap_; 01575 01576 // Get the read & write pointer positions in the incoming CDR 01577 // streams 01578 char *rd_ptr = cdr.start_.rd_ptr (); 01579 char *wr_ptr = cdr.start_.wr_ptr (); 01580 01581 // Now reset the incoming CDR stream 01582 cdr.start_.reset (); 01583 01584 // As we have reset the stream, try to align the underlying message 01585 // block in the incoming stream 01586 ACE_CDR::mb_align (&cdr.start_); 01587 01588 // Get the read & write pointer positions again 01589 char *nrd_ptr = cdr.start_.rd_ptr (); 01590 char *nwr_ptr = cdr.start_.wr_ptr (); 01591 01592 // Actual length of the stream is.. 01593 // @todo: This will look idiotic, but we dont seem to have much of a 01594 // choice. How do we calculate the length of the incoming stream? 01595 // Calling the method before calling reset () would give us the 01596 // wrong length of the stream that needs copying. So we do the 01597 // calulation like this 01598 // (1) We get the <rd_ptr> and <wr_ptr> positions of the incoming 01599 // stream. 01600 // (2) Then we reset the <incoming> stream and then align it. 01601 // (3) We get the <rd_ptr> and <wr_ptr> positions again. (Points #1 01602 // thru #3 has been done already) 01603 // (4) The difference in the <rd_ptr> and <wr_ptr> positions gives 01604 // us the following, the actual bytes traversed by the <rd_ptr> and 01605 // <wr_ptr>. 01606 // (5) The bytes traversed by the <wr_ptr> is the actual length of 01607 // the stream. 01608 01609 // Actual bytes traversed 01610 size_t rd_bytes = rd_ptr - nrd_ptr; 01611 size_t wr_bytes = wr_ptr - nwr_ptr; 01612 01613 ACE_CDR::mb_align (&this->start_); 01614 01615 ACE_Data_Block *db = 01616 this->start_.data_block (); 01617 01618 // If the size of the data that needs to be copied are higher than 01619 // what is available, then do a reallocation. 01620 if (wr_bytes > (this->start_.size () - ACE_CDR::MAX_ALIGNMENT)) 01621 { 01622 // @@NOTE: We need to probably add another method to the message 01623 // block interface to simplify this 01624 db = 01625 cdr.start_.data_block ()->clone_nocopy (); 01626 01627 if (db->size ((wr_bytes) + 01628 ACE_CDR::MAX_ALIGNMENT) == -1) 01629 return 0; 01630 01631 // Replace our data block by using the incoming CDR stream. 01632 db = this->start_.replace_data_block (db); 01633 01634 // Align the start_ message block. 01635 ACE_CDR::mb_align (&this->start_); 01636 01637 // Clear the DONT_DELETE flag if it has been set 01638 this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); 01639 } 01640 01641 // Now do the copy 01642 (void) ACE_OS::memcpy (this->start_.wr_ptr (), 01643 cdr.start_.rd_ptr (), 01644 wr_bytes); 01645 01646 // Set the read pointer position to the same point as that was in 01647 // <incoming> cdr. 01648 this->start_.rd_ptr (rd_bytes); 01649 this->start_.wr_ptr (wr_bytes); 01650 01651 // We have changed the read & write pointers for the incoming 01652 // stream. Set them back to the positions that they were before.. 01653 cdr.start_.rd_ptr (rd_bytes); 01654 cdr.start_.wr_ptr (wr_bytes); 01655 01656 this->major_version_ = cdr.major_version_; 01657 this->minor_version_ = cdr.minor_version_; 01658 01659 return db; 01660 } |
|
If Definition at line 1491 of file CDR_Stream.inl. Referenced by byte_order().
01492 { 01493 return this->do_byte_swap_; 01494 } |
|
Points to the continuation field of the current message block.
Definition at line 1019 of file CDR_Stream.inl. References ACE_Message_Block::end().
|
|
Definition at line 1509 of file CDR_Stream.cpp. References ACE_Message_Block::base(), ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), do_byte_swap_, major_version_, ACE_Message_Block::Message_Flags, minor_version_, ACE_CDR::Octet, ACE_Message_Block::rd_ptr(), ACE_Message_Block::replace_data_block(), ACE_Message_Block::reset(), ACE_Message_Block::self_flags(), ACE_Message_Block::set_self_flags(), ACE_Message_Block::size(), start_, and ACE_Message_Block::wr_ptr().
01510 { 01511 // Exchange byte orders 01512 int byte_order = cdr.do_byte_swap_; 01513 cdr.do_byte_swap_ = this->do_byte_swap_; 01514 this->do_byte_swap_ = byte_order; 01515 01516 // Get the destination read and write pointers 01517 size_t drd_pos = 01518 cdr.start_.rd_ptr () - cdr.start_.base (); 01519 size_t dwr_pos = 01520 cdr.start_.wr_ptr () - cdr.start_.base (); 01521 01522 // Get the source read & write pointers 01523 size_t srd_pos = 01524 this->start_.rd_ptr () - this->start_.base (); 01525 size_t swr_pos = 01526 this->start_.wr_ptr () - this->start_.base (); 01527 01528 // Exchange data_blocks. Dont release any of the data blocks. 01529 ACE_Data_Block *dnb = 01530 this->start_.replace_data_block (cdr.start_.data_block ()); 01531 cdr.start_.replace_data_block (dnb); 01532 01533 // Exchange the flags information.. 01534 ACE_Message_Block::Message_Flags df = cdr.start_.self_flags (); 01535 ACE_Message_Block::Message_Flags sf = this->start_.self_flags (); 01536 01537 cdr.start_.clr_self_flags (df); 01538 this->start_.clr_self_flags (sf); 01539 01540 cdr.start_.set_self_flags (sf); 01541 this->start_.set_self_flags (df); 01542 01543 // Reset the <cdr> pointers to zero before it is set again. 01544 cdr.start_.reset (); 01545 this->start_.reset (); 01546 01547 // Set the read and write pointers. 01548 if (cdr.start_.size () >= srd_pos) 01549 cdr.start_.rd_ptr (srd_pos); 01550 01551 if (cdr.start_.size () >= swr_pos) 01552 cdr.start_.wr_ptr (swr_pos); 01553 01554 if (this->start_.size () >= drd_pos) 01555 this->start_.rd_ptr (drd_pos); 01556 01557 if (this->start_.size () >= dwr_pos) 01558 this->start_.wr_ptr (dwr_pos); 01559 01560 ACE_CDR::Octet dmajor = cdr.major_version_; 01561 ACE_CDR::Octet dminor = cdr.minor_version_; 01562 01563 // Exchange the GIOP version info 01564 cdr.major_version_ = this->major_version_; 01565 cdr.minor_version_ = this->minor_version_; 01566 01567 this->major_version_ = dmajor; 01568 this->minor_version_ = dminor; 01569 } |
|
Set the underlying GIOP version..
Definition at line 1532 of file CDR_Stream.inl. References ACE_CDR::Octet.
01534 { 01535 major = this->major_version_; 01536 minor = this->minor_version_; 01537 return 0; 01538 } |
|
returns
Definition at line 1081 of file CDR_Stream.inl. Referenced by operator>>().
01082 { 01083 return this->good_bit_; 01084 } |
|
Grow the internal buffer, reset Definition at line 1474 of file CDR_Stream.cpp. References ACE_CDR::grow(), ACE_CDR::mb_align(), and ACE_Message_Block::wr_ptr().
01475 { 01476 if (ACE_CDR::grow (&this->start_, newsize) == -1) 01477 return -1; 01478 01479 ACE_CDR::mb_align (&this->start_); 01480 this->start_.wr_ptr (newsize); 01481 return 0; 01482 } |
|
Return how many bytes are left in the stream.
Definition at line 692 of file CDR_Stream.inl. References ACE_Message_Block::length(). Referenced by read_boolean_array(), read_char_array(), read_double_array(), read_float_array(), read_long_array(), read_longdouble_array(), read_longlong_array(), read_octet_array(), read_short_array(), read_string(), read_ulong_array(), read_ulonglong_array(), read_ushort_array(), read_wchar_array(), and read_wstring().
|
|
Definition at line 886 of file CDR_Stream.cpp. References char_translator_, ACE_Message_Block::data_block(), do_byte_swap_, ACE_Data_Block::duplicate(), major_version_, minor_version_, ACE_Message_Block::rd_ptr(), start_, and ACE_Message_Block::wr_ptr().
00887 { 00888 if (this != &rhs) 00889 { 00890 this->start_.data_block (rhs.start_.data_block ()->duplicate ()); 00891 this->start_.rd_ptr (rhs.start_.rd_ptr ()); 00892 this->start_.wr_ptr (rhs.start_.wr_ptr ()); 00893 this->do_byte_swap_ = rhs.do_byte_swap_; 00894 this->good_bit_ = true; 00895 this->char_translator_ = rhs.char_translator_; 00896 this->major_version_ = rhs.major_version_; 00897 this->minor_version_ = rhs.minor_version_; 00898 } 00899 return *this; 00900 } |
|
Move the rd_ptr ahead by bytes.
Definition at line 1025 of file CDR_Stream.inl. References ACE_Message_Block::rd_ptr().
|
|
Returns the current position for the
Definition at line 1031 of file CDR_Stream.inl. References ACE_Message_Block::rd_ptr(). Referenced by adjust(), align_read_ptr(), clone_from(), read_1(), skip_bytes(), and skip_string().
|
|
Definition at line 1298 of file CDR_Stream.cpp. References ACE_CDR::Octet, ACE_Message_Block::rd_ptr(), rd_ptr(), and wr_ptr(). Referenced by ACE_WChar_Codeset_Translator::read_1(), ACE_Char_Codeset_Translator::read_1(), read_char(), read_octet(), read_wchar(), skip_char(), skip_octet(), and skip_wchar().
|
|
Definition at line 1403 of file CDR_Stream.cpp. References adjust(), and ACE_CDR::swap_16(). Referenced by read_longdouble(), and skip_longdouble().
01404 { 01405 char *buf = 0; 01406 if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE, 01407 ACE_CDR::LONGDOUBLE_ALIGN, 01408 buf) == 0) 01409 { 01410 #if !defined (ACE_DISABLE_SWAP_ON_READ) 01411 if (!this->do_byte_swap_) 01412 *x = *reinterpret_cast<ACE_CDR::LongDouble *> (buf); 01413 else 01414 ACE_CDR::swap_16 (buf, reinterpret_cast<char*> (x)); 01415 #else 01416 *x = *reinterpret_cast<ACE_CDR::LongDouble*> (buf); 01417 #endif /* ACE_DISABLE_SWAP_ON_READ */ 01418 return true; 01419 } 01420 01421 this->good_bit_ = false; 01422 return false; 01423 } |
|
Definition at line 1312 of file CDR_Stream.cpp. References adjust(), ACE_CDR::swap_2(), and ACE_CDR::UShort. Referenced by ACE_WChar_Codeset_Translator::read_2(), read_short(), read_ushort(), read_wchar(), skip_short(), skip_ushort(), and skip_wchar().
01313 { 01314 char *buf; 01315 if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0) 01316 { 01317 #if !defined (ACE_DISABLE_SWAP_ON_READ) 01318 if (!this->do_byte_swap_) 01319 *x = *reinterpret_cast<ACE_CDR::UShort*> (buf); 01320 else 01321 ACE_CDR::swap_2 (buf, reinterpret_cast<char*> (x)); 01322 #else 01323 *x = *reinterpret_cast<ACE_CDR::UShort*> (buf); 01324 #endif /* ACE_DISABLE_SWAP_ON_READ */ 01325 return true; 01326 } 01327 this->good_bit_ = false; 01328 return false; 01329 } |
|
Definition at line 1332 of file CDR_Stream.cpp. References adjust(), ACE_CDR::swap_4(), and ACE_CDR::ULong. Referenced by ACE_WChar_Codeset_Translator::read_4(), read_float(), read_long(), read_ulong(), read_wchar(), skip_float(), skip_long(), skip_ulong(), and skip_wchar().
01333 { 01334 char *buf = 0; 01335 if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0) 01336 { 01337 #if !defined (ACE_DISABLE_SWAP_ON_READ) 01338 if (!this->do_byte_swap_) 01339 *x = *reinterpret_cast<ACE_CDR::ULong*> (buf); 01340 else 01341 ACE_CDR::swap_4 (buf, reinterpret_cast<char*> (x)); 01342 #else 01343 *x = *reinterpret_cast<ACE_CDR::ULong*> (buf); 01344 #endif /* ACE_DISABLE_SWAP_ON_READ */ 01345 return true; 01346 } 01347 this->good_bit_ = false; 01348 return false; 01349 } |
|
Definition at line 1352 of file CDR_Stream.cpp. References adjust(), ACE_CDR::swap_8(), and ACE_CDR::ULongLong. Referenced by read_double(), read_longlong(), read_ulonglong(), skip_double(), skip_longlong(), and skip_ulonglong().
01353 { 01354 char *buf = 0; 01355 01356 if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0) 01357 { 01358 #if !defined (ACE_DISABLE_SWAP_ON_READ) 01359 # if defined (__arm__) 01360 if (!this->do_byte_swap_) 01361 { 01362 // Convert from Intel format (12345678 => 56781234) 01363 const char *orig = buf; 01364 char *target = reinterpret_cast<char *> (x); 01365 register ACE_UINT32 x = 01366 *reinterpret_cast<const ACE_UINT32 *> (orig); 01367 register ACE_UINT32 y = 01368 *reinterpret_cast<const ACE_UINT32 *> (orig + 4); 01369 *reinterpret_cast<ACE_UINT32 *> (target) = y; 01370 *reinterpret_cast<ACE_UINT32 *> (target + 4) = x; 01371 } 01372 else 01373 { 01374 // Convert from Sparc format (12345678 => 43218765) 01375 const char *orig = buf; 01376 char *target = reinterpret_cast<char *> (x); 01377 register ACE_UINT32 x = 01378 *reinterpret_cast<const ACE_UINT32 *> (orig); 01379 register ACE_UINT32 y = 01380 *reinterpret_cast<const ACE_UINT32 *> (orig + 4); 01381 x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); 01382 y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24); 01383 *reinterpret_cast<ACE_UINT32 *> (target) = x; 01384 *reinterpret_cast<ACE_UINT32 *> (target + 4) = y; 01385 } 01386 # else 01387 if (!this->do_byte_swap_) 01388 *x = *reinterpret_cast<ACE_CDR::ULongLong *> (buf); 01389 else 01390 ACE_CDR::swap_8 (buf, reinterpret_cast<char *> (x)); 01391 # endif /* !__arm__ */ 01392 #else 01393 *x = *reinterpret_cast<ACE_CDR::ULongLong *> (buf); 01394 #endif /* ACE_DISABLE_SWAP_ON_READ */ 01395 return true; 01396 } 01397 01398 this->good_bit_ = false; 01399 return false; 01400 } |
|
Read an array of elements, each of bytes and the start aligned at a multiple of . The elements are assumed to be packed with the right alignment restrictions. It is mostly designed for buffers of the basic types. This operation uses ; as explained above it is expected that using assignment is faster that for one element, but for several elements should be more efficient, it could be interesting to find the break even point and optimize for that case, but that would be too platform dependent. Definition at line 1188 of file CDR_Stream.cpp. References adjust(), ACE_OS::memcpy(), ACE_CDR::swap_16_array(), ACE_CDR::swap_2_array(), ACE_CDR::swap_4_array(), ACE_CDR::swap_8_array(), and ACE_CDR::ULong. Referenced by ACE_WChar_Codeset_Translator::read_array(), ACE_Char_Codeset_Translator::read_array(), read_char_array(), read_double_array(), read_float_array(), read_long_array(), read_longdouble_array(), read_longlong_array(), read_octet_array(), read_short_array(), read_ulong_array(), read_ulonglong_array(), read_ushort_array(), read_wchar(), and read_wchar_array().
01192 { 01193 if (length == 0) 01194 return true; 01195 char* buf = 0; 01196 01197 if (this->adjust (size * length, align, buf) == 0) 01198 { 01199 #if defined (ACE_DISABLE_SWAP_ON_READ) 01200 ACE_OS::memcpy (x, buf, size*length); 01201 #else 01202 if (!this->do_byte_swap_ || size == 1) 01203 ACE_OS::memcpy (x, buf, size*length); 01204 else 01205 { 01206 char *target = reinterpret_cast<char*> (x); 01207 switch (size) 01208 { 01209 case 2: 01210 ACE_CDR::swap_2_array (buf, target, length); 01211 break; 01212 case 4: 01213 ACE_CDR::swap_4_array (buf, target, length); 01214 break; 01215 case 8: 01216 ACE_CDR::swap_8_array (buf, target, length); 01217 break; 01218 case 16: 01219 ACE_CDR::swap_16_array (buf, target, length); 01220 break; 01221 default: 01222 // TODO: print something? 01223 this->good_bit_ = false; 01224 return false; 01225 } 01226 } 01227 #endif /* ACE_DISABLE_SWAP_ON_READ */ 01228 return this->good_bit_; 01229 } 01230 return false; 01231 } |
|
Return Definition at line 605 of file CDR_Stream.inl. References ACE_CDR::Boolean, ACE_CDR::Octet, and read_octet(). Referenced by ACE_OutputCDR::append_boolean(), operator>>(), and read_boolean_array().
00606 { 00607 ACE_CDR::Octet tmp = 0; 00608 this->read_octet (tmp); 00609 x = tmp ? true : false; 00610 return (ACE_CDR::Boolean) this->good_bit_; 00611 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 1275 of file CDR_Stream.cpp. References ACE_CDR::Boolean, length(), read_boolean(), and ACE_CDR::ULong.
01277 { 01278 // Make sure the length of the array isn't greater than the length of 01279 // the stream. 01280 if (length > this->length ()) 01281 { 01282 this->good_bit_ = false; 01283 return false; 01284 } 01285 01286 // It is hard to optimize this, the spec requires that on the wire 01287 // booleans be represented as a byte with value 0 or 1, but in 01288 // memoery it is possible (though very unlikely) that a boolean has 01289 // a non-zero value (different from 1). 01290 // We resort to a simple loop. 01291 for (ACE_CDR::ULong i = 0; i != length && this->good_bit_; ++i) 01292 this->read_boolean (x[i]); 01293 01294 return this->good_bit_; 01295 } |
|
Return Definition at line 614 of file CDR_Stream.inl. References ACE_CDR::Char, read_1(), and ACE_Char_Codeset_Translator::read_char(). Referenced by ACE_OutputCDR::append_char(), and operator>>().
00615 { 00616 if (this->char_translator_ == 0) 00617 { 00618 void *temp = &x; 00619 return this->read_1 (reinterpret_cast<ACE_CDR::Octet*> (temp)); 00620 } 00621 return this->char_translator_->read_char (*this, x); 00622 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 698 of file CDR_Stream.inl. References ACE_CDR::Char, length(), read_array(), ACE_Char_Codeset_Translator::read_char_array(), and ACE_CDR::ULong. Referenced by operator>>(), and read_string().
00700 { 00701 // Make sure the length of the array isn't greater than the length of 00702 // the stream. 00703 if (length > this->length ()) 00704 { 00705 this->good_bit_ = false; 00706 return false; 00707 } 00708 00709 if (this->char_translator_ == 0) 00710 return this->read_array (x, 00711 ACE_CDR::OCTET_SIZE, 00712 ACE_CDR::OCTET_ALIGN, 00713 length); 00714 return this->char_translator_->read_char_array (*this, x, length); 00715 } |
|
Return Definition at line 678 of file CDR_Stream.inl. References read_8(). Referenced by ACE_OutputCDR::append_double(), and operator>>().
00679 { 00680 void *temp = &x; 00681 return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp)); 00682 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 887 of file CDR_Stream.inl. References length(), read_array(), and ACE_CDR::ULong.
00889 { 00890 // Make sure the length of the array isn't greater than the length of 00891 // the stream. 00892 if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) 00893 { 00894 this->good_bit_ = false; 00895 return false; 00896 } 00897 00898 return this->read_array (x, 00899 ACE_CDR::LONGLONG_SIZE, 00900 ACE_CDR::LONGLONG_ALIGN, 00901 length); 00902 } |
|
Return Definition at line 671 of file CDR_Stream.inl. References read_4(). Referenced by ACE_OutputCDR::append_float(), and operator>>().
00672 { 00673 void *temp = &x; 00674 return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp)); 00675 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 868 of file CDR_Stream.inl. References length(), read_array(), and ACE_CDR::ULong.
00870 { 00871 // Make sure the length of the array isn't greater than the length of 00872 // the stream. 00873 if (length * ACE_CDR::LONG_SIZE > this->length ()) 00874 { 00875 this->good_bit_ = false; 00876 return false; 00877 } 00878 00879 return this->read_array (x, 00880 ACE_CDR::LONG_SIZE, 00881 ACE_CDR::LONG_ALIGN, 00882 length); 00883 } |
|
Return Definition at line 641 of file CDR_Stream.inl. References ACE_CDR::Long, and read_4(). Referenced by ACE_OutputCDR::append_long(), and operator>>().
00642 { 00643 void *temp = &x; 00644 return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp)); 00645 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 796 of file CDR_Stream.inl. References length(), ACE_CDR::Long, read_array(), and ACE_CDR::ULong.
00798 { 00799 // Make sure the length of the array isn't greater than the length of 00800 // the stream. 00801 if (length * ACE_CDR::LONG_SIZE > this->length ()) 00802 { 00803 this->good_bit_ = false; 00804 return false; 00805 } 00806 00807 return this->read_array (x, 00808 ACE_CDR::LONG_SIZE, 00809 ACE_CDR::LONG_ALIGN, 00810 length); 00811 } |
|
Return Definition at line 685 of file CDR_Stream.inl. References read_16(). Referenced by ACE_OutputCDR::append_longdouble(), and operator>>().
00686 { 00687 void *temp = &x; 00688 return this->read_16 (reinterpret_cast<ACE_CDR::LongDouble*> (temp)); 00689 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 905 of file CDR_Stream.inl. References length(), read_array(), and ACE_CDR::ULong.
00907 { 00908 // Make sure the length of the array isn't greater than the length of 00909 // the stream. 00910 if (length * ACE_CDR::LONGDOUBLE_SIZE > this->length ()) 00911 { 00912 this->good_bit_ = false; 00913 return false; 00914 } 00915 return this->read_array (x, 00916 ACE_CDR::LONGDOUBLE_SIZE, 00917 ACE_CDR::LONGDOUBLE_ALIGN, 00918 length); 00919 } |
|
Return Definition at line 657 of file CDR_Stream.inl. References ACE_CDR::LongLong, and read_8(). Referenced by ACE_OutputCDR::append_longlong(), and operator>>().
00658 { 00659 void *temp = &x; 00660 return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp)); 00661 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 832 of file CDR_Stream.inl. References length(), ACE_CDR::LongLong, read_array(), and ACE_CDR::ULong.
00834 { 00835 // Make sure the length of the array isn't greater than the length of 00836 // the stream. 00837 if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) 00838 { 00839 this->good_bit_ = false; 00840 return false; 00841 } 00842 00843 return this->read_array (x, 00844 ACE_CDR::LONGLONG_SIZE, 00845 ACE_CDR::LONGLONG_ALIGN, 00846 length); 00847 } |
|
Return Definition at line 599 of file CDR_Stream.inl. References ACE_CDR::Octet, and read_1(). Referenced by ACE_InputCDR(), ACE_OutputCDR::append_octet(), operator>>(), read_boolean(), and skip_boolean().
00600 { 00601 return this->read_1 (&x); 00602 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 742 of file CDR_Stream.inl. References length(), ACE_CDR::Octet, read_array(), and ACE_CDR::ULong.
00744 { 00745 // Make sure the length of the array isn't greater than the length of 00746 // the stream. 00747 if (length * ACE_CDR::OCTET_SIZE > this->length ()) 00748 { 00749 this->good_bit_ = false; 00750 return false; 00751 } 00752 00753 return this->read_array (x, 00754 ACE_CDR::OCTET_SIZE, 00755 ACE_CDR::OCTET_ALIGN, 00756 length); 00757 } |
|
Return Definition at line 626 of file CDR_Stream.inl. References read_2(), and ACE_CDR::Short. Referenced by ACE_OutputCDR::append_short(), and operator>>().
00627 { 00628 void *temp = &x; 00629 return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp)); 00630 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 760 of file CDR_Stream.inl. References length(), read_array(), ACE_CDR::Short, and ACE_CDR::ULong.
00762 { 00763 // Make sure the length of the array isn't greater than the length of 00764 // the stream. 00765 if (length * ACE_CDR::SHORT_SIZE > this->length ()) 00766 { 00767 this->good_bit_ = false; 00768 return false; 00769 } 00770 00771 return this->read_array (x, 00772 ACE_CDR::SHORT_SIZE, 00773 ACE_CDR::SHORT_ALIGN, 00774 length); 00775 } |
|
Return Definition at line 1097 of file CDR_Stream.cpp. References ACE_CString, ACE_CDR::Char, and read_string().
01098 { 01099 ACE_CDR::Char *data = 0; 01100 if (this->read_string (data)) 01101 { 01102 x = data; 01103 delete [] data; 01104 return true; 01105 } 01106 01107 x = ""; 01108 return (this->good_bit_ = false); 01109 } |
|
Return Definition at line 1052 of file CDR_Stream.cpp. References ACE_NEW_RETURN, ACE_CDR::Char, length(), read_char_array(), ACE_Char_Codeset_Translator::read_string(), read_ulong(), ACE_OS::strcpy(), and ACE_CDR::ULong. Referenced by ACE_OutputCDR::append_string(), operator>>(), and read_string().
01053 { 01054 // @@ This is a slight violation of "Optimize for the common case", 01055 // i.e. normally the translator will be 0, but OTOH the code is 01056 // smaller and should be better for the cache ;-) ;-) 01057 if (this->char_translator_ != 0) 01058 { 01059 this->good_bit_ = this->char_translator_->read_string (*this, x); 01060 return this->good_bit_; 01061 } 01062 01063 ACE_CDR::ULong len = 0; 01064 01065 if (!this->read_ulong (len)) 01066 return false; 01067 01068 // A check for the length being too great is done later in the 01069 // call to read_char_array but we want to have it done before 01070 // the memory is allocated. 01071 if (len > 0 && len <= this->length()) 01072 { 01073 ACE_NEW_RETURN (x, 01074 ACE_CDR::Char[len], 01075 0); 01076 if (this->read_char_array (x, len)) 01077 return true; 01078 01079 delete [] x; 01080 } 01081 else if (len == 0) 01082 { 01083 // Convert any null strings to empty strings since empty 01084 // strings can cause crashes. (See bug 58.) 01085 ACE_NEW_RETURN (x, 01086 ACE_CDR::Char[1], 01087 0); 01088 ACE_OS::strcpy (const_cast<char *&> (x), ""); 01089 return true; 01090 } 01091 01092 x = 0; 01093 return (this->good_bit_ = false); 01094 } |
|
Return Definition at line 649 of file CDR_Stream.inl. References read_4(), and ACE_CDR::ULong. Referenced by ACE_OutputCDR::append_ulong(), operator>>(), read_string(), read_wstring(), skip_string(), and skip_wstring().
00650 { 00651 void *temp = &x; 00652 return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp)); 00653 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 814 of file CDR_Stream.inl. References length(), read_array(), and ACE_CDR::ULong.
00816 { 00817 // Make sure the length of the array isn't greater than the length of 00818 // the stream. 00819 if (length * ACE_CDR::LONG_SIZE > this->length ()) 00820 { 00821 this->good_bit_ = false; 00822 return false; 00823 } 00824 00825 return this->read_array (x, 00826 ACE_CDR::LONG_SIZE, 00827 ACE_CDR::LONG_ALIGN, 00828 length); 00829 } |
|
Return Definition at line 664 of file CDR_Stream.inl. References read_8(), and ACE_CDR::ULongLong. Referenced by ACE_OutputCDR::append_ulonglong(), and operator>>().
00665 { 00666 void *temp = &x; 00667 return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp)); 00668 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 850 of file CDR_Stream.inl. References length(), read_array(), ACE_CDR::ULong, and ACE_CDR::ULongLong.
00852 { 00853 // Make sure the length of the array isn't greater than the length of 00854 // the stream. 00855 if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) 00856 { 00857 this->good_bit_ = false; 00858 return false; 00859 } 00860 00861 return this->read_array (x, 00862 ACE_CDR::LONGLONG_SIZE, 00863 ACE_CDR::LONGLONG_ALIGN, 00864 length); 00865 } |
|
Return Definition at line 633 of file CDR_Stream.inl. References read_2(), and ACE_CDR::UShort. Referenced by ACE_OutputCDR::append_ushort(), and operator>>().
00634 { 00635 void *temp = &x; 00636 return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp)); 00637 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 778 of file CDR_Stream.inl. References length(), read_array(), ACE_CDR::ULong, and ACE_CDR::UShort.
00780 { 00781 // Make sure the length of the array isn't greater than the length of 00782 // the stream. 00783 if (length * ACE_CDR::SHORT_SIZE > this->length ()) 00784 { 00785 this->good_bit_ = false; 00786 return false; 00787 } 00788 00789 return this->read_array (x, 00790 ACE_CDR::SHORT_SIZE, 00791 ACE_CDR::SHORT_ALIGN, 00792 length); 00793 } |
|
Return Definition at line 954 of file CDR_Stream.cpp. References ACE_CDR::Octet, read_1(), read_2(), read_4(), read_array(), ACE_WChar_Codeset_Translator::read_wchar(), ACE_CDR::Short, ACE_CDR::UShort, and ACE_CDR::WChar. Referenced by ACE_OutputCDR::append_wchar(), and operator>>().
00955 { 00956 if (this->wchar_translator_ != 0) 00957 { 00958 this->good_bit_ = this->wchar_translator_->read_wchar (*this,x); 00959 return this->good_bit_; 00960 } 00961 if (ACE_OutputCDR::wchar_maxbytes_ == 0) 00962 { 00963 errno = EACCES; 00964 return (this->good_bit_ = false); 00965 } 00966 00967 if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) 00968 { 00969 if (static_cast<ACE_CDR::Short> (major_version_) == 1 00970 && static_cast<ACE_CDR::Short> (minor_version_) == 2) 00971 { 00972 ACE_CDR::Octet len; 00973 00974 if (this->read_1 (&len)) 00975 return this->read_array 00976 (reinterpret_cast<ACE_CDR::Octet*> (&x), 00977 static_cast<ACE_CDR::ULong> (len), 00978 ACE_CDR::OCTET_ALIGN, 00979 1); 00980 00981 else 00982 return (this->good_bit_ = false); 00983 } 00984 00985 if (sizeof (ACE_CDR::WChar) == 2) 00986 return this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (&x)); 00987 else 00988 return this->read_4 (reinterpret_cast<ACE_CDR::ULong *> (&x)); 00989 } 00990 00991 if (static_cast<ACE_CDR::Short> (major_version_) == 1 00992 && static_cast<ACE_CDR::Short> (minor_version_) == 2) 00993 { 00994 ACE_CDR::Octet len; 00995 00996 if (this->read_1 (&len)) 00997 { 00998 if (len == 2) 00999 { 01000 ACE_CDR::Short sx; 01001 if (this->read_array 01002 (reinterpret_cast<ACE_CDR::Octet*> (&sx), 01003 static_cast<ACE_CDR::ULong> (len), 01004 ACE_CDR::OCTET_ALIGN, 01005 1)) 01006 { 01007 x = static_cast<ACE_CDR::WChar> (sx); 01008 return true; 01009 } 01010 } 01011 else 01012 { 01013 ACE_CDR::Octet ox; 01014 if (this->read_array 01015 (reinterpret_cast<ACE_CDR::Octet*> (&ox), 01016 static_cast<ACE_CDR::ULong> (len), 01017 ACE_CDR::OCTET_ALIGN, 01018 1)) 01019 { 01020 x = static_cast<ACE_CDR::WChar> (ox); 01021 return true; 01022 } 01023 } 01024 } 01025 } 01026 else 01027 { 01028 if (ACE_OutputCDR::wchar_maxbytes_ == 2) 01029 { 01030 ACE_CDR::UShort sx; 01031 if (this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (&sx))) 01032 { 01033 x = static_cast<ACE_CDR::WChar> (sx); 01034 return true; 01035 } 01036 } 01037 else 01038 { 01039 ACE_CDR::Octet ox; 01040 if (this->read_1 (&ox)) 01041 { 01042 x = static_cast<ACE_CDR::WChar> (ox); 01043 return true; 01044 } 01045 01046 } 01047 } 01048 return (this->good_bit_ = false); 01049 } |
|
The buffer x must be large enough to contain length elements. Return Definition at line 718 of file CDR_Stream.inl. References length(), read_array(), ACE_WChar_Codeset_Translator::read_wchar_array(), read_wchar_array_i(), ACE_CDR::ULong, and ACE_CDR::WChar. Referenced by operator>>(), and read_wstring().
00720 { 00721 // Make sure the length of the array isn't greater than the length of 00722 // the stream. 00723 if (length * ACE_OutputCDR::wchar_maxbytes_ > this->length ()) 00724 { 00725 this->good_bit_ = false; 00726 return false; 00727 } 00728 00729 if (this->wchar_translator_ != 0) 00730 return this->wchar_translator_->read_wchar_array (*this, x, length); 00731 if (ACE_OutputCDR::wchar_maxbytes_ != sizeof (ACE_CDR::WChar)) 00732 return this->read_wchar_array_i (x, length); 00733 return this->read_array (x, 00734 sizeof (ACE_CDR::WChar), 00735 sizeof (ACE_CDR::WChar) == 2 00736 ? ACE_CDR::SHORT_ALIGN 00737 : ACE_CDR::LONG_ALIGN, 00738 length); 00739 } |
|
On those occasions when the native codeset for wchar is smaller than the size of a wchar_t, such as using UTF-16 with a 4-byte wchar_t, a special form of reading the array is needed. Actually, this should be a default translator. Definition at line 1234 of file CDR_Stream.cpp. References adjust(), ACE_CDR::swap_2(), ACE_CDR::ULong, ACE_CDR::UShort, and ACE_CDR::WChar. Referenced by read_wchar_array().
01236 { 01237 if (length == 0) 01238 return true; 01239 char* buf = 0; 01240 const size_t align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ? 01241 ACE_CDR::SHORT_ALIGN : 01242 ACE_CDR::OCTET_ALIGN; 01243 01244 if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0) 01245 { 01246 if (ACE_OutputCDR::wchar_maxbytes_ == 2) 01247 { 01248 ACE_CDR::UShort *sb = reinterpret_cast<ACE_CDR::UShort *> (buf); 01249 for (size_t i = 0; i < length; ++i) 01250 #if defined (ACE_DISABLE_SWAP_ON_READ) 01251 x[i] = static_cast<ACE_CDR::WChar> (sb[i]); 01252 #else 01253 if (!this->do_byte_swap_) 01254 x[i] = static_cast<ACE_CDR::WChar> (sb[i]); 01255 else 01256 { 01257 ACE_CDR::UShort sx; 01258 ACE_CDR::swap_2 (&buf[i * 2], reinterpret_cast<char *> (&sx)); 01259 x[i] = static_cast<ACE_CDR::WChar> (sx); 01260 } 01261 #endif /* ACE_DISABLE_SWAP_ON_READ */ 01262 } 01263 else 01264 { 01265 for (size_t i = 0; i < length; ++i) 01266 x[i] = static_cast<ACE_CDR::Octet> (buf[i]); 01267 } 01268 return this->good_bit_; 01269 } 01270 return false; 01271 } |
|
Return Definition at line 1112 of file CDR_Stream.cpp. References ACE_NEW_RETURN, length(), read_ulong(), read_wchar_array(), ACE_WChar_Codeset_Translator::read_wstring(), ACE_CDR::ULong, and ACE_CDR::WChar. Referenced by ACE_OutputCDR::append_wstring(), and operator>>().
01113 { 01114 // @@ This is a slight violation of "Optimize for the common case", 01115 // i.e. normally the translator will be 0, but OTOH the code is 01116 // smaller and should be better for the cache ;-) ;-) 01117 if (this->wchar_translator_ != 0) 01118 { 01119 this->good_bit_ = this->wchar_translator_->read_wstring (*this, x); 01120 return this->good_bit_; 01121 } 01122 if (ACE_OutputCDR::wchar_maxbytes_ == 0) 01123 { 01124 errno = EACCES; 01125 return (this->good_bit_ = false); 01126 } 01127 01128 ACE_CDR::ULong len = 0; 01129 if (!this->read_ulong (len)) 01130 return false; 01131 01132 // A check for the length being too great is done later in the 01133 // call to read_char_array but we want to have it done before 01134 // the memory is allocated. 01135 if (len > 0 && len <= this->length ()) 01136 { 01137 01138 if (static_cast<ACE_CDR::Short> (this->major_version_) == 1 01139 && static_cast<ACE_CDR::Short> (this->minor_version_) == 2) 01140 { 01141 len /= ACE_OutputCDR::wchar_maxbytes_; 01142 01143 //allocating one extra for the null character needed by applications 01144 ACE_NEW_RETURN (x, 01145 ACE_CDR::WChar [len + 1], 01146 false); 01147 01148 if (this->read_wchar_array (x, len)) 01149 { 01150 01151 //Null character used by applications to find the end of 01152 //the wstring 01153 //Is this okay with the GIOP 1.2 spec?? 01154 x[len] = '\x00'; 01155 01156 return true; 01157 } 01158 } 01159 else 01160 { 01161 ACE_NEW_RETURN (x, 01162 ACE_CDR::WChar [len], 01163 false); 01164 01165 if (this->read_wchar_array (x, len)) 01166 return true; 01167 } 01168 01169 delete [] x; 01170 } 01171 else if (len == 0) 01172 { 01173 // Convert any null strings to empty strings since empty 01174 // strings can cause crashes. (See bug 58.) 01175 ACE_NEW_RETURN (x, 01176 ACE_CDR::WChar[1], 01177 false); 01178 x[0] = '\x00'; 01179 return true; 01180 } 01181 01182 this->good_bit_ = false; 01183 x = 0; 01184 return false; 01185 } |
|
Re-initialize the CDR stream, copying the contents of the chain of message_blocks starting from data. Definition at line 1485 of file CDR_Stream.cpp. References ACE_CDR::consolidate(), and reset_byte_order(). Referenced by ACE_InputCDR().
01487 { 01488 this->reset_byte_order (byte_order); 01489 ACE_CDR::consolidate (&this->start_, data); 01490 } |
|
After reading and partially parsing the contents the user can detect a change in the byte order, this method will let him/her change it. Definition at line 1485 of file CDR_Stream.inl. References ACE_CDR_BYTE_ORDER. Referenced by reset().
01486 { 01487 this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); 01488 } |
|
Re-initialize the CDR stream, forgetting about the old contents of the stream and allocating a new buffer (from the allocators). Definition at line 1679 of file CDR_Stream.cpp. References ACE_Message_Block::clr_self_flags(), and ACE_Message_Block::data_block(). Referenced by steal_from().
01680 { 01681 this->start_.data_block (this->start_.data_block ()->clone_nocopy 01682 ()); 01683 01684 // Reset the flags... 01685 this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); 01686 } |
|
Set the underlying GIOP version..
Definition at line 1523 of file CDR_Stream.inl. References ACE_CDR::Octet.
01525 { 01526 this->major_version_ = major; 01527 this->minor_version_ = minor; 01528 return 0; 01529 } |
|
Return Definition at line 937 of file CDR_Stream.inl. References ACE_CDR::Boolean, ACE_CDR::Octet, and read_octet().
00938 { 00939 ACE_CDR::Octet tmp; 00940 this->read_octet (tmp); 00941 return (ACE_CDR::Boolean) this->good_bit_; 00942 } |
|
Skip n bytes in the CDR stream.
Definition at line 1462 of file CDR_Stream.cpp. References rd_ptr(), and wr_ptr(). Referenced by skip_wchar(), and skip_wstring().
|
|
Return Definition at line 922 of file CDR_Stream.inl. References ACE_CDR::Char, and read_1().
00923 { 00924 ACE_CDR::Char x; 00925 void *temp = &x; 00926 return this->read_1 (reinterpret_cast<ACE_CDR::Octet*> (temp)); 00927 } |
|
Return Definition at line 1003 of file CDR_Stream.inl. References read_8().
01004 { 01005 double x; 01006 void *temp = &x; 01007 return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp)); 01008 } |
|
Return Definition at line 993 of file CDR_Stream.inl. References read_4(), and ACE_CDR::ULong.
00994 { 00995 // Changing this removes the warning for GHS and it 00996 // stops the compiler from getting an internal error. 00997 ACE_CDR::ULong value; 00998 void *temp = &value; 00999 return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp)); 01000 } |
|
Return Definition at line 961 of file CDR_Stream.inl. References ACE_CDR::Long, and read_4().
00962 { 00963 ACE_CDR::Long x; 00964 void *temp = &x; 00965 return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp)); 00966 } |
|
Return Definition at line 1011 of file CDR_Stream.inl. References read_16().
01012 { 01013 ACE_CDR::LongDouble x; 01014 void *temp = &x; 01015 return this->read_16 (reinterpret_cast<ACE_CDR::LongDouble*> (temp)); 01016 } |
|
Return Definition at line 977 of file CDR_Stream.inl. References ACE_CDR::LongLong, and read_8().
00978 { 00979 ACE_CDR::LongLong x; 00980 void *temp = &x; 00981 return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp)); 00982 } |
|
Return Definition at line 930 of file CDR_Stream.inl. References ACE_CDR::Octet, and read_1().
00931 { 00932 ACE_CDR::Octet x; 00933 return this->read_1 (&x); 00934 } |
|
Return Definition at line 945 of file CDR_Stream.inl. References read_2(), and ACE_CDR::Short.
00946 { 00947 ACE_CDR::Short x; 00948 void *temp = &x; 00949 return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp)); 00950 } |
|
Definition at line 1426 of file CDR_Stream.cpp. References rd_ptr(), read_ulong(), ACE_CDR::ULong, and wr_ptr().
01427 { 01428 ACE_CDR::ULong len = 0; 01429 if (this->read_ulong (len)) 01430 { 01431 if (this->rd_ptr () + len <= this->wr_ptr ()) 01432 { 01433 this->rd_ptr (len); 01434 return true; 01435 } 01436 this->good_bit_ = false; 01437 } 01438 return false; 01439 } |
|
Return Definition at line 969 of file CDR_Stream.inl. References read_4(), and ACE_CDR::ULong.
00970 { 00971 ACE_CDR::ULong x; 00972 void *temp = &x; 00973 return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp)); 00974 } |
|
Return Definition at line 985 of file CDR_Stream.inl. References read_8(), and ACE_CDR::ULongLong.
00986 { 00987 ACE_CDR::ULongLong x; 00988 void *temp = &x; 00989 return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp)); 00990 } |
|
Return Definition at line 953 of file CDR_Stream.inl. References read_2(), and ACE_CDR::UShort.
00954 { 00955 ACE_CDR::UShort x; 00956 void *temp = &x; 00957 return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp)); 00958 } |
|
Return Definition at line 932 of file CDR_Stream.cpp. References ACE_CDR::Octet, read_1(), read_2(), read_4(), skip_bytes(), and ACE_CDR::WChar. Referenced by skip_wstring().
00933 { 00934 if (static_cast<ACE_CDR::Short> (major_version_) == 1 00935 && static_cast<ACE_CDR::Short> (minor_version_) == 2) 00936 { 00937 ACE_CDR::Octet len; 00938 if (this->read_1 (&len)) 00939 return this->skip_bytes (static_cast<size_t> (len)); 00940 } 00941 else 00942 { 00943 ACE_CDR::WChar x; 00944 if (ACE_OutputCDR::wchar_maxbytes_ == 2) 00945 return this->read_2 (reinterpret_cast<ACE_CDR::UShort *> (&x)); 00946 else 00947 return this->read_4 (reinterpret_cast<ACE_CDR::ULong *> (&x)); 00948 } 00949 00950 return (this->good_bit_ = false); 00951 } |
|
The next field must be a string, this method skips it. It is useful in parsing a TypeCode.
Definition at line 1442 of file CDR_Stream.cpp. References ACE_CDR::Boolean, read_ulong(), skip_bytes(), skip_wchar(), and ACE_CDR::ULong.
01443 { 01444 ACE_CDR::Boolean continue_skipping = true; 01445 ACE_CDR::ULong len = 0; 01446 01447 continue_skipping = read_ulong (len); 01448 01449 if (continue_skipping != false && len != 0) 01450 { 01451 if (static_cast<ACE_CDR::Short> (this->major_version_) == 1 01452 && static_cast<ACE_CDR::Short> (this->minor_version_) == 2) 01453 continue_skipping = this->skip_bytes ((size_t)len); 01454 else 01455 while (continue_skipping != false && len--) 01456 continue_skipping = this->skip_wchar (); 01457 } 01458 return continue_skipping; 01459 } |
|
Definition at line 1075 of file CDR_Stream.inl.
01076 { 01077 return &this->start_; 01078 } |
|
Steal the contents from the current CDR.
Definition at line 1663 of file CDR_Stream.cpp. References ACE_Data_Block::clone(), ACE_Message_Block::clone(), ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), and ACE_CDR::mb_align().
01664 { 01665 ACE_Message_Block* block = 01666 this->start_.clone (); 01667 this->start_.data_block (block->data_block ()->clone ()); 01668 01669 // If at all our message had a DONT_DELETE flag set, just clear it 01670 // off. 01671 this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); 01672 01673 ACE_CDR::mb_align (&this->start_); 01674 01675 return block; 01676 } |
|
Steal the contents of cdr and make a shallow copy into this stream. Definition at line 1493 of file CDR_Stream.cpp. References ACE_Message_Block::clr_self_flags(), ACE_Message_Block::data_block(), do_byte_swap_, ACE_Data_Block::duplicate(), major_version_, minor_version_, ACE_Message_Block::rd_ptr(), reset_contents(), start_, and ACE_Message_Block::wr_ptr().
01494 { 01495 this->do_byte_swap_ = cdr.do_byte_swap_; 01496 this->start_.data_block (cdr.start_.data_block ()->duplicate ()); 01497 01498 // If the message block had a DONT_DELETE flags, just clear it off.. 01499 this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); 01500 this->start_.rd_ptr (cdr.start_.rd_ptr ()); 01501 01502 this->start_.wr_ptr (cdr.start_.wr_ptr ()); 01503 this->major_version_ = cdr.major_version_; 01504 this->minor_version_ = cdr.minor_version_; 01505 cdr.reset_contents (); 01506 } |
|
Definition at line 1560 of file CDR_Stream.inl.
01561 { 01562 this->wchar_translator_ = wctran; 01563 } |
|
Definition at line 1547 of file CDR_Stream.inl.
01548 { 01549 return this->wchar_translator_; 01550 } |
|
Returns the current position for the
Definition at line 1037 of file CDR_Stream.inl. References ACE_Message_Block::wr_ptr(). Referenced by adjust(), align_read_ptr(), clone_from(), read_1(), skip_bytes(), and skip_string().
|
|
The Codeset translators need access to some private members to efficiently marshal arrays For reading from an output CDR stream. Definition at line 538 of file CDR_Stream.h. |
|
Definition at line 539 of file CDR_Stream.h. |
|
If not nil, invoke for translation of character and string data.
Definition at line 928 of file CDR_Stream.h. Referenced by operator=(). |
|
The CDR stream byte order does not match the one on the machine, swapping is needed while reading. Definition at line 918 of file CDR_Stream.h. Referenced by clone_from(), exchange_data_blocks(), operator=(), and steal_from(). |
|
set to
Definition at line 921 of file CDR_Stream.h. |
|
The GIOP versions for this stream.
Definition at line 924 of file CDR_Stream.h. Referenced by clone_from(), exchange_data_blocks(), ACE_WChar_Codeset_Translator::major_version(), ACE_Char_Codeset_Translator::major_version(), operator=(), and steal_from(). |
|
Definition at line 925 of file CDR_Stream.h. Referenced by clone_from(), exchange_data_blocks(), ACE_WChar_Codeset_Translator::minor_version(), ACE_Char_Codeset_Translator::minor_version(), operator=(), and steal_from(). |
|
The start of the chain of message blocks, even though in the current version the chain always has length 1. Definition at line 914 of file CDR_Stream.h. Referenced by ACE_InputCDR(), clone_from(), exchange_data_blocks(), operator=(), and steal_from(). |
|
Definition at line 929 of file CDR_Stream.h. |