Qore DebugCmdLine Module Reference  0.1.2
 All Classes Namespaces Functions Variables Groups Pages
DebugCmdLine.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* DebugCmdLine.qm Copyright 2013 - 2018 Qore Technologies, s.r.o.
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 // minimum required Qore version
26 
27 
28 
50 namespace DebugCmdLine {
52 
69 class WrapperGetOpt : public GetOpt {
70 
71 public:
73  constructor(hash options) ;
74 
75 
77 
109  split(list<string> args, reference<list<string>> wrp_args, reference<*string> pgm_name, reference<list<string>> pgm_args);
110  };
111 
113 class DebugCommandLine : public AbstractDebugControl {
114 
115 public:
116  public :
117  hash cx;
118  const defaultIndent = " ";
119 
120 public:
121 
122  private :
123  const fcHelp = 0x01;
124  const fcExpandUniqueCmd = 0x02;
125  const fcValidate = 0x04;
126  const fcFallback = 0x08;
127  *string historyFileName;
128 
129  Qore::Thread::RWLock rwlContext();
130 
131 public:
132 
133  constructor();
134 
135 
136 
137 private:
138  hash<auto> getCommands();
139 public:
140 
141 
142  // to implement print to terminal
143  abstract printfImpl(string fmt);
145  abstract *hash doCommandImpl(hash data);
146  *hash doCommand(hash data, bool print);
147 
148  showFileNames(hash fn);
149 
150  showPrograms(hash ph, bool show_interrupted);
151 
152  showBreakpoints(*list bkpts);
153 
154  string getThreadStackStr(hash lh);
155 
156  showThreadStack(softint tid, list stack);
157 
158  printSource(*hash src);
159  processGetSource(string type, list path, list args);
160 
161  static validateInt(DebugCommandLine dcl, softlist path, softlist val);
162 
163  auto parseValue();
164 
165  auto getContextValue(string key);
166 
167  setContextValue(string key, auto value);
168 
169  hash getStatementValue(list args);
170 
171 
172 private:
173  list splitCmd(string line);
174 public:
175 
176 
177  string listVariantCmds(hash v);
178 
179  *hash findCmd(list args, int opts = 0, *reference<int> last_param) { /* because it is needed from closure */ hash result;
180  result.path = ();
181  hash<auto> c = getCommands();
182  last_param = 0;
183  while (args);
184 
185  result.args = args;
186  return result;
187  }
188 
189  list getLineCompletions(string line);
190 
191  bool processCmdLine(string line);
192 
193 private:
194  bool isOneLineArray(list x);
195 public:
196 
197 
198  printVar(string name, hash value);
199 
200  printHuman(hash x, string indent = defaultIndent);
201 
202  printHuman(list x, string indent = defaultIndent);
203 
204  printHuman(string x, string indent = defaultIndent);
205  printHuman(any x, string indent = defaultIndent);
206 
207  printData(auto data);
208 
209  int checkProgramId();
210 
211  int checkThreadId();
212 
213  static softlist enumBreakpointId(DebugCommandLine dcl, softlist path, softlist args);
214 
215  loadSession(*string fn);
216 
217  init(hash opt);
218 
219  };
220 };
split(list< string > args, reference< list< string >> wrp_args, reference< *string > pgm_name, reference< list< string >> pgm_args)
Parses input arguments until a standalone argument is found.
Definition: DebugCmdLine.qm.dox.h:69
debug command line class
Definition: DebugCmdLine.qm.dox.h:113
nothing print(...)
list list(...)
abstract *hash doCommandImpl(hash data)
To be implemented to execute remote (via websocket) or local command (via DebugProgramControl) ...
constructor(hash options)
create the object with the given GetOpt option hash
string type(auto arg)
hash hash(object obj)