|
SBB Host
Host communication with the self balancing bike.
|
A class for file reading and writing. More...
#include <File.h>
Public Member Functions | |
| File () | |
| Constructor. More... | |
| File (const char *str, const char *mode) | |
| Constructor. More... | |
| ~File () | |
| Desctructor. More... | |
| bool | open (const char *str, const char *mode) |
| Open the file. More... | |
| size_t | print (const char *str) |
| Print a string. More... | |
| size_t | write (void *buf, size_t len) |
| Write a buffer. More... | |
| size_t | read (void *buf, size_t len) |
| Read a buffer. More... | |
| size_t | read (unsigned char **p_buf) |
| Read all the file. More... | |
| bool | gets (char *str, size_t len) |
| Get a string. More... | |
| void | close () |
| Clone the file. More... | |
| bool | isOpen () |
| Check if open. More... | |
| bool | eof () |
| Check end-of-file. More... | |
| operator bool () | |
Private Attributes | |
| FILE * | p_file |
| Pointer to the C-type file. More... | |
| bool | _isOpen |
| true if file is open More... | |
A class for file reading and writing.
Class for file reading and writing wroking with Windows and Linux. Actually this is just a wrapper for the FILE type in the stdio C library.
| File::File | ( | ) |
Constructor.
Default constructor. File is not open.
| File::File | ( | const char * | str, |
| const char * | mode | ||
| ) |
Constructor.
Constructor for the file class with opening.
| str | The name of the file. |
| mode | The mode for the file opening. Refer to the stdio library for the meaning. |
| File::~File | ( | ) |
Desctructor.
Default destructor. No parameter is necessary. It automatically closes the file if open.
| void File::close | ( | ) |
Clone the file.
Function to clone the file.
| bool File::eof | ( | ) |
Check end-of-file.
Function to check if the end-of-file is reached.
| bool File::gets | ( | char * | str, |
| size_t | len | ||
| ) |
Get a string.
Function to get a string to the file.
| str | The string used to store the char read. |
| len | The length of the string to read. |
|
inline |
Check if open.
Function to check if the file is open.
| bool File::open | ( | const char * | str, |
| const char * | mode | ||
| ) |
Open the file.
Function to open the file.
| str | The name of the file. |
| mode | The mode for the file opening. Refer to the stdio library for the meaning. |
|
inline |
| size_t File::print | ( | const char * | str | ) |
Print a string.
Function to print a string to the file.
| str | The string to print. |
| size_t File::read | ( | unsigned char ** | p_buf | ) |
Read all the file.
Function to read all the file into a buffer. Memory is automatically allocated according to the file size.
| p_buf | The pointer of the pointer to the buffer. |
| size_t File::read | ( | void * | buf, |
| size_t | len | ||
| ) |
Read a buffer.
Function to read a buffer to the file.
| buf | The pointer to the buffer. |
| len | The length of the buffer in bytes. |
| size_t File::write | ( | void * | buf, |
| size_t | len | ||
| ) |
Write a buffer.
Function to write a buffer to the file.
| buf | The pointer to the buffer. |
| len | The length of the buffer in bytes. |
|
private |
true if file is open
|
private |
Pointer to the C-type file.