tcl::t...counter(3tcl)

๐Ÿ“ฆ
version 2.0 ยท 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

โœจ tcl::transform::counter โ€” the counter transformation, bestie edition โœจ

okay so this is a page from the 3tcl manual, sitting in the Reflected/virtual channel support corner of the world ๐Ÿ’… and it's about counting bytes. no cap, that's the whole vibe.


๐ŸŒธ NAME ๐ŸŒธ

tcl::transform::counter โ€” the Counter transformation. that's it, that's the name, she's simple and she's iconic ๐Ÿ‘‘


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

package require Tcl 8.6 9

package require tcl::transform::core ?1.1?

package require tcl::transform::counter ?1.1?

::tcl::transform::counter chan -option value...

๐Ÿ’– DESCRIPTION ๐Ÿ’–

so the tcl::transform::counterr package (yes, two r's, that's literally what it says, do not come for me ๐Ÿ™ˆ) gives you a command that builds a channel transformation. and what does this transformation do?? it passes the read bytes and the written bytes straight through, completely unchanged โ€” exactly like tcl::transform::identity does โ€” but bestie. it also counts the bytes it has seen, separately for each direction ๐Ÿงฎโœจ and then it stashes those counts in Tcl variables that you name at construction time. it's giving "i'm just standing here" but it's actually keeping receipts.

the related transformations in this module โ€” go look at them, they're the friend group ๐Ÿซถ โ€” are tcl::transform::adler32, tcl::transform::crc32, tcl::transform::identity, and tcl::transform::observe.

and the internal TclOO class that actually implements the transform handler? it's a subclass of the tcl::transform::core framework. family tree matters, periodt ๐ŸŒณ


๐Ÿ”ฅ API ๐Ÿ”ฅ

  • ::tcl::transform::counter chan -option value... โ€” this command spins up a counter transformation on top of the channel chan and hands you back its handle. and the options it accepts are... ๐Ÿ‘‡
    • -read-variable varname โ€” the value here is the name of a global or namespaced variable, i.e. the spot where the transformation has to store the byte count of the data that was read from the channel. ๐Ÿ“–

and if you don't specify it, or you give it the empty string, then the read-direction counter just... isn't saved. no variable, no vibes. ๐Ÿซฅ

  • -write-variable varname โ€” same deal, other direction: the value is the name of a global or namespaced variable, the place where the transformation has to store the byte count of the data written to the channel. โœ๏ธ

and again, if it's not specified or it's the empty string, the write-direction counter is not saved. ๐Ÿซฅ


๐Ÿ˜ญ BUGS, IDEAS, FEEDBACK ๐Ÿ˜ญ

ngl, this document and the package it describes will undoubtedly contain bugs and other problems. like, undoubtedly. it's said right there. ๐Ÿ’€ please report them in the virtchannel category of the Tcllib Trackers: http://core.tcl.tk/tcllib/reportlist. and while you're at it, please also drop any ideas for enhancements you have for either the package and/or the documentation โ€” we want them, fr fr ๐Ÿซถ

when you're proposing code changes, please provide unified diffs, i.e. the output of diff -u. that's the move. ๐Ÿงš

also note: attachments are strongly preferred over inlined patches. you make an attachment by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. left-most button. that one. ๐Ÿ‘ˆโœจ


๐Ÿฆ‹ KEYWORDS ๐Ÿฆ‹

channel transformation, counter, reflected channel, tip 230, transformation, virtual channel


๐Ÿ‘‘ CATEGORY ๐Ÿ‘‘

Channels


Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>


okay that's the whole page!! ๐ŸŒˆ and for the cute sign-off: this lil masterpiece comes to you from tcllib, version 1.1, and it lives under the tcl::t...counter(3tcl) title in the manual. mwah, go count some bytes, bestie ๐Ÿ’…๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from