Qore Qorize Module Reference  0.0.10
Qorize Functions

Functions

string Qorize::qorize (bool val, string name="var", bool newstyle=False)
 create code from the boolean value More...
 
string Qorize::qorize (string val, string name="var", bool newstyle=False)
 create code from the string value More...
 
string Qorize::qorize (int val, string name="var", bool newstyle=False)
 create code from the integer value More...
 
string Qorize::qorize (float val, string name="var", bool newstyle=False)
 create code from the float value More...
 
string Qorize::qorize (number val, string name="var", bool newstyle=False)
 create code from the number value More...
 
string Qorize::qorize (date val, string name="var", bool newstyle=False)
 create code from the date value More...
 
string Qorize::qorize (binary val, string name="var", bool newstyle=False)
 create code from the binary value More...
 
string Qorize::qorize (list val, string name="var", bool newstyle=False)
 create code from the list value More...
 
string Qorize::qorize (hash val, string name="var", bool newstyle=False)
 create code from the hash value More...
 
string Qorize::qorize (any val, string name="var", bool newstyle=False)
 create code from the any value - fallback for NULL and NOTHINGS More...
 
string Qorize::qorizeNamed (hash val, string name="var", bool newstyle=False)
 create code from the hash value - with one value per one line More...
 

Detailed Description

Function Documentation

string Qorize::qorize ( bool  val,
string  name = "var",
bool  newstyle = False 
)

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
1 string s = qorize(True);
2 # "bool var = True;"
3 string s = qorize(True, "foo", True);
4 # "bool foo = True;"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( string  val,
string  name = "var",
bool  newstyle = False 
)

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
1 string s = qorize("lorem ipsum");
2 # "string var = \"lorem ipsum\";"
3 string s = qorize("lorem ipsum", "foo", True);
4 # "string foo = \"lorem ipsum\";"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( int  val,
string  name = "var",
bool  newstyle = False 
)

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
1 string s = qorize(1);
2 # "int var = 1;"
3 string s = qorize(1, "foo", True);
4 # "int foo = 1;"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( float  val,
string  name = "var",
bool  newstyle = False 
)

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
1 string s = qorize(1.2);
2 # "float var = 1;"
3 string s = qorize(1.2, "foo", True);
4 # "float foo = 1;"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( number  val,
string  name = "var",
bool  newstyle = False 
)

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
1 string s = qorize(123n);
2 # "number var = 123n;"
3 string s = qorize(123n, "foo", True);
4 # "number foo = 123n;"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( date  val,
string  name = "var",
bool  newstyle = False 
)

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
1 string s = qorize(now());
2 # "date var = 2013-08-16T14:37:05.000;"
3 string s = qorize(now(), "foo", True);
4 # "date foo = 2013-08-16T14:37:05.000;"

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

1 string s = qorize(3h);
2 # date d = PT3H;
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( binary  val,
string  name = "var",
bool  newstyle = False 
)

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.

1 binary bin = ....; # binary value from file for example
2 string s = qorize(bin);
3 # "binary var = parseHexString(\"666f6f\");"
4 string s = qorize(bin, "foo", True);
5 # "binary foo = parseHexString(\"666f6f\");"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( list  val,
string  name = "var",
bool  newstyle = False 
)

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
1 list l = (True, False, now(), 12, 12.1, ( 'a', 'b'), );
2 string s = qorize(l);
3 # "list var =
4 # (True,False,2013-08-16T15:06:29.000,12,12.1,
5 # ("a","b",),);"
6 string s = qorize(l, "foo", True);
7 # "list foo =
8 # (True,False,2013-08-16T15:06:29.000,12,12.1,
9 # ("a","b",),);"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( hash  val,
string  name = "var",
bool  newstyle = False 
)

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
Return values
stringa generated code
1 hash h = (
2  "foo" : "bar",
3  "key1" : now(),
4  "key2" : 12,
5  "key3" : ( 1, 2, 3),
6  "key4" : ( "subkey1" : 1, "subkey2" : 2, ),
7  );
8 string s = qorize(h);
9 # "hash var =
10 # (
11 # "foo" : "bar",
12 # "key1" : 2013-08-16T15:10:30.000,
13 # "key2" : 12,
14 # "key3" :
15 # (1,2,3,),
16 # "key4" :
17 # (
18 # "subkey1" : 1,
19 # "subkey2" : 2,
20 # ),
21 # );"
22 string s = qorize(h, "foo", True);
23 # "hash foo =
24 # (
25 # "foo" : "bar",
26 # "key1" : 2013-08-16T15:10:30.000,
27 # "key2" : 12,
28 # "key3" :
29 # (1,2,3,),
30 # "key4" :
31 # (
32 # "subkey1" : 1,
33 # "subkey2" : 2,
34 # ),
35 # );"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorize ( any  val,
string  name = "var",
bool  newstyle = False 
)

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
1 any s = qorize(NULL);
2 # "any var = NULL;"
3 string s = qorize(NULL, "foo", True);
4 # "any foo = NULL;"
Exceptions
QORIZE-ERRORin case of error in code generator
string Qorize::qorizeNamed ( hash  val,
string  name = "var",
bool  newstyle = False 
)

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
1 hash h = (
2  "foo" : "bar",
3  "key1" : now(),
4  "key2" : 12,
5  "key3" : ( 1, 2, 3),
6  "key4" : ( "subkey1" : 1, "subkey2" : 2, ),
7  );
8 string s = qorizeNamed(h);
9 # "hash name;
10 # var."foo" = "bar";
11 # var."key1" = 2013-08-16T15:14:40.000;
12 # var."key2" = 12;
13 # var."key3" = (1,2,3,);
14 # var."key4"."subkey1" = 1;
15 # var."key4"."subkey2" = 2;
16 string s = qorizeNamed(h, "foo", True);
17 # "hash foo;
18 # foo."foo" = "bar";
19 # foo."key1" = 2013-08-16T15:14:40.000;
20 # foo."key2" = 12;
21 # foo."key3" = (1,2,3,);
22 # foo."key4"."subkey1" = 1;
23 # foo."key4"."subkey2" = 2;"
Exceptions
QORIZE-ERRORin case of error in code generator