From ce750180baec52f1bb64fbd1afe7c1aff1338c5c Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Thu, 6 Mar 2003 11:19:28 -0500 Subject: Add method which returns a list of all variables --- Source/cmMakefile.cxx | 26 ++++++++++++++++++++++++++ Source/cmMakefile.h | 7 +++++++ 2 files changed, 33 insertions(+) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b386041..4a9ef30 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -976,6 +976,32 @@ const char* cmMakefile::GetDefinition(const char* name) const return def; } +std::vector cmMakefile::GetDefinitions(int cacheonly /* = 0 */) const +{ + std::map definitions; + if ( !cacheonly ) + { + DefinitionMap::const_iterator it; + for ( it = m_Definitions.begin(); it != m_Definitions.end(); it ++ ) + { + definitions[it->first] = 1; + } + } + cmCacheManager::CacheIterator cit = this->GetCacheManager()->GetCacheIterator(); + for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) + { + definitions[cit.GetName()] = 1; + } + + std::vector res; + + std::map::iterator fit; + for ( fit = definitions.begin(); fit != definitions.end(); fit ++ ) + { + res.push_back(fit->first); + } + return res; +} const char *cmMakefile::ExpandVariablesInString(std::string& source) const diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 0d9ca16..3180847 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -441,6 +441,13 @@ public: * cache is then queried. */ const char* GetDefinition(const char*) const; + + /** + * Get the list of all variables in the current space. If argument + * cacheonly is specified and is greater than 0, then only cache + * variables will be listed. + */ + std::vector GetDefinitions(int cacheonly=0) const; /** Test a boolean cache entry to see if it is true or false, * returns false if no entry defined. -- cgit v0.12