lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Sean,
sorry, I am not used to lua enough yet ... I read the colons as semi-colons
like in c ... bad c programmer habit. Now I understand your code segment.

So in this case with the table notation, the "lazy approach" with N types
(+t type-info-byte) would be 

result, pos= string.unpack( ">T", blob, 13)

But this would require, that the blob packing also used this "T" format:
result= { service_type= "some string", 
            source= { addr_ton= 1, addr_npi= 2, addr= "source-addr-string"},
            dest= { addr_ton= 10, addr_npi= 20, addr= "dest-addr-string"},
            esm_class= 100, protocol_id= 110, priority= 120,
            schedule_time= "100msec", validity_period= "1 min",
            registered_delivery= 200, replace_if_present= 210, data_coding=
220, sm_default_msg_id= 230,
            message= "This is some messge" }
  
blob = string.pack( result)

... this "T" I think would be mainly useful to a table locally in some file,
and then later retrieve it, or to transfer a table between 2 lua systems.

The price for "T" would be, that all the keys should best be inside your
blob string, this will bloat up your
blob by about 100-200 bytes in this case, quite much of course ... As your
message string is maximum 250 bytes wide, this will bloat your blob string
by minimum 100%, so this is quite much ... .

If you want to use the "T" more size-efficient, you would need to transform
the result table to some index table, then all the keys are NOT put into
blob.

If you want to transfer size-optimum, or from some further "non-lua" device
with prefined byte code, then of course you will HAVE to use the unpacking
with clearly defined format string as shown in your blog above.

Sorry concerning further hints from your side, which I somehow did not
understand yet completely or which I overlooked in your blogs, can you best
send them also in form of such a lua code snippet, so that I see where you
see possible problems which still cannot be handled? (I did not receive any
Email from your side...).




--
Sent from: http://lua.2524044.n2.nabble.com/Lua-l-f2524044.html