Qore Qorize Module Reference  0.1.2
Qorize.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file Qorize.qm Qorize module definition
3 
4 /* Qorize.qm Copyright 2013 - 2017 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 qore version
26 
27 // assume local var scope, do not use "$" for vars, members, and method calls
28 
29 
30 /* Version History
31  * 2016-28-11 v 0.1.2 Tomas Mandys
32  + open parenthesis at the same line
33  + more compact output
34  + indentation size
35  + cutly or round parenthesis for hash
36  + qorize() formatting improvement when a list contains list or hash
37  + object support
38  + qorize_named() supports hash, object, list, any
39 
40  * 2016-06-29 v 0.1.1: Petr Vanek <petr@yarpen.cz>
41  + qorize_val() implemented
42  + new style is used as default for arguments
43  + qorizeNamed() is deprecated now. Use qorize_named() instead
44 
45  * 2015-11-11 v 0.1.0: Petr Vanek <petr@yarpen.cz>
46  + improvements and bugfixes
47 
48  * 2015-11-11 v 0.0.10: David Nichols <david@qore.org>
49  + converted to new-style
50 
51  * 2013-08-15 v 0.0.9: Petr Vanek <petr@yarpen.cz>
52  + initial version
53 */
54 
55 
86 namespace Qorize {
88 
89 
93 
95 
110  string qorize(bool val, string name = "var", bool newstyle = True);
111 
112 
114 
129  string qorize(string val, string name = "var", bool newstyle = True);
130 
131 
133 
148  string qorize(int val, string name = "var", bool newstyle = True);
149 
150 
152 
167  string qorize(float val, string name = "var", bool newstyle = True);
168 
169 
171 
186  string qorize(number val, string name = "var", bool newstyle = True);
187 
188 
190 
212  string qorize(date val, string name = "var", bool newstyle = True);
213 
214 
216 
234  string qorize(binary val, string name = "var", bool newstyle = True);
235 
236 
238 
260  string qorize(list val, string name = "var", bool newstyle = True, int indentation = 2, bool curlyHash = True);
261 
262 
264 
306  string qorize(hash val, string name = "var", bool newstyle = True, int indentation = 2, bool curlyHash = True);
307 
308 
310 
326  string qorize(object val, string name = "var", bool newstyle = True, int indentation = 2, bool curlyHash = True);
327 
328 
329 
331 
369  string qorize_named(hash val, string name = "var", bool newstyle = True);
370 
371 
373 
410  string qorize_named(object val, string name = "var", bool newstyle = True);
411 
412 
414 
431  string qorize_named(list val, string name = "var", bool newstyle = True);
432 
433 
435  deprecated string qorizeNamed(hash val, string name = "var", bool newstyle = True);
436 
438  string qorize_named(auto val, string name = "var", bool newstyle = True);
439 
440 
441 
443 
458  string qorize(auto val, string name = "var", bool newstyle = True);
459 
460 
462 
470  string qorize_val(list val, int indentation = 2, bool curlyHash = True);
471 
472 
474 
482  string qorize_val(hash val, int indentation = 2, bool curlyHash = True);
483 
484 
486 
492  string qorize_val(auto val);
493 
495 
496 
497 // a helper class holding all logic
498 class QorizeHelper {
499 
500 public:
501 
502  private :
503  auto container;
504  string code;
505  int level = 0;
506  bool newstyle;
507  int indentation;
508  bool curlyHash;
509  hash objectSignatures;
510 
511 public:
512 
513  static string checkVariableName(string name, auto val, bool newstyle);
514 
515  static string escape(bool val);
516 
517  static string escape(string val);
518 
519  static string escape(int val);
520 
521  static string escape(float val);
522 
523  static string escape(number val);
524 
525  static string escape(date val);
526 
527  static string escape(binary val);
528 
529  static string escape(object val);
530 
531  static string escape(auto val);
532 
533  constructor(auto n_container, bool n_newstyle = True, int n_indentation = 2, bool n_curlyHash = True);
534 
535 
536  string list();
537 
538 
539  string hash();
540 
541 
542  *string named(string name);
543 
544 
545 
546 private:
547  processNamed(hash val, string prefixName);
548 public:
549 
550 
551 
552 private:
553  processNamed(object val, string prefixName);
554 public:
555 
556 
557 
558 private:
559  processNamed(list val, string prefixName);
560 public:
561 
562 
563 
564 private:
565  processNamed(auto val, string prefixName);
566 public:
567 
568 
569 
570 private:
571  process(list val);
572 public:
573 
574 
575 
576 private:
577  process(hash val);
578 public:
579 
580 
581 
582 private:
583  process(auto val);
584 public:
585 
586 
587 }; // class QorizeHelper
588 
589 }; // namespace Qorize
date date(date dt)
string qorize_named(hash val, string name="var", bool newstyle=True)
create code from the hash value - with one value per one line
const True
number number(softnumber n)
binary binary()
list list(...)
deprecated string qorizeNamed(hash val, string name="var", bool newstyle=True)
Deprecated, use qorize_named() instead.
string qorize(bool val, string name="var", bool newstyle=True)
create code from the boolean value
public Qorize namespace contains all relevant stuff for this module
Definition: Qorize.qm.dox.h:87
hash hash(object obj)
string qorize_val(list val, int indentation=2, bool curlyHash=True)
create code without any variable assignment (lvalue)