-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TDataReader and TDataWriter #904
Comments
- Bit Mirroring - endian flipping - color bit shift - unsigned right bit shift - has LongLong - # bits needed (given a number, how many bits is needed to represent it) - checking System Endian - negative zero float checking - check for floats as negative including -0. - check for -0 specifically. - converting float to half float and mini float (Fp16, Bf16, Fp8-e5m2, and Fp8-e4m3 are supported directly). General utility function for taking a float and outputting an arbitrary exponent and mantissa.
…it shift, half float and mini float support (#914) * #904 TBitHelper Utility class for dealing with bits and endian - Bit Mirroring - endian flipping - color bit shift - unsigned right bit shift - has LongLong - # bits needed (given a number, how many bits is needed to represent it) - checking System Endian - negative zero float checking - check for floats as negative including -0. - check for -0 specifically. - converting float to half float and mini float (Fp16, Bf16, Fp8-e5m2, and Fp8-e4m3 are supported directly). General utility function for taking a float and outputting an arbitrary exponent and mantissa. * Error messages. * Reordered a reordering.
more utility is needed than just TDataReader and TDataWriter. TDataStream - encapsulates a PHP Stream, standardizes stream behavior (mainly writing). TBitReader - for reading a specific number of bits at a time. TDataAllocation - structured memory allocation functionality TLZWCompressor - A common, effective, and fast compression algorithm (with expired patent) |
A Rational is found in EXIF and is common in its GPS "directory". This parses and generates rationals and unsigned rationals into various formats, float, string (eg. `13/8`) and array (eg. `[13, 8]`). The star method of this class is the Continued Fraction computation to generate the integer numerator and integer denominator from a float, to a specific tolerance. Updated TBitHelper with specific max, min, unsigned max, and mask for 32 bit and 64 bit integers, when the values are needed and not just the system values.
* #904 TRational unit classes Prado\Util\Math A Rational is found in EXIF and is common in its GPS "directory". This parses and generates rationals and unsigned rationals into various formats, float, string (eg. `13/8`) and array (eg. `[13, 8]`). The star method of this class is the Continued Fraction computation to generate the integer numerator and integer denominator from a float, to a specific tolerance. Updated TBitHelper with specific max, min, unsigned max, and mask for 32 bit and 64 bit integers, when the values are needed and not just the system values. * TRational[null] Another access option * Removed TRational::__Invoke as redundant added example code to the php doc
TDataStream may be able to handle files is being designed for files, but I think sockets will fit and can be handled as well. Sending binary data by socket through TDataWriter would be utilitarian. |
This is a more interesting issue that I initially figured. Reading and writing binary numbers in a stream could mean the steam is a resource, file, socket, I/O pipe, or process pipes each with their own slighting different open and close function. Each are using fread and fwrite to receive and send data. This adds a great abstraction layer to interprocess communication, which we may need if cron is going to spin off each cron job as its own process at some point. I feel like I have to do at least 4 iterations of anything I do to make the work up to date with current PRADO standards. lol. eg. The very short function and miner tweak to support composer plugins was the reduction of 1.5 years of work with countless classes for making PRADO plugins before composer was a thing. in revisiting it that was how it was reduced to basically one function to support composer plugins. |
BTW, this is turning into a general IO package. It's looking awesome. It adds support for binary IO on StdIn, StdOut, Input, Output, StdErr, Temp Files (3 forms, including a retainable temp), Sockets, Temp-Memory, , Pipes, Processes, Files, and downloaded URLs via fopen. I am hoping this unlocks more potential and utility of PRADO. Other packages like ASP and JAVA have IO and network classes. this is core functionality of an asset and publishing those assets. So, before we address publishing an asset, we need to be able to read it, write it, and process it properly. I also like the standardization of reading and writing so many sources and sinks. and, as stated, bit reader/writer, and LZW and packbits compression. |
Found another bug in PHPStan: phpstan/phpstan#9386 Documented here: https://phpstan.org/r/84a3c6f1-9649-4f59-8a1b-ae9d8af656eb A trait is being used by two classes, but only one class has specific properties. The class is checked for and properties accessed. The problem is that the second class using the trait, PHPStan thinks is also executing on the class properties. The class with the properties is being checked and the class without the properties is excluded. PHPStan thinks the excluded class is executing on those properties but without the properties. There are 4 Reader classes and two have the "Startoffset" and "fixedlength" Technically, the issue being reported goes against standard OOP for traits. I'm refactoring it so it's not an issue, but it's still something phpstan should look at. |
This creates a `fopen`, `stream_socket_client` and `stream_socket_server` context. The class itself is invokable and is what gets notified. Multiple callbacks can be implemented or specific events can be handled.. The context creation method TStreamNotificationCallback::filterStreamContext() can instance new TStreamNotificationCallback (and sub-classes) and register its event handlers and properties. This depends on pradosoft#966 (pradosoft#967)
…e connection/download (#968) * #966 TWeakCollection can insert array of handlers. * #904 TStreamNotificationCallback for observing file connections This creates a `fopen`, `stream_socket_client` and `stream_socket_server` context. The class itself is invokable and is what gets notified. Multiple callbacks can be implemented or specific events can be handled.. The context creation method TStreamNotificationCallback::filterStreamContext() can instance new TStreamNotificationCallback (and sub-classes) and register its event handlers and properties. This depends on #966 (#967) * Update TStreamNotificationCallback.php using constant
We have a TTextWriter but we don't have any solid core classes for reading and writing streams of digital bit/byte-based data. In the world of XML, HTML, and XHTML such formats may seem extraneous. However there are many data that is written and read in bits rather than text encoded.
Reading and writing IPTC, EXIF, JPEG APP tags, and other digital formats does need such classes. No doubt there are other applications for such utility... including streaming data over TCP/UDP, and other digital formed data.
I have these done already and they do a few extra things like read half floats and mini floats that typical php and PHP Readers/Writers do not do. It has push/pop for offset saving and restoring and sectioning for isolating a portion of a file as if it were its own file. The sectioning is useful for designating a portion of the file (start offset and length) as IPTC encoded data and it will start the "file offset" at the start of the IPTC block, and act like its the end of the file at the end of its length.
Necessity is often one of the greatest sources of inspiration.
The text was updated successfully, but these errors were encountered: