00001 // Filename: nameUniquifier.h 00002 // Created by: drose (16Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef NAMEUNIQUIFIER_H 00020 #define NAMEUNIQUIFIER_H 00021 00022 #include <pandabase.h> 00023 00024 #include <string> 00025 #include "pset.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : NameUniquifier 00029 // Description : A handy class for converting a list of arbitrary 00030 // names (strings) so that each name is guaranteed to be 00031 // unique in the list. Useful for writing egg files 00032 // with unique vertex pool names, or for file converters 00033 // to file formats that require unique node names, etc. 00034 //////////////////////////////////////////////////////////////////// 00035 class EXPCL_PANDA NameUniquifier { 00036 public: 00037 NameUniquifier(const string &separator = string(), 00038 const string &empty = string()); 00039 ~NameUniquifier(); 00040 00041 INLINE string add_name(const string &name); 00042 INLINE string add_name(const string &name, const string &prefix); 00043 00044 private: 00045 string add_name_body(const string &name, const string &prefix); 00046 00047 typedef pset<string> Names; 00048 Names _names; 00049 string _separator; 00050 string _empty; 00051 int _counter; 00052 }; 00053 00054 #include "nameUniquifier.I" 00055 00056 #endif