Panda3D
nameUniquifier.h
1 // Filename: nameUniquifier.h
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 #ifndef NAMEUNIQUIFIER_H
16 #define NAMEUNIQUIFIER_H
17 
18 #include "pandabase.h"
19 
20 #include <string>
21 #include "pset.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : NameUniquifier
25 // Description : A handy class for converting a list of arbitrary
26 // names (strings) so that each name is guaranteed to be
27 // unique in the list. Useful for writing egg files
28 // with unique vertex pool names, or for file converters
29 // to file formats that require unique node names, etc.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_PUTIL NameUniquifier {
32 public:
33  NameUniquifier(const string &separator = string(),
34  const string &empty = string());
35  ~NameUniquifier();
36 
37  INLINE string add_name(const string &name);
38  INLINE string add_name(const string &name, const string &prefix);
39 
40 private:
41  string add_name_body(const string &name, const string &prefix);
42 
44  Names _names;
45  string _separator;
46  string _empty;
47  int _counter;
48 };
49 
50 #include "nameUniquifier.I"
51 
52 #endif
A handy class for converting a list of arbitrary names (strings) so that each name is guaranteed to b...