5 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
6 States of America. All Rights Reserved.
8 This product is protected by copyright and distributed under the following
9 license restricting its use.
11 The Interface Definition Language Compiler Front End (CFE) is made
12 available for your use provided that you include this license and copyright
13 notice on all media and documentation and the software program in which
14 this product is incorporated in whole or part. You may copy and extend
15 functionality (but may not remove functionality) of the Interface
16 Definition Language CFE without charge, but you are not authorized to
17 license or distribute it to anyone else except as part of a product or
18 program developed by you or with the express written consent of Sun
19 Microsystems, Inc. ("Sun").
21 The names of Sun Microsystems, Inc. and any of its subsidiaries or
22 affiliates may not be used in advertising or publicity pertaining to
23 distribution of Interface Definition Language CFE as permitted herein.
25 This license is effective until terminated by Sun for failure to comply
26 with this license. Upon termination, you shall destroy or return all code
27 and documentation for the Interface Definition Language CFE.
29 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
30 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
32 DEALING, USAGE OR TRADE PRACTICE.
34 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
35 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
36 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
38 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
39 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
40 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
42 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
43 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
44 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
46 Use, duplication, or disclosure by the government is subject to
47 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
48 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
51 Sun, Sun Microsystems and the Sun logo are trademarks or registered
52 trademarks of Sun Microsystems, Inc.
56 Mountain View, California 94043
60 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
61 trademarks or registered trademarks of Sun Microsystems, Inc.
65 #include "utl_identifier.h"
66 #include "global_extern.h"
68 #include "utl_string.h"
69 #include "fe_private.h"
71 // FUZZ: disable check_for_streams_include
72 #include "ace/streams.h"
73 #include "ace/OS_NS_string.h"
75 Identifier::Identifier (void)
81 Identifier::Identifier (const char *s
)
85 preprocess_and_replace_string (s
);
88 Identifier::Identifier (const Identifier
&other
)
90 escaped_ (other
.escaped ())
95 Identifier::~Identifier (void)
97 if (this->pv_string
!= 0)
99 ACE::strdelete (this->pv_string
);
106 Identifier::get_string (void)
108 return this->pv_string
;
112 Identifier::get_string (void) const
114 return this->pv_string
;
118 Identifier::replace_string (const char * s
)
122 delete [] this->pv_string
;
124 this->pv_string
= s
? ACE::strnew (s
) : 0;
128 Identifier::preprocess_and_replace_string (const char * s
)
134 // Only one leading underscore is allowed.
137 idl_global
->err ()->error0 (UTL_Error::EIDL_UNDERSCORE
);
141 this->escaped_
= true;
143 const char *c_prefix
= "_cxx_";
145 if (str
.find ("_tc_") == 0
146 || str
.find ("_tao_") == 0)
150 else if (str
.find (c_prefix
) == 0)
152 str
= str
.substr (ACE_OS::strlen (c_prefix
));
153 const char *eh_suffix
= "_excep";
154 ACE_CString::size_type pos
=
155 str
.length () - ACE_OS::strlen (eh_suffix
);
157 // If we have an AMI exception holder suffix, strip it off.
158 if (str
.find (eh_suffix
) == pos
)
160 str
= str
.substr (0, pos
);
163 TAO_IDL_CPP_Keyword_Table cpp_key_tbl
;
165 static_cast<unsigned int> (str
.length ());
166 const TAO_IDL_CPP_Keyword_Entry
*entry
=
167 cpp_key_tbl
.lookup (str
.c_str (), len
);
176 replace_string (shift
? s
+ 1 : s
);
179 // Compare two Identifier *
181 Identifier::compare (Identifier
*o
)
186 this->escaped_
^ o
->escaped_
)
191 return !ACE_OS::strcmp (this->pv_string
, o
->pv_string
);
194 // Report the appropriate error if the two identifiers differ only in case.
196 Identifier::case_compare (Identifier
*o
)
198 return UTL_String::compare (this->pv_string
, o
->pv_string
);
201 // Report no error if the two identifiers differ only in case.
203 Identifier::case_compare_quiet (Identifier
*o
)
205 return UTL_String::compare_quiet (this->pv_string
, o
->pv_string
);
209 Identifier::copy (void)
211 Identifier
*retval
= 0;
212 ACE_NEW_RETURN (retval
,
213 Identifier (this->pv_string
),
216 retval
->escaped_
= this->escaped_
;
222 Identifier::escaped (void) const
224 return this->escaped_
;
229 Identifier::dump (ACE_OSTREAM_TYPE
&o
)
231 if (this->pv_string
== 0)
237 * Annotation ids are prefixed with '@' to effectively create an alternative
238 * namespace for them. This hides that hack from dumping.
240 o
<< ((pv_string
[0] == '@') ? pv_string
+ 1 : pv_string
);
244 Identifier::destroy (void)
249 Identifier::operator== (const Identifier
&other
) const
251 return !ACE_OS::strcmp (pv_string
, other
.get_string ());
255 Identifier::operator= (const Identifier
&other
)
257 replace_string (other
.get_string ());