diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2009-04-26 13:10:34 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2009-04-26 13:10:34 +0000 |
commit | 0681fc1f177f7c94b4e98bb0931a5efda50f32b0 (patch) | |
tree | 2174000a919ea016385dac3cdb482ce2d21fee9f /cores/arduino/Print.cpp | |
parent | a42326aba2fd9696a4b2e1239a5a222014056ff5 (diff) |
Adding write(str) and write(buf, size) methods to Print class and Ethernet library Client and Server classes. This allows sending a whole string or buffer at once, reducing the number of ethernet packets.
Diffstat (limited to 'cores/arduino/Print.cpp')
-rwxr-xr-x | cores/arduino/Print.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index d4833da..74d0e5b 100755 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -21,7 +21,6 @@ #include <stdio.h> #include <string.h> -#include <inttypes.h> #include <math.h> #include "wiring.h" @@ -29,6 +28,20 @@ // Public Methods ////////////////////////////////////////////////////////////// +/* default implementation: may be overridden */ +void Print::write(const char *str) +{ + while (*str) + write(*str++); +} + +/* default implementation: may be overridden */ +void Print::write(const uint8_t *buffer, size_t size) +{ + while (size--) + write(*buffer++); +} + void Print::print(uint8_t b) { this->write(b); @@ -39,10 +52,9 @@ void Print::print(char c) print((byte) c); } -void Print::print(const char c[]) +void Print::print(const char str[]) { - while (*c) - print(*c++); + write(str); } void Print::print(int n) |