telosystools

Open full view…

generating C enums and string arrays ?

fenugrec
Fri, 12 Feb 2021 18:30:25 GMT

Hi, I'm wondering if Telosys is the right tool for this job. The examples I've seen don't really apply but I think not... Use case : the "database" is a csv (or other text-based format) something like this: id, errcode, enum_name, shortdescr, longdescr 4, 0x109, ERR_4, "message 1", "long description" and I want to produce e.g. a) an enum with all entries e.g. { ERR_OK = 0, ERR_4 = 4, ....} b) arrays of strings with shortdescr and longdescr. Pretty simple, but it doesn't seem to fit with what telosys was designed to do...

Telosys Team
Tue, 16 Feb 2021 22:08:22 GMT

Hi, Yes, it's possible with the upcoming version of Telosys with the *"$file"* object. For example for a CSV file : --- #set( $file = $fn.fileFromBundle("enum-csv.txt") ) #set( $lines = $file.loadValues(",", 1) ) enum State { #foreach ( $line in $lines ) $line.get(0) = $line.get(1)#if( $foreach.count < $lines.size() ) , #else } #end #end --- If you want to use it right now I can give you a pre-version of Telosys-CLI (the official release 3.3.0 is comming soon)

fenugrec
Tue, 23 Feb 2021 17:29:20 GMT

(sorry, never got a notification for your reply). Thanks, I'll check it out when 3.3 is available on my distro !