Name.h 2.55 KB
Newer Older
con's avatar
con committed
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
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef CPLUSPLUS_NAME_H
#define CPLUSPLUS_NAME_H

#include "CPlusPlusForwardDeclarations.h"

26
#include <functional>
Roberto Raggi's avatar
Roberto Raggi committed
27 28

namespace CPlusPlus {
con's avatar
con committed
29 30 31 32 33 34 35

class CPLUSPLUS_EXPORT Name
{
public:
    Name();
    virtual ~Name();

Roberto Raggi's avatar
Roberto Raggi committed
36
    virtual const Identifier *identifier() const = 0;
Roberto Raggi's avatar
Roberto Raggi committed
37

con's avatar
con committed
38 39 40 41 42 43
    bool isNameId() const;
    bool isTemplateNameId() const;
    bool isDestructorNameId() const;
    bool isOperatorNameId() const;
    bool isConversionNameId() const;
    bool isQualifiedNameId() const;
44
    bool isSelectorNameId() const;
con's avatar
con committed
45

46
    virtual const Identifier *asNameId() const { return 0; }
47 48 49 50 51
    virtual const TemplateNameId *asTemplateNameId() const { return 0; }
    virtual const DestructorNameId *asDestructorNameId() const { return 0; }
    virtual const OperatorNameId *asOperatorNameId() const { return 0; }
    virtual const ConversionNameId *asConversionNameId() const { return 0; }
    virtual const QualifiedNameId *asQualifiedNameId() const { return 0; }
52
    virtual const SelectorNameId *asSelectorNameId() const { return 0; }
con's avatar
con committed
53 54 55

    virtual bool isEqualTo(const Name *other) const = 0;

Roberto Raggi's avatar
Roberto Raggi committed
56 57
    void accept(NameVisitor *visitor) const;
    static void accept(const Name *name, NameVisitor *visitor);
con's avatar
con committed
58

59 60 61 62 63
public:
    struct Compare: std::binary_function<const Name *, const Name *, bool> {
        bool operator()(const Name *name, const Name *other) const;
    };

con's avatar
con committed
64
protected:
Roberto Raggi's avatar
Roberto Raggi committed
65
    virtual void accept0(NameVisitor *visitor) const = 0;
con's avatar
con committed
66 67
};

68
} // namespace CPlusPlus
Roberto Raggi's avatar
Roberto Raggi committed
69

con's avatar
con committed
70 71

#endif // CPLUSPLUS_NAME_H