mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
Adding support for printing Strings to the Print class.
This commit is contained in:
parent
880bc682a9
commit
934312682e
@ -19,6 +19,7 @@
|
|||||||
Modified 23 November 2006 by David A. Mellis
|
Modified 23 November 2006 by David A. Mellis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
Modified 23 November 2006 by David A. Mellis
|
Modified 23 November 2006 by David A. Mellis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -42,6 +43,11 @@ void Print::write(const uint8_t *buffer, size_t size)
|
|||||||
write(*buffer++);
|
write(*buffer++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Print::print(const String &s)
|
||||||
|
{
|
||||||
|
print(s.toCharArray());
|
||||||
|
}
|
||||||
|
|
||||||
void Print::print(const char str[])
|
void Print::print(const char str[])
|
||||||
{
|
{
|
||||||
write(str);
|
write(str);
|
||||||
@ -99,6 +105,12 @@ void Print::println(void)
|
|||||||
print('\n');
|
print('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Print::println(const String &s)
|
||||||
|
{
|
||||||
|
print(s);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
void Print::println(const char c[])
|
void Print::println(const char c[])
|
||||||
{
|
{
|
||||||
print(c);
|
print(c);
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h> // for size_t
|
#include <stdio.h> // for size_t
|
||||||
|
|
||||||
|
#include "WString.h"
|
||||||
|
|
||||||
#define DEC 10
|
#define DEC 10
|
||||||
#define HEX 16
|
#define HEX 16
|
||||||
#define OCT 8
|
#define OCT 8
|
||||||
@ -38,7 +40,8 @@ class Print
|
|||||||
virtual void write(uint8_t) = 0;
|
virtual void write(uint8_t) = 0;
|
||||||
virtual void write(const char *str);
|
virtual void write(const char *str);
|
||||||
virtual void write(const uint8_t *buffer, size_t size);
|
virtual void write(const uint8_t *buffer, size_t size);
|
||||||
|
|
||||||
|
void print(const String &);
|
||||||
void print(const char[]);
|
void print(const char[]);
|
||||||
void print(char, int = BYTE);
|
void print(char, int = BYTE);
|
||||||
void print(unsigned char, int = BYTE);
|
void print(unsigned char, int = BYTE);
|
||||||
@ -48,6 +51,7 @@ class Print
|
|||||||
void print(unsigned long, int = DEC);
|
void print(unsigned long, int = DEC);
|
||||||
void print(double, int = 2);
|
void print(double, int = 2);
|
||||||
|
|
||||||
|
void println(const String &s);
|
||||||
void println(const char[]);
|
void println(const char[]);
|
||||||
void println(char, int = BYTE);
|
void println(char, int = BYTE);
|
||||||
void println(unsigned char, int = BYTE);
|
void println(unsigned char, int = BYTE);
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
#ifndef String_h
|
#ifndef String_h
|
||||||
#define String_h
|
#define String_h
|
||||||
|
|
||||||
#include "WProgram.h"
|
//#include "WProgram.h"
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user