Skip to content

kashif-baig/StringLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Efficient String Building and Reading for Arduino Applications

StringBuilder Class

The StringBuilder class offers several advantages for efficient string manipulation compared to the std::string class:

Mutability: StringBuilder allows in-place modification of strings. This means you can modify the content without creating new string objects for each change. As a result, memory utilization improves, and unnecessary overhead is reduced.

Efficient Concatenation: Manually appending strings using the + operator or other methods creates multiple string objects in memory. In contrast, StringBuilder builds up the string in a pre-allocated buffer. It allows you to add characters to the same instance and then call toString when you need the final string representation.

Useful Methods: The StringBuilder class provides methods for working with strings, such as append, insertAt, and endsWith. These methods give you flexibility and control over your text data.

In summary, if you’re dealing with dynamic string manipulation, especially when concatenating multiple strings, use the StringBuilder class to enhance performance and manage memory more effectively. When passing StringBuilder objects as parameters, be sure to specify a pointer to IStringBuilder in the method signature.

StringReader Class

The StringReader class simplifies reading character data from strings and is particularly useful when you want to treat a string as a character stream. You can read characters individually using the readChar method or in portions using readUntil. Note that the StringReader is destructive, as it changes the original string being read.

About

Efficient string building and reading for Arduino applications.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages