Imported Upstream version 2.8.11.2
[platform/upstream/cmake.git] / Source / cmListFileCache.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmListFileCache_h
13 #define cmListFileCache_h
14
15 #include "cmStandardIncludes.h"
16
17 /** \class cmListFileCache
18  * \brief A class to cache list file contents.
19  *
20  * cmListFileCache is a class used to cache the contents of parsed
21  * cmake list files.
22  */
23
24 class cmMakefile;
25
26 struct cmListFileArgument
27 {
28   cmListFileArgument(): Value(), Quoted(false), FilePath(0), Line(0) {}
29   cmListFileArgument(const cmListFileArgument& r):
30     Value(r.Value), Quoted(r.Quoted), FilePath(r.FilePath), Line(r.Line) {}
31   cmListFileArgument(const std::string& v, bool q, const char* file,
32                      long line): Value(v), Quoted(q),
33                                  FilePath(file), Line(line) {}
34   bool operator == (const cmListFileArgument& r) const
35     {
36     return (this->Value == r.Value) && (this->Quoted == r.Quoted);
37     }
38   bool operator != (const cmListFileArgument& r) const
39     {
40     return !(*this == r);
41     }
42   std::string Value;
43   bool Quoted;
44   const char* FilePath;
45   long Line;
46 };
47
48 struct cmListFileContext
49 {
50   std::string Name;
51   std::string FilePath;
52   long Line;
53   cmListFileContext(): Name(), FilePath(), Line(0) {}
54 };
55
56 std::ostream& operator<<(std::ostream&, cmListFileContext const&);
57
58 struct cmListFileFunction: public cmListFileContext
59 {
60   std::vector<cmListFileArgument> Arguments;
61 };
62
63 class cmListFileBacktrace: public std::vector<cmListFileContext> {};
64
65 struct cmListFile
66 {
67   cmListFile()
68     :ModifiedTime(0)
69     {
70     }
71   bool ParseFile(const char* path,
72                  bool topLevel,
73                  cmMakefile *mf);
74
75   long int ModifiedTime;
76   std::vector<cmListFileFunction> Functions;
77 };
78
79 struct cmValueWithOrigin {
80   cmValueWithOrigin(const std::string &value,
81                           const cmListFileBacktrace &bt)
82     : Value(value), Backtrace(bt)
83   {}
84   std::string Value;
85   cmListFileBacktrace Backtrace;
86 };
87
88 #endif