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

Go to the source code of this file.

Functions

void addSectionInVecPtrSection (PLatexObj &out, PVecPtrSection &vecPtrSection, PLatexObj &sec)
 Add a section into the vecPtrSection. More...
 
PLatexObj platexobj_order (PLatexObj &obj)
 Order the PLatexObj in part,chapter,section,subsection,subsubsection. More...
 

Function Documentation

◆ addSectionInVecPtrSection()

void addSectionInVecPtrSection ( PLatexObj out,
PVecPtrSection vecPtrSection,
PLatexObj sec 
)

Add a section into the vecPtrSection.

Parameters
[out]out: output sorted PLatexObj
[out]vecPtrSection: vector of section pointer to be updated
sec: input section

Definition at line 60 of file platexobj_order.cpp.

60  {
61  if(vecPtrSection.size() != 0lu){
62  PLatexObj & parentSec = *vecPtrSection.back();
63  long unsigned int currentLevel(getSectionLevel(parentSec));
64  long unsigned int secLevel(getSectionLevel(sec));
65 // std::cout << "addSectionInVecPtrSection : currentLevel = " << currentLevel << ", secLevel = " << secLevel << std::endl;
66 
67  if(currentLevel < secLevel){
68  PLatexMenu & parentSecMenu = sec.getParentSec();
69  parentSecMenu.setLink(parentSec.getLink());
70  parentSecMenu.setText(parentSec.getName());
71 
72  parentSec.getVecContent().push_back(sec);
73  vecPtrSection.push_back(&(parentSec.getVecContent().back()));
74  }else{
75  platexobj_orderGetSmallerLevel(vecPtrSection, secLevel);
76 
77  if(vecPtrSection.size() == 0lu){
78  PLatexMenu & parentSecMenu = sec.getParentSec();
79  parentSecMenu.setLink(out.getLink());
80  parentSecMenu.setText(out.getName());
81 
82  out.getVecContent().push_back(sec);
83  vecPtrSection.push_back(&(out.getVecContent().back()));
84  }else{
85  PLatexObj* lastSec = vecPtrSection.back();
86 
87  PLatexMenu & parentSecMenu = sec.getParentSec();
88  parentSecMenu.setLink(lastSec->getLink());
89  parentSecMenu.setText(lastSec->getName());
90 
91  lastSec->getVecContent().push_back(sec);
92  vecPtrSection.push_back(&(lastSec->getVecContent().back()));
93  }
94  }
95  }else{
96  PLatexMenu & parentSecMenu = sec.getParentSec();
97  parentSecMenu.setLink(out.getLink());
98  parentSecMenu.setText(out.getName());
99 
100  out.getVecContent().push_back(sec);
101  vecPtrSection.push_back(&(out.getVecContent().back()));
102  }
103 }
Describe a menu entry.
Definition: PLatexObj.h:17
void setText(const PString &text)
Sets the text of the PLatexMenu.
Definition: PLatexObj.cpp:48
void setLink(const PString &link)
Sets the link of the PLatexMenu.
Definition: PLatexObj.cpp:41
Describe a latex object.
Definition: PLatexObj.h:40
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
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 PLatexMenu & getParentSec() const
Gets the parentSec of the PLatexObj.
Definition: PLatexObj.cpp:494
void platexobj_orderGetSmallerLevel(PVecPtrSection &vecPtrSection, long unsigned int level)
Erase all the higher level from vecPtrSection.
long unsigned int getSectionLevel(const PLatexObj &obj)
Return the section level.

References PLatexObj::getLink(), PLatexObj::getName(), PLatexObj::getParentSec(), getSectionLevel(), PLatexObj::getVecContent(), platexobj_orderGetSmallerLevel(), PLatexMenu::setLink(), and PLatexMenu::setText().

Referenced by platexobj_order().

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

◆ platexobj_order()

PLatexObj platexobj_order ( PLatexObj obj)

Order the PLatexObj in part,chapter,section,subsection,subsubsection.

Parameters
[out]obj: PLatexObj to be reordered
Returns
PLatexObj sorted

Definition at line 109 of file platexobj_order.cpp.

109  {
110  PLatexObj out;
111  out.setType(obj.getType());
112  out.setLink(obj.getLink());
113  out.setName(obj.getName());
114  out.setAuthor(obj.getAuthor());
115  out.setDate(obj.getDate());
116  out.setSubTitle(obj.getSubTitle());
117  out.setSourceFile(obj.getSourceFile());
118  out.setSourceLine(obj.getSourceLine());
119 
120  PVecLatexObj & vecObj = obj.getVecContent();
121 
122  PVecPtrSection vecPtrSection;
123 
124  for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
125  if(isSeparator(*it)){
126  addSeparatorInVecPtrSection(out, vecPtrSection, *it);
127  }else if(isSection(*it)){
128  addSectionInVecPtrSection(out, vecPtrSection, *it);
129  }else{
130  if(vecPtrSection.size() == 0lu){
131  out.getVecContent().push_back(*it);
132  }else{
133  vecPtrSection.back()->getVecContent().push_back(*it);
134  }
135  }
136  }
137  return out;
138 }
void setLink(const PString &link)
Sets the link of the PLatexObj.
Definition: PLatexObj.cpp:165
void setSourceFile(const PString &sourceFile)
Sets the sourceFile of the PLatexObj.
Definition: PLatexObj.cpp:249
const PString & getSubTitle() const
Gets the subTitle of the PLatexObj.
Definition: PLatexObj.cpp:340
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
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
const PString & getAuthor() const
Gets the author of the PLatexObj.
Definition: PLatexObj.cpp:508
const PString & getSourceFile() const
Gets the sourceFile of the PLatexObj.
Definition: PLatexObj.cpp:536
size_t getSourceLine() const
Gets the sourceLine of the PLatexObj.
Definition: PLatexObj.cpp:550
void setAuthor(const PString &author)
Sets the author of the PLatexObj.
Definition: PLatexObj.cpp:235
void setSourceLine(size_t sourceLine)
Sets the sourceLine of the PLatexObj.
Definition: PLatexObj.cpp:256
const PString & getDate() const
Gets the date of the PLatexObj.
Definition: PLatexObj.cpp:522
void setSubTitle(const PString &subTitle)
Sets the subTitle of the PLatexObj.
Definition: PLatexObj.cpp:151
void addSectionInVecPtrSection(PLatexObj &out, PVecPtrSection &vecPtrSection, PLatexObj &sec)
Add a section into the vecPtrSection.
void addSeparatorInVecPtrSection(PLatexObj &out, PVecPtrSection &vecPtrSection, PLatexObj &separator)
Add a section into the vecPtrSection.
bool isSection(const PLatexObj &obj)
Say if the PLatexObj is a part, charpter, section, subsection or subsubsection.
bool isSeparator(const PLatexObj &obj)
Say if the PLatexObj is a book separator.
std::vector< PLatexObj > PVecLatexObj
Vector of obj.
std::vector< PLatexObj * > PVecPtrSection
Vector of section pointer.

References addSectionInVecPtrSection(), addSeparatorInVecPtrSection(), PLatexObj::getAuthor(), PLatexObj::getDate(), PLatexObj::getLink(), PLatexObj::getName(), PLatexObj::getSourceFile(), PLatexObj::getSourceLine(), PLatexObj::getSubTitle(), PLatexObj::getType(), PLatexObj::getVecContent(), isSection(), isSeparator(), PLatexObj::setAuthor(), PLatexObj::setDate(), PLatexObj::setLink(), PLatexObj::setName(), PLatexObj::setSourceFile(), PLatexObj::setSourceLine(), PLatexObj::setSubTitle(), and PLatexObj::setType().

Referenced by processAllFile().

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