Panda3D
nameUniquifier.I
1 // Filename: nameUniquifier.I
2 // Created by: drose (16Feb00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: NameUniquifier::add_name
18 // Access: Public
19 // Description: If name is nonempty and so far unique, returns it
20 // unchanged.
21 //
22 // Otherwise, generates and returns a new name according
23 // to the following rules:
24 //
25 // If the name is empty, the new name is the
26 // NameUniquifier's "empty" string followed by a number,
27 // or the "separator" string if the "empty" string is
28 // empty.
29 //
30 // If the name is nonempty, the new name is the original
31 // name, followed by the NameUniquifier's "separator"
32 // string, followed by a number.
33 ////////////////////////////////////////////////////////////////////
34 INLINE string NameUniquifier::
35 add_name(const string &name) {
36  return add_name_body(name, name);
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: NameUniquifier::add_name
41 // Access: Public
42 // Description: If name is nonempty and so far unique, returns it
43 // unchanged.
44 //
45 // Otherwise, generates and returns a new name according
46 // to the following rules:
47 //
48 // If the prefix is empty, the new name is the
49 // NameUniquifier's "empty" string followed by a number,
50 // or the "separator" string if the "empty" string is
51 // empty.
52 //
53 // If the prefix is nonempty, the new name is the
54 // prefix, followed by the NameUniquifier's "separator"
55 // string, followed by a number.
56 ////////////////////////////////////////////////////////////////////
57 INLINE string NameUniquifier::
58 add_name(const string &name, const string &prefix) {
59  return add_name_body(name, prefix);
60 }
string add_name(const string &name)
If name is nonempty and so far unique, returns it unchanged.