PhoenixLecture  2.0.0
Set of tools to make lectures
updateLabelCitation.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #include "convertToString.h"
8 #include "updateLabelCitation.h"
9 
11 
14 void useMapLabelCite(PLatexObj & obj, const PMapBiblioEntry & mapBiblioEntry){
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 }
47 
48 
50 
53 void updateLabelCitation(PLatexObj & obj, const PMapBiblioEntry & mapBiblioEntry){
54  useMapLabelCite(obj, mapBiblioEntry);
55 }
56 
57 
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
void setLink(const PString &link)
Sets the link of the PLatexObj.
Definition: PLatexObj.cpp:165
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
void setLabelName(const PString &labelName)
Sets the labelName of the PLatexObj.
Definition: PLatexObj.cpp:158
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 setName(const PString &name)
Sets the name of the PLatexObj.
Definition: PLatexObj.cpp:144
void setType(const PLatexType::PLatexType &type)
Sets the type of the PLatexObj.
Definition: PLatexObj.cpp:130
void setDate(const PString &date)
Sets the date of the PLatexObj.
Definition: PLatexObj.cpp:242
void setAuthor(const PString &author)
Sets the author of the PLatexObj.
Definition: PLatexObj.cpp:235
void setText(const PString &text)
Sets the text of the PLatexObj.
Definition: PLatexObj.cpp:137
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::map< PString, PBiblioEntry > PMapBiblioEntry
Describes the map for all PBiblioEntry.
std::vector< PLatexObj > PVecLatexObj
Vector of obj.
void useMapLabelCite(PLatexObj &obj, const PMapBiblioEntry &mapBiblioEntry)
Update the map of label.
void updateLabelCitation(PLatexObj &obj, const PMapBiblioEntry &mapBiblioEntry)
Update the label of the references.