Qore Qorize Module Reference  0.1.2
Qorize Namespace Reference

public Qorize namespace contains all relevant stuff for this module More...

Functions

string qorize (auto val, string name='var', bool newstyle=True)
 create code from the any value - fallback for NULL and NOTHINGS More...
 
string qorize (binary val, string name='var', bool newstyle=True)
 create code from the binary value More...
 
string qorize (bool val, string name='var', bool newstyle=True)
 create code from the boolean value More...
 
string qorize (date val, string name='var', bool newstyle=True)
 create code from the date value More...
 
string qorize (float val, string name='var', bool newstyle=True)
 create code from the float value More...
 
string qorize (hash val, string name='var', bool newstyle=True, int indentation=2, bool curlyHash=True)
 create code from the hash value More...
 
string qorize (int val, string name='var', bool newstyle=True)
 create code from the integer value More...
 
string qorize (list val, string name='var', bool newstyle=True, int indentation=2, bool curlyHash=True)
 create code from the list value More...
 
string qorize (number val, string name='var', bool newstyle=True)
 create code from the number value More...
 
string qorize (object val, string name='var', bool newstyle=True, int indentation=2, bool curlyHash=True)
 create code from the object value. Just initializes object with empty constructor. To initilize members use qorize_named() function More...
 
string qorize (string val, string name='var', bool newstyle=True)
 create code from the string value More...
 
string qorize_named (auto val, string name='var', bool newstyle=True)
 Process other types normal way using qorize().
 
string qorize_named (hash val, string name='var', bool newstyle=True)
 create code from the hash value - with one value per one line More...
 
string qorize_named (list val, string name='var', bool newstyle=True)
 create code from the list value. More...
 
string qorize_named (object val, string name='var', bool newstyle=True)
 create code from the object value, constructor with empty parameters is called and members are created with one member per line. It may not generate valid code as because of private members and overloaded constructor. Circular references are handled to avoid endless loop. More...
 
string qorize_val (auto val)
 create code without any variable assignment (lvalue) More...
 
string qorize_val (hash val, int indentation=2, bool curlyHash=True)
 create code without any variable assignment (lvalue) More...
 
string qorize_val (list val, int indentation=2, bool curlyHash=True)
 create code without any variable assignment (lvalue) More...
 
deprecated string qorizeNamed (hash val, string name='var', bool newstyle=True)
 Deprecated, use qorize_named() instead.
 

Detailed Description

public Qorize namespace contains all relevant stuff for this module

Function Documentation

◆ qorize() [1/11]

string Qorize::qorize ( auto  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the any value - fallback for NULL and NOTHINGS

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
auto s = qorize(NULL);
# "auto var = NULL;"
string s = qorize(NULL, "foo", True);
# "auto foo = NULL;"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [2/11]

string Qorize::qorize ( binary  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the binary value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code

Binary values are encoded in hexadecimal strings.

binary bin = ....; # binary value from file for example
string s = qorize(bin);
# "binary var = parseHexString(\"666f6f\");"
string s = qorize(bin, "foo", True);
# "binary foo = parseHexString(\"666f6f\");"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [3/11]

string Qorize::qorize ( bool  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the boolean value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
string s = qorize(True);
# "bool var = True;"
string s = qorize(True, "foo", True);
# "bool foo = True;"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [4/11]

string Qorize::qorize ( date  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the date value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
string s = qorize(now());
# "date var = 2013-08-16T14:37:05.000;"
string s = qorize(now(), "foo", True);
# "date foo = 2013-08-16T14:37:05.000;"
date now()

Relative date values (1D, etc.) are converted to Short Relative Time Format

string s = qorize(3h);
# date d = PT3H;
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [5/11]

string Qorize::qorize ( float  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the float value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
string s = qorize(1.2);
# "float var = 1;"
string s = qorize(1.2, "foo", True);
# "float foo = 1;"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [6/11]

string Qorize::qorize ( hash  val,
string  name = 'var',
bool  newstyle = True,
int  indentation = 2,
bool  curlyHash = True 
)

create code from the hash value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
indentationnumber of characters to indent inner hashes
curlyHashuse new style curly parentesis to surround hashes or old style round ones
Return values
stringa generated code
hash h = (
"foo" : "bar",
"key1" : now(),
"key2" : 12,
"key3" : ( 1, 2, 3 ),
"key4" : ( "subkey1" : 1, "subkey2" : 2, ),
);
string s = qorize(h);
# "hash var = (
# "foo" : "bar",
# "key1" : 2013-08-16T15:10:30.000,
# "key2" : 12,
# "key3" : (1,2,3,),
# "key4" : (
# "subkey1" : 1,
# "subkey2" : 2,
# ),
# );"
string s = qorize(h, "foo", True);
# "hash foo = (
# "foo" : "bar",
# "key1" : 2013-08-16T15:10:30.000,
# "key2" : 12,
# "key3" : (1,2,3,),
# "key4" : (
# "subkey1" : 1,
# "subkey2" : 2,
# ),
# );"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [7/11]

string Qorize::qorize ( int  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the integer value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
string s = qorize(1);
# "int var = 1;"
string s = qorize(1, "foo", True);
# "int foo = 1;"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [8/11]

string Qorize::qorize ( list  val,
string  name = 'var',
bool  newstyle = True,
int  indentation = 2,
bool  curlyHash = True 
)

create code from the list value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
indentationnumber of characters to indent inner hashes
curlyHashuse new style curly parentesis to surround hashes or old style round ones
Return values
stringa generated code
list l = (True, False, now(), 12, 12.1, ( 'a', 'b'), );
string s = qorize(l);
# "list var =
# (True,False,2013-08-16T15:06:29.000,12,12.1,
# ("a","b",),);"
string s = qorize(l, "foo", True);
# "list foo =
# (True,False,2013-08-16T15:06:29.000,12,12.1,
# ("a","b",),);"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [9/11]

string Qorize::qorize ( number  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the number value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
string s = qorize(123n);
# "number var = 123n;"
string s = qorize(123n, "foo", True);
# "number foo = 123n;"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [10/11]

string Qorize::qorize ( object  val,
string  name = 'var',
bool  newstyle = True,
int  indentation = 2,
bool  curlyHash = True 
)

create code from the object value. Just initializes object with empty constructor. To initilize members use qorize_named() function

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
indentationnumber of characters to indent inner hashes
curlyHashuse new style curly parentesis to surround hashes or old style round ones
Return values
stringa generated code
MyClass o();
string s = qorize(o);
# "MyClass var = new MyClass();"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize() [11/11]

string Qorize::qorize ( string  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the string value

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
string s = qorize("lorem ipsum");
# "string var = \"lorem ipsum\";"
string s = qorize("lorem ipsum", "foo", True);
# "string foo = \"lorem ipsum\";"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize_named() [1/3]

string Qorize::qorize_named ( hash  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the hash value - with one value per one line

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
hash h = (
"foo" : "bar",
"key1" : now(),
"key2" : 12,
"key3" : ( 1, 2, 3 ),
"key4" : ( "subkey1" : 1, "subkey2" : 2, ),
);
string s = qorize_named(h);
# "hash name;
# var."foo" = "bar";
# var."key1" = 2013-08-16T15:14:40.000;
# var."key2" = 12;
# var."key3"[0] = 1;
# var."key3"[1] = 2;
# var."key3"[2] = 3;
# var."key4"."subkey1" = 1;
# var."key4"."subkey2" = 2;
string s = qorize_named(h, "foo", True);
# "hash foo;
# foo."foo" = "bar";
# foo."key1" = 2013-08-16T15:14:40.000;
# foo."key2" = 12;
# foo."key3"[0] = 1;
# foo."key3"[1] = 2;
# foo."key3"[2] = 3;
# foo."key4"."subkey1" = 1;
# foo."key4"."subkey2" = 2;"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize_named() [2/3]

string Qorize::qorize_named ( list  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the list value.

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
list l = (1,2,3);
string s = qorize_named(l);
# "list var;
# var[0] = 1;
# var[1] = 2;
# var[2] = 3;
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize_named() [3/3]

string Qorize::qorize_named ( object  val,
string  name = 'var',
bool  newstyle = True 
)

create code from the object value, constructor with empty parameters is called and members are created with one member per line. It may not generate valid code as because of private members and overloaded constructor. Circular references are handled to avoid endless loop.

Parameters
valan input value
namean optional name of the resulting variable
newstylean optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise
Return values
stringa generated code
class MyClass {
private {
int m1;
int m2;
}
public {
int m3;
string s1;
list l;
auto a;
}
public constructor(int n_m1, int n_m2, int n_m3) {m1=n_m1; m2=n_m2; m3=n_m3;}
}
MyClass o(1, 2, 3);
o.s1 = "xyz";
o.a = o;
string s = qorize_named(o);
# "MyClass var;
# var = new MyClass();
# var."m3" = 3;
# var."s1" = "xyz";
# var."l" = NOTHING;
# var."a" = var;"
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize_val() [1/3]

string Qorize::qorize_val ( auto  val)

create code without any variable assignment (lvalue)

Parameters
valan input value
Return values
stringa generated code
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize_val() [2/3]

string Qorize::qorize_val ( hash  val,
int  indentation = 2,
bool  curlyHash = True 
)

create code without any variable assignment (lvalue)

Parameters
valan input value
indentationnumber of characters to indent inner hashes
curlyHashuse new style curly parentesis to surround hashes or old style round ones
Return values
stringa generated code
Exceptions
QORIZE-ERRORin case of error in code generator

◆ qorize_val() [3/3]

string Qorize::qorize_val ( list  val,
int  indentation = 2,
bool  curlyHash = True 
)

create code without any variable assignment (lvalue)

Parameters
valan input value
indentationnumber of characters to indent inner hashes
curlyHashuse new style curly parentesis to surround hashes or old style round ones
Return values
stringa generated code
Exceptions
QORIZE-ERRORin case of error in code generator