llog2 - LiveLog version 2
livelog2 - data structure & presentation
Interface
livelog2 {
new
# u0, name -> lid
put
# u0, lid, path, msg, replace
# path obj:str|buf|dma
# path -1 - selected path
log
# u0, lid, path, msg
replace
# u0, lid, path, msg
get
# u0, lid, path|node, buf, mode:0 -> node
# u0, lid, path|node, buf, mode:1 -> buf:name
# u0, lid, path|node, buf, mode:2 -> buf:msg
get.node
# u0, lid, path -> node
get.name
# u0, lid, path|node, buf -> buf:name
get.msg
# u0, lid, path|node, buf -> buf:msg
get.children
# u0, lid, path|node, buf, mode -> list.buf
# mode 0 - nodes list
# mode 1 - names only
# mode 2 - full path
# mode 3 - recursive full path only
erase
# u0, lid, path|node
set.splitter
# u0, lid, (slash:0|dot:1)
# NAV
root path.root;
cursor path.cursor;
begin path.push(__);
end path.pop(__);
printv
# u0, lid, path, fmt, v
};
Attributes
set.attribute
# u0, lid, path|node, attr, mode:0, v, 0,0,0 -> 0
# u0, lid, path|node, attr, mode:1, obj, 0,0,0 -> 0
# u0, lid, path|node, attr, mode:2, key, v, 0,0 -> 0
get.attribute
# u0, lid, path|node, attr, mode:0, 0, 0,0,0,0 -> v
# u0, lid, path|node, attr, mode:1, 0, 0,0,0,0 -> obj
# u0, lid, path|node, attr, mode:2, key, 0,0,0,0 -> v
set.attribute.v
# u0, lid, path|node, attr, v -> 0
set.attribute.obj
# u0, lid, path|node, attr, obj -> 0
set.attribute.map.v
# u0, lid, path|node, attr, key, v -> 0
get.attribute.v
# u0, lid, path|node, attr -> v
get.attribute.obj
# u0, lid, path|node, attr -> obj
get.attribute.map.v
# u0, lid, path|node, attr, key -> v
Path
path {
cursor 0-1;
root 0-2345;
select
# u0, lid, path|node, v0
push
# u0, lid, str
pop
# u0, lid
get
# u0, lid, buf -> path.buf
};
Events
pool 888;
ev {
put 0;
replace 1;
erase 2;
add.node 3;
remove.node 4;
update.node 5;
};
events.on
# u0, lid, on
io(_0, a+9, _1, _2, 0,0);
step
# u0
Encode/decode
encoded = llog2.encode(u0, log0, 0);
llog2.decode(u0, lid0, encoded);
Example new, log and set attribute value and object
log0 = llog2.new(u0, LIVE.LOG);
llog2.log(u0, log0, llog2.root, HN.Hello2022);
llog2.set.attribute.v(u0, log0,ATTR.TEST, money, 1000000);
llog2.set.attribute.obj(u0, log0,ATTR.TEST, buffer, buf0);
llog2.set.attribute.v(u0, log0,ATTR.TEST, money, 1000000);
llog2.set.attribute.v(u0, log0,ATTR.TEST, time, 1000000);
llog2.set.attribute.v(u0, log0,ATTR.TEST, freedom, 1000000);
Example: Path
# select path /PATH0
llog2.path.select(u0, log0, llog2.root, PATH0);
# push path P0 - /PATH0/P0
llog2.path.push(u0, log0, P0);
Example: Save and load, encode and decode
file.pool 20000;
file.i 0;
save {
log0 = llog2.new(u0, AP.DATA.NEW);
llog2.log(u0, log0, llog2.root, HN.Hello2022);
llog2.log(u0, log0, NEXT, GOOD);
encoded = llog2.encode(u0, log0, 0);
storage.save.object(storage.t.data,file.pool,file.i, 0, encoded, 0); # save encoded
};
load {
encoded = storage.load.object(storage.t.data,file.pool,file.i, 0, 0,0); # load encoded
lid0 = llog2.new(u0, AP.DATA.LOAD);
llog2.decode(u0, lid0, encoded);
lid0;
};
Example: Children
nodes0 = llog2.get.children(u0, livelog0, pathnode, nodes0, 0);
n = buffer.size(u0, nodes0,0);
i:=0; while(i<n) {
child0 buffer.get(u0, nodes0,0,i);
};
Example: New livelog with events and set splitter
log0:=llog2.new(u0, Livelog.test);
llog2.set.splitter(u0, log0, 1);
llog2.events.on(u0, log0, 1);
Expand all
# EXPAND ALL [
llog2.log00 llog2.log(__);
llog2.log {
llog2.log00(__);
llog2.set.attribute.v(_0, _1, _2, EXPAND, 1);
};