File: ComplexName.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (49 lines) | stat: -rw-r--r-- 1,259 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once

#include <string>
#include <set>

/// Set of unique postfixes, e.g. "1", "6" or "04"
typedef std::set<std::string> PostfixSet;

/// Name consisting of initial text and optional unique-making number-postfix 
/// e.g. "Carl" + "6", or "Mary" + "03"
class ComplexName
{
    // Initial name text
    std::string _name;

    // The number postfix in string form. "-" is considered an invalid/empty postfix
    std::string _postFix;

public:
	static const std::string EMPTY_POSTFIX; // "-"

    /// Construct a ComplexName from the given full name string
    ComplexName(const std::string& fullname);

    /// Get the full name in string format
    std::string getFullname() const;

    /// Get the initial text without any numeric postfix
    const std::string& getNameWithoutPostfix() const
    {
        return _name;
    }

    /// Get the numeric postfix ("-" indicates no postfix is used)
	std::string getPostfix() const
    {
        return _postFix;
    }

    /**
     * \brief
     * Change (if necessary) the postfix to make it unique, and return the new
     * postfix value.
     *
     * \param postfixes
     * Set of existing postfixes which must not be used.
     */
    std::string makePostfixUnique(const PostfixSet& postfixes);
};