1
/*============================================================================
2
CMake - Cross Platform Makefile Generator
3
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5
Distributed under the OSI-approved BSD License (the "License");
6
see accompanying file Copyright.txt for details.
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
15
#include "cmStandardIncludes.h"
17
/** \class cmDefinitions
18
* \brief Store a scope of variable definitions for CMake language.
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.
27
/** Construct with the given parent scope. */
28
cmDefinitions(cmDefinitions* parent = 0);
30
/** Reset object as if newly constructed. */
31
void Reset(cmDefinitions* parent = 0);
33
/** Returns the parent scope, if any. */
34
cmDefinitions* GetParent() const { return this->Up; }
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);
40
/** Set (or unset if null) a value associated with a key. */
41
const char* Set(const char* key, const char* value);
43
/** Compute the closure of all defined keys with values.
44
This flattens the scope. The result has no parent. */
45
cmDefinitions Closure() const;
47
/** Compute the set of all defined keys. */
48
std::set<cmStdString> ClosureKeys() const;
51
// String with existence boolean.
52
struct Def: public cmStdString
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) {}
61
// Parent scope, if any.
64
// Local definitions, set or unset.
65
typedef std::map<cmStdString, Def> MapType;
68
// Internal query and update methods.
69
Def const& GetInternal(const char* key);
70
Def const& SetInternal(const char* key, Def const& def);
72
// Implementation of Closure() method.
74
cmDefinitions(ClosureTag const&, cmDefinitions const* root);
75
void ClosureImpl(std::set<cmStdString>& undefined,
76
cmDefinitions const* defs);
78
// Implementation of ClosureKeys() method.
79
void ClosureKeys(std::set<cmStdString>& defined,
80
std::set<cmStdString>& undefined) const;