#include <calendar.h>
Public Member Functions | |
Calendar () | |
Event & | find (string query) throw ( logic_error ) |
void | print (ostream &out=cout) const |
void | read (string filename) throw ( logic_error, invalid_argument ) |
void | read (istream &in) throw ( invalid_argument ) |
unsigned | size () const |
void | synchronize (Calendar &e) |
void | write (string filename) const |
void | write (ostream &out=cout) const |
Private Member Functions | |
void | synchronize (vector< Event > &e1, vector< Event > &e2) |
Private Attributes | |
vector< Event > | events |
A class for storing events of a calendar that can be synchronized with other calendars. Methods exist to read and write events to and from files, which serve as proxies for sending and receiving between calendars on devices, on computers, and in the cloud. A find method searches for events based on name and location.
Calendar::Calendar | ( | ) |
Default constructor.
Event & Calendar::find | ( | string | query | ) | |
throw | ( | logic_error | |||
) |
Returns a reference to the event with a name or location that partially matches with the query. Otherwise, throws logic_error.
query | the search string |
logic_error | if no event matches |
void Calendar::print | ( | ostream & | out = cout | ) | const |
Prints the events of this Calendar to the output stream in a format suitable for a user view, meaning that the events are printed in the external format and deleted events are excluded.
out | the output stream for printing |
void Calendar::read | ( | string | filename | ) | |
throw | ( | logic_error, | |||
invalid_argument | |||||
) |
Reads the events in the internal format from file with the specified by opening an input-file stream and, if successful, passing it to Calendar::read( istream & )
. Throws an exception if the file does not open successfully. Throws an exception if a read operation encounters invalid input.
filename | the name of the file containing the events |
logic_error | if the file does not open successfully |
invalid_argument | if a read operation encounters invalid input |
void Calendar::read | ( | istream & | in | ) | |
throw | ( | invalid_argument | |||
) |
Reads the events in the internal format from the input stream, and stores them in the vector events
. Throws an exception if a read operation encounters invalid input.
in | the input stream name containing the events |
invalid_argument | if a read operation encounters invalid input |
unsigned Calendar::size | ( | ) | const |
Returns the size of this calendar, that is, the number of events.
void Calendar::synchronize | ( | Calendar & | calendar | ) |
Synchronizes events e2
to e1
. For each event in e2
, adds new events and copies updated and deleted events based on most recent modification date and time of pairs of matching events.
e1 | a vector of events |
e2 | a vector of events |
void Calendar::write | ( | string | filename | ) | const |
Writes the events of this Calendar to the file named filename
in the internal format.
filename | the name of the file for writing |
void Calendar::write | ( | ostream & | out = cout | ) | const |
Writes the events of this Calendar to the output stream in the internal format.
out | the output stream for writing |
|
private |
the events of this calendar