2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2009-07-22 22:22:45 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2009-07-22 22:22:45 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2009-07-22 22:22:45 +04:00
|
|
|
#ifndef cmDefinitions_h
|
|
|
|
#define cmDefinitions_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
2014-03-12 09:48:06 +04:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
#include "cmsys/hash_map.hxx"
|
|
|
|
#endif
|
2009-07-22 22:22:45 +04:00
|
|
|
|
2015-04-26 17:00:18 +03:00
|
|
|
#include <list>
|
|
|
|
|
2009-07-22 22:22:45 +04:00
|
|
|
/** \class cmDefinitions
|
|
|
|
* \brief Store a scope of variable definitions for CMake language.
|
|
|
|
*
|
|
|
|
* This stores the state of variable definitions (set or unset) for
|
|
|
|
* one scope. Sets are always local. Gets search parent scopes
|
|
|
|
* transitively and save results locally.
|
|
|
|
*/
|
|
|
|
class cmDefinitions
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Construct with the given parent scope. */
|
|
|
|
cmDefinitions(cmDefinitions* parent = 0);
|
|
|
|
|
|
|
|
/** Returns the parent scope, if any. */
|
|
|
|
cmDefinitions* GetParent() const { return this->Up; }
|
|
|
|
|
2014-10-24 20:58:12 +04:00
|
|
|
/** Get the value associated with a key; null if none.
|
|
|
|
Store the result locally if it came from a parent. */
|
|
|
|
const char* Get(const std::string& key);
|
2009-07-22 22:22:45 +04:00
|
|
|
|
|
|
|
/** Set (or unset if null) a value associated with a key. */
|
2015-04-25 17:29:54 +03:00
|
|
|
void Set(const std::string& key, const char* value);
|
2009-07-22 22:22:45 +04:00
|
|
|
|
2015-04-25 17:33:26 +03:00
|
|
|
void Erase(const std::string& key);
|
|
|
|
|
2010-08-24 22:40:51 +04:00
|
|
|
/** Get the set of all local keys. */
|
2015-04-26 17:34:13 +03:00
|
|
|
std::vector<std::string> LocalKeys() const;
|
2010-08-24 22:40:51 +04:00
|
|
|
|
2015-04-26 16:38:36 +03:00
|
|
|
std::vector<std::string>
|
|
|
|
ClosureKeys(std::set<std::string>& bound) const;
|
2009-07-22 22:22:45 +04:00
|
|
|
|
2015-04-26 17:13:56 +03:00
|
|
|
static cmDefinitions MakeClosure(
|
2015-04-30 00:48:43 +03:00
|
|
|
std::list<cmDefinitions>::const_reverse_iterator rbegin,
|
|
|
|
std::list<cmDefinitions>::const_reverse_iterator rend);
|
2015-04-26 16:44:26 +03:00
|
|
|
|
2009-07-22 22:22:45 +04:00
|
|
|
private:
|
|
|
|
// String with existence boolean.
|
2014-02-10 09:21:34 +04:00
|
|
|
struct Def: public std::string
|
2009-07-22 22:22:45 +04:00
|
|
|
{
|
2014-02-10 09:21:34 +04:00
|
|
|
private:
|
|
|
|
typedef std::string std_string;
|
|
|
|
public:
|
|
|
|
Def(): std_string(), Exists(false) {}
|
|
|
|
Def(const char* v): std_string(v?v:""), Exists(v?true:false) {}
|
2014-02-22 04:06:54 +04:00
|
|
|
Def(const std_string& v): std_string(v), Exists(true) {}
|
2014-02-10 09:21:34 +04:00
|
|
|
Def(Def const& d): std_string(d), Exists(d.Exists) {}
|
2009-07-22 22:22:45 +04:00
|
|
|
bool Exists;
|
|
|
|
};
|
|
|
|
static Def NoDef;
|
|
|
|
|
|
|
|
// Parent scope, if any.
|
|
|
|
cmDefinitions* Up;
|
|
|
|
|
|
|
|
// Local definitions, set or unset.
|
2014-03-12 09:48:06 +04:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
typedef cmsys::hash_map<std::string, Def> MapType;
|
|
|
|
#else
|
2014-02-10 09:21:34 +04:00
|
|
|
typedef std::map<std::string, Def> MapType;
|
2014-03-12 09:48:06 +04:00
|
|
|
#endif
|
2009-07-22 22:22:45 +04:00
|
|
|
MapType Map;
|
|
|
|
|
|
|
|
// Internal query and update methods.
|
2014-10-24 20:58:12 +04:00
|
|
|
Def const& GetInternal(const std::string& key);
|
2009-07-22 22:22:45 +04:00
|
|
|
|
2015-04-26 16:44:26 +03:00
|
|
|
void MakeClosure(std::set<std::string>& undefined,
|
2015-04-30 00:48:43 +03:00
|
|
|
std::list<cmDefinitions>::const_reverse_iterator rbegin,
|
|
|
|
std::list<cmDefinitions>::const_reverse_iterator rend);
|
2009-07-22 22:22:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|