~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/cpp/cppduchain/macroset.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
   Copyright 2006 David Nolden <david.nolden.kdevelop@art-master.de>
 
3
***************************************************************************/
 
4
 
 
5
/***************************************************************************
 
6
 *                                                                         *
 
7
 *   This program is free software; you can redistribute it and/or modify  *
 
8
 *   it under the terms of the GNU General Public License as published by  *
 
9
 *   the Free Software Foundation; either version 2 of the License, or     *
 
10
 *   (at your option) any later version.                                   *
 
11
 *                                                                         *
 
12
 ***************************************************************************/
 
13
 
 
14
#ifndef MACROSET_H
 
15
#define MACROSET_H
 
16
 
 
17
#include <set>
 
18
#include "rpp/pp-macro.h"
 
19
#include "cppduchainexport.h"
 
20
 
 
21
/**
 
22
 * Represents a set of c++ preprocess-macros.
 
23
 * */
 
24
 
 
25
class QDataStream;
 
26
namespace KDevelop {
 
27
class HashedString;
 
28
}
 
29
 
 
30
namespace Cpp {
 
31
 
 
32
class KDEVCPPDUCHAIN_EXPORT MacroSet {
 
33
    public:
 
34
        typedef std::set< rpp::pp_macro, rpp::pp_macro::NameCompare > Macros;
 
35
        MacroSet() : m_idHashValid( false ), m_valueHashValid( false ) {
 
36
        }
 
37
 
 
38
        void addMacro( const rpp::pp_macro& macro );
 
39
 
 
40
        ///@todo reimplement
 
41
        void read( QDataStream& stream );
 
42
 
 
43
        ///@todo reimplement
 
44
        void write( QDataStream& stream ) const;
 
45
 
 
46
        bool hasMacro( const QString& name ) const;
 
47
        bool hasMacro( const KDevelop::HashedString& name ) const;
 
48
        rpp::pp_macro macro( const KDevelop::HashedString& name ) const;
 
49
        
 
50
        size_t idHash() const;
 
51
        size_t valueHash() const;
 
52
 
 
53
        const Macros& macros() const {
 
54
          return m_usedMacros;
 
55
        }
 
56
 
 
57
        int size() const;
 
58
        
 
59
        void merge( const MacroSet& macros );
 
60
    private:
 
61
        void computeHash() const;
 
62
        Macros m_usedMacros;
 
63
        mutable bool m_idHashValid;
 
64
        mutable bool m_valueHashValid;
 
65
        mutable size_t m_idHash; //Hash that represents the ids of all macros
 
66
        mutable size_t m_valueHash; //Hash that represents the values of all macros
 
67
 
 
68
        friend class Driver;
 
69
};
 
70
 
 
71
}
 
72
#endif