PhoenixLecture  2.0.0
Set of tools to make lectures
updateLabelCitation.cpp File Reference
+ Include dependency graph for updateLabelCitation.cpp:

Go to the source code of this file.

Functions

void updateLabelCitation (PLatexObj &obj, const PMapBiblioEntry &mapBiblioEntry)
 Update the label of the references. More...
 
void useMapLabelCite (PLatexObj &obj, const PMapBiblioEntry &mapBiblioEntry)
 Update the map of label. More...
 

Function Documentation

◆ updateLabelCitation()

void updateLabelCitation ( PLatexObj obj,
const PMapBiblioEntry mapBiblioEntry 
)

Update the label of the references.

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

Definition at line 53 of file updateLabelCitation.cpp.

53  {
54  useMapLabelCite(obj, mapBiblioEntry);
55 }
void useMapLabelCite(PLatexObj &obj, const PMapBiblioEntry &mapBiblioEntry)
Update the map of label.

References useMapLabelCite().

Referenced by processAllFile().

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

◆ useMapLabelCite()

void useMapLabelCite ( PLatexObj obj,
const PMapBiblioEntry mapBiblioEntry 
)

Update the map of label.

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

Definition at line 14 of file updateLabelCitation.cpp.

14  {
15  if(obj.getType() == PLatexType::CITATION){ //We find a citation
16  PString allCitation = obj.getName().eraseChar(" \n\t");
17  PVecString listCitation = allCitation.split(',');
18 
19  PVecLatexObj vecObjCitation;
20  for(PVecString::iterator it(listCitation.begin()); it != listCitation.end(); ++it){
21  PMapBiblioEntry::const_iterator itCite(mapBiblioEntry.find(*it)); //Let's find the corresponding article
22  if(itCite != mapBiblioEntry.end()){
23  const PBiblioEntry & bibiEntry = itCite->second;
24  PString link("bibliography.html#"+valueToString(bibiEntry.getId()));
25  PLatexObj tmpObjCitation(obj);
26  tmpObjCitation.setLink(link);
27  tmpObjCitation.setLabelName(obj.getName()); //Save the biblio entry label (maybe usefull in case of debugging)
28  tmpObjCitation.setName(bibiEntry.getTitle()); //Name becomes the title of the article
29  tmpObjCitation.setAuthor(bibiEntry.getAuthor()); //Author becomes the author of the article
30  tmpObjCitation.setDate(bibiEntry.getYear()); //Date becomes the year of the article
31  tmpObjCitation.setText(valueToString(bibiEntry.getId())); //Text becomes the id of the citation
32  vecObjCitation.push_back(tmpObjCitation);
33  }
34  }
35  if(vecObjCitation.size() == 1lu){
36  obj = vecObjCitation.front();
37  }
39  obj.setVecContent(vecObjCitation);
40  }else{
41  PVecLatexObj & vecObj = obj.getVecContent();
42  for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
43  useMapLabelCite(*it, mapBiblioEntry);
44  }
45  }
46 }
std::vector< PString > PVecString
Definition: PString.h:96
Entry in the bibliography.
Definition: PLatexObj.h:409
const PString & getAuthor() const
Gets the author of the PBiblioEntry.
Definition: PLatexObj.cpp:1935
const PString & getTitle() const
Gets the title of the PBiblioEntry.
Definition: PLatexObj.cpp:1949
const PString & getYear() const
Gets the year of the PBiblioEntry.
Definition: PLatexObj.cpp:2033
size_t getId() const
Gets the id of the PBiblioEntry.
Definition: PLatexObj.cpp:1893
Describe a latex object.
Definition: PLatexObj.h:40
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
void setVecContent(const std::vector< PLatexObj > &vecContent)
Sets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:186
const PLatexType::PLatexType & getType() const
Gets the type of the PLatexObj.
Definition: PLatexObj.cpp:298
const PString & getName() const
Gets the name of the PLatexObj.
Definition: PLatexObj.cpp:326
void setType(const PLatexType::PLatexType &type)
Sets the type of the PLatexObj.
Definition: PLatexObj.cpp:130
Extends the std::string.
Definition: PString.h:16
PString eraseChar(char ch) const
Erase char ch of current string.
Definition: PString.cpp:478
std::vector< PString > split(char separator) const
Cut a PString on the given separator char.
Definition: PString.cpp:420
std::string valueToString(const T &val)
Convert a type into a string.
std::vector< PLatexObj > PVecLatexObj
Vector of obj.

References PLatexType::CITATION, PString::eraseChar(), PBiblioEntry::getAuthor(), PBiblioEntry::getId(), PLatexObj::getName(), PBiblioEntry::getTitle(), PLatexObj::getType(), PLatexObj::getVecContent(), PBiblioEntry::getYear(), PLatexType::NONE, PLatexObj::setAuthor(), PLatexObj::setDate(), PLatexObj::setLabelName(), PLatexObj::setLink(), PLatexObj::setName(), PLatexObj::setText(), PLatexObj::setType(), PLatexObj::setVecContent(), PString::split(), and valueToString().

Referenced by updateLabelCitation().

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