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

Proposed by Paul J. Lucas
Status: Merged
Approved by: Paul J. Lucas
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 Approve
Paul J. Lucas Approve
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.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
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

Revision history for this message
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
11424. By Paul J. Lucas

Forgot a file.

Revision history for this message
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

Revision history for this message
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}

Revision history for this message
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.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
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

Revision history for this message
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
=== modified file 'bin/CMakeLists.txt'
--- bin/CMakeLists.txt 2013-08-09 09:04:36 +0000
+++ bin/CMakeLists.txt 2014-01-31 23:33:08 +0000
@@ -45,6 +45,7 @@
4545
46SET(SRCS46SET(SRCS
47 zorbacmd.cpp47 zorbacmd.cpp
48 zorbacmdproperties_base.cpp
48 zorbacmdproperties.cpp49 zorbacmdproperties.cpp
49 util.cpp50 util.cpp
50 path_util.cpp51 path_util.cpp
5152
=== modified file 'bin/zorbacmdproperties.h'
--- bin/zorbacmdproperties.h 2013-06-16 00:37:21 +0000
+++ bin/zorbacmdproperties.h 2014-01-31 23:33:08 +0000
@@ -122,4 +122,5 @@
122122
123 bool loadProperties(int argc, char* argv[]);123 bool loadProperties(int argc, char* argv[]);
124};124};
125#endif125#endif /* ZORBA_CMD_PROPERTIES_H */
126/* vim:set et sw=2 ts=2: */
126127
=== modified file 'bin/zorbacmdproperties.txt'
--- bin/zorbacmdproperties.txt 2013-08-09 09:04:36 +0000
+++ bin/zorbacmdproperties.txt 2014-01-31 23:33:08 +0000
@@ -1,40 +1,40 @@
1("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.")1("as-files,f", "Treat all -q arguments as file paths instead of URIs or inline queries.")
2("output-file,o", po::value<std::string>(), "Write the result to the given file.")
3("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).")
4("serialize-html", "Serialize the result as HTML.")
5("serialize-text", "Serialize the result as Text.")
6("indent,i", "Indent output.")
7("print-query", "Print the queries.")
8("print-errors-as-xml,x", "Print the errors as XML.")
9("byte-order-mark", "Set the byte-order-mark for the serializer.")
10("omit-xml-declaration,r", "Omit the XML declaration from the result.")
11("base-uri", po::value<std::string>(), "Set the base URI property of the static context.")2("base-uri", po::value<std::string>(), "Set the base URI property of the static context.")
12("boundary-space", po::value<std::string>(), "Set the boundary-space policy ('strip' or 'preserve') in the static context.")3("boundary-space", po::value<std::string>(), "Set the boundary-space policy ('strip' or 'preserve') in the static context.")
13("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.")4("byte-order-mark", "Set the byte-order-mark for the serializer.")
5("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
6("compile-only", "Only compile (don't execute)")
7("compile-plan,c", "Output the query plan as binary.")
14("construction-mode", po::value<std::string>(), "Set the construction mode ('strip' or 'preserve') in the static context.")8("construction-mode", po::value<std::string>(), "Set the construction mode ('strip' or 'preserve') in the static context.")
15("ordering-mode", po::value<std::string>(), "Set the ordering mode ('ordered' or 'unordered') in the static context.")
16("multiple,m", po::value<unsigned long>()->default_value (1), "Execute the given queries multiple times.")
17("query,q", po::value<std::vector<std::string> >(&theQueriesOrFiles), "Query test or file URI (file://...)")
18("as-files,f", "Treat all -q arguments as file paths instead of URIs or inline queries.")
19("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)")
20("context-item", po::value<std::string> (), "Set the context item to the XML document in a given file.")9("context-item", po::value<std::string> (), "Set the context item to the XML document in a given file.")
21("optimization-level", po::value<std::string>()->default_value("O1"), "Optimization level for the query compiler (O0, O1 or O2 - default: O1)")
22("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.")
23("parse-only", "Stop after parsing the query.")
24("compile-only", "Only compile (don't execute)")
25("no-serializer", "Do not serialize (discard) result.")
26("debug,d", "Launch the Zorba debugger server and connect to a DBGP-enabled debugger client.")10("debug,d", "Launch the Zorba debugger server and connect to a DBGP-enabled debugger client.")
27("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")11("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")
28("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")12("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")
29("no-logo", "Print no logo when starting.")13("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.")
30("timeout", po::value<long>()->default_value(-1), "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.")14("execute-plan", "Take a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.")
31("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.")15("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)")
16("indent,i", "Indent output.")
17("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.")
32("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")18("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")
33("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")19("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")
34("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")20("multiple,m", po::value<unsigned long>()->default_value (1), "Execute the given queries multiple times.")
21("no-logo", "Print no logo when starting.")
22("no-serializer", "Do not serialize (discard) result.")
23("omit-xml-declaration,r", "Omit the XML declaration from the result.")
24("optimization-level", po::value<std::string>()->default_value("O1"), "Optimization level for the query compiler (O0, O1 or O2 - default: O1)")
35("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").25("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").
36("trailing-nl", "Output a trailing newline after the result of the query.")26("ordering-mode", po::value<std::string>(), "Set the ordering mode ('ordered' or 'unordered') in the static context.")
27("output-file,o", po::value<std::string>(), "Write the result to the given file.")
28("parse-only", "Stop after parsing the query.")
29("print-errors-as-xml,x", "Print the errors as XML.")
30("print-query", "Print the queries.")
31("query,q", po::value<std::vector<std::string> >(&theQueriesOrFiles), "Query test or file URI (file://...)")
32("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).")
33("serialize-html", "Serialize the result as HTML.")
34("serialize-text", "Serialize the result as Text.")
37("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")35("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")
38("thesaurus", po::value<std::vector<std::string> >(), "Mapping specifying a thesaurus URI to another.")36("thesaurus", po::value<std::vector<std::string> >(), "Mapping specifying a thesaurus URI to another.")
39("compile-plan,c", "Output the query plan as binary.")37("timeout", po::value<long>()->default_value(-1), "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.")
40("execute-plan", "Take a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.")38("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.")
39("trailing-nl", "Output a trailing newline after the result of the query.")
40("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.")
4141
=== added file 'bin/zorbacmdproperties_base.cpp'
--- bin/zorbacmdproperties_base.cpp 1970-01-01 00:00:00 +0000
+++ bin/zorbacmdproperties_base.cpp 2014-01-31 23:33:08 +0000
@@ -0,0 +1,374 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "zorbacmdproperties_base.h"
18
19namespace zorbacmd {
20
21///////////////////////////////////////////////////////////////////////////////
22
23ZorbaCMDPropertiesBase::ZorbaCMDPropertiesBase() {
24 theAsFiles = true;
25 theByteOrderMark = false;
26 theCompileOnly = false;
27 theDebug = false;
28 theDebugHost = "127.0.0.1";
29 theDebugPort = 28028;
30 theFparm = false;
31 theIndent = false;
32 theLibModule = false;
33 theLoadPlan = false;
34 theMultiple = 1;
35 theNoLogo = false;
36 theNoSerializer = false;
37 theOmitXmlDeclaration = false;
38 theOptimizationLevel = "O1";
39 theParseOnly = false;
40 thePrintErrorsAsXml = false;
41 thePrintQuery = false;
42 theQBeforeF = false;
43 theSavePlan = false;
44 theSerializeHtml = false;
45 theSerializePlan = false;
46 theSerializeText = false;
47 theTimeout = -1;
48 theTiming = false;
49 theTrailingNl = false;
50 theUnknownOption = false;
51}
52
53char const** ZorbaCMDPropertiesBase::get_all_options() const {
54 static const char* result [] = {
55 "--as-files",
56 "--base-uri",
57 "--boundary-space",
58 "--byte-order-mark",
59 "--classpath",
60 "--compile-only",
61 "--compile-plan",
62 "--construction-mode",
63 "--context-item",
64 "--debug",
65 "--debug-host",
66 "--debug-port",
67 "--default-collation",
68 "--disable-http-resolution",
69 "--execute-plan",
70 "--external-variable",
71 "--indent",
72 "--lib-module",
73 "--lib-path",
74 "--module-path",
75 "--multiple",
76 "--no-logo",
77 "--no-serializer",
78 "--omit-xml-declaration",
79 "--optimization-level",
80 "--option",
81 "--ordering-mode",
82#ifdef ZORBA_WITH_FILE_ACCESS
83 "--output-file",
84#endif /* ZORBA_WITH_FILE_ACCESS */
85 "--parse-only",
86 "--print-errors-as-xml",
87 "--print-query",
88 "--query",
89 "--serialization-parameter",
90 "--serialize-html",
91 "--serialize-plan",
92 "--serialize-text",
93 "--stop-words",
94 "--thesaurus",
95 "--timeout",
96 "--timing",
97 "--trailing-nl",
98 "--uri-path",
99 NULL
100 };
101 return result;
102}
103
104#define IS_LONG_OPT(OPT) (strcmp( *argv, (OPT) ) == 0)
105#define IS_SHORT_OPT(OPT) (strncmp( *argv, (OPT), 2 ) == 0)
106#define IS_OPT(LOPT,SOPT) (IS_LONG_OPT(LOPT) || IS_SHORT_OPT(SOPT))
107
108std::string ZorbaCMDPropertiesBase::load_argv(int argc, const char **argv) {
109 if ( !argv )
110 return "";
111
112 std::string result;
113 for ( ++argv; *argv; ++argv ) {
114 if ( IS_OPT( "--help", "-h" ) )
115 return "!HELP";
116 if ( IS_OPT( "--version", "-v" ) )
117 return "!VER";
118
119 if ( IS_OPT( "--as-files", "-f" ) ) {
120 theFparm = true;
121 theAsFiles = true;
122 }
123 else if ( IS_LONG_OPT( "--base-uri" ) ) {
124 int d = 2;
125 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
126 if (!*argv) { result = "No value given for --base-uri option"; break; }
127 init_val(*argv, theBaseUri, d);
128 }
129 else if ( IS_LONG_OPT( "--boundary-space" ) ) {
130 int d = 2;
131 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
132 if (!*argv) { result = "No value given for --boundary-space option"; break; }
133 init_val(*argv, theBoundarySpace, d);
134 }
135 else if ( IS_LONG_OPT( "--byte-order-mark" ) )
136 theByteOrderMark = true;
137 else if ( IS_LONG_OPT( "--classpath" ) ) {
138 int d = 2;
139 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
140 if (!*argv) { result = "No value given for --classpath option"; break; }
141 init_val(*argv, theClasspath, d);
142 }
143 else if ( IS_LONG_OPT( "--compile-only" ) )
144 theCompileOnly = true;
145 else if ( IS_LONG_OPT( "--compile-plan" ) )
146 theSavePlan = true;
147 else if ( IS_LONG_OPT( "--construction-mode" ) ) {
148 int d = 2;
149 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
150 if (!*argv) { result = "No value given for --construction-mode option"; break; }
151 init_val(*argv, theConstructionMode, d);
152 }
153 else if ( IS_LONG_OPT( "--context-item" ) ) {
154 int d = 2;
155 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
156 if (!*argv) { result = "No value given for --context-item option"; break; }
157 init_val(*argv, theContextItem, d);
158 }
159 else if ( IS_OPT( "--debug", "-d" ) )
160 theDebug = true;
161 else if ( IS_OPT( "--debug-host", "-h" ) ) {
162 int d = 2;
163 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
164 if (!*argv) { result = "No value given for --debug-host option"; break; }
165 init_val(*argv, theDebugHost, d);
166 }
167 else if ( IS_OPT( "--debug-port", "-p" ) ) {
168 int d = 2;
169 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
170 if (!*argv) { result = "No value given for --debug-port option"; break; }
171 init_val(*argv, theDebugPort, d);
172 }
173 else if ( IS_LONG_OPT( "--default-collation" ) ) {
174 int d = 2;
175 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
176 if (!*argv) { result = "No value given for --default-collation option"; break; }
177 init_val(*argv, theDefaultCollation, d);
178 }
179 else if ( IS_LONG_OPT( "--execute-plan" ) )
180 theLoadPlan = true;
181 else if ( IS_OPT( "--external-variable", "-e" ) ) {
182 int d = 2;
183 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
184 if (!*argv) { result = "No value given for --external-variable option"; break; }
185 init_val(*argv, theExternalVariable, d);
186 }
187 else if ( IS_OPT( "--indent", "-i" ) )
188 theIndent = true;
189 else if ( IS_OPT( "--lib-module", "-l" ) )
190 theLibModule = true;
191 else if ( IS_LONG_OPT( "--lib-path" ) ) {
192 int d = 2;
193 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
194 if (!*argv) { result = "No value given for --lib-path option"; break; }
195 init_val(*argv, theLibPath, d);
196 }
197 else if ( IS_LONG_OPT( "--module-path" ) ) {
198 int d = 2;
199 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
200 if (!*argv) { result = "No value given for --module-path option"; break; }
201 init_val(*argv, theModulePath, d);
202 }
203 else if ( IS_LONG_OPT( "--no-logo" ) )
204 theNoLogo = true;
205 else if ( IS_LONG_OPT( "--no-serializer" ) )
206 theNoSerializer = true;
207 else if ( IS_OPT( "--multiple", "-m" ) ) {
208 int d = 2;
209 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
210 if (!*argv) { result = "No value given for --multiple option"; break; }
211 init_val(*argv, theMultiple, d);
212 }
213 else if ( IS_OPT( "--omit-xml-declaration", "-r" ) )
214 theOmitXmlDeclaration = true;
215 else if ( IS_LONG_OPT( "--optimization-level" ) ) {
216 int d = 2;
217 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
218 if (!*argv) { result = "No value given for --optimization-level option"; break; }
219 init_val(*argv, theOptimizationLevel, d);
220 }
221 else if ( IS_LONG_OPT( "--option" ) ) {
222 int d = 2;
223 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
224 if (!*argv) { result = "No value given for --option option"; break; }
225 init_val(*argv, theOption, d);
226 }
227 else if ( IS_LONG_OPT( "--ordering-mode" ) ) {
228 int d = 2;
229 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
230 if (!*argv) { result = "No value given for --ordering-mode option"; break; }
231 init_val(*argv, theOrderingMode, d);
232 }
233#ifdef ZORBA_WITH_FILE_ACCESS
234 else if ( IS_OPT( "--output-file", "-o" ) ) {
235 int d = 2;
236 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
237 if (!*argv) { result = "No value given for --output-file option"; break; }
238 init_val(*argv, theOutputFile, d);
239 }
240#endif /* ZORBA_WITH_FILE_ACCESS */
241 else if ( IS_LONG_OPT( "--parse-only" ) )
242 theParseOnly = true;
243 else if ( IS_OPT( "--print-errors-as-xml", "-x" ) )
244 thePrintErrorsAsXml = true;
245 else if ( IS_LONG_OPT( "--print-query" ) )
246 thePrintQuery = true;
247 else if ( IS_OPT( "--query", "-q" ) ) {
248 int d = 2;
249 if(theFparm == false)
250 theAsFiles = false;
251 if(*(argv+1) && !strncmp(*(argv+1), "-f", 2))
252 {
253 theQBeforeF = true; // is it "-q -f <filename>" perhaps?
254 break; // stop functionality here
255 }
256 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
257 if (!*argv) { result = "No value given for --query option"; break; }
258 init_val(*argv, theQueriesOrFiles, d);
259 }
260 else if ( IS_LONG_OPT( "--serialize-html" ) )
261 theSerializeHtml = true;
262 else if ( IS_LONG_OPT( "--serialize-text" ) )
263 theSerializeText = true;
264 else if ( IS_OPT( "--serialization-parameter", "-z" ) ) {
265 int d = 2;
266 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
267 if (!*argv) { result = "No value given for --serialization-parameter option"; break; }
268 init_val(*argv, theSerializationParameter, d);
269 }
270 else if ( IS_LONG_OPT( "--stop-words" ) ) {
271 int d = 2;
272 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
273 if (!*argv) { result = "No value given for --stop-words option"; break; }
274 init_val(*argv, theStopWords, d);
275 }
276 else if ( IS_OPT( "--timing", "-t" ) )
277 theTiming = true;
278 else if ( IS_LONG_OPT( "--timeout" ) ) {
279 int d = 2;
280 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
281 if (!*argv) { result = "No value given for --timeout option"; break; }
282 init_val(*argv, theTimeout, d);
283 }
284 else if ( IS_LONG_OPT( "--trailing-nl" ) )
285 theTrailingNl = true;
286 else if ( IS_LONG_OPT( "--uri-path" ) ) {
287 int d = 2;
288 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
289 if (!*argv) { result = "No value given for --uri-path option"; break; }
290 init_val(*argv, theUriPath, d);
291 }
292 else if ( IS_OPT( "--serialize-plan", "-s" ) )
293 theSerializePlan = true;
294 else if ( IS_LONG_OPT( "--disable-http-resolution" ) ) {
295 init_val("{http://zorba.io/options/features}disable=http-uri-resolution",
296 theOption, 0);
297 }
298 else if ( IS_LONG_OPT( "--thesaurus" ) ) {
299 int d = 2;
300 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
301 if (!*argv) { result = "No value given for --thesaurus option"; break; }
302 init_val(*argv, theThesaurus, d);
303 }
304
305 else if ( IS_LONG_OPT( "--" ) ) {
306 copy_args (++argv);
307 break;
308 } else if ( (*argv)[0] == '-' ) {
309 result = "unknown command line option "; result += *argv;
310 theUnknownOption = true; break;
311 } else {
312 init_val(*argv, theQueriesOrFiles, 0);
313 copy_args( argv );
314 }
315 } // for
316 return result;
317}
318
319char const* ZorbaCMDPropertiesBase::get_help_msg() const {
320 return
321 "--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"
322 "--base-uri\nSet the base URI property of the static context.\n\n"
323 "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
324 "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
325 "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
326 "--compile-only\nOnly compile (don't execute)\n\n"
327 "--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"
328 "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
329 "--context-item\nSet the context item to the XML document in a given file.\n\n"
330 "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
331 "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
332 "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
333 "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
334 "--disable-http-resolution\nDo not use HTTP to resolve URIs\n\n"
335 "--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"
336 "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
337 "--indent, -i\nIndent output.\n\n"
338 "--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"
339 "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
340 "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
341 "--multiple, -m\nExecute the given queries multiple times.\n\n"
342 "--no-logo\nPrint no logo when starting.\n\n"
343 "--no-serializer\nDo not serialize (discard) result.\n\n"
344 "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
345 "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
346 "--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"
347 "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
348 "--output-file, -o\nWrite the result to the given file.\n\n"
349 "--parse-only\nStop after parsing the query.\n\n"
350 "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
351 "--print-query\nPrint the queries.\n\n"
352 "--query, -q\nQuery test or file URI (file://...)\n\n"
353 "--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"
354 "--serialize-html\nSerialize the result as HTML.\n\n"
355 "--serialize-plan, -s\nSerialize and then load the query execution plan.\n\n"
356 "--serialize-text\nSerialize the result as Text.\n\n"
357 "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
358 "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
359 "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
360 "--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"
361 "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
362 "--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"
363 ;
364}
365
366ZorbaCMDPropertiesBase const* ZorbaCMDPropertiesBase::instance() {
367 static ZorbaCMDPropertiesBase result;
368 return &result;
369}
370
371///////////////////////////////////////////////////////////////////////////////
372
373} // namespace zorbacmd
374/* vim:set et sw=2 ts=2: */
0375
=== modified file 'bin/zorbacmdproperties_base.h'
--- bin/zorbacmdproperties_base.h 2013-08-09 09:04:36 +0000
+++ bin/zorbacmdproperties_base.h 2014-01-31 23:33:08 +0000
@@ -13,7 +13,6 @@
13 * See the License for the specific language governing permissions and13 * See the License for the specific language governing permissions and
14 * limitations under the License.14 * limitations under the License.
15 */15 */
16/* vim:set et sw=2 ts=2: */
1716
18#include <string>17#include <string>
19#include <sstream>18#include <sstream>
@@ -23,34 +22,12 @@
2322
24#ifndef ZORBACMD_ZORBACMDPROPERTIESBASE23#ifndef ZORBACMD_ZORBACMDPROPERTIESBASE
25#define ZORBACMD_ZORBACMDPROPERTIESBASE24#define ZORBACMD_ZORBACMDPROPERTIESBASE
26namespace zorbacmd25namespace zorbacmd {
27{26
2827///////////////////////////////////////////////////////////////////////////////
29class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase28
30{29class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase {
31protected:30protected:
32 const char** get_all_options () const
33 {
34 static const char* result [] = {
35 "--timing",
36#ifdef ZORBA_WITH_FILE_ACCESS
37 "--output-file",
38#endif /* ZORBA_WITH_FILE_ACCESS */
39 "--serialization-parameter",
40 "--serialize-html", "--serialize-text", "--indent", "--print-query",
41 "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration",
42 "--base-uri", "--boundary-space", "--default-collation",
43 "--construction-mode", "--ordering-mode", "--multiple", "--query",
44 "--as-files", "--external-variable", "--context-item",
45 "--optimization-level", "--lib-module", "--parse-only", "--compile-only",
46 "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo",
47 "--timeout", "--uri-path", "--lib-path", "--module-path", "--classpath",
48 "--option", "--trailing-nl", "--stop-words", "--thesaurus",
49 "--compile-plan", "--execute-plan", "--serialize-plan",
50 "--disable-http-resolution", NULL };
51 return result;
52 }
53
54 bool theTiming;31 bool theTiming;
55#ifdef ZORBA_WITH_FILE_ACCESS32#ifdef ZORBA_WITH_FILE_ACCESS
56 std::string theOutputFile;33 std::string theOutputFile;
@@ -98,444 +75,68 @@
98 bool theQBeforeF;75 bool theQBeforeF;
99 bool theUnknownOption;76 bool theUnknownOption;
10077
101 void initialize () 78 // inherited
102 {79 const char** get_all_options() const;
103 theTiming = false;
104 theSerializeHtml = false;
105 theSerializeText = false;
106 theIndent = false;
107 thePrintQuery = false;
108 thePrintErrorsAsXml = false;
109 theByteOrderMark = false;
110 theOmitXmlDeclaration = false;
111 theMultiple = 1;
112 theAsFiles = true;
113 theOptimizationLevel = "O1";
114 theLibModule = false;
115 theParseOnly = false;
116 theCompileOnly = false;
117 theNoSerializer = false;
118 theDebug = false;
119 theDebugHost = "127.0.0.1";
120 theDebugPort = 28028;
121 theNoLogo = false;
122 theTimeout = -1;
123 theTrailingNl = false;
124 theSerializePlan = false;
125 theSavePlan = false;
126 theLoadPlan = false;
127 theFparm = false;
128 theQBeforeF = false;
129 theUnknownOption = false;
130 }
13180
132public:81public:
133 const bool &timing () const { return theTiming; }82 ZorbaCMDPropertiesBase();
83
84 bool timing () const { return theTiming; }
134#ifdef ZORBA_WITH_FILE_ACCESS85#ifdef ZORBA_WITH_FILE_ACCESS
135 const std::string &outputFile () const { return theOutputFile; }86 const std::string &outputFile () const { return theOutputFile; }
136#endif /* ZORBA_WITH_FILE_ACCESS */87#endif /* ZORBA_WITH_FILE_ACCESS */
137 const std::vector<std::string> &serializationParameter () const { return theSerializationParameter; }88 const std::vector<std::string> &serializationParameter () const { return theSerializationParameter; }
138 const bool &serializeHtml () const { return theSerializeHtml; }89 bool serializeHtml () const { return theSerializeHtml; }
139 const bool &serializeText () const { return theSerializeText; }90 bool serializeText () const { return theSerializeText; }
140 const bool &indent () const { return theIndent; }91 bool indent () const { return theIndent; }
141 const bool &printQuery () const { return thePrintQuery; }92 bool printQuery () const { return thePrintQuery; }
142 const bool &printErrorsAsXml () const { return thePrintErrorsAsXml; }93 bool printErrorsAsXml () const { return thePrintErrorsAsXml; }
143 const bool &byteOrderMark () const { return theByteOrderMark; }94 bool byteOrderMark () const { return theByteOrderMark; }
144 const bool &omitXmlDeclaration () const { return theOmitXmlDeclaration; }95 bool omitXmlDeclaration () const { return theOmitXmlDeclaration; }
145 const std::string &baseUri () const { return theBaseUri; }96 const std::string &baseUri () const { return theBaseUri; }
146 const std::string &boundarySpace () const { return theBoundarySpace; }97 const std::string &boundarySpace () const { return theBoundarySpace; }
147 const std::string &defaultCollation () const { return theDefaultCollation; }98 const std::string &defaultCollation () const { return theDefaultCollation; }
148 const std::string &constructionMode () const { return theConstructionMode; }99 const std::string &constructionMode () const { return theConstructionMode; }
149 const std::string &orderingMode () const { return theOrderingMode; }100 const std::string &orderingMode () const { return theOrderingMode; }
150 const unsigned long &multiple () const { return theMultiple; }101 unsigned long multiple () const { return theMultiple; }
151 const std::vector<std::string> &query () const { return theQueriesOrFiles; }102 const std::vector<std::string> &query () const { return theQueriesOrFiles; }
152 const bool &asFiles () const { return theAsFiles; }103 bool asFiles () const { return theAsFiles; }
153 const std::vector<std::string> &externalVariable () const { return theExternalVariable; }104 const std::vector<std::string> &externalVariable () const { return theExternalVariable; }
154 const std::string &contextItem () const { return theContextItem; }105 const std::string &contextItem () const { return theContextItem; }
155 const std::string &optimizationLevel () const { return theOptimizationLevel; }106 const std::string &optimizationLevel () const { return theOptimizationLevel; }
156 const bool &libModule () const { return theLibModule; }107 bool libModule () const { return theLibModule; }
157 const bool &parseOnly () const { return theParseOnly; }108 bool parseOnly () const { return theParseOnly; }
158 const bool &compileOnly () const { return theCompileOnly; }109 bool compileOnly () const { return theCompileOnly; }
159 const bool &noSerializer () const { return theNoSerializer; }110 bool noSerializer () const { return theNoSerializer; }
160 const bool &debug () const { return theDebug; }111 bool debug () const { return theDebug; }
161 const std::string &debugHost () const { return theDebugHost; }112 const std::string &debugHost () const { return theDebugHost; }
162 const unsigned int &debugPort () const { return theDebugPort; }113 unsigned debugPort () const { return theDebugPort; }
163 const bool &noLogo () const { return theNoLogo; }114 bool noLogo () const { return theNoLogo; }
164 const long &timeout () const { return theTimeout; }115 const long &timeout () const { return theTimeout; }
165 const std::string &uriPath () const { return theUriPath; }116 const std::string &uriPath () const { return theUriPath; }
166 const std::string &libPath () const { return theLibPath; }117 const std::string &libPath () const { return theLibPath; }
167 const std::string &modulePath () const { return theModulePath; }118 const std::string &modulePath () const { return theModulePath; }
168 const std::string &classpath () const { return theClasspath; }119 const std::string &classpath () const { return theClasspath; }
169 const std::vector<std::string> &option () const { return theOption; }120 const std::vector<std::string> &option () const { return theOption; }
170 const bool &trailingNl () const { return theTrailingNl; }121 bool trailingNl () const { return theTrailingNl; }
171 const std::vector<std::string> &stopWords () const { return theStopWords; }122 const std::vector<std::string> &stopWords () const { return theStopWords; }
172 const std::vector<std::string> &thesaurus () const { return theThesaurus; }123 const std::vector<std::string> &thesaurus () const { return theThesaurus; }
173 const bool& serializePlan () const { return theSerializePlan; }124 bool serializePlan () const { return theSerializePlan; }
174 const bool& loadPlan () const { return theLoadPlan; }125 bool loadPlan () const { return theLoadPlan; }
175 const bool& savePlan () const { return theSavePlan; }126 bool savePlan () const { return theSavePlan; }
176 const bool& qBeforeF () const { return theQBeforeF; }127 bool qBeforeF () const { return theQBeforeF; }
177 const bool& unknownOption() const { return theUnknownOption; }128 bool unknownOption() const { return theUnknownOption; }
178129
179 std::string load_argv (int argc, const char **argv) 130 std::string load_argv(int argc, const char **argv);
180 {131
181 if (argv == NULL) return "";132 const char* get_help_msg() const;
182133
183 std::string result;134 static const ZorbaCMDPropertiesBase* instance();
184 for (++argv; *argv != NULL; ++argv)
185 {
186 if (strcmp (*argv, "--help") == 0 || strcmp (*argv, "-h") == 0)
187 return "!HELP";
188
189 else if (strcmp (*argv, "--version") == 0)
190 return "!VER";
191
192 else if (strcmp (*argv, "--timing") == 0 || strncmp (*argv, "-t", 2) == 0)
193 {
194 theTiming = true;
195 }
196#ifdef ZORBA_WITH_FILE_ACCESS
197 else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0)
198 {
199 int d = 2;
200 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
201 if (*argv == NULL) { result = "No value given for --output-file option"; break; }
202 init_val (*argv, theOutputFile, d);
203 }
204#endif /* ZORBA_WITH_FILE_ACCESS */
205 else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0)
206 {
207 int d = 2;
208 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
209 if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; }
210
211 init_val (*argv, theSerializationParameter, d);
212 }
213 else if (strcmp (*argv, "--serialize-html") == 0)
214 {
215 theSerializeHtml = true;
216 }
217 else if (strcmp (*argv, "--serialize-text") == 0)
218 {
219 theSerializeText = true;
220 }
221 else if (strcmp (*argv, "--indent") == 0 || strncmp (*argv, "-i", 2) == 0)
222 {
223 theIndent = true;
224 }
225 else if (strcmp (*argv, "--print-query") == 0)
226 {
227 thePrintQuery = true;
228 }
229 else if (strcmp (*argv, "--print-errors-as-xml") == 0 || strncmp (*argv, "-x", 2) == 0)
230 {
231 thePrintErrorsAsXml = true;
232 }
233 else if (strcmp (*argv, "--byte-order-mark") == 0)
234 {
235 theByteOrderMark = true;
236 }
237 else if (strcmp (*argv, "--omit-xml-declaration") == 0 || strncmp (*argv, "-r", 2) == 0)
238 {
239 theOmitXmlDeclaration = true;
240 }
241 else if (strcmp (*argv, "--base-uri") == 0)
242 {
243 int d = 2;
244 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
245 if (*argv == NULL) { result = "No value given for --base-uri option"; break; }
246 init_val (*argv, theBaseUri, d);
247 }
248 else if (strcmp (*argv, "--boundary-space") == 0)
249 {
250 int d = 2;
251 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
252 if (*argv == NULL) { result = "No value given for --boundary-space option"; break; }
253 init_val (*argv, theBoundarySpace, d);
254 }
255 else if (strcmp (*argv, "--default-collation") == 0)
256 {
257 int d = 2;
258 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
259 if (*argv == NULL) { result = "No value given for --default-collation option"; break; }
260 init_val (*argv, theDefaultCollation, d);
261 }
262 else if (strcmp (*argv, "--construction-mode") == 0)
263 {
264 int d = 2;
265 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
266 if (*argv == NULL) { result = "No value given for --construction-mode option"; break; }
267
268 init_val (*argv, theConstructionMode, d);
269 }
270 else if (strcmp (*argv, "--ordering-mode") == 0) {
271 int d = 2;
272 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
273 if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; }
274
275 init_val (*argv, theOrderingMode, d);
276 }
277 else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0)
278 {
279 int d = 2;
280 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
281 if (*argv == NULL)
282 {
283 result = "No value given for --multiple option"; break;
284 }
285 init_val(*argv, theMultiple, d);
286 }
287 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0)
288 {
289 int d = 2;
290 if(theFparm == false)
291 theAsFiles = false;
292 if(*(argv+1) && !strncmp(*(argv+1), "-f", 2))
293 {
294 theQBeforeF = true; // is it "-q -f <filename>" perhaps?
295 break; // stop functionality here
296 }
297 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
298 if (*argv == NULL)
299 {
300 result = "No value given for --query option"; break;
301 }
302 init_val (*argv, theQueriesOrFiles, d);
303 }
304 else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0)
305 {
306 theFparm = true;
307 theAsFiles = true;
308 }
309 else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0)
310 {
311 int d = 2;
312 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
313 if (*argv == NULL)
314 {
315 result = "No value given for --external-variable option"; break;
316 }
317 init_val(*argv, theExternalVariable, d);
318 }
319 else if (strcmp (*argv, "--context-item") == 0)
320 {
321 int d = 2;
322 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
323 if (*argv == NULL)
324 {
325 result = "No value given for --context-item option"; break;
326 }
327 init_val (*argv, theContextItem, d);
328 }
329 else if (strcmp (*argv, "--optimization-level") == 0)
330 {
331 int d = 2;
332 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
333 if (*argv == NULL)
334 {
335 result = "No value given for --optimization-level option"; break;
336 }
337 init_val(*argv, theOptimizationLevel, d);
338 }
339 else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0)
340 {
341 theLibModule = true;
342 }
343 else if (strcmp (*argv, "--parse-only") == 0)
344 {
345 theParseOnly = true;
346 }
347 else if (strcmp (*argv, "--compile-only") == 0)
348 {
349 theCompileOnly = true;
350 }
351 else if (strcmp (*argv, "--no-serializer") == 0)
352 {
353 theNoSerializer = true;
354 }
355 else if (strcmp (*argv, "--debug") == 0 || strncmp (*argv, "-d", 2) == 0)
356 {
357 theDebug = true;
358 }
359 else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0)
360 {
361 int d = 2;
362 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
363 if (*argv == NULL)
364 {
365 result = "No value given for --debug-host option"; break;
366 }
367 init_val (*argv, theDebugHost, d);
368 }
369 else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0)
370 {
371 int d = 2;
372 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
373 if (*argv == NULL)
374 {
375 result = "No value given for --debug-port option"; break;
376 }
377 init_val (*argv, theDebugPort, d);
378 }
379 else if (strcmp (*argv, "--no-logo") == 0)
380 {
381 theNoLogo = true;
382 }
383 else if (strcmp (*argv, "--timeout") == 0)
384 {
385 int d = 2;
386 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
387 if (*argv == NULL) { result = "No value given for --timeout option"; break; }
388 init_val (*argv, theTimeout, d);
389 }
390 else if (strcmp (*argv, "--uri-path") == 0)
391 {
392 int d = 2;
393 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
394 if (*argv == NULL) { result = "No value given for --uri-path option"; break; }
395 init_val (*argv, theUriPath, d);
396 }
397 else if (strcmp (*argv, "--lib-path") == 0)
398 {
399 int d = 2;
400 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
401 if (*argv == NULL) { result = "No value given for --lib-path option"; break; }
402 init_val (*argv, theLibPath, d);
403 }
404 else if (strcmp (*argv, "--module-path") == 0)
405 {
406 int d = 2;
407 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
408 if (*argv == NULL) { result = "No value given for --module-path option"; break; }
409 init_val (*argv, theModulePath, d);
410 }
411 else if (strcmp (*argv, "--classpath") == 0)
412 {
413 int d = 2;
414 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
415 if (*argv == NULL) { result = "No value given for --classpath option"; break; }
416
417 init_val (*argv, theClasspath, d);
418 }
419 else if (strcmp (*argv, "--option") == 0)
420 {
421 int d = 2;
422 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
423 if (*argv == NULL) { result = "No value given for --option option"; break; }
424 init_val (*argv, theOption, d);
425 }
426 else if (strcmp (*argv, "--trailing-nl") == 0)
427 {
428 theTrailingNl = true;
429 }
430 else if (strcmp (*argv, "--stop-words") == 0)
431 {
432 int d = 2;
433 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
434 if (*argv == NULL) { result = "No value given for --stop-words option"; break; }
435 init_val (*argv, theStopWords, d);
436 }
437 else if (strcmp (*argv, "--thesaurus") == 0)
438 {
439 int d = 2;
440 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
441 if (*argv == NULL) { result = "No value given for --thesaurus option"; break; }
442 init_val (*argv, theThesaurus, d);
443 }
444 else if (strcmp (*argv, "--serialize-plan") == 0 || strncmp (*argv, "-s", 2) == 0)
445 {
446 theSerializePlan = true;
447 }
448 else if (strcmp (*argv, "--compile-plan") == 0)
449 {
450 theSavePlan = true;
451 }
452 else if (strcmp (*argv, "--execute-plan") == 0)
453 {
454 theLoadPlan = true;
455 }
456 else if (strcmp (*argv, "--disable-http-resolution") == 0)
457 {
458 init_val ("{http://zorba.io/options/features}disable=http-uri-resolution",
459 theOption, 0);
460 }
461 else if (strcmp (*argv, "--") == 0)
462 {
463 copy_args (++argv);
464 break;
465 }
466 else if ((*argv) [0] == '-')
467 {
468 result = "unknown command line option "; result += *argv;
469 theUnknownOption = true; break;
470 }
471 else
472 {
473 init_val(*argv, theQueriesOrFiles, 0);
474 copy_args (argv);
475 }
476 }
477
478 return result;
479 }
480
481 const char *get_help_msg () const
482 {
483 return
484 "--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"
485 "--output-file, -o\nWrite the result to the given file.\n\n"
486 "--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"
487 "--serialize-html\nSerialize the result as HTML.\n\n"
488 "--serialize-text\nSerialize the result as Text.\n\n"
489 "--indent, -i\nIndent output.\n\n"
490 "--print-query\nPrint the queries.\n\n"
491 "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
492 "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
493 "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
494 "--base-uri\nSet the base URI property of the static context.\n\n"
495 "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
496 "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
497 "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
498 "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
499 "--multiple, -m\nExecute the given queries multiple times.\n\n"
500 "--query, -q\nQuery test or file URI (file://...)\n\n"
501 "--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"
502 "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
503 "--context-item\nSet the context item to the XML document in a given file.\n\n"
504 "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
505 "--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"
506 "--parse-only\nStop after parsing the query.\n\n"
507 "--compile-only\nOnly compile (don't execute)\n\n"
508 "--no-serializer\nDo not serialize (discard) result.\n\n"
509 "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
510 "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
511 "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
512 "--no-logo\nPrint no logo when starting.\n\n"
513 "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
514 "--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"
515 "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
516 "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
517 "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
518 "--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"
519 "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
520 "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
521 "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
522 "--serialize-plan, -s\nSerialize and then load the query execution plan.\n\n"
523 "--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"
524 "--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"
525 "--disable-http-resolution\nDo not use HTTP to resolve URIs\n\n"
526 ;
527 }
528
529 static const ZorbaCMDPropertiesBase *instance ()
530 {
531 static ZorbaCMDPropertiesBase result;
532 return &result;
533 }
534
535 ZorbaCMDPropertiesBase () { initialize (); }
536
537};135};
538136
539} // namespaces137///////////////////////////////////////////////////////////////////////////////
540138
541#endif // ZORBACMD_ZORBACMDPROPERTIESBASE139} // namespace zorbacmd
140
141#endif /* ZORBACMD_ZORBACMDPROPERTIESBASE */
142/* vim:set et sw=2 ts=2: */

Subscribers

People subscribed via source and target branches