Does ORBit2 Support Inserting a Sequence of Octets in an Any Type?
- From: <lgust verizon net>
- To: <orbitcpp-list gnome org>
- Subject: Does ORBit2 Support Inserting a Sequence of Octets in an Any Type?
- Date: Tue, 18 Nov 2003 21:46:46 -0600
In the book “Advanced CORBA Programming with C++” the authors indicate on page 681 that it is possible to insert and extract sequences from type Any. They give the following example in the textbook:
CORBA::Any a;
BtData btd; // Structure variable
a <<= btd;
To test inserting a sequence of octets in type Any, I created the following IDL file:
//Source file: C:/Docs/Netfires/cf-idl/cf.idl
#ifndef __CF_DEFINED
#define __CF_DEFINED
/* CmIdentification
%X% %Q% %Z% %W% */
module CF {
typedef sequence<octet> OctetSeq;
interface FileSystem {
readonly attribute string SIZE;
/*
@roseuid 3FBACC770392 */
boolean f (
in CF::OctetSeq data
);
/*
@roseuid 3FBADABD020B */
boolean g (
in any data
);
};
};
#endif
-------------------------------------------------------------------
I create the following client program that tries to insert a sequence of octets in the Any type:
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: f; c-basic-offset: 4 -*- */
#include "cf-cpp-stubs.h"
#include <iostream>
#include <fstream>
char D[24] = {0x11, 0x22, 0x06, 0x00, \
0x45, 0x00, 0x13, 0x14, \
0x15, 0x16, 0x17, 0x18, \
0x1A, 0x1B, 0x1C, 0x1D, \
0x1E, 0x1F, 0x20, 0x21, \
0x22, 0x23, 0x24, 0x25};
int main (int argc, char *argv[])
{
#if 0
if (argc != 2)
{
std::cerr << "Usage:" << std::endl
<< " " << argv[0] << " IOR" << std::endl
<< std::endl;
return -1;
}
#endif
try
{
// Sync the iostreams and the C standard io
std::cout.sync_with_stdio();
// Initialize ORBit
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv, "orbit-local-orb");
#if 0
// Get a reference to the server from the IOR passed on the
// command line
std::cout << "IOR = ";
std::cout << argv[1] << "END IOR" << std::endl << std::endl;
#else
// Read the stringified IOR from the file
std::ifstream iorFile("NetFiresSecurity-server.ior");
if (iorFile.is_open() == false)
{
// Failed to open the IOR file
std::cerr << argv[0];
std::cerr << " - failed to open the file with ";
std::cerr << "stringified IOR from the server nameed: ";
std::cerr << "NetFiresSecurity-server.ior" << std::endl;
return -1;
}
// Read the IOR from the file
std::string iorString;
iorFile >> iorString;
// Convert the IOR string into an IOR object
CORBA::Object_var obj = orb->string_to_object(iorString.c_str());
CF::FileSystem_var ptr = CF::FileSystem::_narrow(obj);
CF::OctetSeq clearData(4, 4, (CORBA::Octet *)D, 0);
CORBA::Any bypass;
bypass <<= clearData;
#endif
} catch(const CORBA::Exception& ex) {
std::cout << "Exception caught. Maybe the server is not running, or the IOR is wrong." << std::endl;
}
return 0;
}
-------------------------------------------------------------------
When the client is compiled it generates error messages indicating it cannot find the correct overloaded <<= operator on the following statement:
bypass <<= clearData;
[lgust urouter17 ~/test/rose-cf] $ make
gcc -c -g -DORBIT2=1 -D_REENTRANT -I/home/nfr/local/include/orbit-2.0 -I/home/nfr/local/include/linc-1.0 -I/home/nfr/local/include/glib-2.0 -I/home/nfr/local/lib/glib-2.0/include -I/home/nfr/local/include/orbitcpp-2.0 client.cc
client.cc: In function `int main(int, char**)':
client.cc:65: no match for `CORBA::Any& <<= CF::OctetSeq&' operator
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:199: candidates
are: void CORBA::Any::operator<<=(short int)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:202:
void CORBA::Any::operator<<=(short unsigned int)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:205:
void CORBA::Any::operator<<=(int)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:208:
void CORBA::Any::operator<<=(unsigned int)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:211:
void CORBA::Any::operator<<=(long long int)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:214:
void CORBA::Any::operator<<=(long long unsigned int)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:217:
void CORBA::Any::operator<<=(float)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:220:
void CORBA::Any::operator<<=(double)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:227:
void CORBA::Any::operator<<=(const CORBA::Any&)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:230:
void CORBA::Any::operator<<=(CORBA::Any*)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:235:
void CORBA::Any::operator<<=(const char*)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:238:
void CORBA::Any::operator<<=(const WChar*)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:241:
void CORBA::Any::operator<<=(CORBA::Any::from_boolean)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:244:
void CORBA::Any::operator<<=(CORBA::Any::from_octet)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:247:
void CORBA::Any::operator<<=(CORBA::Any::from_char)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:250:
void CORBA::Any::operator<<=(CORBA::Any::from_wchar)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:253:
void CORBA::Any::operator<<=(CORBA::Any::from_string)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:254:
void CORBA::Any::operator<<=(CORBA::Any::from_wstring)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:255:
void CORBA::Any::operator<<=(CORBA::Object*)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:258:
void CORBA::Any::operator<<=(CORBA::Object**)
/home/nfr/local/include/orbitcpp-2.0/orbitcpp/orb-cpp/orbitcpp_any.h:327:
void CORBA::Any::operator<<=(unsigned char)
cf-cpp-common.h:81: void operator<<=(CORBA::Any&,
CF::FileSystem**)
cf-cpp-common.h:87: void operator<<=(CORBA::Any&,
CF::FileSystem*)
make: *** [client.o] Error 1
-------------------------------------------------------------------
It doesn’t appear that the file orbitcpp_any.h contains an overloaded <<= operator that works with sequences.
Does ORBit2 support storing sequences in type Any? Is my code wrong and there is another way to do this?
Regards,
Larry S. Gustafson
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]