2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2001-08-29 02:28:31 +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.
|
2001-08-29 02:28:31 +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.
|
|
|
|
============================================================================*/
|
2001-08-29 02:28:31 +04:00
|
|
|
#ifndef cmListFileCache_h
|
|
|
|
#define cmListFileCache_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
|
|
|
|
2015-06-04 21:00:14 +03:00
|
|
|
#include "cmState.h"
|
2014-03-13 01:59:42 +04:00
|
|
|
|
2001-08-29 02:28:31 +04:00
|
|
|
/** \class cmListFileCache
|
|
|
|
* \brief A class to cache list file contents.
|
|
|
|
*
|
|
|
|
* cmListFileCache is a class used to cache the contents of parsed
|
|
|
|
* cmake list files.
|
|
|
|
*/
|
|
|
|
|
2016-01-29 00:10:28 +03:00
|
|
|
class cmMessenger;
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2015-07-04 14:12:50 +03:00
|
|
|
struct cmCommandContext
|
|
|
|
{
|
|
|
|
std::string Name;
|
|
|
|
long Line;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCommandContext()
|
|
|
|
: Name()
|
|
|
|
, Line(0)
|
|
|
|
{
|
|
|
|
}
|
2015-07-04 14:12:50 +03:00
|
|
|
};
|
|
|
|
|
2002-12-12 02:13:33 +03:00
|
|
|
struct cmListFileArgument
|
|
|
|
{
|
2012-08-06 18:07:58 +04:00
|
|
|
enum Delimiter
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2012-08-06 18:07:58 +04:00
|
|
|
Unquoted,
|
2013-08-06 23:58:22 +04:00
|
|
|
Quoted,
|
|
|
|
Bracket
|
2016-05-16 17:34:04 +03:00
|
|
|
};
|
|
|
|
cmListFileArgument()
|
|
|
|
: Value()
|
|
|
|
, Delim(Unquoted)
|
|
|
|
, Line(0)
|
|
|
|
{
|
|
|
|
}
|
2015-05-24 00:43:37 +03:00
|
|
|
cmListFileArgument(const cmListFileArgument& r)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Value(r.Value)
|
|
|
|
, Delim(r.Delim)
|
|
|
|
, Line(r.Line)
|
|
|
|
{
|
|
|
|
}
|
2015-05-24 00:43:37 +03:00
|
|
|
cmListFileArgument(const std::string& v, Delimiter d, long line)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Value(v)
|
|
|
|
, Delim(d)
|
|
|
|
, Line(line)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
bool operator==(const cmListFileArgument& r) const
|
|
|
|
{
|
2012-08-06 18:07:58 +04:00
|
|
|
return (this->Value == r.Value) && (this->Delim == r.Delim);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
bool operator!=(const cmListFileArgument& r) const { return !(*this == r); }
|
2002-12-12 02:13:33 +03:00
|
|
|
std::string Value;
|
2012-08-06 18:07:58 +04:00
|
|
|
Delimiter Delim;
|
2004-08-04 18:45:11 +04:00
|
|
|
long Line;
|
2002-12-12 02:13:33 +03:00
|
|
|
};
|
|
|
|
|
2016-02-11 19:47:42 +03:00
|
|
|
class cmListFileContext
|
2001-08-29 02:28:31 +04:00
|
|
|
{
|
2016-02-11 19:47:42 +03:00
|
|
|
public:
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string Name;
|
2007-05-11 16:36:05 +04:00
|
|
|
std::string FilePath;
|
2006-03-15 19:02:08 +03:00
|
|
|
long Line;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmListFileContext()
|
|
|
|
: Name()
|
|
|
|
, FilePath()
|
|
|
|
, Line(0)
|
|
|
|
{
|
|
|
|
}
|
2015-07-04 14:12:50 +03:00
|
|
|
|
|
|
|
static cmListFileContext FromCommandContext(cmCommandContext const& lfcc,
|
|
|
|
std::string const& fileName)
|
|
|
|
{
|
|
|
|
cmListFileContext lfc;
|
|
|
|
lfc.FilePath = fileName;
|
|
|
|
lfc.Line = lfcc.Line;
|
|
|
|
lfc.Name = lfcc.Name;
|
|
|
|
return lfc;
|
|
|
|
}
|
2001-08-29 02:28:31 +04:00
|
|
|
};
|
|
|
|
|
2008-03-13 20:48:57 +03:00
|
|
|
std::ostream& operator<<(std::ostream&, cmListFileContext const&);
|
2015-05-18 22:44:14 +03:00
|
|
|
bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
|
2015-05-18 22:51:42 +03:00
|
|
|
bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
|
|
|
|
bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
|
2008-03-13 20:48:57 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
struct cmListFileFunction : public cmCommandContext
|
2008-03-07 16:40:36 +03:00
|
|
|
{
|
|
|
|
std::vector<cmListFileArgument> Arguments;
|
|
|
|
};
|
|
|
|
|
2016-04-14 18:24:08 +03:00
|
|
|
// Represent a backtrace (call stack). Provide value semantics
|
|
|
|
// but use efficient reference-counting underneath to avoid copies.
|
|
|
|
class cmListFileBacktrace
|
2014-03-13 01:59:42 +04:00
|
|
|
{
|
2016-04-14 18:24:08 +03:00
|
|
|
public:
|
|
|
|
// Default-constructed backtrace may not be used until after
|
|
|
|
// set via assignment from a backtrace constructed with a
|
|
|
|
// valid snapshot.
|
|
|
|
cmListFileBacktrace();
|
|
|
|
|
|
|
|
// Construct an empty backtrace whose bottom sits in the directory
|
|
|
|
// indicated by the given valid snapshot.
|
|
|
|
cmListFileBacktrace(cmState::Snapshot snapshot);
|
|
|
|
|
|
|
|
// Backtraces may be copied and assigned as values.
|
|
|
|
cmListFileBacktrace(cmListFileBacktrace const& r);
|
|
|
|
cmListFileBacktrace& operator=(cmListFileBacktrace const& r);
|
|
|
|
~cmListFileBacktrace();
|
|
|
|
|
|
|
|
// Get a backtrace with the given file scope added to the top.
|
|
|
|
// May not be called until after construction with a valid snapshot.
|
|
|
|
cmListFileBacktrace Push(std::string const& file) const;
|
|
|
|
|
|
|
|
// Get a backtrace with the given call context added to the top.
|
|
|
|
// May not be called until after construction with a valid snapshot.
|
|
|
|
cmListFileBacktrace Push(cmListFileContext const& lfc) const;
|
|
|
|
|
|
|
|
// Get a backtrace with the top level removed.
|
|
|
|
// May not be called until after a matching Push.
|
|
|
|
cmListFileBacktrace Pop() const;
|
|
|
|
|
|
|
|
// Get the context at the top of the backtrace.
|
|
|
|
// Returns an empty context if the backtrace is empty.
|
|
|
|
cmListFileContext const& Top() const;
|
|
|
|
|
|
|
|
// Print the top of the backtrace.
|
|
|
|
void PrintTitle(std::ostream& out) const;
|
|
|
|
|
|
|
|
// Print the call stack below the top of the backtrace.
|
|
|
|
void PrintCallStack(std::ostream& out) const;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2016-04-14 18:24:08 +03:00
|
|
|
private:
|
|
|
|
struct Entry;
|
|
|
|
cmState::Snapshot Bottom;
|
|
|
|
Entry* Cur;
|
|
|
|
cmListFileBacktrace(cmState::Snapshot bottom, Entry* up,
|
|
|
|
cmListFileContext const& lfc);
|
|
|
|
cmListFileBacktrace(cmState::Snapshot bottom, Entry* cur);
|
2014-03-13 01:59:42 +04:00
|
|
|
};
|
2008-03-13 20:48:57 +03:00
|
|
|
|
2001-08-29 02:28:31 +04:00
|
|
|
struct cmListFile
|
|
|
|
{
|
2016-01-29 00:10:28 +03:00
|
|
|
bool ParseFile(const char* path, cmMessenger* messenger,
|
|
|
|
cmListFileBacktrace const& lfbt);
|
2006-03-15 19:02:08 +03:00
|
|
|
|
|
|
|
std::vector<cmListFileFunction> Functions;
|
2001-08-29 02:28:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|