2 * Copyright (c) 2001 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 #ident "$Id: HName.cc,v 1.8 2007/06/02 03:42:12 steve Exp $"
38 hname_t::hname_t(perm_string text
)
44 hname_t::hname_t(perm_string text
, int num
)
50 hname_t::hname_t(const hname_t
&that
)
53 number_
= that
.number_
;
56 hname_t
& hname_t::operator = (const hname_t
&that
)
59 number_
= that
.number_
;
67 perm_string
hname_t::peek_name(void) const
72 bool hname_t::has_number() const
74 return number_
!= INT_MIN
;
77 int hname_t::peek_number() const
82 bool operator < (const hname_t
&l
, const hname_t
&r
)
84 int cmp
= strcmp(l
.peek_name(), r
.peek_name());
85 if (cmp
< 0) return true;
86 if (cmp
> 0) return false;
87 if (l
.has_number() && r
.has_number())
88 return l
.peek_number() < r
.peek_number();
93 bool operator == (const hname_t
&l
, const hname_t
&r
)
95 if (l
.peek_name() == r
.peek_name()) {
96 if (l
.has_number() && r
.has_number())
97 return l
.peek_number() == r
.peek_number();
105 bool operator != (const hname_t
&l
, const hname_t
&r
)
108 ostream
& operator<< (ostream
&out
, const hname_t
&that
)
110 if (that
.peek_name() == 0) {
115 out
<< that
.peek_name();
116 if (that
.has_number())
117 out
<< "[" << that
.peek_number() << "]";
124 * Revision 1.8 2007/06/02 03:42:12 steve
125 * Properly evaluate scope path expressions.
127 * Revision 1.7 2007/05/16 19:12:33 steve
128 * Fix hname_t use of space for 1 perm_string.
130 * Revision 1.6 2007/04/26 03:06:21 steve
131 * Rework hname_t to use perm_strings.
133 * Revision 1.5 2002/11/02 03:27:52 steve
134 * Allow named events to be referenced by
135 * hierarchical names.
137 * Revision 1.4 2002/08/12 01:34:58 steve
138 * conditional ident string using autoconfig.
140 * Revision 1.3 2002/01/05 04:36:06 steve
141 * include malloc.h only when available.
143 * Revision 1.2 2001/12/18 04:52:45 steve
144 * Include config.h for namespace declaration.
146 * Revision 1.1 2001/12/03 04:47:14 steve
147 * Parser and pform use hierarchical names as hname_t
148 * objects instead of encoded strings.