cmake/Source/cmListFileCache.h

122 lines
3.2 KiB
C
Raw Normal View History

2009-10-04 10:30:41 +03:00
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
2009-10-04 10:30:41 +03:00
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
2009-10-04 10:30:41 +03: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.
============================================================================*/
#ifndef cmListFileCache_h
#define cmListFileCache_h
#include "cmStandardIncludes.h"
2015-11-17 17:22:37 +01:00
#include "cmState.h"
2015-04-27 22:25:09 +02: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.
*/
class cmMakefile;
2013-03-16 19:13:01 +02:00
2015-11-17 17:22:37 +01:00
struct cmCommandContext
{
std::string Name;
long Line;
cmCommandContext(): Name(), Line(0) {}
};
struct cmListFileArgument
{
2013-11-03 12:27:13 +02:00
enum Delimiter
{
Unquoted,
2014-08-03 19:52:23 +02:00
Quoted,
Bracket
2013-11-03 12:27:13 +02:00
};
2015-11-17 17:22:37 +01:00
cmListFileArgument(): Value(), Delim(Unquoted), Line(0) {}
cmListFileArgument(const cmListFileArgument& r)
: Value(r.Value), Delim(r.Delim), Line(r.Line) {}
cmListFileArgument(const std::string& v, Delimiter d, long line)
: Value(v), Delim(d), Line(line) {}
bool operator == (const cmListFileArgument& r) const
{
2013-11-03 12:27:13 +02:00
return (this->Value == r.Value) && (this->Delim == r.Delim);
}
bool operator != (const cmListFileArgument& r) const
{
return !(*this == r);
}
std::string Value;
2013-11-03 12:27:13 +02:00
Delimiter Delim;
long Line;
};
struct cmListFileContext
{
std::string Name;
std::string FilePath;
long Line;
cmListFileContext(): Name(), FilePath(), Line(0) {}
2015-11-17 17:22:37 +01: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;
}
};
std::ostream& operator<<(std::ostream&, cmListFileContext const&);
2015-08-17 11:37:30 +02:00
bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
2015-11-17 17:22:37 +01:00
struct cmListFileFunction: public cmCommandContext
{
std::vector<cmListFileArgument> Arguments;
};
2015-11-17 17:22:37 +01:00
class cmListFileBacktrace
2015-04-27 22:25:09 +02:00
{
public:
2015-11-17 17:22:37 +01:00
cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(),
2015-12-03 18:43:53 +01:00
cmCommandContext const& cc = cmCommandContext());
~cmListFileBacktrace();
2015-04-27 22:25:09 +02:00
2015-11-17 17:22:37 +01:00
void PrintTitle(std::ostream& out) const;
void PrintCallStack(std::ostream& out) const;
2015-04-27 22:25:09 +02:00
private:
2015-11-17 17:22:37 +01:00
cmCommandContext Context;
cmState::Snapshot Snapshot;
2015-04-27 22:25:09 +02:00
};
struct cmListFile
{
2013-03-16 19:13:01 +02:00
bool ParseFile(const char* path,
bool topLevel,
cmMakefile *mf);
std::vector<cmListFileFunction> Functions;
};
2013-03-16 19:13:01 +02:00
struct cmValueWithOrigin {
cmValueWithOrigin(const std::string &value,
const cmListFileBacktrace &bt)
: Value(value), Backtrace(bt)
{}
std::string Value;
cmListFileBacktrace Backtrace;
};
#endif