~ubuntu-branches/ubuntu/lucid/cmake/lucid

« back to all changes in this revision

Viewing changes to Source/cmDefinitions.h

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2009-12-16 11:11:54 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091216111154-6accvv6yq86h2hkc
Tags: 2.8.0-5ubuntu1
* Merge from debian testing (LP: #497349). Remaining changes:
  - Keep the Replaces: on cmake-data to cover the Kubuntu version from
    Jaunty in case someone decides to do an (unsupported) Jaunty->Lucid
    upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*============================================================================
 
2
  CMake - Cross Platform Makefile Generator
 
3
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
 
4
 
 
5
  Distributed under the OSI-approved BSD License (the "License");
 
6
  see accompanying file Copyright.txt for details.
 
7
 
 
8
  This software is distributed WITHOUT ANY WARRANTY; without even the
 
9
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
10
  See the License for more information.
 
11
============================================================================*/
 
12
#ifndef cmDefinitions_h
 
13
#define cmDefinitions_h
 
14
 
 
15
#include "cmStandardIncludes.h"
 
16
 
 
17
/** \class cmDefinitions
 
18
 * \brief Store a scope of variable definitions for CMake language.
 
19
 *
 
20
 * This stores the state of variable definitions (set or unset) for
 
21
 * one scope.  Sets are always local.  Gets search parent scopes
 
22
 * transitively and save results locally.
 
23
 */
 
24
class cmDefinitions
 
25
{
 
26
public:
 
27
  /** Construct with the given parent scope.  */
 
28
  cmDefinitions(cmDefinitions* parent = 0);
 
29
 
 
30
  /** Reset object as if newly constructed.  */
 
31
  void Reset(cmDefinitions* parent = 0);
 
32
 
 
33
  /** Returns the parent scope, if any.  */
 
34
  cmDefinitions* GetParent() const { return this->Up; }
 
35
 
 
36
  /** Get the value associated with a key; null if none.
 
37
      Store the result locally if it came from a parent.  */
 
38
  const char* Get(const char* key);
 
39
 
 
40
  /** Set (or unset if null) a value associated with a key.  */
 
41
  const char* Set(const char* key, const char* value);
 
42
 
 
43
  /** Compute the closure of all defined keys with values.
 
44
      This flattens the scope.  The result has no parent.  */
 
45
  cmDefinitions Closure() const;
 
46
 
 
47
  /** Compute the set of all defined keys.  */
 
48
  std::set<cmStdString> ClosureKeys() const;
 
49
 
 
50
private:
 
51
  // String with existence boolean.
 
52
  struct Def: public cmStdString
 
53
  {
 
54
    Def(): cmStdString(), Exists(false) {}
 
55
    Def(const char* v): cmStdString(v?v:""), Exists(v?true:false) {}
 
56
    Def(Def const& d): cmStdString(d), Exists(d.Exists) {}
 
57
    bool Exists;
 
58
  };
 
59
  static Def NoDef;
 
60
 
 
61
  // Parent scope, if any.
 
62
  cmDefinitions* Up;
 
63
 
 
64
  // Local definitions, set or unset.
 
65
  typedef std::map<cmStdString, Def> MapType;
 
66
  MapType Map;
 
67
 
 
68
  // Internal query and update methods.
 
69
  Def const& GetInternal(const char* key);
 
70
  Def const& SetInternal(const char* key, Def const& def);
 
71
 
 
72
  // Implementation of Closure() method.
 
73
  struct ClosureTag {};
 
74
  cmDefinitions(ClosureTag const&, cmDefinitions const* root);
 
75
  void ClosureImpl(std::set<cmStdString>& undefined,
 
76
                   cmDefinitions const* defs);
 
77
 
 
78
  // Implementation of ClosureKeys() method.
 
79
  void ClosureKeys(std::set<cmStdString>& defined,
 
80
                   std::set<cmStdString>& undefined) const;
 
81
};
 
82
 
 
83
#endif