blob: 84592e7cb07ae431ee09b47155c4a062744cd4db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// @(#)corbacom.cpp 1.1 95/08/31
// Copyright 1994-1995 by Sun Microsystems Inc.
// All Rights Reserved
//
// ORB: support for primitive data types
#include "tao/corba.h"
// String utility support; this can need to be integrated with the
// ORB's own memory allocation subsystem.
CORBA::String
CORBA::string_copy (const CORBA::Char *str)
{
if (!str)
return 0;
CORBA::String retval = CORBA::string_alloc (ACE_OS::strlen (str));
// clear the contents of the allocated string
ACE_OS::memset(retval, '\0', ACE_OS::strlen (str));
return ACE_OS::strcpy (retval, str);
}
CORBA::String_var &
CORBA::String_var::operator= (char *p)
{
if (this->ptr_ != p)
{
if (this->ptr_ != 0)
CORBA::string_free (this->ptr_);
this->ptr_ = p;
}
return *this;
}
CORBA::String_var &
CORBA::String_var::operator= (const char *p)
{
if (this->ptr_ != 0)
CORBA::string_free (this->ptr_);
this->ptr_ = CORBA::string_dup (p);
return *this;
}
CORBA::String_var &
CORBA::String_var::operator= (const CORBA::String_var& r)
{
if (this->ptr_ != 0)
CORBA::string_free (this->ptr_);
this->ptr_ = CORBA::string_dup (r.ptr_);
return *this;
}
// Wide Character string utility support; this can need to be
// integrated with the ORB's own memory allocation subsystem.
CORBA::WString
CORBA::wstring_alloc (CORBA::ULong len)
{
return new CORBA::WChar [(size_t) (len + 1)];
}
CORBA::WString
CORBA::wstring_copy (const CORBA::WChar *const str)
{
if (*str)
return 0;
CORBA::WString retval = CORBA::wstring_alloc (ACE_OS::strlen (str));
return ACE_OS::strcpy (retval, str);
}
void
CORBA::wstring_free (CORBA::WChar *const str)
{
delete str;
}
|