File: macroset.h

package info (click to toggle)
kdevelop 4%3A4.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 18,844 kB
  • sloc: cpp: 91,758; python: 1,095; lex: 422; ruby: 120; sh: 114; xml: 42; makefile: 38
file content (72 lines) | stat: -rw-r--r-- 2,296 bytes parent folder | download | duplicates (3)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/***************************************************************************
   Copyright 2006 David Nolden <david.nolden.kdevelop@art-master.de>
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef MACROSET_H
#define MACROSET_H

#include <set>
#include "rpp/pp-macro.h"
#include "cppduchainexport.h"

/**
 * Represents a set of c++ preprocess-macros.
 * */

class QDataStream;
namespace KDevelop {
class IndexedString;
}

namespace Cpp {

class KDEVCPPDUCHAIN_EXPORT MacroSet {
    public:
        typedef std::set< rpp::pp_macro, rpp::pp_macro::NameCompare > Macros;
        MacroSet() : m_idHashValid( false ), m_valueHashValid( false ) {
        }

        void addMacro( const rpp::pp_macro& macro );

        ///@todo reimplement
        void read( QDataStream& stream );

        ///@todo reimplement
        void write( QDataStream& stream ) const;

        bool hasMacro( const QString& name ) const;
        bool hasMacro( const KDevelop::IndexedString& name ) const;
        rpp::pp_macro macro( const KDevelop::IndexedString& name ) const;
        
        size_t idHash() const;
        size_t valueHash() const;

        const Macros& macros() const {
          return m_usedMacros;
        }

        int size() const;
        
        void merge( const MacroSet& macros );
    private:
        void computeHash() const;
        Macros m_usedMacros;
        mutable bool m_idHashValid;
        mutable bool m_valueHashValid;
        mutable size_t m_idHash; //Hash that represents the ids of all macros
        mutable size_t m_valueHash; //Hash that represents the values of all macros

        friend class Driver;
};

}
#endif