- Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathPrint.h
97 lines (81 loc) · 3.03 KB
/
Print.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
Print.h - Base class that provides print() and println()
Copyright (c) 2016 Arduino LLC. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include<inttypes.h>
#include<stdio.h>// for size_t
#include"String.h"
#include"Printable.h"
#defineDEC10
#defineHEX16
#defineOCT8
#defineBIN2
namespacearduino {
classPrint
{
private:
int write_error;
size_tprintNumber(unsignedlong, uint8_t);
size_tprintULLNumber(unsignedlonglong, uint8_t);
size_tprintFloat(double, int);
protected:
voidsetWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
intgetWriteError() { return write_error; }
voidclearWriteError() { setWriteError(0); }
virtualsize_twrite(uint8_t) = 0;
size_twrite(constchar *str) {
if (str == NULL) return0;
returnwrite((constuint8_t *)str, strlen(str));
}
virtualsize_twrite(constuint8_t *buffer, size_t size);
size_twrite(constchar *buffer, size_t size) {
returnwrite((constuint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overridden by subclasses with buffering
virtualintavailableForWrite() { return0; }
size_tprint(const __FlashStringHelper *);
size_tprint(const String &);
size_tprint(constchar[]);
size_tprint(char);
size_tprint(unsignedchar, int = DEC);
size_tprint(int, int = DEC);
size_tprint(unsignedint, int = DEC);
size_tprint(long, int = DEC);
size_tprint(unsignedlong, int = DEC);
size_tprint(longlong, int = DEC);
size_tprint(unsignedlonglong, int = DEC);
size_tprint(double, int = 2);
size_tprint(const Printable&);
size_tprintln(const __FlashStringHelper *);
size_tprintln(const String &s);
size_tprintln(constchar[]);
size_tprintln(char);
size_tprintln(unsignedchar, int = DEC);
size_tprintln(int, int = DEC);
size_tprintln(unsignedint, int = DEC);
size_tprintln(long, int = DEC);
size_tprintln(unsignedlong, int = DEC);
size_tprintln(longlong, int = DEC);
size_tprintln(unsignedlonglong, int = DEC);
size_tprintln(double, int = 2);
size_tprintln(const Printable&);
size_tprintln(void);
virtualvoidflush() { /* Empty implementation for backward compatibility */ }
};
}
using arduino::Print;