Imported Upstream version 2.8.12.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   enum Delimiter
29     {
30     Unquoted,
31     Quoted
32     };
33   cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {}
34   cmListFileArgument(const cmListFileArgument& r):
35     Value(r.Value), Delim(r.Delim), FilePath(r.FilePath), Line(r.Line) {}
36   cmListFileArgument(const std::string& v, Delimiter d, const char* file,
37                      long line): Value(v), Delim(d),
38                                  FilePath(file), Line(line) {}
39   bool operator == (const cmListFileArgument& r) const
40     {
41     return (this->Value == r.Value) && (this->Delim == r.Delim);
42     }
43   bool operator != (const cmListFileArgument& r) const
44     {
45     return !(*this == r);
46     }
47   std::string Value;
48   Delimiter Delim;
49   const char* FilePath;
50   long Line;
51 };
52
53 struct cmListFileContext
54 {
55   std::string Name;
56   std::string FilePath;
57   long Line;
58   cmListFileContext(): Name(), FilePath(), Line(0) {}
59 };
60
61 std::ostream& operator<<(std::ostream&, cmListFileContext const&);
62
63 struct cmListFileFunction: public cmListFileContext
64 {
65   std::vector<cmListFileArgument> Arguments;
66 };
67
68 class cmListFileBacktrace: public std::vector<cmListFileContext> {};
69
70 struct cmListFile
71 {
72   cmListFile()
73     :ModifiedTime(0)
74     {
75     }
76   bool ParseFile(const char* path,
77                  bool topLevel,
78                  cmMakefile *mf);
79
80   long int ModifiedTime;
81   std::vector<cmListFileFunction> Functions;
82 };
83
84 struct cmValueWithOrigin {
85   cmValueWithOrigin(const std::string &value,
86                           const cmListFileBacktrace &bt)
87     : Value(value), Backtrace(bt)
88   {}
89   std::string Value;
90   cmListFileBacktrace Backtrace;
91 };
92
93 #endif