string const full_author_string = to_utf8(name + email);
// Bernstein's hash function
unsigned int hash = 5381;
- for (unsigned int i = 0; i < full_author_string.length(); ++i)
- hash = ((hash << 5) + hash) + (unsigned int)(full_author_string[i]);
+ for (char c : full_author_string)
+ hash = ((hash << 5) + hash) + (unsigned int)c;
return int(hash);
}
docstring uncodable_glyphs;
Encoding const * const enc = runparams.encoding;
if (enc) {
- for (size_t n = 0; n < inputpath.size(); ++n) {
- if (!enc->encodable(inputpath[n])) {
- docstring const glyph(1, inputpath[n]);
+ for (char_type n : inputpath) {
+ if (!enc->encodable(n)) {
+ docstring const glyph(1, n);
LYXERR0("Uncodable character '"
<< glyph
<< "' in input path!");
docstring options_encodable;
Encoding const * const enc = features.runparams().encoding;
if (enc) {
- for (size_t n = 0; n < strOptions.size(); ++n) {
- char_type c = strOptions[n];
+ for (char_type c : strOptions) {
if (!enc->encodable(c)) {
docstring const glyph(1, c);
LYXERR0("Uncodable character '"
docstring uncodable_glyphs;
Encoding const * const enc = features.runparams().encoding;
if (enc) {
- for (size_t n = 0; n < preamble.size(); ++n) {
- char_type c = preamble[n];
+ for (char_type c : preamble) {
if (!enc->encodable(c)) {
docstring const glyph(1, c);
LYXERR0("Uncodable character '"
docstring result;
docstring uncodable;
bool terminate = false;
- for (size_t n = 0; n < input.size(); ++n) {
- char_type const c = input[n];
+ for (char_type const c : input) {
try {
pair<docstring, bool> latex_char = latexChar(c);
docstring const latex = latex_char.first;
if (dryrun) {
result += "<" + _("LyX Warning: ")
+ _("uncodable character") + " '";
- result += docstring(1, input[n]);
+ result += docstring(1, c);
result += "'>";
} else
- uncodable += input[n];
+ uncodable += c;
}
}
return make_pair(result, uncodable);
} else if (prefixIs(flag, "force=")) {
vector<string> encs =
getVectorFromString(flag.substr(6), ";");
- for (size_t i = 0; i < encs.size(); ++i)
- forcedselected[encs[i]].insert(symbol);
+ for (auto const & enc : encs)
+ forcedselected[enc].insert(symbol);
flags |= CharInfoForceSelected;
} else if (prefixIs(flag, "force!=")) {
vector<string> encs =
getVectorFromString(flag.substr(7), ";");
- for (size_t i = 0; i < encs.size(); ++i)
- forcednotselected[encs[i]].insert(symbol);
+ for (auto const & enc : encs)
+ forcednotselected[enc].insert(symbol);
flags |= CharInfoForceSelected;
} else if (flag == "mathalpha") {
mathalpha.insert(symbol);
"named"
};
-int const nb_bibliofeatures = sizeof(bibliofeatures) / sizeof(char const *);
-
-int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
-
} // namespace
// These are all the 'simple' includes. i.e
// packages which we just \usepackage{package}
- for (int i = 0; i < nb_simplefeatures; ++i) {
- if (mustProvide(simplefeatures[i]))
- packages << "\\usepackage{" << simplefeatures[i] << "}\n";
+ for (char const * feature : simplefeatures) {
+ if (mustProvide(feature))
+ packages << "\\usepackage{" << feature << "}\n";
}
// The rest of these packages are somewhat more complicated
packages << "\\usepackage{esint}\n";
// Known bibliography packages (simple \usepackage{package})
- for (int i = 0; i < nb_bibliofeatures; ++i) {
- if (mustProvide(bibliofeatures[i]))
- packages << "\\usepackage{"
- << bibliofeatures[i] << "}\n";
+ for (char const * feature : bibliofeatures) {
+ if (mustProvide(feature))
+ packages << "\\usepackage{" << feature << "}\n";
}
// Compatibility between achicago and natbib
{
// Check whether name can be encoded in the buffer encoding
bool encodable = true;
- for (size_t i = 0; i < name.size(); ++i) {
- if (!enc.encodable(name[i])) {
+ for (char_type c : name) {
+ if (!enc.encodable(c)) {
encodable = false;
break;
}
&& LaTeXFeatures::isAvailable(to_ascii(package_)))
return true;
else if (!altfonts_.empty()) {
- for (size_t i = 0; i < altfonts_.size(); ++i) {
- if (altFont(altfonts_[i]).available(ot1, nomath))
+ for (auto const & name : altfonts_) {
+ if (altFont(name).available(ot1, nomath))
return true;
}
}
else if (provides_.empty())
return false;
- for (size_t i = 0; i < provides_.size(); ++i) {
- if (provides_[i] == name)
+ for (auto const & provide : provides_) {
+ if (provide == name)
return true;
}
return false;
return name_;
}
else if (!altfonts_.empty()) {
- for (size_t i = 0; i < altfonts_.size(); ++i) {
- LaTeXFont altf = altFont(altfonts_[i]);
+ for (auto const & name : altfonts_) {
+ LaTeXFont altf = altFont(name);
if (altf.available(ot1, nomath))
return altf.getUsedFont(ot1, complete, nomath, osf);
}
docstring const hs = from_utf8(hyperset);
bool need_unicode = false;
if (enc) {
- for (size_t n = 0; n < hs.size(); ++n) {
- if (!enc->encodable(hs[n]))
+ for (char_type h : hs) {
+ if (!enc->encodable(h))
need_unicode = true;
}
}
}
int erasePos = pos - changes.size();
- for (size_t i = 0; i < changes.size(); i++) {
- insertChar(pos, changes[i].first,
- changes[i].second,
- trackChanges);
+ for (auto const & change : changes) {
+ insertChar(pos, change.first, change.second, trackChanges);
if (!eraseChar(erasePos, trackChanges)) {
++erasePos;
++pos; // advance
void LastOpenedSection::write(ostream & os) const
{
os << '\n' << sec_lastopened << '\n';
- for (size_t i = 0; i < lastopened.size(); ++i)
- os << lastopened[i].active << ", " << lastopened[i].file_name << '\n';
+ for (auto const & last : lastopened)
+ os << last.active << ", " << last.file_name << '\n';
}
// currently, we even crash in some cases (see #9483).
// FIXME: Add session support for multiple views of
// the same buffer (split-view etc.).
- for (size_t i = 0; i < lastopened.size(); ++i) {
- if (lastopened[i].file_name == file)
+ for (auto const & last : lastopened) {
+ if (last.file_name == file)
return;
}
lastopened.push_back(lof);
tmp.accent = accent;
kmod_list_[accent] = tmp;
- for (docstring::size_type i = 0; i < keys.length(); ++i) {
+ for (char_type key : keys) {
// FIXME This is a hack.
// tmp is no valid UCS4 string, but misused to store the
// accent.
docstring tmpd;
tmpd += char_type(0);
tmpd += char_type(accent);
- keymap_[keys[i]] = tmpd;
+ keymap_[key] = tmpd;
}
}
public:
typedef QList<CheckedLineEdit> CheckedWidgetList;
- Private()
- : okay_(nullptr), apply_(nullptr), cancel_(nullptr),
- restore_(nullptr), auto_apply_(nullptr), default_(nullptr),
- policy_(ButtonPolicy::IgnorantPolicy)
- {}
+ Private() {}
/// \return true if all CheckedWidgets are in a valid state.
bool checkWidgets() const
public:
CheckedWidgetList checked_widgets_;
- QPushButton * okay_;
- QPushButton * apply_;
- QPushButton * cancel_;
- QPushButton * restore_;
- QCheckBox * auto_apply_;
- QPushButton * default_;
+ QPushButton * okay_ = nullptr;
+ QPushButton * apply_ = nullptr;
+ QPushButton * cancel_ = nullptr;
+ QPushButton * restore_ = nullptr;
+ QCheckBox * auto_apply_ = nullptr;
+ QPushButton * default_ = nullptr;
typedef QList<QWidget *> Widgets;
Widgets read_only_;
- ButtonPolicy policy_;
+ ButtonPolicy policy_ {ButtonPolicy::IgnorantPolicy};
};
{}
-Dialog::~Dialog()
-{}
-
-
bool Dialog::canApply() const
{
FuncRequest const fr(getLfun(), fromqstr(name_));
/// \param title is the window title used for decoration.
Dialog(GuiView & lv, QString const & name, QString const & title);
- virtual ~Dialog();
+ virtual ~Dialog() {}
virtual QWidget * asQWidget() = 0;
virtual QWidget const * asQWidget() const = 0;
}
}
-FancyLineEdit::~FancyLineEdit()
-{
-}
-
void FancyLineEdit::setButtonVisible(Side side, bool visible)
{
m_d->m_iconbutton[side]->setVisible(visible);
public:
explicit FancyLineEdit(QWidget *parent = 0);
- ~FancyLineEdit();
+ ~FancyLineEdit() {}
QPixmap buttonPixmap(Side side) const;
void setButtonPixmap(Side side, const QPixmap &pixmap);
// do not add to the lastfile list since these files are restored from
// last session, and should be already there (regular files), or should
// not be added at all (help files).
- for (size_t i = 0; i < lastopened.size(); ++i) {
- FileName const & file_name = lastopened[i].file_name;
+ for (auto const & last : lastopened) {
+ FileName const & file_name = last.file_name;
if (!current_view_ || (!lyxrc.open_buffers_in_tabs
&& current_view_->documentBufferView() != 0)) {
boost::crc_32_type crc;
}
current_view_->loadDocument(file_name, false);
- if (lastopened[i].active)
+ if (last.active)
active_file = file_name;
}
selected_model_.match(selected_model_.index(0, 1),
Qt::DisplayRole, toqstr(key), -1,
Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap));
- for (int i = 0; i < qmil.size(); ++i){
- QModelIndex idx = qmil[i];
+ for (auto const & idx : qmil) {
if (!handled.contains(idx)) {
selected_model_.setItem(idx.row(), 0, si);
handled.append(idx);
selected_model_.match(selected_model_.index(0, 1),
Qt::DisplayRole, toqstr(key), -1,
Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap));
- for (int i = 0; i < qmil.size(); ++i){
- QModelIndex idx = qmil[i];
+ for (auto const & idx : qmil) {
if (!handled.contains(idx)) {
selected_model_.setItem(idx.row(), 2, si);
handled.append(idx);
QFontDatabase fontdb;
QStringList families(fontdb.families());
- for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
- fontModule->fontsRomanCO->addItem(*it, *it);
- fontModule->fontsSansCO->addItem(*it, *it);
- fontModule->fontsTypewriterCO->addItem(*it, *it);
+ for (auto const & family : families) {
+ fontModule->fontsRomanCO->addItem(family, family);
+ fontModule->fontsSansCO->addItem(family, family);
+ fontModule->fontsTypewriterCO->addItem(family, family);
}
return;
}
int nn = 0;
- for (size_t i = 0; i < pagestyles.size(); ++i)
- if (pagestyles[i].first == sel)
- nn = pageLayoutModule->pagestyleCO->findText(pagestyles[i].second);
+ for (auto const & pagestyle : pagestyles)
+ if (pagestyle.first == sel)
+ nn = pageLayoutModule->pagestyleCO->findText(pagestyle.second);
if (nn > 0)
pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
QTreeWidgetItem * subcatItem = nullptr;
if (cats.contains(catsave)) {
QList<QTreeWidgetItem *> pcats = filesLW->findItems(cat, Qt::MatchExactly);
- for (int iit = 0; iit < pcats.size(); ++iit) {
- for (int cit = 0; cit < pcats.at(iit)->childCount(); ++cit) {
- if (pcats.at(iit)->child(cit)->text(0) == subcat) {
- subcatItem = pcats.at(iit)->child(cit);
+ for (auto const & pcat : pcats) {
+ for (int cit = 0; cit < pcat->childCount(); ++cit) {
+ if (pcat->child(cit)->text(0) == subcat) {
+ subcatItem = pcat->child(cit);
break;
}
}
QFontDatabase fontdb;
QStringList families(fontdb.families());
- for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
- screenRomanCO->addItem(*it);
- screenSansCO->addItem(*it);
- screenTypewriterCO->addItem(*it);
+ for (auto const & family : families) {
+ screenRomanCO->addItem(family);
+ screenSansCO->addItem(family);
+ screenTypewriterCO->addItem(family);
}
connect(screenRomanCO, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
if (tag == KeyMap::UserUnbind) {
QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(lfun_name,
Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
- for (int i = 0; i < items.size(); ++i) {
- if (items[i]->text(1) == shortcut) {
- newItem = items[i];
+ for (auto const & item : items) {
+ if (item->text(1) == shortcut) {
+ newItem = item;
break;
}
}
// list of items that match lfun
QList<QTreeWidgetItem*> items = shortcutsTW->findItems(lfun,
Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
- for (int i = 0; i < items.size(); ++i) {
- QTreeWidgetItem * item = items[i];
+ for (auto const & item : items) {
if (isAlwaysHidden(*item)) {
setItemType(item, KeyMap::System);
if (select)
// it seems that only one item can be selected, but I am
// removing all selected items anyway.
QList<QTreeWidgetItem*> items = shortcutsTW->selectedItems();
- for (int i = 0; i < items.size(); ++i) {
- string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
- string lfun = fromqstr(items[i]->text(0));
+ for (auto & item : items) {
+ string shortcut = fromqstr(item->data(1, Qt::UserRole).toString());
+ string lfun = fromqstr(item->text(0));
FuncRequest func = lyxaction.lookupFunc(lfun);
- switch (itemType(*items[i])) {
+ switch (itemType(*item)) {
case KeyMap::System: {
// for system bind, we do not touch the item
// but add an user unbind item
user_unbind_.bind(shortcut, func);
- setItemType(items[i], KeyMap::UserUnbind);
+ setItemType(item, KeyMap::UserUnbind);
removePB->setText(qt_("Res&tore"));
break;
}
case KeyMap::UserBind: {
// for user_bind, we remove this bind
- QTreeWidgetItem * parent = items[i]->parent();
- int itemIdx = parent->indexOfChild(items[i]);
+ QTreeWidgetItem * parent = item->parent();
+ int itemIdx = parent->indexOfChild(item);
parent->takeChild(itemIdx);
if (itemIdx > 0)
shortcutsTW->scrollToItem(parent->child(itemIdx - 1));
user_bind_.unbind(shortcut, func);
// If this user binding hid an empty system binding, unhide the
// latter and select it.
- unhideEmpty(items[i]->text(0), true);
+ unhideEmpty(item->text(0), true);
break;
}
case KeyMap::UserUnbind: {
if (!validateNewShortcut(func, seq, QString()))
break;
user_unbind_.unbind(shortcut, func);
- setItemType(items[i], KeyMap::System);
+ setItemType(item, KeyMap::System);
removePB->setText(qt_("Remo&ve"));
break;
}
case KeyMap::UserExtraUnbind: {
// for user unbind that is not in system bind file,
// remove this unbind file
- QTreeWidgetItem * parent = items[i]->parent();
- parent->takeChild(parent->indexOfChild(items[i]));
+ QTreeWidgetItem * parent = item->parent();
+ parent->takeChild(parent->indexOfChild(item));
user_unbind_.unbind(shortcut, func);
}
}
void PrefShortcuts::deactivateShortcuts(QList<QTreeWidgetItem*> const & items)
{
- for (int i = 0; i < items.size(); ++i) {
- string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
- string lfun = fromqstr(items[i]->text(0));
+ for (auto item : items) {
+ string shortcut = fromqstr(item->data(1, Qt::UserRole).toString());
+ string lfun = fromqstr(item->text(0));
FuncRequest func = lyxaction.lookupFunc(lfun);
- switch (itemType(*items[i])) {
+ switch (itemType(*item)) {
case KeyMap::System:
// for system bind, we do not touch the item
// but add an user unbind item
user_unbind_.bind(shortcut, func);
- setItemType(items[i], KeyMap::UserUnbind);
+ setItemType(item, KeyMap::UserUnbind);
break;
case KeyMap::UserBind: {
// for user_bind, we remove this bind
- QTreeWidgetItem * parent = items[i]->parent();
- int itemIdx = parent->indexOfChild(items[i]);
+ QTreeWidgetItem * parent = item->parent();
+ int itemIdx = parent->indexOfChild(item);
parent->takeChild(itemIdx);
user_bind_.unbind(shortcut, func);
- unhideEmpty(items[i]->text(0), false);
+ unhideEmpty(item->text(0), false);
break;
}
default:
while (*it)
(*it++)->setHidden(true);
// show matched items
- for (int i = 0; i < matched.size(); ++i)
- if (!isAlwaysHidden(*matched[i])) {
- matched[i]->setHidden(false);
- if (matched[i]->parent())
- matched[i]->parent()->setExpanded(true);
+ for (auto & item : matched)
+ if (!isAlwaysHidden(*item)) {
+ item->setHidden(false);
+ if (item->parent())
+ item->parent()->setExpanded(true);
}
}
bool enabled = false;
QList<QAction *> acts = menu()->actions();
- for (int i = 0; i < acts.size(); ++i)
- if (acts[i]->isEnabled()) {
+ for (auto const & act : acts)
+ if (act->isEnabled()) {
enabled = true;
break;
}
// This is a speed bottleneck because this is called on every keypress
// and update calls getStatus, which copies the cursor at least two times
- for (int i = 0; i < actions_.size(); ++i)
- actions_[i]->update();
+ for (auto const & action : actions_)
+ action->update();
LayoutBox * layout = owner_.getLayoutDialog();
if (layout)
immediateApplyCB->setEnabled(ins && !read_only);
// This seems to be the only way to access custom buttons
QList<QAbstractButton*> buttons = buttonBox->buttons();
- for (int i = 0; i < buttons.size(); ++i) {
- if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::ActionRole)
- buttons.at(i)->setEnabled(widget_ok && !read_only
+ for (auto & button : buttons) {
+ if (buttonBox->buttonRole(button) == QDialogButtonBox::ActionRole)
+ button->setEnabled(widget_ok && !read_only
&& valid_argument
&& newInsetAllowed());
}
bool MenuDefinition::hasFunc(FuncRequest const & func) const
{
- for (const_iterator it = begin(), et = end(); it != et; ++it)
- if (*it->func() == func)
+ for (auto const & it : *this)
+ if (*it.func() == func)
return true;
return false;
}
// we can only output characters covered by the current
// encoding!
docstring uncodable;
- for (size_type i = 0 ; i < command.size() ; ++i) {
- char_type c = command[i];
+ for (char_type c : command) {
try {
if (runparams.encoding->encodable(c))
result += c;
// encoding!
docstring uncodable;
docstring encodable_file_path;
- for (size_type i = 0 ; i < file_path.size() ; ++i) {
- char_type c = file_path[i];
+ for (char_type c : file_path) {
try {
if (runparams.encoding->encodable(c))
encodable_file_path += c;
string const lcode = params_.lang->code();
docstring trans;
bool is_translated = sequence != seq_untranslated;
- for (size_t n = 0; n < sequence.size(); ++n) {
- char_type const c = sequence[n];
+ for (char_type const c : sequence) {
switch(c) {
case 0x21b5://Return
gui = _("Return[[Key]]");
return bformat(_("Please specify one or more of '%1$s'."),
from_utf8(info_));
}
- for (size_t i = 0; i < par2.size(); ++i)
- if (info_.find(par2[i], 0) == string::npos)
+ for (char c : par2)
+ if (info_.find(c, 0) == string::npos)
return bformat(_("Should be composed of one or more of %1$s."),
from_utf8(info_));
if (unclosed)
// non-ascii/number characters, just to be safe
else {
bool has_special_char = false;
- for (size_t i = 0; i < value.size(); ++i)
- if (!isAlnumASCII(value[i])) {
+ for (char c : value)
+ if (!isAlnumASCII(c)) {
has_special_char = true;
break;
}
const char delim = '|';
while (getline(s, name, delim)) {
size_t start = 0;
- for (size_t i = 0; i < param.size(); i++) {
- string key = name + "{" + param[i] + "}";
+ for (char c : param) {
+ string key = name + "{" + c + "}";
// get the corresponding utf8-value
if ((values[start] & 0xc0) != 0xc0) {
// should not happen, utf8 encoding starts at least with 11xxxxxx
InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh)
{
col_type col = 0;
- for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it)
- if (*it == 'c' || *it == 'l' || *it == 'r'||
- *it == 'p' || *it == 'm' || *it == 'b')
+ for (char_type const c : hh)
+ if (c == 'c' || c == 'l' || c == 'r'||
+ c == 'p' || c == 'm' || c == 'b')
++col;
// let's have at least one column, even if we did not recognize its
// alignment
InsetMathHull::~InsetMathHull()
{
- for (size_t i = 0; i < label_.size(); ++i)
- delete label_[i];
+ for (auto & i : label_)
+ delete i;
}
numbered_ = other.numbered_;
numbers_ = other.numbers_;
buffer_ = other.buffer_;
- for (size_t i = 0; i < label_.size(); ++i)
- delete label_[i];
+ for (auto & i : label_)
+ delete i;
label_ = other.label_;
for (size_t i = 0; i != label_.size(); ++i) {
if (label_[i])
case hullEqnArray:
break;
}
- for (size_t row = 0; row < numbered_.size(); ++row)
- if (numbered_[row] == NOTAG)
+ for (auto const & row : numbered_)
+ if (row == NOTAG)
return true;
return false;
}
// valid characters?
if (n.size() > 1) {
- for (size_t i = 0; i<n.size(); ++i) {
- if (!(n[i] >= 'a' && n[i] <= 'z')
- && !(n[i] >= 'A' && n[i] <= 'Z')
- && n[i] != '*')
+ for (char_type c : n) {
+ if (!(c >= 'a' && c <= 'z')
+ && !(c >= 'A' && c <= 'Z')
+ && c != '*')
return false;
}
}
// valid characters?
if (n.size() > 1) {
- for (size_t i = 0; i < n.size(); ++i) {
- if (!(n[i] >= 'a' && n[i] <= 'z')
- && !(n[i] >= 'A' && n[i] <= 'Z')
- && n[i] != '*')
+ for (char_type c : n) {
+ if (!(c >= 'a' && c <= 'z')
+ && !(c >= 'A' && c <= 'Z')
+ && c != '*')
return false;
}
}
// FIXME: Abdel 16/10/2006
// This drawT() method is never used, this is dead code.
- for (const_iterator it = begin(), et = end(); it != et; ++it) {
- (*it)->drawT(pain, x, y);
- //x += (*it)->width_;
+ for (auto const & it : *this) {
+ it->drawT(pain, x, y);
+ //x += it->width_;
x += 2;
}
}
cmd = Encodings::fromLaTeXCommand(cmd,
Encodings::MATH_CMD | Encodings::TEXT_CMD,
termination, rem);
- for (size_t i = 0; i < cmd.size(); ++i)
- cell->push_back(MathAtom(new InsetMathChar(cmd[i])));
+ for (char_type c : cmd)
+ cell->push_back(MathAtom(new InsetMathChar(c)));
if (!rem.empty()) {
char_type c = rem[0];
cell->push_back(MathAtom(new InsetMathChar(c)));
frontend::FontMetrics const & fm = theFontMetrics(font);
dim.asc = 0;
dim.des = 0;
- for (docstring::const_iterator it = s.begin();
- it != s.end();
- ++it) {
- dim.asc = max(dim.asc, fm.ascent(*it));
- dim.des = max(dim.des, fm.descent(*it));
+ for (char_type const c : s) {
+ dim.asc = max(dim.asc, fm.ascent(c));
+ dim.des = max(dim.des, fm.descent(c));
}
dim.wid = fm.width(s);
}
char_type hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
docstring enc;
- for (size_t i = 0; i < lab.length(); ++i) {
- char_type c = lab[i];
+ for (char_type const c : lab) {
if (c >= 128 || c == '=' || c == '%' || c == '#' || c == '$'
|| c == '}' || c == '{' || c == ']' || c == '[' || c == '&'
|| c == '\\') {
QString charFilterRegExp(QString const & filter)
{
QString re = ".*";
- for (int i = 0; i < filter.length(); ++i) {
- QChar c = filter[i];
+ for (QChar const & c : filter) {
if (c.isLower())
re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
else
QString charFilterRegExpC(QString const & filter)
{
QString re = "(";
- for (int i = 0; i < filter.length(); ++i) {
- QChar c = filter[i];
+ for (QChar const & c : filter) {
if (c.isLower())
re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
else
}
// Move the lines and alignment settings to the special field if
// necessary
- for (size_t col = 0; col < colinfo.size(); ++col)
- fix_colalign(colinfo[col]);
+ for (auto & col : colinfo)
+ fix_colalign(col);
}
void handle_hline_above(RowInfo & ri, vector<CellInfo> & ci)
{
ri.topline = true;
- for (size_t col = 0; col < ci.size(); ++col)
- ci[col].topline = true;
+ for (auto & col : ci)
+ col.topline = true;
}
void handle_hline_below(RowInfo & ri, vector<CellInfo> & ci)
{
ri.bottomline = true;
- for (size_t col = 0; col < ci.size(); ++col)
- ci[col].bottomline = true;
+ for (auto & col : ci)
+ col.bottomline = true;
}
//cerr << "// output what we have\n";
// output what we have
size_type cols = colinfo.size();
- for (size_t col = 0; col < colinfo.size(); ++col) {
- if (colinfo[col].decimal_point != '\0' && colinfo[col].align != 'd')
+ for (auto const & col : colinfo) {
+ if (col.decimal_point != '\0' && col.align != 'd')
--cols;
}
os << "\n<lyxtabular version=\"3\" rows=\"" << rowinfo.size()
os << write_attribute("tabularwidth", tabularwidth) << ">\n";
//cerr << "// after header\n";
- for (size_t col = 0; col < colinfo.size(); ++col) {
- if (colinfo[col].decimal_point != '\0' && colinfo[col].align != 'd')
+ for (auto const & col : colinfo) {
+ if (col.decimal_point != '\0' && col.align != 'd')
continue;
os << "<column alignment=\""
- << verbose_align(colinfo[col].align) << "\"";
- if (colinfo[col].decimal_point != '\0')
- os << " decimal_point=\"" << colinfo[col].decimal_point << "\"";
+ << verbose_align(col.align) << "\"";
+ if (col.decimal_point != '\0')
+ os << " decimal_point=\"" << col.decimal_point << "\"";
os << " valignment=\""
- << verbose_valign(colinfo[col].valign) << "\""
- << write_attribute("width", translate_len(colinfo[col].width))
- << write_attribute("special", colinfo[col].special)
- << write_attribute("varwidth", colinfo[col].varwidth)
+ << verbose_valign(col.valign) << "\""
+ << write_attribute("width", translate_len(col.width))
+ << write_attribute("special", col.special)
+ << write_attribute("varwidth", col.varwidth)
<< ">\n";
}
//cerr << "// after cols\n";
// class may not be known before. It neds to be done before parsing
// body, since otherwise the commands/environments provided by the
// modules would be parsed as ERT.
- for (size_t i = 0; i < preloaded_modules.size(); ++i) {
- if (!addModule(preloaded_modules[i])) {
+ for (auto const & module : preloaded_modules) {
+ if (!addModule(module)) {
cerr << "Error: Could not load module \""
- << preloaded_modules[i] << "\"." << endl;
+ << module << "\"." << endl;
return false;
}
}
void output_ert(ostream & os, string const & s, Context & context)
{
context.check_layout(os);
- for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
- if (*it == '\\')
+ for (char const c : s) {
+ if (c == '\\')
os << "\n\\backslash\n";
- else if (*it == '\n') {
+ else if (c == '\n') {
context.new_paragraph(os);
context.check_layout(os);
} else
- os << *it;
+ os << c;
}
context.check_end_layout(os);
}