Printable.h
Go to the documentation of this file.
1 /* $Id: Printable.h 1151 2011-06-06 21:13:05Z bhagman $
2 ||
3 || @author Adrian McEwen
4 || @url http://wiring.org.co/
5 || @contribution Alexander Brevig <abrevig@wiring.org.co>
6 || @contribution Brett Hagman <bhagman@wiring.org.co>
7 ||
8 || @description
9 || | Abstract base class to allow "printing" of complex types through
10 || | the Print class.
11 || |
12 || | Wiring Common API
13 || #
14 ||
15 || @notes
16 || | The Printable class provides a way for new classes to allow themselves
17 || | to be printed. By deriving from Printable and implementing the printTo
18 || | method, it will then be possible for users to print out instances of this
19 || | class by passing them into the usual Print::print and Print::println
20 || | methods.
21 || #
22 ||
23 || @example
24 || | class T : public Printable {
25 || | public:
26 || | void printTo(Print &p) {
27 || | p.print("test");
28 || | }
29 || | };
30 || #
31 ||
32 || @license Please see cores/Common/License.txt.
33 ||
34 */
35 
36 #pragma once
37 
38 #include <cstddef>
39 
40 class Print;
41 
42 class Printable
43 {
44 public:
45  virtual ~Printable()
46  {
47  }
48 
49  virtual size_t printTo(Print& p) const = 0;
50 };
Provides formatted output to stream.
Definition: Print.h:37
Definition: Printable.h:43
virtual size_t printTo(Print &p) const =0
virtual ~Printable()
Definition: Printable.h:45