Hi Jeff.
Sorry, blame the fact its Thursday.
I meant TAO 1.6.8.
Anyway, I guess the answer is the memcpy.
Thanks.
Nick.
Nick Adamson
Software Engineer
C4I Systems
General Dynamics United Kingdom Limited
Bryn Brithdir, Oakdale Business Park, Blackwood, South Wales, NP12 4AA
Telephone:
+44 (0) 1495 236467
Email:
Nick.A...@generaldynamics.uk.com
Website:
www.generaldynamics.uk.com
Please consider the environment before printing this email
-----Original Message-----
From: Jeff Parsons [mailto:
j.pa...@vanderbilt.edu]
Sent: Thursday, 19 January 2012 15:24
To: Nick Adamson;
tao-...@list.isis.vanderbilt.edu
Cc:
jwill...@remedy.nl
Subject: RE: [tao-users] Copying corba data to STL types.
Hi Nick,
I'm looking through our Subversion repository tags and I don't see a TAO
1.8.6. It seems to go from 1.8.3 to 2.0.0. In any case, the lastest
modification to the octet sequence file was just before 1.8.1.
That said, it's entirely appropriate that the exception should be
thrown, since the 2nd parameter passed to the vector constructor from
TAO sequence is past the end of the sequence's buffer. The amazing thing
is that it works on Linux. There is some preprocessor stuff around some
of the range checking code, one of which is ACE_NDEBUG - could the
definition of this be different on the 2 platforms?
thanks,
Jeff
From:
tao-user...@list.isis.vanderbilt.edu
[mailto:
tao-user...@list.isis.vanderbilt.edu] On Behalf Of
Nick.A...@generaldynamics.uk.com
Sent: Thursday, January 19, 2012 5:57 AM
To:
tao-...@list.isis.vanderbilt.edu
Subject: [tao-users] Copying corba data to STL types.
Hi All.
We've recently upgraded to version 2.0.5 of TAO and I'm developing some
code on windows XP using visual studio 2005.
I've come across a problem when copying from a corba sequence of octets
to a std::vector <char>.
This is something we do quite often and on previous versions of TAO, v
1.8.6 was the last we tried it on, works fine but version 2.0.5 throws a
corba bad param exception. We think this is because the way the
std::vector constructor uses iteraters which conflicts with what appears
to be some sort of bounds checking introduced in to TAO recently.
Below I've listed a program that shows this.
If you compile and run it with TAO 1.8.6 it works fine. but throws an
exception with 2.0.5.
Have we guessed correctly what's causing this? what is the intended
behaviour?
If version 2.0.5 is correct then there are inconsistencies between Linux
based platforms, which this code works on irrespective of which version
of TAO we use, and windows.
If 2.0.5 is correct what is the recommended way of doing this? We've
found that memcpy works.
Thanks.
Nick.
Example program:
{
// create a std vector and populate it.
std::vector < char > srcvec( 5 );
srcvec[0] = 'h';
srcvec[1] = 'e';
srcvec[2] = 'l';
srcvec[3] = 'l';
srcvec[4] = 'o';
std::cout << "srcvec = ";
unsigned long nIndex;
for (nIndex = 0; nIndex < srcvec.size(); nIndex++)
{
std::cout << srcvec[ nIndex ];
}
std::cout << std::endl;
// translate it in to a corba type.
// idl code for the databody is:
// typedef sequence<octet> DataBody;
MDSB::ClientInterface::DataBody corbadata;
corbadata.length( srcvec.size() );
std::copy( srcvec.begin(),
srcvec.end(),
&corbadata[0] );
std::cout << "corbadata = ";
for (nIndex = 0; nIndex < corbadata.length(); nIndex++)
{
std::cout << corbadata[ nIndex ];
}
std::cout << std::endl;
// translate it back.
// using the std::vector constructor which takes in the begining and
end iterators.
// below line works with TAO 5.8.6 but not with tao 6.0.5
std::vector < char > destvec( &corbadata[0], &corbadata[
corbadata.length() ] );
std::cout << "destvec = ";
for (nIndex = 0; nIndex < destvec.size(); nIndex++)
{
std::cout << destvec[ nIndex ];
}
std::cout << std::endl;
}
Nick Adamson
Software Engineer
C4I Systems
General Dynamics United Kingdom Limited
Bryn Brithdir, Oakdale Business Park, Blackwood, South Wales, NP12 4AA
Telephone:
+44 (0) 1495 236467
Email:
Nick.A...@generaldynamics.uk.com
<mailto:
Nick.A...@generaldynamics.uk.com>
Website:
www.generaldynamics.uk.com <
http://www.generaldynamics.uk.com/>
Please consider the environment before printing this email
________________________________
This email and any files attached are intended for the addressee and may
contain information of a confidential nature. If you are not the
intended recipient, be aware that this email was sent to you in error
and you should not disclose, distribute, print, copy or make other use
of this email or its attachments. Such actions, in fact, may be
unlawful. In compliance with the various Regulations and Acts, General
Dynamics United Kingdom Limited reserves the right to monitor (and
examine for viruses) all emails and email attachments, both inbound and
outbound. Email communications and their attachments may not be secure
or error- or virus-free and the company does not accept liability or
responsibility for such matters or the consequences thereof. General
Dynamics United Kingdom Limited, Registered Office: 21 Holborn Viaduct,
London EC1A 2DY. Registered in England and Wales No: 1911653.
This email and any files attached are intended for the addressee and may contain information of a confidential nature. If you are not the intended recipient, be aware that this email was sent to you in error and you should not disclose, distribute, print, copy or make other use of this email or its attachments. Such actions, in fact, may be unlawful. In compliance with the various Regulations and Acts, General Dynamics United Kingdom Limited reserves the right to monitor (and examine for viruses) all emails and email attachments, both inbound and outbound. Email communications and their attachments may not be secure or error- or virus-free and the company does not accept liability or responsibility for such matters or the consequences thereof. General Dynamics United Kingdom Limited, Registered Office: 21 Holborn Viaduct, London EC1A 2DY. Registered in England and Wales No: 1911653.