Text::Text(InsetText * owner, Text const & text)
: owner_(owner), pars_(text.pars_)
{
- ParagraphList::iterator const end = pars_.end();
- ParagraphList::iterator it = pars_.begin();
- for (; it != end; ++it)
- it->setInsetOwner(owner);
+ for (auto & p : pars_)
+ p.setInsetOwner(owner);
}
// insert the string, don't insert doublespace
bool space_inserted = true;
- for (docstring::const_iterator cit = str.begin();
- cit != str.end(); ++cit) {
+ for (auto const & ch : str) {
Paragraph & par = pars_[pit];
- if (*cit == '\n') {
+ if (ch == '\n') {
if (inset().allowMultiPar() && (!par.empty() || par.allowEmpty())) {
lyx::breakParagraph(*this, pit, pos,
par.layout().isEnvironment());
continue;
}
// do not insert consecutive spaces if !free_spacing
- } else if ((*cit == ' ' || *cit == '\t') &&
+ } else if ((ch == ' ' || ch == '\t') &&
space_inserted && !par.isFreeSpacing()) {
continue;
- } else if (*cit == '\t') {
+ } else if (ch == '\t') {
if (!par.isFreeSpacing()) {
// tabs are like spaces here
par.insertChar(pos, ' ', font, bparams.track_changes);
++pos;
space_inserted = true;
} else {
- par.insertChar(pos, *cit, font, bparams.track_changes);
+ par.insertChar(pos, ch, font, bparams.track_changes);
++pos;
space_inserted = true;
}
- } else if (!isPrintable(*cit)) {
+ } else if (!isPrintable(ch)) {
// Ignore unprintables
continue;
} else {
// just insert the character
- par.insertChar(pos, *cit, font, bparams.track_changes);
+ par.insertChar(pos, ch, font, bparams.track_changes);
++pos;
- space_inserted = (*cit == ' ');
+ space_inserted = (ch == ' ');
}
}
setCursor(cur, pit, pos);
// ERT paragraphs have the Language latex_language.
// This is invalid outside of ERT, so we need to
// change it to the buffer language.
- ParagraphList::iterator it = plist.begin();
- ParagraphList::iterator it_end = plist.end();
- for (; it != it_end; ++it)
- it->changeLanguage(b.params(), latex_language, b.language());
+ for (auto & p : plist)
+ p.changeLanguage(b.params(), latex_language, b.language());
/* If the inset is the only thing in paragraph and the layout
* is not plain, then the layout of the first paragraph of
continue;
DocumentClass const & tc = buf.params().documentClass();
- DocumentClass::const_iterator lit = tc.begin();
- DocumentClass::const_iterator len = tc.end();
int const newtoclevel =
(mode == OutlineIn ? toclevel + 1 : toclevel - 1);
LabelType const oldlabeltype = start->layout().labeltype;
- for (; lit != len; ++lit) {
- if (lit->toclevel == newtoclevel &&
- lit->labeltype == oldlabeltype) {
- start->setLayout(*lit);
+ for (auto const & lay : tc) {
+ if (lay.toclevel == newtoclevel &&
+ lay.labeltype == oldlabeltype) {
+ start->setLayout(lay);
break;
}
}
// Insert auto-insert arguments
bool autoargs = false, inautoarg = false;
Layout::LaTeXArgMap args = cur.inset().getLayout().args();
- Layout::LaTeXArgMap::const_iterator lait = args.begin();
- Layout::LaTeXArgMap::const_iterator const laend = args.end();
- for (; lait != laend; ++lait) {
- Layout::latexarg arg = (*lait).second;
+ for (auto const & argt : args) {
+ Layout::latexarg arg = argt.second;
if (!inautoarg && arg.insertonnewline && cur.pos() > 0) {
FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
lyx::dispatch(cmd2);
lyx::dispatch(cmd2);
}
}
- FuncRequest cmd2(LFUN_ARGUMENT_INSERT, (*lait).first);
+ FuncRequest cmd2(LFUN_ARGUMENT_INSERT, argt.first);
lyx::dispatch(cmd2);
autoargs = true;
inautoarg = true;
case LFUN_SPELLING_ADD:
case LFUN_SPELLING_IGNORE:
case LFUN_SPELLING_REMOVE:
- enable = theSpellChecker() != NULL;
+ enable = theSpellChecker() != nullptr;
if (enable && !cmd.getArg(1).empty()) {
// validate explicitly given language
Language const * const lang = const_cast<Language *>(languages.getLanguage(cmd.getArg(1)));
- enable &= lang != NULL;
+ enable &= lang != nullptr;
}
break;
{
vector<docstring> ffList;
- FontStack::const_iterator cit = freeFonts.begin();
- FontStack::const_iterator end = freeFonts.end();
- for (; cit != end; ++cit)
- // we do not use cit-> here because gcc 2.9x does not
- // like it (JMarc)
- ffList.push_back((*cit).first);
+ for (auto const & f : freeFonts)
+ ffList.push_back(f.first);
return ffList;
}
if (lexrc.next()) {
vector<string> const dbs =
getVectorFromString(rtrim(lexrc.getString()), "|");
- vector<string>::const_iterator it = dbs.begin();
- vector<string>::const_iterator end = dbs.end();
- for (; it != end; ++it) {
- if (!contains(*it, ':')) {
+ for (auto const & dbase : dbs) {
+ if (!contains(dbase, ':')) {
vector<string> const enginetypes =
getVectorFromString(opt_enginetype_, "|");
- for (string const &s: enginetypes)
- cite_default_biblio_style_[s] = *it;
+ for (string const & s: enginetypes)
+ cite_default_biblio_style_[s] = dbase;
} else {
string eng;
- string const db = split(*it, eng, ':');
+ string const db = split(dbase, eng, ':');
cite_default_biblio_style_[eng] = db;
}
}
min_toclevel_ = Layout::NOT_IN_TOC;
max_toclevel_ = Layout::NOT_IN_TOC;
- const_iterator lit = begin();
- const_iterator len = end();
- for (; lit != len; ++lit) {
- int const toclevel = lit->toclevel;
+ for (auto const & lay : *this) {
+ int const toclevel = lay.toclevel;
if (toclevel != Layout::NOT_IN_TOC) {
if (min_toclevel_ == Layout::NOT_IN_TOC)
min_toclevel_ = toclevel;
cs.cmd = latex_cmd.empty() ? lyx_cmd : latex_cmd;
if (!alias.empty()) {
vector<string> const aliases = getVectorFromString(alias);
- for (string const &s: aliases)
+ for (string const & s: aliases)
cite_command_aliases_[s] = lyx_cmd;
}
vector<string> const stardescs = getVectorFromString(stardesc, "!");
if (!usesfloat && listcommand.empty()) {
// if this float uses the same auxfile as an existing one,
// there is no need for it to provide a list command.
- FloatList::const_iterator it = floatlist_.begin();
- FloatList::const_iterator en = floatlist_.end();
bool found_ext = false;
- for (; it != en; ++it) {
- if (it->second.ext() == ext) {
+ for (auto const & f : floatlist_) {
+ if (f.second.ext() == ext) {
found_ext = true;
break;
}
if (it == end()) {
LYXERR0("We failed to find the layout '" << name
<< "' in the layout list. You MUST investigate!");
- for (const_iterator cit = begin(); cit != end(); ++cit)
- lyxerr << " " << to_utf8(cit->name()) << endl;
+ for (auto const & lay : *this)
+ lyxerr << " " << to_utf8(lay.name()) << endl;
// We require the name to exist
static const Layout dummy;
if (it == end()) {
LYXERR0("We failed to find the layout '" << to_utf8(name)
<< "' in the layout list. You MUST investigate!");
- for (const_iterator cit = begin(); cit != end(); ++cit)
- LYXERR0(" " << to_utf8(cit->name()));
+ for (auto const & lay : *this)
+ LYXERR0(" " << to_utf8(lay.name()));
// we require the name to exist
LATTEST(false);
{
ostringstream os;
bool first = true;
- const_iterator const e = end();
- for (const_iterator i = begin(); i != e; ++i) {
- if (i->forcelocal > 0) {
+ for (auto const & lay : *this) {
+ if (lay.forcelocal > 0) {
if (first) {
os << "Format " << LAYOUT_FORMAT << '\n';
first = false;
}
- i->write(os);
+ lay.write(os);
}
}
return os.str();
Layout TextClass::createBasicLayout(docstring const & name, bool unknown) const
{
- static Layout * defaultLayout = NULL;
+ static Layout * defaultLayout = nullptr;
if (defaultLayout) {
defaultLayout->setUnknown(unknown);
{
DocumentClassPtr doc_class =
DocumentClassPtr(new DocumentClass(baseClass));
- LayoutModuleList::const_iterator it = modlist.begin();
- LayoutModuleList::const_iterator en = modlist.end();
- for (; it != en; ++it) {
- string const modName = *it;
- LyXModule * lm = theModuleList[modName];
+ for (auto const & mod : modlist) {
+ LyXModule * lm = theModuleList[mod];
if (!lm) {
docstring const msg =
bformat(_("The module %1$s has been requested by\n"
"this document but has not been found in the list of\n"
"available modules. If you recently installed it, you\n"
- "probably need to reconfigure LyX.\n"), from_utf8(modName));
+ "probably need to reconfigure LyX.\n"), from_utf8(mod));
if (!clone)
frontend::Alert::warning(_("Module not available"), msg);
continue;
"Missing prerequisites:\n"
"\t%2$s\n"
"See section 3.1.2.3 (Modules) of the User's Guide for more information."),
- from_utf8(modName), prereqs);
+ from_utf8(mod), prereqs);
frontend::Alert::warning(_("Package not available"), msg, true);
}
FileName layout_file = libFileSearch("layouts", lm->getFilename());
if (!doc_class->read(layout_file, TextClass::MODULE)) {
docstring const msg =
- bformat(_("Error reading module %1$s\n"), from_utf8(modName));
+ bformat(_("Error reading module %1$s\n"), from_utf8(mod));
frontend::Alert::warning(_("Read Error"), msg);
}
}
bool DocumentClass::hasLaTeXLayout(std::string const & lay) const
{
- LayoutList::const_iterator it = layoutlist_.begin();
- LayoutList::const_iterator end = layoutlist_.end();
- for (; it != end; ++it)
- if (it->latexname() == lay)
+ for (auto const & l : layoutlist_)
+ if (l.latexname() == lay)
return true;
return false;
}
Layout const & DocumentClass::getTOCLayout() const
{
// we're going to look for the layout with the minimum toclevel
- TextClass::LayoutList::const_iterator lit = begin();
- TextClass::LayoutList::const_iterator const len = end();
int minlevel = 1000;
- Layout const * lay = NULL;
- for (; lit != len; ++lit) {
- int const level = lit->toclevel;
+ Layout const * lay = nullptr;
+ for (auto const & l : *this) {
+ int const level = l.toclevel;
// we don't want Part or unnumbered sections
if (level == Layout::NOT_IN_TOC || level < 0
- || level >= minlevel || lit->counter.empty())
+ || level >= minlevel || l.counter.empty())
continue;
- lay = &*lit;
+ lay = &l;
minlevel = level;
}
if (lay)
CiteEngineType const & type) const
{
vector<CitationStyle> const styles = citeStyles(type);
- vector<CitationStyle>::const_iterator it = styles.begin();
- vector<CitationStyle>::const_iterator end = styles.end();
vector<string> cmds;
- for (; it != end; ++it) {
- CitationStyle const cite = *it;
- cmds.push_back(cite.name);
- }
+ for (auto const & cs : styles)
+ cmds.push_back(cs.name);
+
return cmds;
}