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