Skip to content
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

Add PrintBuffer classes #2873

Merged
merged 2 commits into from
Aug 7, 2024
Merged

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Aug 6, 2024

Using ArduinoJson to serialize directly to a file stream performs poorly because writes are done byte-by-byte. This issue is mentioned under performance.

The mentioned ArduinoStreamUtils library is a bit hefty and doesn't particular fit with the existing Sming stream classes.

This PR adds a very simple PrintBuffer class which operates on a Print output and can be employed very easily if additional generic buffering is required.

Note that there is little benefit to using this with other memory-based streams so best left to the library or application to decide when its appropriate.

Copy link

what-the-diff bot commented Aug 6, 2024

PR Summary

  • New Files Addition
    Three new files have been added namely:
    • WriteBuffer.cpp
    • WriteBuffer.h
    • buffering.rst
  • Function Additions in WriteBuffer.cpp
    • A write function has been added that records a single character.
    • An additional write function has been added that records a group of characters.
    • A flush function has been included that relays the saved content to our desired output.
  • Class Inclusions in WriteBuffer.h
    • BaseWriteBuffer: A fundamental, basic write-through buffer class.
    • StaticWriteBuffer: A write-through buffer that utilizes stack-based storage.
    • HeapWriteBuffer: A write-through buffer that employs heap storage.
    • DynamicWriteBuffer: A write-through buffer that uses heap storage and possesses its own stream pointer.
  • Documentation in buffering.rst
    A thorough documentation has been provided about buffering in Sming along with an explanation and the functionalities of the three buffer classes mentioned previously.

@mikee47 mikee47 changed the title Add WriteBuffer classes Add PrintBuffer classes Aug 6, 2024
@slaff slaff merged commit f8d10e6 into SmingHub:develop Aug 7, 2024
46 checks passed
@mikee47 mikee47 deleted the feature/write-buffer branch August 7, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants