Boo0ns / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Add Stream.readString() and Stream.readStringUntil() that return String instances. #454

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The Stream class needs to work well with the String class.  That is, there 
should be functions for reading a String from a Stream (in addition to the 
functions for writing a String to a Stream).

Original issue reported on code.google.com by dmel...@gmail.com on 8 Jan 2011 at 5:22

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 7 May 2011 at 5:09

GoogleCodeExporter commented 9 years ago
Can you take a look at this one too?  You probably should bounce the potential 
implementation off of the developers list, as there have been lots of 
efficiency concerns about Strings and their implementation.

Original comment by dmel...@gmail.com on 5 Sep 2011 at 2:53

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 16 Dec 2011 at 10:08

GoogleCodeExporter commented 9 years ago
I needed the readStringUntil method for some other work I've been doing, so 
thought I'd propose a patch.

The attached issue454-patch.txt includes the changes needed, and 
readStringExamples.ino is a simple sketch to allow testing of it.

Original comment by adrian.m...@gmail.com on 15 May 2012 at 1:17

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks Adrian!  I'll try to squeeze these in for Arduino 1.0.1.  We might want 
to optimize the functions later (i.e. allocate the memory in larger chunks 
instead of one character at a time), but this seems like a good implementation 
to start with.

Original comment by dmel...@gmail.com on 15 May 2012 at 3:36

GoogleCodeExporter commented 9 years ago
Yeah, I did wonder about allocating memory in larger chunks at a time, but 
there didn't seem to be an obvious chunk size to choose.  I'm hoping (though 
haven't checked) that most of the time the string will just be able to grow in 
place and so not fragment things.

Original comment by adrian.m...@gmail.com on 15 May 2012 at 9:57

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/commit/39eed5acc2f3a62f35bd83df71df2d9ed422a8
a8

Original comment by dmel...@gmail.com on 16 May 2012 at 7:40