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

Go to the source code of this file.

Typedefs

typedef std::map< PString, std::pair< PString, PString > > PMapLabel
 Map of the label (name, link) More...
 

Functions

void updateLabelRef (PLatexObj &obj)
 Update the label of the references. More...
 
void updateMapLabel (PMapLabel &mapLabel, const PLatexObj &obj)
 Update the map of label. More...
 
void useMapLabel (PLatexObj &obj, const PMapLabel &mapLabel)
 Update the map of label. More...
 
void useMapLabel (std::vector< PLatexObj > &vecObj, const PMapLabel &mapLabel)
 Update the map of label. More...
 

Typedef Documentation

◆ PMapLabel

typedef std::map<PString, std::pair<PString, PString> > PMapLabel

Map of the label (name, link)

Definition at line 14 of file updateLabelRef.h.

Function Documentation

◆ updateLabelRef()

void updateLabelRef ( PLatexObj obj)

Update the label of the references.

Parameters
[out]obj: PLatexObj to be updated

Definition at line 66 of file updateLabelRef.cpp.

66  {
67  PMapLabel mapLabel;
68  updateMapLabel(mapLabel, obj);
69  useMapLabel(obj, mapLabel);
70 
71  PPath redirectFileName("redirect.html");
72  if(!redirect_html(redirectFileName, mapLabel)){
73  std::cerr << "updateLabelRef : cannot save the file '"<<redirectFileName<<"'" << std::endl;
74  }
75 }
Path of a directory or a file.
Definition: PPath.h:17
bool redirect_html(const PPath &fileName, const PMapLabel &mapLabel)
Create the redirection page to get page with label name as reference.
void updateMapLabel(PMapLabel &mapLabel, const PLatexObj &obj)
Update the map of label.
void useMapLabel(PLatexObj &obj, const PMapLabel &mapLabel)
Update the map of label.
std::map< PString, std::pair< PString, PString > > PMapLabel
Map of the label (name, link)

References redirect_html(), updateMapLabel(), and useMapLabel().

Referenced by processAllFile().

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

◆ updateMapLabel()

void updateMapLabel ( PMapLabel mapLabel,
const PLatexObj obj 
)

Update the map of label.

Parameters
[out]mapLabel: map of label to be updated
obj: PLatexObj to deal with

Definition at line 16 of file updateLabelRef.cpp.

16  {
17  if(obj.getLabelName() != ""){
18  //TODO : update the text of the reference
19  PString name(obj.getName());
20  if(obj.getVecSecNumber().size() != 0lu){
21  name = vecNumberToString(obj.getVecSecNumber());
22  }
23  mapLabel[obj.getLabelName()] = std::pair<PString,PString>(obj.getLink(), name);
24  }
25  const PVecLatexObj & vecObj = obj.getVecContent();
26  for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
27  updateMapLabel(mapLabel, *it);
28  }
29 }
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
const PString & getLabelName() const
Gets the labelName of the PLatexObj.
Definition: PLatexObj.cpp:354
const PString & getName() const
Gets the name of the PLatexObj.
Definition: PLatexObj.cpp:326
const PString & getLink() const
Gets the link of the PLatexObj.
Definition: PLatexObj.cpp:368
const std::vector< long unsigned int > & getVecSecNumber() const
Gets the vecSecNumber of the PLatexObj.
Definition: PLatexObj.cpp:438
Extends the std::string.
Definition: PString.h:16
PString vecNumberToString(const std::vector< long unsigned int > &vecNb)
Convert a vector of numbers into a string.
std::vector< PLatexObj > PVecLatexObj
Vector of obj.

References PLatexObj::getLabelName(), PLatexObj::getLink(), PLatexObj::getName(), PLatexObj::getVecContent(), PLatexObj::getVecSecNumber(), and vecNumberToString().

Referenced by updateLabelRef().

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

◆ useMapLabel() [1/2]

void useMapLabel ( PLatexObj obj,
const PMapLabel mapLabel 
)

Update the map of label.

Parameters
[out]obj: PLatexObj to be updated
mapLabel: map of label to be used

Definition at line 35 of file updateLabelRef.cpp.

35  {
36  if(obj.getType() == PLatexType::REF){
37  PMapLabel::const_iterator it(mapLabel.find(obj.getName()));
38  if(it != mapLabel.end()){
39  const PString & link = it->second.first;
40  obj.setLink(link);
41  obj.setName(it->second.second);
42  }else{
43  std::cerr << "useMapLabel : reference to '"<<obj.getName()<<"' not found" << std::endl;
44  }
45  }else{
46  useMapLabel(obj.getVecContent(), mapLabel);
48  useMapLabel(obj.getComplexTitle(), mapLabel);
49  }
50  }
51 }
void setLink(const PString &link)
Sets the link of the PLatexObj.
Definition: PLatexObj.cpp:165
const std::vector< PLatexObj > & getComplexTitle() const
Gets the complexTitle of the PLatexObj.
Definition: PLatexObj.cpp:396
const PLatexType::PLatexType & getType() const
Gets the type of the PLatexObj.
Definition: PLatexObj.cpp:298
void setName(const PString &name)
Sets the name of the PLatexObj.
Definition: PLatexObj.cpp:144
@ TIMETABLE_WEEK
Definition: PLatexType.h:99

References PLatexObj::getComplexTitle(), PLatexObj::getName(), PLatexObj::getType(), PLatexObj::getVecContent(), PLatexType::REF, PLatexObj::setLink(), PLatexObj::setName(), and PLatexType::TIMETABLE_WEEK.

Referenced by updateLabelRef(), and useMapLabel().

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

◆ useMapLabel() [2/2]

void useMapLabel ( std::vector< PLatexObj > &  vecObj,
const PMapLabel mapLabel 
)

Update the map of label.

Parameters
[out]obj: PLatexObj to be updated
mapLabel: map of label to be used

Definition at line 57 of file updateLabelRef.cpp.

57  {
58  for(std::vector<PLatexObj>::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
59  useMapLabel(*it, mapLabel);
60  }
61 }

References useMapLabel().

+ Here is the call graph for this function: