00001 // Filename: nameUniquifier.I 00002 // Created by: drose (16Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: NameUniquifier::add_name 00018 // Access: Public 00019 // Description: If name is nonempty and so far unique, returns it 00020 // unchanged. 00021 // 00022 // Otherwise, generates and returns a new name according 00023 // to the following rules: 00024 // 00025 // If the name is empty, the new name is the 00026 // NameUniquifier's "empty" string followed by a number, 00027 // or the "separator" string if the "empty" string is 00028 // empty. 00029 // 00030 // If the name is nonempty, the new name is the original 00031 // name, followed by the NameUniquifier's "separator" 00032 // string, followed by a number. 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE string NameUniquifier:: 00035 add_name(const string &name) { 00036 return add_name_body(name, name); 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: NameUniquifier::add_name 00041 // Access: Public 00042 // Description: If name is nonempty and so far unique, returns it 00043 // unchanged. 00044 // 00045 // Otherwise, generates and returns a new name according 00046 // to the following rules: 00047 // 00048 // If the prefix is empty, the new name is the 00049 // NameUniquifier's "empty" string followed by a number, 00050 // or the "separator" string if the "empty" string is 00051 // empty. 00052 // 00053 // If the prefix is nonempty, the new name is the 00054 // prefix, followed by the NameUniquifier's "separator" 00055 // string, followed by a number. 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE string NameUniquifier:: 00058 add_name(const string &name, const string &prefix) { 00059 return add_name_body(name, prefix); 00060 }