-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreader.h
70 lines (54 loc) · 1.6 KB
/
reader.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
#ifndef CALENDARI__ICS__READER_H
#define CALENDARI__ICS__READER_H 1
#include "err.h"
#include <libical/ical.h>
#include <string>
namespace calendari {
struct Calendari;
class Db;
}
namespace calendari {
namespace ics {
/** Helper class used by ics functions that read calendars. */
class Reader
{
icalcomponent* _ical;
const std::string _ical_filename;
bool _discard_ids;
public:
struct Exception: public util::Exception {
const char* what(void) const throw()
{ return "calendari::util::Reader::Exception"; }
};
struct OpenFailed: public Exception {
const char* what(void) const throw()
{ return "calendari::util::Reader::Exception::OpenFailed"; }
};
struct ReadFailed: public Exception {
const char* what(void) const throw()
{ return "calendari::util::Reader::Exception::ReadFailed"; }
};
std::string calid;
std::string calname;
std::string path;
bool readonly;
/** Read _ical from 'ical_filename' and initialise members. */
Reader(const char* ical_filename);
~Reader(void);
/** Returns FALSE if 'calid' is already in use in database 'db'. */
bool calid_is_unique(Db& db) const;
/** Tell the object to throw away all of the unique IDs (calid & UIDs)
* read from the .ics file, and create new ones. */
void discard_ids(void);
/** Load the calendar into database 'db'. */
int load(
Calendari* app,
Db& db,
int version
);
private:
Reader(Reader&);
Reader& operator = (Reader&);
};
} } // end namespace calendari::ics
#endif // CALENDARI__ICS__READER_H