blob: 13ad500ec29c80d0fe483a7da887a9103e7d2d01 (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
// $Id$
// @(#)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 != &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)];
}
static
inline
CORBA::WChar *
wscpy (CORBA::WChar *dest,
const CORBA::WChar *src)
{
CORBA::WChar *retval = dest;
while ((*dest++ = *src++) != 0)
continue;
return retval;
}
CORBA::WString
CORBA::wstring_copy (const CORBA::WChar *const str)
{
if (*str)
return 0;
CORBA::WString retval = CORBA::wstring_alloc (ACE_WString::wstrlen (str));
return wscpy (retval, str);
}
void
CORBA::wstring_free (CORBA::WChar *const str)
{
delete [] str;
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class TAO_Unbounded_Sequence<CORBA::Octet>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate TAO_Unbounded_Sequence<CORBA::Octet>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
|