PhoenixLecture  2.0.0
Set of tools to make lectures
ptimetable_invitation.h File Reference
#include "TexTimetable.h"
+ Include dependency graph for ptimetable_invitation.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PString ptimetable_beginInvitation (const PString &name, const PString &motif)
 Begins an invitation. More...
 
PString ptimetable_blockToEvent (const PTimeTableBlock &block)
 
bool ptimetable_createInvitation (const PPath &outputDirectory, const TexTimetable &timetable)
 Create an invitation. More...
 
bool ptimetable_createInvitationMergBlock (const PPath &outputDirectory, const TexTimetable &timetable)
 Create invitations but merge blocks with the same invitation. More...
 
PString ptimetable_endInvitation ()
 Ends an invitation. More...
 

Function Documentation

◆ ptimetable_beginInvitation()

PString ptimetable_beginInvitation ( const PString name,
const PString motif 
)

Begins an invitation.

Parameters
name: name of entity which create this invitation
motif: motif of the invitation
Returns
begining of the invitation

Definition at line 20 of file ptimetable_invitation.cpp.

20  {
21  PString body("");
22  body += "BEGIN:VCALENDAR\n";
23  body += "VERSION:2.0\n";
24  body += "PRODID:-//"+name+"//"+motif+"/\n";
25  return body;
26 }
Extends the std::string.
Definition: PString.h:16

Referenced by ptimetable_createFullWeekDayInvitation(), ptimetable_createInvitation(), and ptimetable_createInvitationMergBlock().

+ Here is the caller graph for this function:

◆ ptimetable_blockToEvent()

PString ptimetable_blockToEvent ( const PTimeTableBlock block)

◆ ptimetable_createInvitation()

bool ptimetable_createInvitation ( const PPath outputDirectory,
const TexTimetable timetable 
)

Create an invitation.

Parameters
outputDirectory: output directory where to put all generated invitations
timetable: TexTimetable to be used to generate invitations
Returns
true on success, false otherwise

Definition at line 139 of file ptimetable_invitation.cpp.

139  {
140  bool b(true);
141  size_t counter(0lu);
142  PString bevt(ptimetable_beginInvitation("PhoenixTex2Html", timetable.invitation)), eevt(ptimetable_endInvitation());
143  b &= outputDirectory.createDirectory();
144  const std::vector<TexWeek> & vecWeek = timetable.vecWeek;
145  for(std::vector<TexWeek>::const_iterator itWeek(vecWeek.begin()); itWeek != vecWeek.end(); ++itWeek){
146  const std::map<PString, TexDay> & mapDay = itWeek->mapDay;
147  for(std::map<PString, TexDay>::const_iterator itDay(mapDay.begin()); itDay != mapDay.end(); ++itDay){
148  const std::map<PString, PTimeTableBlock> & mapBlock = itDay->second.mapBlock;
149  for(std::map<PString, PTimeTableBlock>::const_iterator it(mapBlock.begin()); it != mapBlock.end(); ++it){
150  if(it->second.getInvitation() != ""){
151  b &= PPath(outputDirectory + PPath("/") + it->second.getInvitation() + PPath(".ics")).saveFileContent(
152  bevt+ptimetable_blockToEvent(counter, it->second)+eevt);
153  }
154  }
155  if(itDay->second.invitation != ""){
156  b &= PPath(outputDirectory + PPath("/") + itDay->second.invitation + PPath(".ics")).saveFileContent(
157  bevt+ptimetable_dayToVecEvent(counter, itDay->second)+eevt);
158  }
159  }
160  if(itWeek->invitation != ""){
161  b &= PPath(outputDirectory + PPath("/") + itWeek->invitation + PPath(".ics")).saveFileContent(
162  bevt+ptimetable_weekToVecEvent(counter, *itWeek)+eevt);
163  }
164  }
165  if(timetable.invitation != ""){
166  b &= PPath(outputDirectory + PPath("/") + timetable.invitation + PPath(".ics")).saveFileContent(
167  bevt+ptimetable_timetableToVecEvent(counter, timetable)+eevt);
168  }
169  return b;
170 }
Path of a directory or a file.
Definition: PPath.h:17
bool saveFileContent(const PString &content) const
Save a PString in a file.
Definition: PPath.cpp:395
bool createDirectory(mode_t mode=0755) const
Create the current directory.
Definition: PPath.cpp:331
PString ptimetable_blockToEvent(size_t &counter, const PTimeTableBlock &block)
Convert a block into a event calendar.
PString ptimetable_endInvitation()
Ends an invitation.
PString ptimetable_dayToVecEvent(size_t &counter, const TexDay &day)
Convert a day into a event calendar.
PString ptimetable_weekToVecEvent(size_t &counter, const TexWeek &week)
Convert a week into a event calendar.
PString ptimetable_beginInvitation(const PString &name, const PString &motif)
Begins an invitation.
PString ptimetable_timetableToVecEvent(size_t &counter, const TexTimetable &texTimeTable)
Convert a timetable into a event calendar.
PString invitation
Invitation of the full event.
Definition: TexTimetable.h:40
std::vector< TexWeek > vecWeek
Vector of week.
Definition: TexTimetable.h:42

References PPath::createDirectory(), TexTimetable::invitation, ptimetable_beginInvitation(), ptimetable_blockToEvent(), ptimetable_dayToVecEvent(), ptimetable_endInvitation(), ptimetable_timetableToVecEvent(), ptimetable_weekToVecEvent(), PPath::saveFileContent(), and TexTimetable::vecWeek.

+ Here is the call graph for this function:

◆ ptimetable_createInvitationMergBlock()

bool ptimetable_createInvitationMergBlock ( const PPath outputDirectory,
const TexTimetable timetable 
)

Create invitations but merge blocks with the same invitation.

Parameters
outputDirectory: output directory where to put all generated invitations
timetable: TexTimetable to be used to generate invitations
Returns
true on success, false otherwise

Definition at line 253 of file ptimetable_invitation.cpp.

253  {
254  std::map<PString, std::vector<PTimeTableBlock>> mapInviteVecBlock;
255  ptimetable_createMapInviteBlock(mapInviteVecBlock, timetable);
256 
257  bool b(true);
258  PString bevt(ptimetable_beginInvitation("PhoenixTex2Html", timetable.invitation)), eevt(ptimetable_endInvitation());
259  b &= outputDirectory.createDirectory();
260  size_t counter(0lu);
261  b &= ptimetable_saveMapInviteBlock(counter, outputDirectory, mapInviteVecBlock, bevt, eevt);
262  b &= ptimetable_createFullWeekDayInvitation(counter, outputDirectory, timetable);
263  return b;
264 }
void ptimetable_createMapInviteBlock(std::map< PString, std::vector< PTimeTableBlock > > &mapInviteVecBlock, const TexTimetable &timetable)
Create the map of invitation blocks.
bool ptimetable_saveMapInviteBlock(size_t &counter, const PPath &outputDirectory, const std::map< PString, std::vector< PTimeTableBlock > > &mapInviteVecBlock, const PString &bevt, const PString &eevt)
Create the map of invitation blocks.
bool ptimetable_createFullWeekDayInvitation(size_t &counter, const PPath &outputDirectory, const TexTimetable &timetable)
Create invitations for timetable, weeks and days.

References PPath::createDirectory(), TexTimetable::invitation, ptimetable_beginInvitation(), ptimetable_createFullWeekDayInvitation(), ptimetable_createMapInviteBlock(), ptimetable_endInvitation(), and ptimetable_saveMapInviteBlock().

Referenced by ptimetable_tex().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ptimetable_endInvitation()

PString ptimetable_endInvitation ( )

Ends an invitation.

Returns
end of the invitation

Definition at line 31 of file ptimetable_invitation.cpp.

31  {
32  return "END:VCALENDAR\n\n";
33 }

Referenced by ptimetable_createFullWeekDayInvitation(), ptimetable_createInvitation(), and ptimetable_createInvitationMergBlock().

+ Here is the caller graph for this function: