1 karl 1.6 //%2005////////////////////////////////////////////////////////////////////////
|
2 chuck 1.2 //
|
3 karl 1.6 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 chuck 1.2 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.6 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 chuck 1.2 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Humberto Rivero (hurivero@us.ibm.com)
31 //
|
32 david.dillard 1.5 // Modified By: David Dillard, VERITAS Software Corp.
33 // (david.dillard@veritas.com)
|
34 chuck 1.2 //
35 //%/////////////////////////////////////////////////////////////////////////////
36
37 #ifndef Pegasus_CQLParser_h
38 #define Pegasus_CQLParser_h
39
|
40 david.dillard 1.7 #include <Pegasus/CQL/Linkage.h>
|
41 chuck 1.2 #include <Pegasus/Common/ArrayInternal.h>
42 #include <Pegasus/CQL/CQLSelectStatement.h>
43
44 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
45
46 PEGASUS_NAMESPACE_BEGIN
47
|
48 humberto 1.3 /** This class is the main interface to the CQL parser used for parsing CQL compliant statements.
|
49 chuck 1.2
50 Here's an example which parses a SELECT statement:
51
52 <pre>
|
53 david.dillard 1.7 const char TEXT[] = "SELECT X,Y FROM MyClass WHERE X > 10 AND Y < 3";
|
54 chuck 1.2
|
55 david.dillard 1.7 // Note that this array must be null-terminated (sizeof(TEXT) includes
56 // the null-terminator in the count).
|
57 chuck 1.2
|
58 david.dillard 1.7 Array<char> text(TEXT, sizeof(TEXT));
|
59 chuck 1.2
|
60 david.dillard 1.7 CQLSelectStatement selectStatement;
|
61 chuck 1.2
|
62 david.dillard 1.7 try
63 {
64 CQLParser::parse(text, selectStatement);
65 }
66 catch (QueryException&)
67 {
68 ...
69 }
|
70 chuck 1.2 </pre>
71
72 The text is read and the result is left in the selectStatement output
73 argument.
74
75 */
76 class PEGASUS_CQL_LINKAGE CQLParser
77 {
78 public:
79
80 /** Parse the SELECT statement given by the text parameter and initialize
|
81 david.dillard 1.7 the statement parameter accordingly.
|
82 chuck 1.2
|
83 david.dillard 1.7 Please note that this method is not thread safe. It must be guarded
84 with mutexes by the caller.
|
85 chuck 1.2
|
86 david.dillard 1.7 @param text null-terminated C-string which points to CQL statement.
87 @param statement object which holds the compiled version of the SELECT
88 statement upon return.
89 @exception CQLSyntaxErrorException if text is not a valid SELECT statement.
90 @exception MissingNullTerminator if text argument is not
91 terminated with a null.
|
92 chuck 1.2 */
93 static void parse(
|
94 david.dillard 1.7 const char* text,
95 CQLSelectStatement& statement);
|
96 chuck 1.2
97 /** Version of parse() taking an array of characters.
98 */
99 static void parse(
|
100 david.dillard 1.7 const Array<char>& text,
101 CQLSelectStatement& statement);
|
102 chuck 1.2
103 /** Version of parse() taking a string.
104 */
105 static void parse(
|
106 david.dillard 1.7 const String& text,
107 CQLSelectStatement& statement);
|
108 chuck 1.2
109 private:
110
111 /** This method cleans up all the strings which were created by LEX and
|
112 david.dillard 1.7 passed to YACC. These strings cannot be cleaned up by YACC actions
113 since the actions that clean up certain strings are not always reached
114 when errors occur.
|
115 chuck 1.2 */
116 static void cleanup();
117
118 /** Private constructor to avoid user from creating instance of this class.
119 */
120 CQLParser() { }
121 };
122
123 PEGASUS_NAMESPACE_END
124 #endif
|
125 humberto 1.3 #endif /* Pegasus_CQLParser_h */
|