Use empty() to check empty and non-empty'ness not size()

Also add FormatList::empty().
This commit is contained in:
Lars Gullik Bjønnes 2012-10-21 21:14:16 +02:00
parent 62394258da
commit 43f6b1672b
29 changed files with 106 additions and 107 deletions

View File

@ -66,7 +66,7 @@ docstring familyName(docstring const & name)
vector<docstring>::const_iterator it = pieces.begin();
vector<docstring>::const_iterator en = pieces.end();
for (; it != en; ++it) {
if ((*it).size() == 0)
if ((*it).empty())
continue;
char_type const c = (*it)[0];
if (isLower(c))
@ -99,7 +99,7 @@ docstring convertLaTeXCommands(docstring const & str)
bool scanning_cmd = false;
bool scanning_math = false;
bool escaped = false; // used to catch \$, etc.
while (val.size()) {
while (!val.empty()) {
char_type const ch = val[0];
// if we're scanning math, we output everything until we
@ -323,7 +323,7 @@ namespace {
fmt = fmt.substr(2);
// we'll remove characters from the front of fmt as we
// deal with them
while (fmt.size()) {
while (!fmt.empty()) {
if (fmt[0] == ']' && fmt.size() > 1 && fmt[1] == ']') {
// that's the end
fmt = fmt.substr(2);
@ -415,7 +415,7 @@ docstring BibTeXInfo::expandFormat(string const & format,
string fmt = format;
// we'll remove characters from the front of fmt as we
// deal with them
while (fmt.size()) {
while (!fmt.empty()) {
if (counter++ > max_passes) {
LYXERR0("Recursion limit reached while parsing `"
<< format << "'.");

View File

@ -588,7 +588,7 @@ void Cursor::checkNewWordPosition()
clearNewWordPosition();
else {
FontSpan nw = locateWord(WHOLE_WORD);
if (nw.size()) {
if (!nw.empty()) {
FontSpan ow = new_word_.locateWord(WHOLE_WORD);
if (nw.intersect(ow).empty())
clearNewWordPosition();
@ -1637,7 +1637,7 @@ bool Cursor::macroModeClose()
// we have to resolve the macro here manually and check its arity
// to put the selection behind it if arity > 0.
MacroData const * data = buffer()->getMacro(atomAsMacro->name());
if (selection.size() > 0 && data && data->numargs() - data->optionals() > 0) {
if (!selection.empty() && data && data->numargs() - data->optionals() > 0) {
macroArg = true;
atomAsMacro->setDisplayMode(MathMacro::DISPLAY_INTERACTIVE_INIT, 1);
} else

View File

@ -201,6 +201,8 @@ public:
///
const_iterator end() const { return formatlist.end(); }
///
bool empty() const { return formatlist.empty(); }
///
FormatList::size_type size() const { return formatlist.size(); }
private:
///

View File

@ -125,8 +125,7 @@ size_t KeySequence::parse(string const & s)
}
}
// empty sequence?
if (sequence.size() == 0)
if (sequence.empty())
return 0;
// everything is fine

View File

@ -3733,7 +3733,7 @@ SpellChecker::Result Paragraph::spellCheck(pos_type & from, pos_type & to,
wl = WordLangTuple(word, lang);
if (!word.size())
if (word.empty())
return result;
if (needsSpellCheck() || check_learned) {
@ -3830,7 +3830,7 @@ void Paragraph::Private::markMisspelledWords(
void Paragraph::spellCheck() const
{
SpellChecker * speller = theSpellChecker();
if (!speller || !size() ||!needsSpellCheck())
if (!speller || empty() ||!needsSpellCheck())
return;
pos_type start;
pos_type endpos;

View File

@ -462,7 +462,7 @@ docstring clientName =
int n(vector<docstring> const & arg)
{
if (arg.size() < 1) {
if (arg.empty()) {
cerr << "lyxclient: The option -n requires 1 argument."
<< endl;
return -1;
@ -477,7 +477,7 @@ docstring singleCommand;
int c(vector<docstring> const & arg)
{
if (arg.size() < 1) {
if (arg.empty()) {
cerr << "lyxclient: The option -c requires 1 argument."
<< endl;
return -1;
@ -507,7 +507,7 @@ docstring serverAddress;
int a(vector<docstring> const & arg)
{
if (arg.size() < 1) {
if (arg.empty()) {
cerr << "lyxclient: The option -a requires 1 argument."
<< endl;
return -1;
@ -522,7 +522,7 @@ int a(vector<docstring> const & arg)
int t(vector<docstring> const & arg)
{
if (arg.size() < 1) {
if (arg.empty()) {
cerr << "lyxclient: The option -t requires 1 argument."
<< endl;
return -1;
@ -537,7 +537,7 @@ string serverPid; // Init to empty string
int p(vector<docstring> const & arg)
{
if (arg.size() < 1) {
if (arg.empty()) {
cerr << "lyxclient: The option -p requires 1 argument."
<< endl;
return -1;

View File

@ -1678,7 +1678,7 @@ void PrefConverters::changeConverter()
void PrefConverters::updateButtons()
{
if (form_->formats().size() == 0)
if (form_->formats().empty())
return;
Format const & from = form_->formats().get(converterFromCO->currentIndex());
Format const & to = form_->formats().get(converterToCO->currentIndex());
@ -1975,7 +1975,7 @@ void PrefFileformats::updateView()
void PrefFileformats::on_formatsCB_currentIndexChanged(int i)
{
if (form_->formats().size() == 0)
if (form_->formats().empty())
return;
int const nr = formatsCB->itemData(i).toInt();
Format const f = form_->formats().get(nr);

View File

@ -99,7 +99,7 @@ Action * GuiToolbar::addItem(ToolbarItem const & item)
// Get the keys bound to this action, but keep only the
// first one later
KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(item.func_);
if (bindings.size())
if (!bindings.empty())
text += " [" + toqstr(bindings.begin()->print(KeySequence::ForGui)) + "]";
Action * act = new Action(&owner_, getIcon(item.func_, false),

View File

@ -241,7 +241,7 @@ public:
// Get the keys bound to this action, but keep only the
// first one later
KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(func_);
if (bindings.size())
if (!bindings.empty())
return toqstr(bindings.begin()->print(KeySequence::ForGui));
LYXERR(Debug::KBMAP, "No binding for "
@ -1301,7 +1301,7 @@ void MenuDefinition::expandToc(Buffer const * buf)
if (cit == end)
LYXERR(Debug::GUI, "No table of contents.");
else {
if (cit->second.size() > 0 )
if (!cit->second.empty())
expandToc2(cit->second, 0, cit->second.size(), 0);
else
add(MenuItem(MenuItem::Info, qt_("<Empty Table of Contents>")));
@ -1574,7 +1574,7 @@ static QString label(MenuItem const & mi)
void Menu::Impl::populate(QMenu & qMenu, MenuDefinition const & menu)
{
LYXERR(Debug::GUI, "populating menu " << menu.name());
if (menu.size() == 0) {
if (menu.empty()) {
LYXERR(Debug::GUI, "\tERROR: empty menu " << menu.name());
return;
}
@ -1759,7 +1759,7 @@ void Menus::Impl::macxMenuBarInit(GuiView * view, QMenuBar * qmb)
{LFUN_LYX_QUIT, "", "Quit LyX", QAction::QuitRole}
};
const size_t num_entries = sizeof(entries) / sizeof(entries[0]);
const bool first_call = mac_special_menu_.size() == 0;
const bool first_call = mac_special_menu_.empty();
// the special menu for Menus. Fill it up only once.
if (first_call) {
@ -2050,7 +2050,7 @@ void Menus::fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial)
LYXERR(Debug::GUI, "populating menu bar" << d->menubar_.name());
if (d->menubar_.size() == 0) {
if (d->menubar_.empty()) {
LYXERR(Debug::GUI, "\tERROR: empty menu bar"
<< d->menubar_.name());
return;
@ -2115,7 +2115,7 @@ void Menus::updateMenu(Menu * qmenu)
MenuDefinition cat_menu = d->getMenu(toqstr(menu_name));
//FIXME: 50 is a wild guess. We should take into account here
//the expansion of menu items, disabled optional items etc.
bool const in_sub_menu = fromLyxMenu.size() > 0
bool const in_sub_menu = !fromLyxMenu.empty()
&& fromLyxMenu.size() + cat_menu.size() > 50 ;
if (in_sub_menu)
fromLyxMenu.catSub(menu_name);

View File

@ -89,7 +89,7 @@ void LoaderQueue::loadNext()
LYXERR(Debug::GRAPHICS, "LoaderQueue: "
<< cache_queue_.size() << " items in the queue");
int counter = s_numimages_;
while (cache_queue_.size() && counter--) {
while (!cache_queue_.empty() && counter--) {
Cache::ItemPtr ptr = cache_queue_.front();
cache_set_.erase(ptr);
cache_queue_.pop_front();

View File

@ -968,10 +968,10 @@ string MatchStringAdv::normalize(docstring const & s, bool hack_braces) const
else
t = lyx::to_utf8(s);
// Remove \n at begin
while (t.size() > 0 && t[0] == '\n')
while (!t.empty() && t[0] == '\n')
t = t.substr(1);
// Remove \n at end
while (t.size() > 0 && t[t.size() - 1] == '\n')
while (!t.empty() && t[t.size() - 1] == '\n')
t = t.substr(0, t.size() - 1);
size_t pos;
// Replace all other \n with spaces

View File

@ -67,7 +67,7 @@ void CommandInset::write(WriteStream & os) const
ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly());
MathEnsurer ensurer(os, needs_math_mode_);
os << '\\' << name_;
if (cell(1).size())
if (!cell(1).empty())
os << '[' << cell(1) << ']';
os << '{' << cell(0) << '}';
}

View File

@ -282,9 +282,9 @@ void InsetMathMakebox::write(WriteStream & os) const
{
ModeSpecifier specifier(os, TEXT_MODE);
os << (framebox_ ? "\\framebox" : "\\makebox");
if (cell(0).size() || !os.latex()) {
if (!cell(0).empty() || !os.latex()) {
os << '[' << cell(0) << ']';
if (cell(1).size() || !os.latex())
if (!cell(1).empty() || !os.latex())
os << '[' << cell(1) << ']';
}
os << '{' << cell(2) << '}';

View File

@ -76,7 +76,7 @@ void InsetMathExInt::draw(PainterInfo &, int, int) const
void InsetMathExInt::maple(MapleStream & os) const
{
os << symbol_ << '(';
if (cell(0).size())
if (!cell(0).empty())
os << cell(0);
else
os << '1';
@ -94,7 +94,7 @@ void InsetMathExInt::maxima(MaximaStream & os) const
else
os << symbol_ << '(';
if (cell(0).size())
if (!cell(0).empty())
os << cell(0) << ',';
else
os << '1' << ',';
@ -113,7 +113,7 @@ void InsetMathExInt::mathematica(MathematicaStream & os) const
else
os << symbol_ << '[';
if (cell(0).size())
if (!cell(0).empty())
os << cell(0) << ',';
else
os << '1' << ',';

View File

@ -674,7 +674,7 @@ docstring InsetMathGrid::eolString(row_type row, bool fragile,
// make sure an upcoming '[' does not break anything
if (row + 1 < nrows()) {
MathData const & c = cell(index(row + 1, 0));
if (c.size() && c.front()->getChar() == '[')
if (!c.empty() && c.front()->getChar() == '[')
//eol += "[0pt]";
eol += "{}";
}
@ -905,7 +905,7 @@ bool InsetMathGrid::idxDelete(idx_type & idx)
// try to delete entire sequence of ncols() empty cells if possible
for (idx_type i = idx; i < idx + ncols(); ++i)
if (cell(i).size())
if (!cell(i).empty())
return false;
// move cells if necessary

View File

@ -1039,7 +1039,7 @@ void InsetMathHull::splitTo3Cols()
InsetMathGrid::addCol(2);
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 3 * row + 1;
if (cell(i).size()) {
if (!cell(i).empty()) {
cell(i + 1) = MathData(buffer_, cell(i).begin() + 1, cell(i).end());
cell(i).erase(1, cell(i).size());
}
@ -1309,7 +1309,7 @@ void InsetMathHull::doExtern(Cursor & cur, FuncRequest & func)
MathData ar;
if (cur.inMathed() && cur.selection()) {
asArray(grabAndEraseSelection(cur), ar);
} else if (pos == cur.cell().size()) {
} else if (!pos == cur.cell().empty()) {
ar = cur.cell();
lyxerr << "use whole cell: " << ar << endl;
} else {

View File

@ -177,7 +177,7 @@ int InsetMathScript::dy01(BufferView const & bv, int asc, int des, int what) con
{
int dasc = 0;
int slevel = 0;
bool isCharBox = nuc().size() ? isAlphaSymbol(nuc().back()) : false;
bool isCharBox = !nuc().empty() ? isAlphaSymbol(nuc().back()) : false;
if (hasDown()) {
Dimension const & dimdown = down().dimension(bv);
dasc = dimdown.ascent();
@ -271,25 +271,25 @@ int InsetMathScript::dxx(BufferView const & bv) const
int InsetMathScript::nwid(BufferView const & bv) const
{
return nuc().size() ? nuc().dimension(bv).width() : 2;
return !nuc().empty() ? nuc().dimension(bv).width() : 2;
}
int InsetMathScript::nasc(BufferView const & bv) const
{
return nuc().size() ? nuc().dimension(bv).ascent() : 5;
return !nuc().empty() ? nuc().dimension(bv).ascent() : 5;
}
int InsetMathScript::ndes(BufferView const & bv) const
{
return nuc().size() ? nuc().dimension(bv).descent() : 0;
return !nuc().empty() ? nuc().dimension(bv).descent() : 0;
}
int InsetMathScript::nker(BufferView const * bv) const
{
if (nuc().size()) {
if (!nuc().empty()) {
int kerning = nuc().kerning(bv);
return kerning > 0 ? kerning : 0;
}
@ -351,7 +351,7 @@ void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathScript::draw(PainterInfo & pi, int x, int y) const
{
BufferView & bv = *pi.base.bv;
if (nuc().size())
if (!nuc().empty())
nuc().draw(pi, x + dxx(bv), y);
else {
nuc().setXY(bv, x + dxx(bv), y);
@ -380,7 +380,7 @@ void InsetMathScript::metricsT(TextMetricsInfo const & mi, Dimension & dim) cons
void InsetMathScript::drawT(TextPainter & pain, int x, int y) const
{
// FIXME: BROKEN
if (nuc().size())
if (!nuc().empty())
nuc().drawT(pain, x + 1, y);
if (hasUp())
up().drawT(pain, x + 1, y - 1 /*dy1()*/);
@ -399,7 +399,7 @@ bool InsetMathScript::hasLimits() const
return false;
// we can only display limits if the nucleus wants some
if (!nuc().size())
if (nuc().empty())
return false;
if (!nuc().back()->isScriptable())
return false;
@ -530,7 +530,7 @@ void InsetMathScript::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
if (nuc().size()) {
if (!nuc().empty()) {
os << nuc();
//if (nuc().back()->takesLimits()) {
if (limits_ == -1)
@ -545,13 +545,13 @@ void InsetMathScript::write(WriteStream & os) const
os << "{}";
}
if (hasDown() /*&& down().size()*/)
if (hasDown() /*&& !down().empty()*/)
os << "_{" << down() << '}';
if (hasUp() /*&& up().size()*/) {
if (hasUp() /*&& !up().empty()*/) {
// insert space if up() is empty or an empty brace inset
// (see bug 8305)
if (os.latex() && (up().size() == 0 ||
if (os.latex() && (up().empty() ||
(up().size() == 1 && up().back()->asBraceInset() &&
up().back()->asBraceInset()->cell(0).empty())))
os << "^ {}";
@ -566,8 +566,8 @@ void InsetMathScript::write(WriteStream & os) const
void InsetMathScript::normalize(NormalStream & os) const
{
bool d = hasDown() && down().size();
bool u = hasUp() && up().size();
bool d = hasDown() && !down().empty();
bool u = hasUp() && !up().empty();
if (u && d)
os << "[subsup ";
@ -576,7 +576,7 @@ void InsetMathScript::normalize(NormalStream & os) const
else if (d)
os << "[sub ";
if (nuc().size())
if (!nuc().empty())
os << nuc() << ' ';
else
os << "[par]";
@ -592,21 +592,21 @@ void InsetMathScript::normalize(NormalStream & os) const
void InsetMathScript::maple(MapleStream & os) const
{
if (nuc().size())
if (!nuc().empty())
os << nuc();
if (hasDown() && down().size())
if (hasDown() && !down().empty())
os << '[' << down() << ']';
if (hasUp() && up().size())
if (hasUp() && !up().empty())
os << "^(" << up() << ')';
}
void InsetMathScript::mathematica(MathematicaStream & os) const
{
bool d = hasDown() && down().size();
bool u = hasUp() && up().size();
bool d = hasDown() && !down().empty();
bool u = hasUp() && !up().empty();
if (nuc().size()) {
if (!nuc().empty()) {
if (d)
os << "Subscript[" << nuc();
else
@ -616,7 +616,7 @@ void InsetMathScript::mathematica(MathematicaStream & os) const
if (u)
os << "^(" << up() << ')';
if (nuc().size()) {
if (!nuc().empty()) {
if (d)
os << ',' << down() << ']';
}
@ -629,8 +629,8 @@ void InsetMathScript::mathematica(MathematicaStream & os) const
// need to know if we're in a display formula.
void InsetMathScript::mathmlize(MathStream & os) const
{
bool d = hasDown() && down().size();
bool u = hasUp() && up().size();
bool d = hasDown() && !down().empty();
bool u = hasUp() && !up().empty();
if (u && d)
os << MTag("msubsup");
@ -639,7 +639,7 @@ void InsetMathScript::mathmlize(MathStream & os) const
else if (d)
os << MTag("msub");
if (nuc().size())
if (!nuc().empty())
os << MTag("mrow") << nuc() << ETag("mrow");
else
os << "<mrow />";
@ -657,10 +657,10 @@ void InsetMathScript::mathmlize(MathStream & os) const
void InsetMathScript::htmlize(HtmlStream & os) const
{
bool d = hasDown() && down().size();
bool u = hasUp() && up().size();
bool d = hasDown() && !down().empty();
bool u = hasUp() && !up().empty();
if (nuc().size())
if (!nuc().empty())
os << nuc();
if (u && d)
@ -677,11 +677,11 @@ void InsetMathScript::htmlize(HtmlStream & os) const
void InsetMathScript::octave(OctaveStream & os) const
{
if (nuc().size())
if (!nuc().empty())
os << nuc();
if (hasDown() && down().size())
if (hasDown() && !down().empty())
os << '[' << down() << ']';
if (hasUp() && up().size())
if (hasUp() && !up().empty())
os << "^(" << up() << ')';
}

View File

@ -64,7 +64,7 @@ void InsetMathXArrow::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
os << '\\' << name_;
if (cell(1).size())
if (!cell(1).empty())
os << '[' << cell(1) << ']';
os << '{' << cell(0) << '}';
}

View File

@ -142,9 +142,9 @@ void InsetMathXYArrow::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
os << "\\ar";
if (cell(0).size())
if (!cell(0).empty())
os << '[' << cell(0) << ']';
if (cell(1).size())
if (!cell(1).empty())
os << (up_ ? '^' : '_') << '{' << cell(1) << '}';
os << " ";
}

View File

@ -149,7 +149,7 @@ void initAutoCorrect()
string line;
ifstream is(file.toFilesystemEncoding().c_str());
while (getline(is, line)) {
if (line.size() == 0 || line[0] == '#') {
if (line.empty() || line[0] == '#') {
//LYXERR(Debug::MATHED, "ignoring line '" << line << '\'');
continue;
}

View File

@ -339,13 +339,13 @@ void MathData::draw(PainterInfo & pi, int x, int y) const
docstring s1 = completion.substr(0, uniqueTo);
docstring s2 = completion.substr(uniqueTo);
if (s1.size() > 0) {
if (!s1.empty()) {
f.setColor(Color_inlinecompletion);
pi.pain.text(x, y, s1, f);
x += mathed_string_width(f, s1);
}
if (s2.size() > 0) {
if (!s2.empty()) {
f.setColor(Color_nonunique_inlinecompletion);
pi.pain.text(x, y, s2, f);
x += mathed_string_width(f, s2);

View File

@ -352,7 +352,7 @@ void splitScripts(MathData & ar)
continue;
// we must have a nucleus if we only have a superscript
if (!script->hasDown() && script->nuc().size() == 0)
if (!script->hasDown() && script->nuc().empty())
continue;
if (script->nuc().size() == 1) {
@ -619,7 +619,7 @@ bool testIntegral(MathAtom const & at)
return
testIntSymbol(at) ||
( at->asScriptInset()
&& at->asScriptInset()->nuc().size()
&& !at->asScriptInset()->nuc().empty()
&& testIntSymbol(at->asScriptInset()->nuc().back()) );
}
@ -719,7 +719,7 @@ bool testSum(MathAtom const & at)
return
testSumSymbol(at) ||
( at->asScriptInset()
&& at->asScriptInset()->nuc().size()
&& !at->asScriptInset()->nuc().empty()
&& testSumSymbol(at->asScriptInset()->nuc().back()) );
}
@ -800,7 +800,7 @@ bool testDiffItem(MathAtom const & at)
bool testDiffArray(MathData const & ar)
{
return ar.size() && testDiffItem(ar.front());
return !ar.empty() && testDiffItem(ar.front());
}
@ -1419,7 +1419,7 @@ void mathmlize(MathData const & dat, MathStream & os)
{
MathData ar = dat;
extractStructure(ar, MATHML);
if (ar.size() == 0)
if (ar.empty())
os << "<mrow/>";
else if (ar.size() == 1)
os << ar.front();
@ -1436,7 +1436,7 @@ void htmlize(MathData const & dat, HtmlStream & os)
{
MathData ar = dat;
extractStructure(ar, HTML);
if (ar.size() == 0)
if (ar.empty())
return;
if (ar.size() == 1) {
os << ar.front();

View File

@ -465,7 +465,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
void MathMacro::drawSelection(PainterInfo & pi, int x, int y) const
{
// We may have 0 arguments, but InsetMathNest requires at least one.
if (cells_.size() > 0)
if (!cells_.empty())
InsetMathNest::drawSelection(pi, x, y);
}
@ -507,8 +507,7 @@ bool MathMacro::validName() const
{
docstring n = name();
// empty name?
if (n.size() == 0)
if (n.empty())
return false;
// converting back and force doesn't swallow anything?

View File

@ -994,7 +994,7 @@ void MathMacroTemplate::doDispatch(Cursor & cur, FuncRequest & cmd)
commitEditChanges(cur, cur);
cur.recordUndoFullDocument();
size_t pos = numargs_;
if (arg.size() != 0)
if (!arg.empty())
pos = (size_t)convert<int>(arg) - 1; // it is checked for >=0 in getStatus
insertParameter(cur, cur, pos);
}
@ -1006,7 +1006,7 @@ void MathMacroTemplate::doDispatch(Cursor & cur, FuncRequest & cmd)
commitEditChanges(cur, cur);
cur.recordUndoFullDocument();
size_t pos = numargs_ - 1;
if (arg.size() != 0)
if (!arg.empty())
pos = (size_t)convert<int>(arg) - 1; // it is checked for >=0 in getStatus
removeParameter(cur, cur, pos);
}
@ -1080,7 +1080,7 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd,
switch (cmd.action()) {
case LFUN_MATH_MACRO_ADD_PARAM: {
int num = numargs_ + 1;
if (arg.size() != 0)
if (!arg.empty())
num = convert<int>(arg);
bool on = (num >= optionals_
&& numargs_ < 9 && num <= numargs_ + 1);
@ -1095,7 +1095,7 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd,
case LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM:
case LFUN_MATH_MACRO_REMOVE_PARAM: {
int num = numargs_;
if (arg.size() != 0)
if (!arg.empty())
num = convert<int>(arg);
flag.setEnabled(num >= 1 && num <= numargs_);
break;
@ -1266,8 +1266,7 @@ bool MathMacroTemplate::validName() const
{
docstring n = name();
// empty name?
if (n.size() == 0)
if (n.empty())
return false;
// converting back and force doesn't swallow anything?
@ -1316,7 +1315,7 @@ bool MathMacroTemplate::fixNameAndCheckIfValid()
}
// now it should be valid if anything in the name survived
return data.size() > 0;
return !data.empty();
}

View File

@ -334,9 +334,9 @@ public:
///
char_type character() const { return char_; }
///
docstring asString() const { return cs_.size() ? cs_ : docstring(1, char_); }
docstring asString() const { return !cs_.empty() ? cs_ : docstring(1, char_); }
///
docstring asInput() const { return cs_.size() ? '\\' + cs_ : docstring(1, char_); }
docstring asInput() const { return !cs_.empty() ? '\\' + cs_ : docstring(1, char_); }
private:
///
@ -350,7 +350,7 @@ private:
ostream & operator<<(ostream & os, Token const & t)
{
if (t.cs().size()) {
if (!t.cs().empty()) {
docstring const & cs = t.cs();
// FIXME: For some strange reason, the stream operator instanciate
// a new Token before outputting the contents of t.cs().
@ -951,7 +951,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
bool up = (t.cat() == catSuper);
// we need no new script inset if the last thing was a scriptinset,
// which has that script already not the same script already
if (!cell->size())
if (cell->empty())
cell->push_back(MathAtom(new InsetMathScript(buf, up)));
else if (cell->back()->asScriptInset() &&
!cell->back()->asScriptInset()->has(up))
@ -1029,7 +1029,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
//
else if (t.cs() == "lyxlock") {
if (cell->size())
if (!cell->empty())
cell->back().nucleus()->lock(true);
}
@ -1377,7 +1377,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
else if (t.cs() == "sqrt") {
MathData ar;
parse(ar, FLAG_OPTION, mode);
if (ar.size()) {
if (!ar.empty()) {
cell->push_back(MathAtom(new InsetMathRoot(buf)));
cell->back().nucleus()->cell(0) = ar;
parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
@ -1399,7 +1399,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
// Allowed formats \unit[val]{unit}
MathData ar;
parse(ar, FLAG_OPTION, mode);
if (ar.size()) {
if (!ar.empty()) {
cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNIT)));
cell->back().nucleus()->cell(0) = ar;
parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
@ -1413,7 +1413,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
// Here allowed formats are \unitfrac[val]{num}{denom}
MathData ar;
parse(ar, FLAG_OPTION, mode);
if (ar.size()) {
if (!ar.empty()) {
cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNITFRAC, 3)));
cell->back().nucleus()->cell(2) = ar;
} else {
@ -1845,10 +1845,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
rem.clear();
} else
cmd.clear();
} while (cmd.size());
} while (!cmd.empty());
}
else if (t.cs().size()) {
else if (!t.cs().empty()) {
bool const no_mhchem =
(t.cs() == "ce" || t.cs() == "cf")
&& buf && buf->params().use_package("mhchem") ==
@ -1979,7 +1979,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
// this fails on \bigg[...\bigg]
//MathData opt;
//parse(opt, FLAG_OPTION, InsetMath::VERBATIM_MODE);
//if (opt.size()) {
//if (!opt.empty()) {
// start = 1;
// at.nucleus()->cell(0) = opt;
//}

View File

@ -1111,13 +1111,13 @@ void RowPainter::paintInlineCompletion(Font const & font)
swap(c1, c2);
}
if (s1.size() > 0) {
if (!s1.empty()) {
f.setColor(c1);
pi_.pain.text(int(x_), yo_, s1, f);
x_ += theFontMetrics(font).width(s1);
}
if (s2.size() > 0) {
if (!s2.empty()) {
f.setColor(c2);
pi_.pain.text(int(x_), yo_, s2, f);
x_ += theFontMetrics(font).width(s2);

View File

@ -133,7 +133,7 @@ string const to_local8bit(docstring const & s)
if (s.empty())
return string();
QByteArray const local = toqstr(s).toLocal8Bit();
if (local.size() == 0)
if (local.isEmpty())
throw to_local8bit_failure();
return string(local.begin(), local.end());
}

View File

@ -1769,7 +1769,7 @@ public:
clear();
key_less = other.key_comp();
if (other.size() != 0)
if (!other.empty())
{
stats.leaves = stats.innernodes = 0;
root = copy_recursive(other.root);
@ -1788,7 +1788,7 @@ public:
stats( other.stats ),
key_less( other.key_comp() )
{
if (size() > 0)
if (!empty())
{
stats.leaves = stats.innernodes = 0;
root = copy_recursive(other.root);

View File

@ -4384,7 +4384,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
/*
string s = t.asInput();
string z = p.verbatim_item();
while (p.good() && z != " " && z.size()) {
while (p.good() && z != " " && !z.empty()) {
//cerr << "read: " << z << endl;
s += z;
z = p.verbatim_item();