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

Go to the source code of this file.

Functions

bool ptimetable_load (PTimeTable &timetable, const PPath &configFile)
 Load the PTimeTable with a toml configuration. More...
 
bool ptimetable_loadSpeaker (std::vector< PLatexSpeaker > &vecSpeaker, const PPath &configFile)
 Load the PTimeTable with a toml configuration. More...
 

Function Documentation

◆ ptimetable_load()

bool ptimetable_load ( PTimeTable timetable,
const PPath configFile 
)

Load the PTimeTable with a toml configuration.

Parameters
[out]timetable: PTimeTable to be updated
configFile: configuration file to be used
Returns
true on success, false otherwise

Definition at line 158 of file ptimtable_load.cpp.

158  {
159  DicoValue dico;
160  if(!parser_toml(dico, configFile)){
161  std::cerr << "ptimetable_load : cannot load toml file '"<<configFile<<"'" << std::endl;
162  return false;
163  }
164  if(!ptimetable_loadSpeaker(timetable.getVecSpeaker(), dico)){
165  std::cerr << "ptimetable_load : cannot load speakers from file '"<<configFile<<"'" << std::endl;
166  return false;
167  }
168 
169  DicoValue * dicoTimetable = dico.getMap("timetable");
170  if(dicoTimetable != NULL){
171  if(!ptimetable_parseLatexAttribute(timetable.getName(), *dicoTimetable, "name")){
172  std::cerr << "ptimetable_load : missing 'name' of the event" << std::endl;
173  }
174  if(!ptimetable_parseLatexAttribute(timetable.getLocation(), *dicoTimetable, "location")){
175  std::cerr << "ptimetable_load : missing 'location' of the event" << std::endl;
176  }
177  timetable.setInvitation(ptimetable_loadString(*dicoTimetable, "invitation"));
178  timetable.setBeginDate(ptimetable_parsePLatexDate(ptimetable_loadString(*dicoTimetable, "begin_date")));
179  timetable.setEndDate(ptimetable_parsePLatexDate(ptimetable_loadString(*dicoTimetable, "end_date")));
180  timetable.setMainUrl(ptimetable_loadString(*dicoTimetable, "main_url"));
181  }
182  if(!ptimetable_loadBlock(timetable, dico)){
183  std::cerr << "ptimetable_load : cannot load blocks from file '"<<configFile<<"'" << std::endl;
184  return false;
185  }
186  return true;
187 }
Dictionnary of values.
Definition: DicoValue.h:17
const DicoValue * getMap(const PString &key) const
Get a DicoValue in the map of the current one.
Definition: DicoValue.cpp:116
const PLatexObj & getLocation() const
Gets the location of the PTimeTable.
Definition: PTimeTable.cpp:915
const PLatexObj & getName() const
Gets the name of the PTimeTable.
Definition: PTimeTable.cpp:845
void setInvitation(const PString &invitation)
Sets the invitation of the PTimeTable.
Definition: PTimeTable.cpp:782
void setBeginDate(const PLatexDate &beginDate)
Sets the beginDate of the PTimeTable.
Definition: PTimeTable.cpp:789
void setEndDate(const PLatexDate &endDate)
Sets the endDate of the PTimeTable.
Definition: PTimeTable.cpp:796
void setMainUrl(const PString &mainUrl)
Sets the mainUrl of the PTimeTable.
Definition: PTimeTable.cpp:768
const std::vector< PLatexSpeaker > & getVecSpeaker() const
Gets the vecSpeaker of the PTimeTable.
Definition: PTimeTable.cpp:943
bool parser_toml(DicoValue &dico, const PPath &fileName)
bool ptimetable_parseLatexAttribute(PLatexObj &obj, const DicoValue &value, const PString &attributeName)
Parse an attribute in PLatexObj.
PString ptimetable_loadString(const DicoValue &dico, const PString &attributeName)
Load a string value.
bool ptimetable_loadSpeaker(std::vector< PLatexSpeaker > &vecOutputSpeaker, const DicoValue &dico)
Load the speakers of the PTimeTable.
bool ptimetable_loadBlock(PTimeTable &timetable, const DicoValue &dico)
Load the blocks of the PTimeTable.
PLatexDate ptimetable_parsePLatexDate(const PString &str)
Load a PLatexDate with a string.

References PTimeTable::getLocation(), DicoValue::getMap(), PTimeTable::getName(), PTimeTable::getVecSpeaker(), parser_toml(), ptimetable_loadBlock(), ptimetable_loadSpeaker(), ptimetable_loadString(), ptimetable_parseLatexAttribute(), ptimetable_parsePLatexDate(), PTimeTable::setBeginDate(), PTimeTable::setEndDate(), PTimeTable::setInvitation(), and PTimeTable::setMainUrl().

Referenced by PConfigParser::parseTimeTable().

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

◆ ptimetable_loadSpeaker()

bool ptimetable_loadSpeaker ( std::vector< PLatexSpeaker > &  vecSpeaker,
const PPath configFile 
)

Load the PTimeTable with a toml configuration.

Parameters
[out]timetable: PTimeTable to be updated
configFile: configuration file to be used
Returns
true on success, false otherwise

Definition at line 140 of file ptimtable_load.cpp.

140  {
141  DicoValue dico;
142  if(!parser_toml(dico, configFile)){
143  std::cerr << "ptimetable_loadSpeaker : cannot load toml file '"<<configFile<<"'" << std::endl;
144  return false;
145  }
146  if(!ptimetable_loadSpeaker(vecSpeaker, dico)){
147  std::cerr << "ptimetable_loadSpeaker : cannot load speakers from file '"<<configFile<<"'" << std::endl;
148  return false;
149  }
150  return true;
151 }

References parser_toml(), and ptimetable_loadSpeaker().

+ Here is the call graph for this function: