Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba

Proposed by Paul J. Lucas on 2014-01-31
Status: Merged
Approved by: Paul J. Lucas on 2014-01-31
Approved revision: 11423
Merged at revision: 11693
Proposed branch: lp:~paul-lucas/zorba/pjl-misc
Merge into: lp:zorba
Diff against target: 1010 lines (+449/-472)
5 files modified
bin/CMakeLists.txt (+1/-0)
bin/zorbacmdproperties.h (+2/-1)
bin/zorbacmdproperties.txt (+28/-28)
bin/zorbacmdproperties_base.cpp (+374/-0)
bin/zorbacmdproperties_base.h (+44/-443)
To merge this branch: bzr merge lp:~paul-lucas/zorba/pjl-misc
Reviewer Review Type Date Requested Status
Matthias Brantner 2014-01-31 Approve on 2014-02-01
Paul J. Lucas Approve on 2014-01-31
Review via email: mp+204361@code.launchpad.net

Commit message

zorba-cmd clean-up. Why this code is (mostly) duplicated here and inside libzorba isn't clear.

Description of the change

zorba-cmd clean-up. Why this code is (mostly) duplicated here and inside libzorba isn't clear.

To post a comment you must log in.
Paul J. Lucas (paul-lucas) :
review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/204361

Progress dashboard at http://jenkins.zorba.io:8180/view/ValidationQueue

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/204361

Stage "BuildZorbaUbuntu" failed.

Check compiler output at http://jenkins.zorba.io:8180/job/BuildZorbaUbuntu/510/parsed_console to view the results.

lp:~paul-lucas/zorba/pjl-misc updated on 2014-01-31
11424. By Paul J. Lucas on 2014-01-31

Forgot a file.

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/204361

Progress dashboard at http://jenkins.zorba.io:8180/view/ValidationQueue

Zorba Build Bot (zorba-buildbot) wrote :

Voting criteria failed for the following merge proposals:

https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/204361 :
Votes: {'Approve': 1}

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/204361

Stage "CommitZorba" failed.

Check console output at http://jenkins.zorba.io:8180/job/CommitZorba/285/console to view the results.

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/204361

Progress dashboard at http://jenkins.zorba.io:8180/view/ValidationQueue

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue succeeded - proposal merged!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/CMakeLists.txt'
2--- bin/CMakeLists.txt 2013-08-09 09:04:36 +0000
3+++ bin/CMakeLists.txt 2014-01-31 23:33:08 +0000
4@@ -45,6 +45,7 @@
5
6 SET(SRCS
7 zorbacmd.cpp
8+ zorbacmdproperties_base.cpp
9 zorbacmdproperties.cpp
10 util.cpp
11 path_util.cpp
12
13=== modified file 'bin/zorbacmdproperties.h'
14--- bin/zorbacmdproperties.h 2013-06-16 00:37:21 +0000
15+++ bin/zorbacmdproperties.h 2014-01-31 23:33:08 +0000
16@@ -122,4 +122,5 @@
17
18 bool loadProperties(int argc, char* argv[]);
19 };
20-#endif
21+#endif /* ZORBA_CMD_PROPERTIES_H */
22+/* vim:set et sw=2 ts=2: */
23
24=== modified file 'bin/zorbacmdproperties.txt'
25--- bin/zorbacmdproperties.txt 2013-08-09 09:04:36 +0000
26+++ bin/zorbacmdproperties.txt 2014-01-31 23:33:08 +0000
27@@ -1,40 +1,40 @@
28-("timing,t", "Print timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.")
29-("output-file,o", po::value<std::string>(), "Write the result to the given file.")
30-("serialization-parameter,z", po::value<std::vector<std::string> >(), "Set serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).")
31-("serialize-html", "Serialize the result as HTML.")
32-("serialize-text", "Serialize the result as Text.")
33-("indent,i", "Indent output.")
34-("print-query", "Print the queries.")
35-("print-errors-as-xml,x", "Print the errors as XML.")
36-("byte-order-mark", "Set the byte-order-mark for the serializer.")
37-("omit-xml-declaration,r", "Omit the XML declaration from the result.")
38+("as-files,f", "Treat all -q arguments as file paths instead of URIs or inline queries.")
39 ("base-uri", po::value<std::string>(), "Set the base URI property of the static context.")
40 ("boundary-space", po::value<std::string>(), "Set the boundary-space policy ('strip' or 'preserve') in the static context.")
41-("default-collation", po::value<std::string>(), "Add the given collation and set the value of the default collation in the static context to the given collation.")
42+("byte-order-mark", "Set the byte-order-mark for the serializer.")
43+("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
44+("compile-only", "Only compile (don't execute)")
45+("compile-plan,c", "Output the query plan as binary.")
46 ("construction-mode", po::value<std::string>(), "Set the construction mode ('strip' or 'preserve') in the static context.")
47-("ordering-mode", po::value<std::string>(), "Set the ordering mode ('ordered' or 'unordered') in the static context.")
48-("multiple,m", po::value<unsigned long>()->default_value (1), "Execute the given queries multiple times.")
49-("query,q", po::value<std::vector<std::string> >(&theQueriesOrFiles), "Query test or file URI (file://...)")
50-("as-files,f", "Treat all -q arguments as file paths instead of URIs or inline queries.")
51-("external-variable,e", po::value<std::vector<std::string> >(), "Provide the value for a variable given a file (name=file) or a value (name:=value)")
52 ("context-item", po::value<std::string> (), "Set the context item to the XML document in a given file.")
53-("optimization-level", po::value<std::string>()->default_value("O1"), "Optimization level for the query compiler (O0, O1 or O2 - default: O1)")
54-("lib-module,l", "Query compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.")
55-("parse-only", "Stop after parsing the query.")
56-("compile-only", "Only compile (don't execute)")
57-("no-serializer", "Do not serialize (discard) result.")
58 ("debug,d", "Launch the Zorba debugger server and connect to a DBGP-enabled debugger client.")
59 ("debug-host,h", po::value<std::string>()->default_value("127.0.0.1"), "The host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1")
60 ("debug-port,p", po::value<unsigned int>()->default_value (28028), "The port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028")
61-("no-logo", "Print no logo when starting.")
62-("timeout", po::value<long>()->default_value(-1), "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.")
63-("uri-path", po::value<std::string>(), "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.")
64+("default-collation", po::value<std::string>(), "Add the given collation and set the value of the default collation in the static context to the given collation.")
65+("execute-plan", "Take a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.")
66+("external-variable,e", po::value<std::vector<std::string> >(), "Provide the value for a variable given a file (name=file) or a value (name:=value)")
67+("indent,i", "Indent output.")
68+("lib-module,l", "Query compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.")
69 ("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")
70 ("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")
71-("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
72+("multiple,m", po::value<unsigned long>()->default_value (1), "Execute the given queries multiple times.")
73+("no-logo", "Print no logo when starting.")
74+("no-serializer", "Do not serialize (discard) result.")
75+("omit-xml-declaration,r", "Omit the XML declaration from the result.")
76+("optimization-level", po::value<std::string>()->default_value("O1"), "Optimization level for the query compiler (O0, O1 or O2 - default: O1)")
77 ("option", po::value<std::vector<std::string> >(), "Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://zorba.io/}option=value").
78-("trailing-nl", "Output a trailing newline after the result of the query.")
79+("ordering-mode", po::value<std::string>(), "Set the ordering mode ('ordered' or 'unordered') in the static context.")
80+("output-file,o", po::value<std::string>(), "Write the result to the given file.")
81+("parse-only", "Stop after parsing the query.")
82+("print-errors-as-xml,x", "Print the errors as XML.")
83+("print-query", "Print the queries.")
84+("query,q", po::value<std::vector<std::string> >(&theQueriesOrFiles), "Query test or file URI (file://...)")
85+("serialization-parameter,z", po::value<std::vector<std::string> >(), "Set serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).")
86+("serialize-html", "Serialize the result as HTML.")
87+("serialize-text", "Serialize the result as Text.")
88 ("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")
89 ("thesaurus", po::value<std::vector<std::string> >(), "Mapping specifying a thesaurus URI to another.")
90-("compile-plan,c", "Output the query plan as binary.")
91-("execute-plan", "Take a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.")
92+("timeout", po::value<long>()->default_value(-1), "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.")
93+("timing,t", "Print timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.")
94+("trailing-nl", "Output a trailing newline after the result of the query.")
95+("uri-path", po::value<std::string>(), "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.")
96
97=== added file 'bin/zorbacmdproperties_base.cpp'
98--- bin/zorbacmdproperties_base.cpp 1970-01-01 00:00:00 +0000
99+++ bin/zorbacmdproperties_base.cpp 2014-01-31 23:33:08 +0000
100@@ -0,0 +1,374 @@
101+/*
102+ * Copyright 2006-2008 The FLWOR Foundation.
103+ *
104+ * Licensed under the Apache License, Version 2.0 (the "License");
105+ * you may not use this file except in compliance with the License.
106+ * You may obtain a copy of the License at
107+ *
108+ * http://www.apache.org/licenses/LICENSE-2.0
109+ *
110+ * Unless required by applicable law or agreed to in writing, software
111+ * distributed under the License is distributed on an "AS IS" BASIS,
112+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
113+ * See the License for the specific language governing permissions and
114+ * limitations under the License.
115+ */
116+
117+#include "zorbacmdproperties_base.h"
118+
119+namespace zorbacmd {
120+
121+///////////////////////////////////////////////////////////////////////////////
122+
123+ZorbaCMDPropertiesBase::ZorbaCMDPropertiesBase() {
124+ theAsFiles = true;
125+ theByteOrderMark = false;
126+ theCompileOnly = false;
127+ theDebug = false;
128+ theDebugHost = "127.0.0.1";
129+ theDebugPort = 28028;
130+ theFparm = false;
131+ theIndent = false;
132+ theLibModule = false;
133+ theLoadPlan = false;
134+ theMultiple = 1;
135+ theNoLogo = false;
136+ theNoSerializer = false;
137+ theOmitXmlDeclaration = false;
138+ theOptimizationLevel = "O1";
139+ theParseOnly = false;
140+ thePrintErrorsAsXml = false;
141+ thePrintQuery = false;
142+ theQBeforeF = false;
143+ theSavePlan = false;
144+ theSerializeHtml = false;
145+ theSerializePlan = false;
146+ theSerializeText = false;
147+ theTimeout = -1;
148+ theTiming = false;
149+ theTrailingNl = false;
150+ theUnknownOption = false;
151+}
152+
153+char const** ZorbaCMDPropertiesBase::get_all_options() const {
154+ static const char* result [] = {
155+ "--as-files",
156+ "--base-uri",
157+ "--boundary-space",
158+ "--byte-order-mark",
159+ "--classpath",
160+ "--compile-only",
161+ "--compile-plan",
162+ "--construction-mode",
163+ "--context-item",
164+ "--debug",
165+ "--debug-host",
166+ "--debug-port",
167+ "--default-collation",
168+ "--disable-http-resolution",
169+ "--execute-plan",
170+ "--external-variable",
171+ "--indent",
172+ "--lib-module",
173+ "--lib-path",
174+ "--module-path",
175+ "--multiple",
176+ "--no-logo",
177+ "--no-serializer",
178+ "--omit-xml-declaration",
179+ "--optimization-level",
180+ "--option",
181+ "--ordering-mode",
182+#ifdef ZORBA_WITH_FILE_ACCESS
183+ "--output-file",
184+#endif /* ZORBA_WITH_FILE_ACCESS */
185+ "--parse-only",
186+ "--print-errors-as-xml",
187+ "--print-query",
188+ "--query",
189+ "--serialization-parameter",
190+ "--serialize-html",
191+ "--serialize-plan",
192+ "--serialize-text",
193+ "--stop-words",
194+ "--thesaurus",
195+ "--timeout",
196+ "--timing",
197+ "--trailing-nl",
198+ "--uri-path",
199+ NULL
200+ };
201+ return result;
202+}
203+
204+#define IS_LONG_OPT(OPT) (strcmp( *argv, (OPT) ) == 0)
205+#define IS_SHORT_OPT(OPT) (strncmp( *argv, (OPT), 2 ) == 0)
206+#define IS_OPT(LOPT,SOPT) (IS_LONG_OPT(LOPT) || IS_SHORT_OPT(SOPT))
207+
208+std::string ZorbaCMDPropertiesBase::load_argv(int argc, const char **argv) {
209+ if ( !argv )
210+ return "";
211+
212+ std::string result;
213+ for ( ++argv; *argv; ++argv ) {
214+ if ( IS_OPT( "--help", "-h" ) )
215+ return "!HELP";
216+ if ( IS_OPT( "--version", "-v" ) )
217+ return "!VER";
218+
219+ if ( IS_OPT( "--as-files", "-f" ) ) {
220+ theFparm = true;
221+ theAsFiles = true;
222+ }
223+ else if ( IS_LONG_OPT( "--base-uri" ) ) {
224+ int d = 2;
225+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
226+ if (!*argv) { result = "No value given for --base-uri option"; break; }
227+ init_val(*argv, theBaseUri, d);
228+ }
229+ else if ( IS_LONG_OPT( "--boundary-space" ) ) {
230+ int d = 2;
231+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
232+ if (!*argv) { result = "No value given for --boundary-space option"; break; }
233+ init_val(*argv, theBoundarySpace, d);
234+ }
235+ else if ( IS_LONG_OPT( "--byte-order-mark" ) )
236+ theByteOrderMark = true;
237+ else if ( IS_LONG_OPT( "--classpath" ) ) {
238+ int d = 2;
239+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
240+ if (!*argv) { result = "No value given for --classpath option"; break; }
241+ init_val(*argv, theClasspath, d);
242+ }
243+ else if ( IS_LONG_OPT( "--compile-only" ) )
244+ theCompileOnly = true;
245+ else if ( IS_LONG_OPT( "--compile-plan" ) )
246+ theSavePlan = true;
247+ else if ( IS_LONG_OPT( "--construction-mode" ) ) {
248+ int d = 2;
249+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
250+ if (!*argv) { result = "No value given for --construction-mode option"; break; }
251+ init_val(*argv, theConstructionMode, d);
252+ }
253+ else if ( IS_LONG_OPT( "--context-item" ) ) {
254+ int d = 2;
255+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
256+ if (!*argv) { result = "No value given for --context-item option"; break; }
257+ init_val(*argv, theContextItem, d);
258+ }
259+ else if ( IS_OPT( "--debug", "-d" ) )
260+ theDebug = true;
261+ else if ( IS_OPT( "--debug-host", "-h" ) ) {
262+ int d = 2;
263+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
264+ if (!*argv) { result = "No value given for --debug-host option"; break; }
265+ init_val(*argv, theDebugHost, d);
266+ }
267+ else if ( IS_OPT( "--debug-port", "-p" ) ) {
268+ int d = 2;
269+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
270+ if (!*argv) { result = "No value given for --debug-port option"; break; }
271+ init_val(*argv, theDebugPort, d);
272+ }
273+ else if ( IS_LONG_OPT( "--default-collation" ) ) {
274+ int d = 2;
275+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
276+ if (!*argv) { result = "No value given for --default-collation option"; break; }
277+ init_val(*argv, theDefaultCollation, d);
278+ }
279+ else if ( IS_LONG_OPT( "--execute-plan" ) )
280+ theLoadPlan = true;
281+ else if ( IS_OPT( "--external-variable", "-e" ) ) {
282+ int d = 2;
283+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
284+ if (!*argv) { result = "No value given for --external-variable option"; break; }
285+ init_val(*argv, theExternalVariable, d);
286+ }
287+ else if ( IS_OPT( "--indent", "-i" ) )
288+ theIndent = true;
289+ else if ( IS_OPT( "--lib-module", "-l" ) )
290+ theLibModule = true;
291+ else if ( IS_LONG_OPT( "--lib-path" ) ) {
292+ int d = 2;
293+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
294+ if (!*argv) { result = "No value given for --lib-path option"; break; }
295+ init_val(*argv, theLibPath, d);
296+ }
297+ else if ( IS_LONG_OPT( "--module-path" ) ) {
298+ int d = 2;
299+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
300+ if (!*argv) { result = "No value given for --module-path option"; break; }
301+ init_val(*argv, theModulePath, d);
302+ }
303+ else if ( IS_LONG_OPT( "--no-logo" ) )
304+ theNoLogo = true;
305+ else if ( IS_LONG_OPT( "--no-serializer" ) )
306+ theNoSerializer = true;
307+ else if ( IS_OPT( "--multiple", "-m" ) ) {
308+ int d = 2;
309+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
310+ if (!*argv) { result = "No value given for --multiple option"; break; }
311+ init_val(*argv, theMultiple, d);
312+ }
313+ else if ( IS_OPT( "--omit-xml-declaration", "-r" ) )
314+ theOmitXmlDeclaration = true;
315+ else if ( IS_LONG_OPT( "--optimization-level" ) ) {
316+ int d = 2;
317+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
318+ if (!*argv) { result = "No value given for --optimization-level option"; break; }
319+ init_val(*argv, theOptimizationLevel, d);
320+ }
321+ else if ( IS_LONG_OPT( "--option" ) ) {
322+ int d = 2;
323+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
324+ if (!*argv) { result = "No value given for --option option"; break; }
325+ init_val(*argv, theOption, d);
326+ }
327+ else if ( IS_LONG_OPT( "--ordering-mode" ) ) {
328+ int d = 2;
329+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
330+ if (!*argv) { result = "No value given for --ordering-mode option"; break; }
331+ init_val(*argv, theOrderingMode, d);
332+ }
333+#ifdef ZORBA_WITH_FILE_ACCESS
334+ else if ( IS_OPT( "--output-file", "-o" ) ) {
335+ int d = 2;
336+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
337+ if (!*argv) { result = "No value given for --output-file option"; break; }
338+ init_val(*argv, theOutputFile, d);
339+ }
340+#endif /* ZORBA_WITH_FILE_ACCESS */
341+ else if ( IS_LONG_OPT( "--parse-only" ) )
342+ theParseOnly = true;
343+ else if ( IS_OPT( "--print-errors-as-xml", "-x" ) )
344+ thePrintErrorsAsXml = true;
345+ else if ( IS_LONG_OPT( "--print-query" ) )
346+ thePrintQuery = true;
347+ else if ( IS_OPT( "--query", "-q" ) ) {
348+ int d = 2;
349+ if(theFparm == false)
350+ theAsFiles = false;
351+ if(*(argv+1) && !strncmp(*(argv+1), "-f", 2))
352+ {
353+ theQBeforeF = true; // is it "-q -f <filename>" perhaps?
354+ break; // stop functionality here
355+ }
356+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
357+ if (!*argv) { result = "No value given for --query option"; break; }
358+ init_val(*argv, theQueriesOrFiles, d);
359+ }
360+ else if ( IS_LONG_OPT( "--serialize-html" ) )
361+ theSerializeHtml = true;
362+ else if ( IS_LONG_OPT( "--serialize-text" ) )
363+ theSerializeText = true;
364+ else if ( IS_OPT( "--serialization-parameter", "-z" ) ) {
365+ int d = 2;
366+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
367+ if (!*argv) { result = "No value given for --serialization-parameter option"; break; }
368+ init_val(*argv, theSerializationParameter, d);
369+ }
370+ else if ( IS_LONG_OPT( "--stop-words" ) ) {
371+ int d = 2;
372+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
373+ if (!*argv) { result = "No value given for --stop-words option"; break; }
374+ init_val(*argv, theStopWords, d);
375+ }
376+ else if ( IS_OPT( "--timing", "-t" ) )
377+ theTiming = true;
378+ else if ( IS_LONG_OPT( "--timeout" ) ) {
379+ int d = 2;
380+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
381+ if (!*argv) { result = "No value given for --timeout option"; break; }
382+ init_val(*argv, theTimeout, d);
383+ }
384+ else if ( IS_LONG_OPT( "--trailing-nl" ) )
385+ theTrailingNl = true;
386+ else if ( IS_LONG_OPT( "--uri-path" ) ) {
387+ int d = 2;
388+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
389+ if (!*argv) { result = "No value given for --uri-path option"; break; }
390+ init_val(*argv, theUriPath, d);
391+ }
392+ else if ( IS_OPT( "--serialize-plan", "-s" ) )
393+ theSerializePlan = true;
394+ else if ( IS_LONG_OPT( "--disable-http-resolution" ) ) {
395+ init_val("{http://zorba.io/options/features}disable=http-uri-resolution",
396+ theOption, 0);
397+ }
398+ else if ( IS_LONG_OPT( "--thesaurus" ) ) {
399+ int d = 2;
400+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
401+ if (!*argv) { result = "No value given for --thesaurus option"; break; }
402+ init_val(*argv, theThesaurus, d);
403+ }
404+
405+ else if ( IS_LONG_OPT( "--" ) ) {
406+ copy_args (++argv);
407+ break;
408+ } else if ( (*argv)[0] == '-' ) {
409+ result = "unknown command line option "; result += *argv;
410+ theUnknownOption = true; break;
411+ } else {
412+ init_val(*argv, theQueriesOrFiles, 0);
413+ copy_args( argv );
414+ }
415+ } // for
416+ return result;
417+}
418+
419+char const* ZorbaCMDPropertiesBase::get_help_msg() const {
420+ return
421+ "--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries. This option is deprecated and will be defaulted to true in the future, so any entry in the command line is going to be treated as files.\n\n"
422+ "--base-uri\nSet the base URI property of the static context.\n\n"
423+ "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
424+ "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
425+ "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
426+ "--compile-only\nOnly compile (don't execute)\n\n"
427+ "--compile-plan,\nDo not execute the query; just compile it and save the execution plan in the file specified with the -o option.\n\n"
428+ "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
429+ "--context-item\nSet the context item to the XML document in a given file.\n\n"
430+ "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
431+ "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
432+ "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
433+ "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
434+ "--disable-http-resolution\nDo not use HTTP to resolve URIs\n\n"
435+ "--execute-plan\nDo not compile the query; instead load the execution plan from the file specified by the -f -q options (or by any file specified without any other argument), and execute the loaded plan.\n\n"
436+ "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
437+ "--indent, -i\nIndent output.\n\n"
438+ "--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
439+ "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
440+ "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
441+ "--multiple, -m\nExecute the given queries multiple times.\n\n"
442+ "--no-logo\nPrint no logo when starting.\n\n"
443+ "--no-serializer\nDo not serialize (discard) result.\n\n"
444+ "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
445+ "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
446+ "--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://zorba.io/}option=value\n\n"
447+ "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
448+ "--output-file, -o\nWrite the result to the given file.\n\n"
449+ "--parse-only\nStop after parsing the query.\n\n"
450+ "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
451+ "--print-query\nPrint the queries.\n\n"
452+ "--query, -q\nQuery test or file URI (file://...)\n\n"
453+ "--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
454+ "--serialize-html\nSerialize the result as HTML.\n\n"
455+ "--serialize-plan, -s\nSerialize and then load the query execution plan.\n\n"
456+ "--serialize-text\nSerialize the result as Text.\n\n"
457+ "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
458+ "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
459+ "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
460+ "--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"
461+ "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
462+ "--uri-path\nURI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n"
463+ ;
464+}
465+
466+ZorbaCMDPropertiesBase const* ZorbaCMDPropertiesBase::instance() {
467+ static ZorbaCMDPropertiesBase result;
468+ return &result;
469+}
470+
471+///////////////////////////////////////////////////////////////////////////////
472+
473+} // namespace zorbacmd
474+/* vim:set et sw=2 ts=2: */
475
476=== modified file 'bin/zorbacmdproperties_base.h'
477--- bin/zorbacmdproperties_base.h 2013-08-09 09:04:36 +0000
478+++ bin/zorbacmdproperties_base.h 2014-01-31 23:33:08 +0000
479@@ -13,7 +13,6 @@
480 * See the License for the specific language governing permissions and
481 * limitations under the License.
482 */
483-/* vim:set et sw=2 ts=2: */
484
485 #include <string>
486 #include <sstream>
487@@ -23,34 +22,12 @@
488
489 #ifndef ZORBACMD_ZORBACMDPROPERTIESBASE
490 #define ZORBACMD_ZORBACMDPROPERTIESBASE
491-namespace zorbacmd
492-{
493-
494-class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase
495-{
496+namespace zorbacmd {
497+
498+///////////////////////////////////////////////////////////////////////////////
499+
500+class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase {
501 protected:
502- const char** get_all_options () const
503- {
504- static const char* result [] = {
505- "--timing",
506-#ifdef ZORBA_WITH_FILE_ACCESS
507- "--output-file",
508-#endif /* ZORBA_WITH_FILE_ACCESS */
509- "--serialization-parameter",
510- "--serialize-html", "--serialize-text", "--indent", "--print-query",
511- "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration",
512- "--base-uri", "--boundary-space", "--default-collation",
513- "--construction-mode", "--ordering-mode", "--multiple", "--query",
514- "--as-files", "--external-variable", "--context-item",
515- "--optimization-level", "--lib-module", "--parse-only", "--compile-only",
516- "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo",
517- "--timeout", "--uri-path", "--lib-path", "--module-path", "--classpath",
518- "--option", "--trailing-nl", "--stop-words", "--thesaurus",
519- "--compile-plan", "--execute-plan", "--serialize-plan",
520- "--disable-http-resolution", NULL };
521- return result;
522- }
523-
524 bool theTiming;
525 #ifdef ZORBA_WITH_FILE_ACCESS
526 std::string theOutputFile;
527@@ -98,444 +75,68 @@
528 bool theQBeforeF;
529 bool theUnknownOption;
530
531- void initialize ()
532- {
533- theTiming = false;
534- theSerializeHtml = false;
535- theSerializeText = false;
536- theIndent = false;
537- thePrintQuery = false;
538- thePrintErrorsAsXml = false;
539- theByteOrderMark = false;
540- theOmitXmlDeclaration = false;
541- theMultiple = 1;
542- theAsFiles = true;
543- theOptimizationLevel = "O1";
544- theLibModule = false;
545- theParseOnly = false;
546- theCompileOnly = false;
547- theNoSerializer = false;
548- theDebug = false;
549- theDebugHost = "127.0.0.1";
550- theDebugPort = 28028;
551- theNoLogo = false;
552- theTimeout = -1;
553- theTrailingNl = false;
554- theSerializePlan = false;
555- theSavePlan = false;
556- theLoadPlan = false;
557- theFparm = false;
558- theQBeforeF = false;
559- theUnknownOption = false;
560- }
561+ // inherited
562+ const char** get_all_options() const;
563
564 public:
565- const bool &timing () const { return theTiming; }
566+ ZorbaCMDPropertiesBase();
567+
568+ bool timing () const { return theTiming; }
569 #ifdef ZORBA_WITH_FILE_ACCESS
570 const std::string &outputFile () const { return theOutputFile; }
571 #endif /* ZORBA_WITH_FILE_ACCESS */
572 const std::vector<std::string> &serializationParameter () const { return theSerializationParameter; }
573- const bool &serializeHtml () const { return theSerializeHtml; }
574- const bool &serializeText () const { return theSerializeText; }
575- const bool &indent () const { return theIndent; }
576- const bool &printQuery () const { return thePrintQuery; }
577- const bool &printErrorsAsXml () const { return thePrintErrorsAsXml; }
578- const bool &byteOrderMark () const { return theByteOrderMark; }
579- const bool &omitXmlDeclaration () const { return theOmitXmlDeclaration; }
580+ bool serializeHtml () const { return theSerializeHtml; }
581+ bool serializeText () const { return theSerializeText; }
582+ bool indent () const { return theIndent; }
583+ bool printQuery () const { return thePrintQuery; }
584+ bool printErrorsAsXml () const { return thePrintErrorsAsXml; }
585+ bool byteOrderMark () const { return theByteOrderMark; }
586+ bool omitXmlDeclaration () const { return theOmitXmlDeclaration; }
587 const std::string &baseUri () const { return theBaseUri; }
588 const std::string &boundarySpace () const { return theBoundarySpace; }
589 const std::string &defaultCollation () const { return theDefaultCollation; }
590 const std::string &constructionMode () const { return theConstructionMode; }
591 const std::string &orderingMode () const { return theOrderingMode; }
592- const unsigned long &multiple () const { return theMultiple; }
593+ unsigned long multiple () const { return theMultiple; }
594 const std::vector<std::string> &query () const { return theQueriesOrFiles; }
595- const bool &asFiles () const { return theAsFiles; }
596+ bool asFiles () const { return theAsFiles; }
597 const std::vector<std::string> &externalVariable () const { return theExternalVariable; }
598 const std::string &contextItem () const { return theContextItem; }
599 const std::string &optimizationLevel () const { return theOptimizationLevel; }
600- const bool &libModule () const { return theLibModule; }
601- const bool &parseOnly () const { return theParseOnly; }
602- const bool &compileOnly () const { return theCompileOnly; }
603- const bool &noSerializer () const { return theNoSerializer; }
604- const bool &debug () const { return theDebug; }
605+ bool libModule () const { return theLibModule; }
606+ bool parseOnly () const { return theParseOnly; }
607+ bool compileOnly () const { return theCompileOnly; }
608+ bool noSerializer () const { return theNoSerializer; }
609+ bool debug () const { return theDebug; }
610 const std::string &debugHost () const { return theDebugHost; }
611- const unsigned int &debugPort () const { return theDebugPort; }
612- const bool &noLogo () const { return theNoLogo; }
613+ unsigned debugPort () const { return theDebugPort; }
614+ bool noLogo () const { return theNoLogo; }
615 const long &timeout () const { return theTimeout; }
616 const std::string &uriPath () const { return theUriPath; }
617 const std::string &libPath () const { return theLibPath; }
618 const std::string &modulePath () const { return theModulePath; }
619 const std::string &classpath () const { return theClasspath; }
620 const std::vector<std::string> &option () const { return theOption; }
621- const bool &trailingNl () const { return theTrailingNl; }
622+ bool trailingNl () const { return theTrailingNl; }
623 const std::vector<std::string> &stopWords () const { return theStopWords; }
624 const std::vector<std::string> &thesaurus () const { return theThesaurus; }
625- const bool& serializePlan () const { return theSerializePlan; }
626- const bool& loadPlan () const { return theLoadPlan; }
627- const bool& savePlan () const { return theSavePlan; }
628- const bool& qBeforeF () const { return theQBeforeF; }
629- const bool& unknownOption() const { return theUnknownOption; }
630-
631- std::string load_argv (int argc, const char **argv)
632- {
633- if (argv == NULL) return "";
634-
635- std::string result;
636- for (++argv; *argv != NULL; ++argv)
637- {
638- if (strcmp (*argv, "--help") == 0 || strcmp (*argv, "-h") == 0)
639- return "!HELP";
640-
641- else if (strcmp (*argv, "--version") == 0)
642- return "!VER";
643-
644- else if (strcmp (*argv, "--timing") == 0 || strncmp (*argv, "-t", 2) == 0)
645- {
646- theTiming = true;
647- }
648-#ifdef ZORBA_WITH_FILE_ACCESS
649- else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0)
650- {
651- int d = 2;
652- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
653- if (*argv == NULL) { result = "No value given for --output-file option"; break; }
654- init_val (*argv, theOutputFile, d);
655- }
656-#endif /* ZORBA_WITH_FILE_ACCESS */
657- else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0)
658- {
659- int d = 2;
660- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
661- if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; }
662-
663- init_val (*argv, theSerializationParameter, d);
664- }
665- else if (strcmp (*argv, "--serialize-html") == 0)
666- {
667- theSerializeHtml = true;
668- }
669- else if (strcmp (*argv, "--serialize-text") == 0)
670- {
671- theSerializeText = true;
672- }
673- else if (strcmp (*argv, "--indent") == 0 || strncmp (*argv, "-i", 2) == 0)
674- {
675- theIndent = true;
676- }
677- else if (strcmp (*argv, "--print-query") == 0)
678- {
679- thePrintQuery = true;
680- }
681- else if (strcmp (*argv, "--print-errors-as-xml") == 0 || strncmp (*argv, "-x", 2) == 0)
682- {
683- thePrintErrorsAsXml = true;
684- }
685- else if (strcmp (*argv, "--byte-order-mark") == 0)
686- {
687- theByteOrderMark = true;
688- }
689- else if (strcmp (*argv, "--omit-xml-declaration") == 0 || strncmp (*argv, "-r", 2) == 0)
690- {
691- theOmitXmlDeclaration = true;
692- }
693- else if (strcmp (*argv, "--base-uri") == 0)
694- {
695- int d = 2;
696- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
697- if (*argv == NULL) { result = "No value given for --base-uri option"; break; }
698- init_val (*argv, theBaseUri, d);
699- }
700- else if (strcmp (*argv, "--boundary-space") == 0)
701- {
702- int d = 2;
703- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
704- if (*argv == NULL) { result = "No value given for --boundary-space option"; break; }
705- init_val (*argv, theBoundarySpace, d);
706- }
707- else if (strcmp (*argv, "--default-collation") == 0)
708- {
709- int d = 2;
710- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
711- if (*argv == NULL) { result = "No value given for --default-collation option"; break; }
712- init_val (*argv, theDefaultCollation, d);
713- }
714- else if (strcmp (*argv, "--construction-mode") == 0)
715- {
716- int d = 2;
717- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
718- if (*argv == NULL) { result = "No value given for --construction-mode option"; break; }
719-
720- init_val (*argv, theConstructionMode, d);
721- }
722- else if (strcmp (*argv, "--ordering-mode") == 0) {
723- int d = 2;
724- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
725- if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; }
726-
727- init_val (*argv, theOrderingMode, d);
728- }
729- else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0)
730- {
731- int d = 2;
732- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
733- if (*argv == NULL)
734- {
735- result = "No value given for --multiple option"; break;
736- }
737- init_val(*argv, theMultiple, d);
738- }
739- else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0)
740- {
741- int d = 2;
742- if(theFparm == false)
743- theAsFiles = false;
744- if(*(argv+1) && !strncmp(*(argv+1), "-f", 2))
745- {
746- theQBeforeF = true; // is it "-q -f <filename>" perhaps?
747- break; // stop functionality here
748- }
749- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
750- if (*argv == NULL)
751- {
752- result = "No value given for --query option"; break;
753- }
754- init_val (*argv, theQueriesOrFiles, d);
755- }
756- else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0)
757- {
758- theFparm = true;
759- theAsFiles = true;
760- }
761- else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0)
762- {
763- int d = 2;
764- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
765- if (*argv == NULL)
766- {
767- result = "No value given for --external-variable option"; break;
768- }
769- init_val(*argv, theExternalVariable, d);
770- }
771- else if (strcmp (*argv, "--context-item") == 0)
772- {
773- int d = 2;
774- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
775- if (*argv == NULL)
776- {
777- result = "No value given for --context-item option"; break;
778- }
779- init_val (*argv, theContextItem, d);
780- }
781- else if (strcmp (*argv, "--optimization-level") == 0)
782- {
783- int d = 2;
784- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
785- if (*argv == NULL)
786- {
787- result = "No value given for --optimization-level option"; break;
788- }
789- init_val(*argv, theOptimizationLevel, d);
790- }
791- else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0)
792- {
793- theLibModule = true;
794- }
795- else if (strcmp (*argv, "--parse-only") == 0)
796- {
797- theParseOnly = true;
798- }
799- else if (strcmp (*argv, "--compile-only") == 0)
800- {
801- theCompileOnly = true;
802- }
803- else if (strcmp (*argv, "--no-serializer") == 0)
804- {
805- theNoSerializer = true;
806- }
807- else if (strcmp (*argv, "--debug") == 0 || strncmp (*argv, "-d", 2) == 0)
808- {
809- theDebug = true;
810- }
811- else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0)
812- {
813- int d = 2;
814- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
815- if (*argv == NULL)
816- {
817- result = "No value given for --debug-host option"; break;
818- }
819- init_val (*argv, theDebugHost, d);
820- }
821- else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0)
822- {
823- int d = 2;
824- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
825- if (*argv == NULL)
826- {
827- result = "No value given for --debug-port option"; break;
828- }
829- init_val (*argv, theDebugPort, d);
830- }
831- else if (strcmp (*argv, "--no-logo") == 0)
832- {
833- theNoLogo = true;
834- }
835- else if (strcmp (*argv, "--timeout") == 0)
836- {
837- int d = 2;
838- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
839- if (*argv == NULL) { result = "No value given for --timeout option"; break; }
840- init_val (*argv, theTimeout, d);
841- }
842- else if (strcmp (*argv, "--uri-path") == 0)
843- {
844- int d = 2;
845- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
846- if (*argv == NULL) { result = "No value given for --uri-path option"; break; }
847- init_val (*argv, theUriPath, d);
848- }
849- else if (strcmp (*argv, "--lib-path") == 0)
850- {
851- int d = 2;
852- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
853- if (*argv == NULL) { result = "No value given for --lib-path option"; break; }
854- init_val (*argv, theLibPath, d);
855- }
856- else if (strcmp (*argv, "--module-path") == 0)
857- {
858- int d = 2;
859- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
860- if (*argv == NULL) { result = "No value given for --module-path option"; break; }
861- init_val (*argv, theModulePath, d);
862- }
863- else if (strcmp (*argv, "--classpath") == 0)
864- {
865- int d = 2;
866- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
867- if (*argv == NULL) { result = "No value given for --classpath option"; break; }
868-
869- init_val (*argv, theClasspath, d);
870- }
871- else if (strcmp (*argv, "--option") == 0)
872- {
873- int d = 2;
874- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
875- if (*argv == NULL) { result = "No value given for --option option"; break; }
876- init_val (*argv, theOption, d);
877- }
878- else if (strcmp (*argv, "--trailing-nl") == 0)
879- {
880- theTrailingNl = true;
881- }
882- else if (strcmp (*argv, "--stop-words") == 0)
883- {
884- int d = 2;
885- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
886- if (*argv == NULL) { result = "No value given for --stop-words option"; break; }
887- init_val (*argv, theStopWords, d);
888- }
889- else if (strcmp (*argv, "--thesaurus") == 0)
890- {
891- int d = 2;
892- if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
893- if (*argv == NULL) { result = "No value given for --thesaurus option"; break; }
894- init_val (*argv, theThesaurus, d);
895- }
896- else if (strcmp (*argv, "--serialize-plan") == 0 || strncmp (*argv, "-s", 2) == 0)
897- {
898- theSerializePlan = true;
899- }
900- else if (strcmp (*argv, "--compile-plan") == 0)
901- {
902- theSavePlan = true;
903- }
904- else if (strcmp (*argv, "--execute-plan") == 0)
905- {
906- theLoadPlan = true;
907- }
908- else if (strcmp (*argv, "--disable-http-resolution") == 0)
909- {
910- init_val ("{http://zorba.io/options/features}disable=http-uri-resolution",
911- theOption, 0);
912- }
913- else if (strcmp (*argv, "--") == 0)
914- {
915- copy_args (++argv);
916- break;
917- }
918- else if ((*argv) [0] == '-')
919- {
920- result = "unknown command line option "; result += *argv;
921- theUnknownOption = true; break;
922- }
923- else
924- {
925- init_val(*argv, theQueriesOrFiles, 0);
926- copy_args (argv);
927- }
928- }
929-
930- return result;
931- }
932-
933- const char *get_help_msg () const
934- {
935- return
936- "--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"
937- "--output-file, -o\nWrite the result to the given file.\n\n"
938- "--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
939- "--serialize-html\nSerialize the result as HTML.\n\n"
940- "--serialize-text\nSerialize the result as Text.\n\n"
941- "--indent, -i\nIndent output.\n\n"
942- "--print-query\nPrint the queries.\n\n"
943- "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
944- "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
945- "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
946- "--base-uri\nSet the base URI property of the static context.\n\n"
947- "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
948- "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
949- "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
950- "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
951- "--multiple, -m\nExecute the given queries multiple times.\n\n"
952- "--query, -q\nQuery test or file URI (file://...)\n\n"
953- "--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries. This option is deprecated and will be defaulted to true in the future, so any entry in the command line is going to be treated as files.\n\n"
954- "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
955- "--context-item\nSet the context item to the XML document in a given file.\n\n"
956- "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
957- "--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
958- "--parse-only\nStop after parsing the query.\n\n"
959- "--compile-only\nOnly compile (don't execute)\n\n"
960- "--no-serializer\nDo not serialize (discard) result.\n\n"
961- "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
962- "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
963- "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
964- "--no-logo\nPrint no logo when starting.\n\n"
965- "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
966- "--uri-path\nURI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n"
967- "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
968- "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
969- "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
970- "--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://zorba.io/}option=value\n\n"
971- "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
972- "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
973- "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
974- "--serialize-plan, -s\nSerialize and then load the query execution plan.\n\n"
975- "--compile-plan,\nDo not execute the query; just compile it and save the execution plan in the file specified with the -o option.\n\n"
976- "--execute-plan\nDo not compile the query; instead load the execution plan from the file specified by the -f -q options (or by any file specified without any other argument), and execute the loaded plan.\n\n"
977- "--disable-http-resolution\nDo not use HTTP to resolve URIs\n\n"
978- ;
979- }
980-
981- static const ZorbaCMDPropertiesBase *instance ()
982- {
983- static ZorbaCMDPropertiesBase result;
984- return &result;
985- }
986-
987- ZorbaCMDPropertiesBase () { initialize (); }
988-
989+ bool serializePlan () const { return theSerializePlan; }
990+ bool loadPlan () const { return theLoadPlan; }
991+ bool savePlan () const { return theSavePlan; }
992+ bool qBeforeF () const { return theQBeforeF; }
993+ bool unknownOption() const { return theUnknownOption; }
994+
995+ std::string load_argv(int argc, const char **argv);
996+
997+ const char* get_help_msg() const;
998+
999+ static const ZorbaCMDPropertiesBase* instance();
1000 };
1001
1002-} // namespaces
1003-
1004-#endif // ZORBACMD_ZORBACMDPROPERTIESBASE
1005+///////////////////////////////////////////////////////////////////////////////
1006+
1007+} // namespace zorbacmd
1008+
1009+#endif /* ZORBACMD_ZORBACMDPROPERTIESBASE */
1010+/* vim:set et sw=2 ts=2: */

Subscribers

People subscribed via source and target branches