本文整理汇总了C++中corba::String_var::inout方法的典型用法代码示例。如果您正苦于以下问题:C++ String_var::inout方法的具体用法?C++ String_var::inout怎么用?C++ String_var::inout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corba::String_var
的用法示例。
在下文中一共展示了String_var::inout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTests
int runTests(CORBA::ORB_var orb, First::IHello_ptr hello)
{
result = 0;
try
{
std::cout << " AddValue: ";
check(5 == hello->AddValue(2, 3));
}
catch (...)
{
check(false);
}
try
{
std::cout << " SayHello: ";
check(std::wstring(L"Hello, Andy. It's Bob.") == (wchar_t*)CORBA::WString_var(hello->SayHello(L"Andy")));
}
catch (...)
{
check(false);
}
try
{
std::cout << " SayHello2: ";
CORBA::String_var greeting;
hello->SayHello2("Andy", greeting.out());
check(std::string("Hello, Andy. It's Bob.") == (char*)greeting);
}
catch (...)
{
check(false);
}
try
{
std::cout << " Message: ";
CORBA::String_var message = "Hello, Bob";
hello->Message(message.inout());
check(std::string("Hello, Andy.") == (char*)message);
}
catch (...)
{
check(false);
}
try
{
std::cout << " MulComplex: ";
First::MyComplexNumber x, y;
x.re = 2, x.im = 3;
y.re = 5, y.im = 6;
First::MyComplexNumber expected;
expected.re = x.re * y.re - x.im * y.im;
expected.im = x.re * y.im + x.im - y.re;
First::MyComplexNumber result = hello->MulComplex(x, y);
check(equal(result, expected) && equal(result, y));
}
catch (...)
{
check(false);
}
try
{
std::cout << " MulComplexAsAny: ";
First::MyComplexNumber x, y;
x.re = 2, x.im = 3;
y.re = 5, y.im = 6;
First::MyComplexNumber expected;
expected.re = x.re * y.re - x.im * y.im;
expected.im = x.re * y.im + x.im - y.re;
CORBA::Any _x, _y;
_x <<= x;
_y <<= y;
CORBA::Any_var _result;
bool success = hello->MulComplexAsAny(_x, _y, _result.out());
First::MyComplexNumber* result;
_result >>= result;
check(success && result && equal(*result, expected));
}
catch (...)
{
check(false);
}
try
{
std::cout << " DataTimeTransfer: ";
SYSTEMTIME initial_systemtime = {};
initial_systemtime.wMilliseconds = 0;
initial_systemtime.wSecond = 0;
initial_systemtime.wMinute = 0;
//.........这里部分代码省略.........
示例2: svc
int svc ()
{
CORBA::String_var str = CORBA::string_alloc (200*2000 + 1);
if (str.in () == 0) return 1;
str.inout ()[0] = CORBA::Char ('\0');
for (int i=0; i < 2000; ++i)
{
ACE_OS::strcat (str.inout (), twohundredbytes);
}
while (1)
{
try
{
CORBA::String_var ret = srv_->test_method (str.in ());
if (0 != ACE_OS::strcmp (str.in (), ret.in ())) return 1;
}
catch (const CORBA::Exception& ex)
{
ACE_DEBUG ((LM_ERROR,
ACE_TEXT ("(%P|%t) Exception caught: \n%C\n"),
ex._info ().c_str ()));
return 1;
}
}
return 0;
}
示例3: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR * argv[])
{
try
{
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var rootObj =
orb->resolve_initial_references("NameService");
CosNaming::NamingContext_var rootContext =
CosNaming::NamingContext::_narrow(rootObj.in());
CosNaming::Name name;
name.length (1);
name[0].id = CORBA::string_dup ("MessengerService");
CORBA::Object_var messengerObj = rootContext->resolve(name);
if (CORBA::is_nil(messengerObj.in())) {
std::cerr << "Nil Messenger reference" << std::endl;
return 1;
}
// Narrow
Messenger_var messenger = Messenger::_narrow(messengerObj.in());
if (CORBA::is_nil(messenger.in ())) {
std::cerr << "Argument is not a Messenger reference" << std::endl;
return 1;
}
CORBA::String_var message = CORBA::string_dup(
"We are experiencing network problems.");
messenger->send_message ("[email protected]",
"urgent",
message.inout());
message = CORBA::string_dup("Where can I get TAO?");
messenger->send_message ("[email protected]",
"OCI's Distribution of TAO",
message.inout());
message = CORBA::string_dup(
"Please contact [email protected] regarding your request.");
messenger->send_message ("[email protected]",
"OCI's Distribution of TAO",
message.inout());
}
catch(const CORBA::Exception& ex) {
std::cerr << "Caught a CORBA exception: " << ex << std::endl;
return 1;
}
std::cout << "MessengerClient: success" << std::endl;
return 0;
}
示例4: defined
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
// Detection of closed on read currently not working certain platforms.
#if defined (sun) || defined (AIX) || defined (__FreeBSD_version)
return 2;
#endif
try {
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
if (parse_args (argc, argv) != 0)
return 1;
// Destringify ior
CORBA::Object_var obj = orb->string_to_object( ior );
if (CORBA::is_nil(obj.in())) {
std::cerr << "Nil Messenger reference" << std::endl;
return 1;
}
// Narrow
Messenger_var messenger = Messenger::_narrow( obj.in() );
if (CORBA::is_nil(messenger.in())) {
std::cerr << "Argument is not a Messenger reference" << std::endl;
return 1;
}
CORBA::String_var message = CORBA::string_dup( "Hello!" );
messenger->send_message( "TAO User", "Test 1", message.inout() );
// Force server to abort to verify it will be brought
// back up when send_message() is called.
messenger->abort(2);
ACE_OS::sleep(seconds_between_requests);
ACE_DEBUG ((LM_INFO,
"(%P|%t) - Sending another message after abort of server\n"));
messenger->send_message( "TAO User", "Test 2", message.inout() );
std::cout << "messages were sent" << std::endl;
}
catch(const CORBA::Exception& ex) {
std::cerr << "Client main() Caught CORBA::Exception: " << ex << std::endl;
return 1;
}
return 0;
}
示例5: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) {
try {
if (argc <= 1) {
std::cerr << "Error: Must specify the name of an IOR file." << std::endl;
return 1;
}
ACE_TString ior = ACE_TEXT("file://");
ior += argv[1];
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var obj = orb->string_to_object(ior.c_str());
Messenger_var messenger = Messenger::_narrow(obj.in());
if (CORBA::is_nil(messenger.in())) {
std::cerr << "Unable to get a Messenger reference." << std::endl;
return 1;
}
CORBA::String_var message = CORBA::string_dup("Hello!");
messenger->send_message("TAO User", "TAO Test", message.inout());
std::cout << "message was sent" << std::endl;
std::cout << "Reply was : " << message.in() << std::endl;
return 0;
} catch(const CORBA::Exception& ex) {
std::cerr << "Client main() Caught Exception: " << ex << std::endl;
}
return 1;
}
示例6: activateObject
//--------------------------------------------------------------------------
// activateObject:
//--------------------------------------------------------------------------
int activateObject (ClientData clientData,
Tcl_Interp *interp,
int argc,
const char *argv[])
{
if (argc < 2)
{
sprintf (interp->result,
"Usage: %s serviceId ?objectId?",
ACTIVATE_OBJECT_CMD);
return TCL_ERROR;
}
const char *serviceId = argv[1];
const char *objectId = (argc > 2) ? argv[2] : 0;
try
{
CORBA::String_var strObjectReference =
ServiceManager::instance()->activateObject (serviceId, objectId);
Tcl_SetResult (interp, strObjectReference.inout (), TCL_VOLATILE);
return TCL_OK;
}
catch (Exception &exp)
{
error ("%s:%d %s", exp.getFile (), exp.getLine (), exp.getMessage ());
interp->result = exp.getMessage ();
return TCL_ERROR;
}
}
示例7: while
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try {
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
// Find the Naming Service
CORBA::Object_var naming_obj = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var root =
CosNaming::NamingContextExt::_narrow(naming_obj.in());
if (CORBA::is_nil(root.in())) {
std::cerr << "Nil Naming Context reference" << std::endl;
return 1;
}
// Resolve the Messenger object
CosNaming::Name name;
name.length( 2 );
name[0].id = CORBA::string_dup( "example" );
name[1].id = CORBA::string_dup( "Messenger" );
CORBA::Object_var obj = CORBA::Object::_nil();
while (CORBA::is_nil(obj.in())) {
try {
obj = root->resolve_str("example/Messenger");
} catch (const CosNaming::NamingContext::NotFound&) {
// Sleep for a second and try again
ACE_OS::sleep(1);
}
}
// Narrow the Messenger object reference
Messenger_var messenger = Messenger::_narrow(obj.in());
if (CORBA::is_nil(messenger.in())) {
std::cerr << "Not a Messenger reference" << std::endl;
return 1;
}
CORBA::String_var message = CORBA::string_dup("Hello!");
// Send a message
messenger->send_message("TAO User", "TAO Test", message.inout());
std::cout << "Message was sent" << std::endl;
orb->destroy();
}
catch(const CORBA::Exception& ex) {
std::cerr << "Caught a CORBA exception: " << ex << std::endl;
return 1;
}
return 0;
}
示例8: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try {
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
if (parse_args (argc, argv) != 0)
return 1;
// Find the Naming Service & the Message Server name in it
CORBA::Object_var obj = orb->string_to_object(ior_input_file);
// Narrow
Messenger_var messenger = Messenger::_narrow(obj.in());
if (CORBA::is_nil(messenger.in())) {
std::cerr << "Not a Messenger reference" << std::endl;
return 1;
}
CORBA::String_var message = CORBA::string_dup("Hello!");
messenger->send_message( "TAO User", "TAO Test", message.inout());
std::cout << "Message was sent" << std::endl;
std::cout << "Now try the same thing with the simple name." << std::endl;
obj = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var root =
CosNaming::NamingContextExt::_narrow(obj.in());
obj = root->resolve_str("Simple/Messenger");
messenger = Messenger::_narrow(obj.in());
messenger->send_message( "ACE User", "TAO Test", message.inout());
std::cout << "Message was sent" << std::endl;
}
catch(const CORBA::Exception& ex) {
std::cerr << "Caught a CORBA::Exception: " << ex << std::endl;
return 1;
}
return 0;
}
示例9: svc
int synch_foo_generator::svc ()
{
ACE_OS::sleep (3);
//run some synch calls
::InterInOutT::MyFoo_var my_foo_ami_ =
context_->get_connection_run_my_foo ();
CORBA::String_var answer = CORBA::string_dup("Hi from sender");
CORBA::Long l_cmd = 1;
try
{
CORBA::Long result = my_foo_ami_->foo ("Do something synchronous",
l_cmd ,
answer.inout ());
if ((result == (update_val + cmd_synch_ok)) &&
(ACE_OS::strcmp (answer.in(), "Hi from receiver") == 0))
{
++this->nr_of_received_;
}
}
catch (const InterInOutT::InternalError&)
{
ACE_ERROR ((LM_ERROR, "ERROR: synch_foo_generator::foo: "
"Unexpected exception.\n"));
}
try
{
l_cmd = 2;
answer = CORBA::string_dup("Hi from sender");
my_foo_ami_->foo ("",l_cmd, answer.inout());
}
catch (const InterInOutT::InternalError& ex)
{
HandleException (ex.id, (update_val + cmd_synch_nok),
ex.error_string.in(),
"synch foo");
}
return 0;
}
示例10: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR * argv[])
{
try {
// Initialize the ORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
// Create a smart proxy factory. It will register itself with the
// smart proxy factory adapter so it can be used to create
// Messenger proxies. It must be created on the heap, but is
// otherwise unused here.
new Smart_Messenger_Proxy_Factory(orb.in());
// Convert the contents of the Messenger.ior file to an object reference.
CORBA::Object_var obj = orb->string_to_object(ior);
if (CORBA::is_nil(obj.in())) {
std::cerr << "Nil Messenger reference" << std::endl;
return 1;
}
// Narrow the object reference to a Messenger object reference.
Messenger_var messenger = Messenger::_narrow(obj.in());
if (CORBA::is_nil(messenger.in())) {
std::cerr << "Not a Messenger object reference" << std::endl;
return 1;
}
// Create a message and send it to the Messenger.
CORBA::String_var message = CORBA::string_dup("Hello!");
messenger->send_message ("TAO User", "TAO Test", message.inout());
std::cout << "Message was sent" << std::endl;
// Release resources.
orb->destroy();
}
catch(const CORBA::Exception& ex) {
std::cerr << "Caught a CORBA exception: " << ex << std::endl;
return 1;
}
catch(...) {
std::cerr << "Caught an unknown exception type" << std::endl;
return 1;
}
return 0;
}
示例11: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
try {
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
if (parse_args(argc, argv) != 0) {
return 1;
}
// Read and destringify the Messenger object's IOR.
CORBA::Object_var obj = orb->string_to_object(ior.c_str());
if( CORBA::is_nil( obj.in() ) ) {
std::cerr << "Could not get Messenger IOR." << std::endl;
return 1;
}
// Narrow the IOR to a Messenger object reference.
DevGuide::Messenger_var messenger =
DevGuide::Messenger::_narrow( obj.in() );
if( CORBA::is_nil( messenger.in() ) ) {
std::cerr << "IOR was not a Messenger object reference." << std::endl;
return 1;
}
// Send a message the the Messenger object.
CORBA::String_var msg = CORBA::string_dup( "Hello!" );
messenger->send_message( "TAO User", "TAO Test", msg.inout() );
// Print the Messenger's reply.
std::cout << "Reply: " << msg.in() << std::endl;
orb->destroy();
return 0;
}
catch(const CORBA::Exception& ex) {
std::cerr << "CORBA exception: " << ex << std::endl;
}
return 1;
}
示例12: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR * argv[])
{
try
{
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var obj = orb->string_to_object( ior );
if (CORBA::is_nil(obj.in())) {
std::cerr << "Nil Messenger reference" << std::endl;
return 1;
}
// Narrow
Messenger_var messenger = Messenger::_narrow( obj.in() );
if (CORBA::is_nil(messenger.in())) {
std::cerr << "Argument is not a Messenger reference" << std::endl;
return 1;
}
CORBA::String_var message = CORBA::string_dup(
"Where can I get TAO?");
for (int i=0; i<3; i++) {
messenger->send_message ("[email protected]",
"OCI's Distribution of TAO",
message.inout());
}
}
catch(const CORBA::Exception& ex)
{
std::cerr << "Caught exception: " << ex << std::endl;
return 1;
}
return 0;
}
示例13: ACE_TMAIN
int ACE_TMAIN (int, ACE_TCHAR **)
{
try {
// Construct a Messenger object and use it "as if" it's a corba object.
// Put it into CORBA object reference
// comparable to activation, narrow, etc.
Messenger_var messenger(new Messenger_i);
// Send a message the the Messenger object.
CORBA::String_var message = CORBA::string_dup ("Hello!");
messenger->send_message("TAO User", "TAO Test", message.inout());
// Print the Messenger's reply.
std::cout << "Reply: " << message.in() << std::endl;
}
catch(const CORBA::Exception& ex) {
std::cerr << "Caught CORBA::Exception : " << ex << std::endl;
return 1;
}
return 0;
}
示例14: catch
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv );
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var obj =
orb->string_to_object (ior);
// Narrow the Messenger object reference
Messenger_var messenger = Messenger::_narrow(obj.in());
if (CORBA::is_nil(messenger.in())) {
ACE_ERROR((LM_ERROR, " ERROR: Client cannot get a Messenger reference\n"));
return 1;
}
CORBA::String_var message = CORBA::string_dup("Hello!");
// Send a message
messenger->send_message("user", "TAO Test", message.inout());
ACE_DEBUG((LM_DEBUG, "CLIENT: Message was sent\n"));
orb->destroy();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return 1;
}
return 0;
}
示例15: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv [])
{
try {
// Initialize the ORB
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
// Converts the contents of the file to an object reference
CORBA::Object_var obj = orb->string_to_object (ior);
if (CORBA::is_nil (obj.in())) {
std::cerr << "Nill Messenger reference" << std::endl;
return 1;
}
// Narrow the object reference to a Messenger object reference
Messenger_var messenger = Messenger::_narrow(obj.in());
if (CORBA::is_nil (messenger.in())) {
std::cerr << "Not a Messenger object reference" << std::endl;
return 1;
}
// Create a message and send it to the Messenger
CORBA::String_var message = CORBA::string_dup("Hello!");
messenger->send_message ("TAO User", "TAO Test", message.inout());
orb->destroy();
std::cout << "Message was sent" << std::endl;
}
catch(const CORBA::Exception& ex) {
std::cerr << "Client Caught a CORBA exception: " << ex << std::endl;
return 1;
}
std::cout << "Message was sent" << std::endl;
return 0;
}