packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmCommandArgumentParserHelper.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 cmCommandArgumentParserHelper_h
13 #define cmCommandArgumentParserHelper_h
14
15 #include "cmStandardIncludes.h"
16
17 #define YYSTYPE cmCommandArgumentParserHelper::ParserType
18 #define YYSTYPE_IS_DECLARED
19 #define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
20 #define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp,\
21   yyscan_t yyscanner)
22
23 /** \class cmCommandArgumentParserHelper
24  * \brief Helper class for parsing java source files
25  *
26  * Finds dependencies for java file and list of outputs
27  */
28
29 class cmMakefile;
30
31 class cmCommandArgumentParserHelper
32 {
33 public:
34   typedef struct {
35     char* str;
36   } ParserType;
37
38   cmCommandArgumentParserHelper();
39   ~cmCommandArgumentParserHelper();
40
41   int ParseString(const char* str, int verb);
42
43   // For the lexer:
44   void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
45     const char* str, int len = 0);
46   bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt,
47     char symbol);
48
49   int LexInput(char* buf, int maxlen);
50   void Error(const char* str);
51
52   // For yacc
53   char* CombineUnions(char* in1, char* in2);
54
55   char* ExpandSpecialVariable(const char* key, const char* var);
56   char* ExpandVariable(const char* var);
57   char* ExpandVariableForAt(const char* var);
58   void SetResult(const char* value);
59
60   void SetMakefile(const cmMakefile* mf);
61
62   std::string& GetResult() { return this->Result; }
63
64   void SetLineFile(long line, const char* file);
65   void SetEscapeQuotes(bool b) { this->EscapeQuotes = b; }
66   void SetNoEscapeMode(bool b) { this->NoEscapeMode = b; }
67   void SetReplaceAtSyntax(bool b) { this->ReplaceAtSyntax = b; }
68   void SetRemoveEmpty(bool b) { this->RemoveEmpty = b; }
69
70   const char* GetError() { return this->ErrorString.c_str(); }
71   char EmptyVariable[1];
72   char DCURLYVariable[3];
73   char RCURLYVariable[3];
74   char ATVariable[3];
75   char DOLLARVariable[3];
76   char LCURLYVariable[3];
77   char BSLASHVariable[3];
78
79 private:
80   cmStdString::size_type InputBufferPos;
81   cmStdString InputBuffer;
82   std::vector<char> OutputBuffer;
83   int CurrentLine;
84   int Verbose;
85
86   void Print(const char* place, const char* str);
87   void SafePrintMissing(const char* str, int line, int cnt);
88
89   char* AddString(const char* str);
90
91   void CleanupParser();
92   void SetError(std::string const& msg);
93
94   std::vector<char*> Variables;
95   const cmMakefile* Makefile;
96   std::string Result;
97   const char* FileName;
98   bool WarnUninitialized;
99   bool CheckSystemVars;
100   long FileLine;
101   bool EscapeQuotes;
102   std::string ErrorString;
103   bool NoEscapeMode;
104   bool ReplaceAtSyntax;
105   bool RemoveEmpty;
106 };
107
108 #endif
109
110