Initial Release
Interpretor of $list for python named DollarList.
This interpretor was made because :
This is a work in progress. For now, it only support embedded $list in $list, int and string.
WIP float,decimal,double
This module is available on Pypi :
pip3 install iris-dollar-list
It is compatible with embedded python and native api.
example :
set ^list = $lb("test",$lb(4))
example of use with native api :
import iris from iris_dollar_list import DollarList
conn = iris.connect("localhost", 57161,"IRISAPP", "SuperUser", "SYS")
iris_obj = iris.createIRIS(conn)
gl = iris_obj.get("^list")
my_list = DollarList.from_bytes(gl.encode('ascii'))
print(my_list.to_list())
['test', [4]]
example of use with embedded python :
import iris from iris_dollar_list import DollarList
gl = iris.gref("^list")
my_list = DollarList.from_bytes(gl[None].encode('ascii'))
print(my_list.to_list())
['test', [4]]
Append an element to the list.
This element can be :
my_list = DollarList()
my_list.append("one")
my_list.append(1)
my_list.append(DollarList.from_list(["list",2]))
my_list.append(DollarItem(dollar_type=1, value="item",
raw_value=b"item",
buffer=b'\x06\x01item'))
print(DollarList.from_bytes(my_list))
# $lb("one",1,$lb("list",2),"item")
Create a DollarList from bytes.
my_list = DollarList.from_bytes(b'\x05\x01one')
print(my_list)
# $lb("one")
Create a DollarList from a list.
print(DollarList.from_list(["list",2]))
# $lb("list",2)
Create a DollarList from a string.
str_list = DollarList.from_string('$lb("test",$lb(4))')
print(str_list)
# $lb("test",$lb(4))
print(str_list.to_list())
# ['test', [4]]
Convert the DollarList to bytes.
my_list = DollarList.from_list(["list",2])
print(my_list.to_bytes())
# b'\x06\x01list\x03\x04\x02'
Convert the DollarList to a list.
my_list = DollarList.from_bytes(b'\x05\x01one')
print(my_list.to_list())
# ['one']
$list is binary format for storing data. It is used in Iris Engine. It is a format that is easy to read and write. It is also easy to parse.
The neat thing about $list is that it is not limited for storage. It also used for communication on the SuperServer port of IRIS.
$list is a binary format that store list of values. Each value is stored in a block. Each block is composed of a header and a body. The header is composed of a size and a type. The body is composed of the value.
The header is composed of a size and a type.
The header can have a size of 2, 4 or 8 bytes.
Three types of header are possible :
There is 3 types of size :
The type is a byte that represent the type of the value.
The type is stored just after the size.
List of types:
The body is composed of the value.
To parse the body, you need to know the type of the value.
Decode the value as ascii.
If decoding fails, consider the value as a sub-list.
If decoding the sub-list fails, consider the value as a binary.
Decode the value as unicode.
Parse the value as an integer in little endian and unsigned.
Parse the value as an integer in little endian and signed.
????
????
????
????