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)
|
2015-05-16 07:57:53 +03:00
|
|
|
#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
|
|
|
|
#include <unordered_map>
|
|
|
|
#else
|
2014-03-12 09:48:06 +04:00
|
|
|
#include "cmsys/hash_map.hxx"
|
|
|
|
#endif
|
2015-05-16 07:57:53 +03:00
|
|
|
#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
|
|
|
|
{
|
2015-05-16 06:33:25 +03:00
|
|
|
typedef std::list<cmDefinitions>::reverse_iterator StackIter;
|
|
|
|
typedef std::list<cmDefinitions>::const_reverse_iterator StackConstIter;
|
2009-07-22 22:22:45 +04:00
|
|
|
public:
|
2015-05-01 02:50:45 +03:00
|
|
|
static const char* Get(const std::string& key,
|
2015-05-16 06:33:25 +03:00
|
|
|
StackIter begin, StackIter end);
|
2009-07-22 22:22:45 +04:00
|
|
|
|
2015-05-17 14:21:02 +03:00
|
|
|
static void Raise(const std::string& key, StackIter begin, StackIter end);
|
|
|
|
|
2015-05-17 14:37:41 +03:00
|
|
|
static bool HasKey(const std::string& key,
|
|
|
|
StackConstIter begin, StackConstIter end);
|
|
|
|
|
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-05-17 17:19:55 +03:00
|
|
|
std::vector<std::string> UnusedKeys() const;
|
2010-08-24 22:40:51 +04:00
|
|
|
|
2015-05-16 06:33:30 +03:00
|
|
|
static std::vector<std::string> ClosureKeys(StackConstIter begin,
|
|
|
|
StackConstIter end);
|
2009-07-22 22:22:45 +04:00
|
|
|
|
2015-05-16 06:33:25 +03:00
|
|
|
static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end);
|
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:
|
2015-05-17 17:19:55 +03:00
|
|
|
Def(): std_string(), Exists(false), Used(false) {}
|
|
|
|
Def(const char* v)
|
|
|
|
: std_string(v ? v : ""),
|
|
|
|
Exists(v ? true : false),
|
|
|
|
Used(false)
|
|
|
|
{}
|
|
|
|
Def(const std_string& v): std_string(v), Exists(true), Used(false) {}
|
|
|
|
Def(Def const& d): std_string(d), Exists(d.Exists), Used(d.Used) {}
|
2009-07-22 22:22:45 +04:00
|
|
|
bool Exists;
|
2015-05-17 17:19:55 +03:00
|
|
|
bool Used;
|
2009-07-22 22:22:45 +04:00
|
|
|
};
|
|
|
|
static Def NoDef;
|
|
|
|
|
2014-03-12 09:48:06 +04:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2015-05-16 07:57:53 +03:00
|
|
|
#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
|
|
|
|
typedef std::unordered_map<std::string, Def> MapType;
|
|
|
|
#else
|
2014-03-12 09:48:06 +04:00
|
|
|
typedef cmsys::hash_map<std::string, Def> MapType;
|
2015-05-16 07:57:53 +03:00
|
|
|
#endif
|
2014-03-12 09:48:06 +04:00
|
|
|
#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;
|
|
|
|
|
2015-05-01 02:13:38 +03:00
|
|
|
static Def const& GetInternal(const std::string& key,
|
2015-05-17 14:21:02 +03:00
|
|
|
StackIter begin, StackIter end, bool raise);
|
2009-07-22 22:22:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|