Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::common::OutputStream Class Reference

A stream that strings can be written to. More...

#include <outputStream.h>

Inheritance diagram for MaxOS::common::OutputStream:
MaxOS::common::GenericOutputStream< string > MaxOS::common::InputStreamProcessor< Type, ProcessorType > MaxOS::common::InputStreamEventHandler< Type > MaxOS::common::GenericInputStream< ProcessorType > MaxOS::Logger MaxOS::drivers::SerialConsole MaxOS::drivers::console::ConsoleStream

Public Member Functions

 OutputStream ()
 Constructs an OutputStream object that uses strings as the underlying data type.
 
virtual void line_feed ()
 Writes a newline to the output stream.
 
virtual void carriage_return ()
 Writes a carriage return to the output stream.
 
virtual void clear ()
 Clears the output stream.
 
void write (string string_to_write) override
 Writes a string to the output stream.
 
void write (const char *string_to_write)
 Writes a string to the output stream.
 
virtual void write_char (char char_to_write)
 Writes a character to the output stream.
 
virtual void write_int (int int_to_write)
 Writes an integer to the output stream.
 
virtual void write_hex (uint64_t hex_to_write)
 Writes a hex to the output stream.
 
OutputStreamoperator<< (string string_to_write) override
 Writes a string to the output stream.
 
OutputStreamoperator<< (const char *string_to_write)
 Writes a string to the output stream.
 
OutputStreamoperator<< (int int_to_write)
 Writes a integer to the output stream.
 
OutputStreamoperator<< (uint64_t hex_to_write)
 Writes a hexadecimal to the output stream.
 
OutputStreamoperator<< (char char_to_write)
 Writes a character to the output stream.
 
- Public Member Functions inherited from MaxOS::common::GenericOutputStream< string >
 GenericOutputStream ()
 __________________________________________Templates__________________________________________________///
 
 ~GenericOutputStream ()
 Destructor of the GenericOutputStream class.
 
void on_stream_read (string) override
 Writes the date that was read from the input stream to the output stream.
 
void on_end_of_stream (GenericInputStream< string > *) override
 Close the stream and remove it from the list of streams when the end of the stream is reached.
 
virtual void write (string)
 write an element to the stream.
 
virtual void close ()
 Close the stream.
 
virtual GenericOutputStream< string > & operator<< (string)
 Overload the << operator to write an element to the stream.
 
- Public Member Functions inherited from MaxOS::common::InputStreamProcessor< Type, ProcessorType >
 InputStreamProcessor ()
 Creates a new InputStreamProcessor.
 
 InputStreamProcessor (InputStreamEventHandler< ProcessorType > *generic_stream_event_handler)
 Creates a new InputStreamProcessor.
 
 ~InputStreamProcessor ()
 Destroys the InputStreamProcessor.
 
void on_end_of_stream (GenericInputStream< Type > *stream) override
 Called when a stream has finished. Passes the event on to the handlers and then removes the stream from the array of streams.
 
- Public Member Functions inherited from MaxOS::common::InputStreamEventHandler< Type >
 InputStreamEventHandler ()
 _______________________________________________TEMPLATES_________________________________________________________________///
 
 ~InputStreamEventHandler ()
 Destroys the InputStreamProcessor and disconnects it from all streams.
 
- Public Member Functions inherited from MaxOS::common::GenericInputStream< ProcessorType >
 GenericInputStream ()
 Creates a new GenericInputStream.
 
 GenericInputStream (InputStreamEventHandler< ProcessorType > *)
 Creates a new GenericInputStream and connects it to the handler.
 
 ~GenericInputStream ()
 Destroys the GenericInputStream and disconnects all handlers.
 
void connect_input_stream_event_handler (InputStreamEventHandler< ProcessorType > *)
 Adds a inputStreamEventHandler to the list of internetProtocolHandlers.
 
void disconnect_input_stream_event_handler (InputStreamEventHandler< ProcessorType > *)
 Removes a handler from the list of handlers.
 

Additional Inherited Members

- Protected Attributes inherited from MaxOS::common::InputStreamEventHandler< Type >
common::Vector< GenericInputStream< Type > * > m_generic_input_streams
 List of streams being observed by this handler.
 
- Protected Attributes inherited from MaxOS::common::GenericInputStream< ProcessorType >
common::Vector< InputStreamEventHandler< ProcessorType > * > m_input_stream_event_handlers
 List of streams being observed by this handler.
 

Detailed Description

A stream that strings can be written to.

Definition at line 43 of file outputStream.h.

Constructor & Destructor Documentation

◆ OutputStream()

OutputStream::OutputStream ( )

Constructs an OutputStream object that uses strings as the underlying data type.

Definition at line 17 of file outputStream.cpp.

19{
20
21}
GenericOutputStream()
__________________________________________Templates__________________________________________________...

Member Function Documentation

◆ carriage_return()

void OutputStream::carriage_return ( )
virtual

Writes a carriage return to the output stream.

Definition at line 37 of file outputStream.cpp.

37 {
38
39 // write the text representation of a carriage return to the output stream.
40 write_char('\r');
41
42}
virtual void write_char(char char_to_write)
Writes a character to the output stream.

References write_char().

Referenced by write().

◆ clear()

void OutputStream::clear ( )
virtual

Clears the output stream.

Definition at line 47 of file outputStream.cpp.

47 {
48
49}

◆ line_feed()

void OutputStream::line_feed ( )
virtual

Writes a newline to the output stream.

Definition at line 28 of file outputStream.cpp.

28 {
29
30 write_char('\n');
31
32}

References write_char().

Referenced by write(), and MaxOS::drivers::console::ConsoleStream::write_char().

◆ operator<<() [1/5]

OutputStream & OutputStream::operator<< ( char  char_to_write)

Writes a character to the output stream.

Parameters
char_to_writeThe character to write to the output stream.
Returns
The output stream.

Definition at line 166 of file outputStream.cpp.

166 {
167
169 return *this;
170}
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22

References write_char().

◆ operator<<() [2/5]

OutputStream & OutputStream::operator<< ( const char string_to_write)

Writes a string to the output stream.

Parameters
string_to_writeThe string to write to the output stream.
Returns
The output stream.

Definition at line 178 of file outputStream.cpp.

178 {
179
181 return *this;
182}
void write(string string_to_write) override
Writes a string to the output stream.

References write().

◆ operator<<() [3/5]

OutputStream & OutputStream::operator<< ( int  int_to_write)

Writes a integer to the output stream.

Parameters
int_to_writeThe integer to write to the output stream.
Returns
The output stream.

Definition at line 130 of file outputStream.cpp.

130 {
131
133 return *this;
134}
virtual void write_int(int int_to_write)
Writes an integer to the output stream.

References write_int().

◆ operator<<() [4/5]

OutputStream & OutputStream::operator<< ( string  string_to_write)
override

Writes a string to the output stream.

Parameters
string_to_writeThe string to write to the output stream.
Returns
The output stream.

Definition at line 154 of file outputStream.cpp.

154 {
155
157 return *this;
158}

References write().

◆ operator<<() [5/5]

OutputStream & OutputStream::operator<< ( uint64_t  hex_to_write)

Writes a hexadecimal to the output stream.

Parameters
hex_to_writeThe hex to write to the output stream.
Returns
The output stream.

Definition at line 142 of file outputStream.cpp.

142 {
143
145 return *this;
146}
virtual void write_hex(uint64_t hex_to_write)
Writes a hex to the output stream.

References write_hex().

◆ write() [1/2]

void OutputStream::write ( const char string_to_write)

Writes a string to the output stream.

Parameters
string_to_writeThe string to write to the output stream.

Definition at line 66 of file outputStream.cpp.

66 {
67
68 int i = 0;
69 while (string_to_write[i] != '\0') {
70
71 switch (string_to_write[i]) {
72
73 case '\n':
74 line_feed();
75 break;
76
77 case '\r':
79 break;
80
81 case '\0':
82 return;
83
84 default:
86 break;
87
88 }
89 i++;
90 }
91}
virtual void carriage_return()
Writes a carriage return to the output stream.
virtual void line_feed()
Writes a newline to the output stream.

References carriage_return(), line_feed(), and write_char().

◆ write() [2/2]

◆ write_char()

void OutputStream::write_char ( char  char_to_write)
virtual

Writes a character to the output stream.

Parameters
char_to_writeThe character to write to the output stream.

Reimplemented in MaxOS::Logger, MaxOS::drivers::SerialConsole, and MaxOS::drivers::console::ConsoleStream.

Definition at line 98 of file outputStream.cpp.

98 {
99
100}

Referenced by carriage_return(), line_feed(), operator<<(), write(), and MaxOS::Logger::write_char().

◆ write_hex()

void OutputStream::write_hex ( uint64_t  hex_to_write)
virtual

Writes a hex to the output stream.

Parameters
hex_to_writeThe hex to write to the output stream.

Definition at line 118 of file outputStream.cpp.

118 {
119
121
122}
char * htoa(uint64_t number)
Converts hex to string.
Definition string.cpp:738

References htoa(), and write().

Referenced by MaxOS::net::EthernetFrameHandler::data_received(), and operator<<().

◆ write_int()

void OutputStream::write_int ( int  int_to_write)
virtual

Writes an integer to the output stream.

Parameters
int_to_writeThe integer to write to the output stream.

Definition at line 107 of file outputStream.cpp.

107 {
108
109 write(itoa(10, int_to_write));
110
111}
char * itoa(int base, int64_t number)
Converts integer to string.
Definition string.cpp:703

References itoa(), and write().

Referenced by operator<<().


The documentation for this class was generated from the following files: