2 //=============================================================================
6 * Extension of class AST_String that provides additional means for C++
9 * @author Copyright 1994-1995 by Sun Microsystems
10 * @author Inc. and Aniruddha Gokhale
12 //=============================================================================
14 #include "be_string.h"
15 #include "be_visitor.h"
16 #include "be_helper.h"
18 #include "utl_identifier.h"
19 #include "global_extern.h"
21 be_string::be_string (AST_Decl::NodeType nt
,
42 if (!this->imported ())
44 idl_global
->string_seen_
= true;
46 if (v
->ev ()->u
.ulval
!= 0)
48 idl_global
->bd_string_seen_
= true;
52 idl_global
->ub_string_seen_
= true;
59 be_string::gen_member_ostream_operator (TAO_OutStream
*os
,
60 const char *instance_name
,
64 // For wide strings, generate code that outputs the hex values of
65 // the individual wchars inside square brackets, otherwise generate
66 // code that outputs the string literal bracketed with quotes.
67 if (this->width () == 1)
69 *os
<< "\"\\\"\" << ";
71 this->be_type::gen_member_ostream_operator (os
,
76 *os
<< " << \"\\\"\"";
80 *os
<< "\"[\";" << be_nl_2
81 << "for (size_t i = 0; i < " << "ACE_OS::strlen ("
83 << (accessor
? " ()" : ".in ()") << "); ++i)" << be_idt_nl
85 << "if (i != 0)" << be_idt_nl
87 << "strm << \", \";" << be_uidt_nl
88 << "}" << be_uidt_nl
<< be_nl
89 << "strm << ACE_OutputCDR::from_wchar (" << instance_name
90 << (accessor
? " ()" : "") << "[i]);" << be_uidt_nl
91 << "}" << be_uidt_nl
<< be_nl
98 be_string::compute_tc_name (void)
101 ACE_CDR::ULong val
= 0UL;
102 AST_Expression
zero (val
);
104 if (*this->max_size () == &zero
)
106 // If the string is unbounded, use the string TypeCode
109 // Start with the head as the CORBA namespace.
110 Identifier
* corba_id
= 0;
112 Identifier ("CORBA"));
114 ACE_NEW (this->tc_name_
,
115 UTL_ScopedName (corba_id
,
119 Identifier (this->width () == 1
125 // We have a bounded string. Generate a TypeCode name that is
126 // meant for internal use alone.
128 Identifier
* tao_id
= 0;
132 ACE_NEW (this->tc_name_
,
133 UTL_ScopedName (tao_id
,
136 ACE_CString local_tc_name
=
138 + ACE_CString (this->flat_name ());
140 Identifier
* typecode_scope
= 0;
141 ACE_NEW (typecode_scope
,
142 Identifier ("TypeCode"));
144 UTL_ScopedName
* tc_scope_conc_name
= 0;
145 ACE_NEW (tc_scope_conc_name
,
146 UTL_ScopedName (typecode_scope
,
149 this->tc_name_
->nconc (tc_scope_conc_name
);
152 Identifier (local_tc_name
.c_str ()));
157 UTL_ScopedName
*conc_name
= 0;
162 this->tc_name_
->nconc (conc_name
);
166 be_string::accept (be_visitor
* visitor
)
168 return visitor
->visit_string (this);
172 be_string::destroy (void)
174 this->be_type::destroy ();
175 this->AST_String::destroy ();
178 IMPL_NARROW_FROM_DECL (be_string
)