All Classes Namespaces Functions Variables Groups Pages
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

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my string $s = qorize(True);
# "my bool $var = True;"
my string $s = qorize(True, "foo", True);
# "bool foo = True;"

Exceptions

  QORIZE-ERROR | in case of error in code generator

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

create code from the string value

Parameters

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my string $s = qorize("lorem ipsum");
# "my string $var = \"lorem ipsum\";"
my string $s = qorize("lorem ipsum", "foo", True);
# "string foo = \"lorem ipsum\";"

Exceptions

  QORIZE-ERROR | in case of error in code generator

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

create code from the integer value

Parameters

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my string $s = qorize(1);
# "my int $var = 1;"
my string $s = qorize(1, "foo", True);
# "int foo = 1;"

Exceptions

  QORIZE-ERROR | in case of error in code generator

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

create code from the float value

Parameters

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my string $s = qorize(1.2);
# "my float $var = 1;"
my string $s = qorize(1.2, "foo", True);
# "float foo = 1;"

Exceptions

  QORIZE-ERROR | in case of error in code generator

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

create code from the number value

Parameters

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my string $s = qorize(123n);
# "my number $var = 123n;"
my string $s = qorize(123n, "foo", True);
# "number foo = 123n;"

Exceptions

  QORIZE-ERROR | in case of error in code generator

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

create code from the date value

Parameters

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my string $s = qorize(now());
# "my date $var = 2013-08-16T14:37:05.000;"
my string $s = qorize(now(), "foo", True);
# "date foo = 2013-08-16T14:37:05.000;"

Relative date values (1D, etc.) are converted to short_reldates

my string $s = qorize(3h);
# my date $d = PT3H;

Exceptions

  QORIZE-ERROR | in case of error in code generator

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

create code from the binary value

Parameters

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

Binary values are encoded in hexadecimal strings.

my binary $bin = ....; # binary value from file for example
my string $s = qorize($bin);
# "my binary $var = parseHexString(\"666f6f\");"
my string $s = qorize($bin, "foo", True);
# "binary foo = parseHexString(\"666f6f\");"

Exceptions

  QORIZE-ERROR | in case of error in code generator

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

create code from the list value

Parameters

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my list $l = (True, False, now(), 12, 12.1, ( 'a', 'b'), );
my string $s = qorize($l);
# "my list $var =
# (True,False,2013-08-16T15:06:29.000,12,12.1,
# ("a","b",),);"
my string $s = qorize($l, "foo", True);
# "list foo =
# (True,False,2013-08-16T15:06:29.000,12,12.1,
# ("a","b",),);"

Exceptions

  QORIZE-ERROR | in case of error in code generator

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

create code from the hash value

Parameters

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my hash $h = (
"foo" : "bar",
"key1" : now(),
"key2" : 12,
"key3" : ( 1, 2, 3),
"key4" : ( "subkey1" : 1, "subkey2" : 2, ),
);
my string $s = qorize($h);
# "my hash $var =
# (
# "foo" : "bar",
# "key1" : 2013-08-16T15:10:30.000,
# "key2" : 12,
# "key3" :
# (1,2,3,),
# "key4" :
# (
# "subkey1" : 1,
# "subkey2" : 2,
# ),
# );"
my 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-ERROR | in 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

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my any $s = qorize(NULL);
# "my any $var = NULL;"
my string $s = qorize(NULL, "foo", True);
# "any foo = NULL;"

Exceptions

  QORIZE-ERROR | in 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

  val | an input value
  name | an optional name of the resulting variable
  newstyle | an optional argument. True when to use Qore::PO_NEW_STYLE syntax, False otherwise

Return values

  string | a generated code

my hash $h = (
"foo" : "bar",
"key1" : now(),
"key2" : 12,
"key3" : ( 1, 2, 3),
"key4" : ( "subkey1" : 1, "subkey2" : 2, ),
);
my string $s = qorizeNamed($h);
# "my hash $name;
# $var."foo" = "bar";
# $var."key1" = 2013-08-16T15:14:40.000;
# $var."key2" = 12;
# $var."key3" = (1,2,3,);
# $var."key4"."subkey1" = 1;
# $var."key4"."subkey2" = 2;
my string $s = qorizeNamed($h, "foo", True);
# "hash foo;
# foo."foo" = "bar";
# foo."key1" = 2013-08-16T15:14:40.000;
# foo."key2" = 12;
# foo."key3" = (1,2,3,);
# foo."key4"."subkey1" = 1;
# foo."key4"."subkey2" = 2;"

Exceptions

  QORIZE-ERROR | in case of error in code generator