View Single Post
  #1 (permalink)  
Old 02-24-2003
rodrigc rodrigc is offline
Registered User
 
 
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 27
Cool Questions about sequence<byte> in C++?

Hi,

In CORBA C++, I'm used to dealing with sequence<octet>.
This maps to a CORBA::Octet buffer (which basically is a char buffer),
which you can manipulate quite
easily with get_buffer() and replace().

In Ice, a sequence<byte> maps to a vector<Ice::Byte>.

Is there a way to do the CORBA C++ equivalent of get_buffer() and
replace()?

To try thiings out in Ice, I made an interface::

sequence<byte> FrameData;

interface FrameOps
{

void sendFrame(FrameData f);
};

My client code looks like (eliminating all the Ice boilerplate to
get an object reference to a FrameOps object:

std::ifstream f;
f.open(argv[1], std::ios_base::binary);

if( f.fail() ) {
std::cout << "Failed" << std::endl;
return -1;
}

f.seekg(0, std::ios_base::end);
long len = f.tellg();
std::cout << "Pos: " << len << std::endl;
f.seekg(0, std::ios_base::beg);

Ice::Byte *buf = new Ice::Byte[len];
f.read(buf, len);

FrameData v(&buf[0], &buf[len]);
frame_ops->sendFrame(v);


Using this technique, I have to create
a separate Ice::Byte buffer, and then
copy that into a vector<Ice::Byte>
before calling the remote method.

Is there a more optimal way for me to do this, or is this the best way?

Thanks.
__________________
--
Craig Rodrigues
Reply With Quote