+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * configure.ac: add src/support/tests/Makefile
+
2005-01-21 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* configure.ac: indicate in final info whether aiksaurus is used.
src/graphics/Makefile \
src/insets/Makefile \
src/support/Makefile \
+ src/support/tests/Makefile \
src/frontends/Makefile \
src/frontends/controllers/Makefile \
src/frontends/xforms/Makefile \
src/rowpainter.C
src/support/filefilterlist.C
src/support/package.C.in
+src/support/path_defines.C
src/text.C
src/text2.C
src/text3.C
using lyx::support::MakeDisplayPath;
using lyx::support::MakeAbsPath;
using lyx::support::package;
-using lyx::support::strToUnsignedInt;
using std::endl;
using std::istringstream;
break;
case LFUN_BOOKMARK_GOTO:
- flag.enabled(bv_->isSavedPosition(strToUnsignedInt(cmd.argument)));
+ flag.enabled(bv_->isSavedPosition(convert<unsigned int>(cmd.argument)));
break;
case LFUN_TRACK_CHANGES:
flag.enabled(true);
case LFUN_OUTPUT_CHANGES: {
LaTeXFeatures features(*buf, buf->params(), false);
- flag.enabled(buf && buf->params().tracking_changes
+ flag.enabled(buf && buf->params().tracking_changes
&& features.isAvailable("dvipost"));
flag.setOnOff(buf->params().output_changes);
break;
break;
case LFUN_BOOKMARK_SAVE:
- savePosition(strToUnsignedInt(cmd.argument));
+ savePosition(convert<unsigned int>(cmd.argument));
break;
case LFUN_BOOKMARK_GOTO:
- restorePosition(strToUnsignedInt(cmd.argument));
+ restorePosition(convert<unsigned int>(cmd.argument));
break;
case LFUN_REF_GOTO: {
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * lyxlayout.[Ch]: change some vars from float to double
+
+ * buffer.C (readFile): make a local var const
+
+ * Several files: use convert<> instead of atoi,strToXXX and friends
+
2005-01-24 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* LaTeXFeatures.[Ch]: Add a static list packages_ that
holds the contens of packages.lst. New functions getAvailable
and isAvailable to parse and check that list, resp.
-
+
* LyXAction.C:
* lfuns.h:
* BufferView_pimpl.C: new LFUN_OUTPUT_CHANGES.
-
+
* bufferparams.[Ch]: new param output_changes.
-
+
* Buffer.C: increase file format to 240.
Use output_changes and isVailable.
-
- * changes.[Ch]:
- * paragraph.C:
+
+ * changes.[Ch]:
+ * paragraph.C:
* paragraph_pimpl.C: Use output_changes and isVailable.
2005-01-23 Angus Leeming <leeming@lyx.org>
2005-01-20 Angus Leeming <leeming@lyx.org>
- * lyxfont.C (setLyXFamily, setLyXSeries, setLyXShape, setLyXSize)
+ * lyxfont.C (setLyXFamily, setLyXSeries, setLyXShape, setLyXSize)
(setLyXMisc): (char string literal) != (char string literal) is
performing a comparison on the addresses. Convert one operand
explicitly to string to guarantee expected behaviour.
* lyxlex_pimpl.[Ch]: use USE_COMPRESSION guard.
* output_plaintext.C: remove unneeded #include gzstream.h.
-
+
2005-01-20 Angus Leeming <leeming@lyx.org>
* SpellBase.h: rename some of the elements of the Result enum.
#include "LaTeX.h" // TeXErrors
+#include "support/convert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
-#include "support/lyxlib.h"
#include "support/systemcall.h"
#include <boost/format.hpp>
#include <fstream>
-using lyx::support::atoi;
using lyx::support::ChangeExtension;
using lyx::support::OnlyFilename;
using lyx::support::split;
token = split(token, warno, ':');
token = split(token, warning, ':');
- int const lineno = atoi(line);
+ int const lineno = convert<int>(line);
#if USE_BOOST_FORMAT
msg % warno;
#include <sstream>
#include <string>
-using lyx::support::strToDbl;
-//using std::ios;
using std::ostream;
using std::ostringstream;
using std::string;
double Spacing::getValue() const
{
- return strToDbl(getValueAsString());
+ return convert<double>(getValueAsString());
}
-void Spacing::set(Spacing::Space sp, float val)
+void Spacing::set(Spacing::Space sp, double val)
{
set(sp, convert<string>(val));
}
{
space = sp;
if (sp == Other) {
- switch (int(strToDbl(val) * 1000 + 0.5)) {
+ switch (int(convert<double>(val) * 1000 + 0.5)) {
case 1000:
space = Single;
break;
///
Spacing() : space(Default), value("1.0") {}
///
- Spacing(Spacing::Space sp, float val = 1.0) {
+ Spacing(Spacing::Space sp, double val = 1.0) {
set(sp, val);
}
Spacing(Spacing::Space sp, std::string const & val) {
///
Spacing::Space getSpace() const { return space; }
///
- void set(Spacing::Space sp, float val = 1.0);
+ void set(Spacing::Space sp, double val = 1.0);
///
void set(Spacing::Space sp, std::string const & val);
///
using lyx::support::rename;
using lyx::support::RunCommand;
using lyx::support::split;
-using lyx::support::strToInt;
using lyx::support::subst;
using lyx::support::tempName;
using lyx::support::trim;
//lyxerr << " dot found at " << dot << endl;
if (dot != string::npos)
tmp_format.erase(dot, 1);
- int file_format = strToInt(tmp_format);
+ int const file_format = convert<int>(tmp_format);
//lyxerr << "format: " << file_format << endl;
if (file_format != LYX_FORMAT) {
filename));
return false;
} else {
- bool ret = readFile(tmpfile, pit);
+ bool const ret = readFile(tmpfile, pit);
// Do stuff with tmpfile name and buffer name here.
return ret;
}
{
LyXTextClass const & tclass = params().getLyXTextClass();
- if (features.isAvailable("dvipost") && params().tracking_changes
+ if (features.isAvailable("dvipost") && params().tracking_changes
&& params().output_changes) {
features.require("dvipost");
features.require("color");
#include "debug.h"
+#include "support/convert.h"
#include "support/filetools.h"
-#include "support/lyxlib.h"
#include <boost/regex.hpp>
#include <fstream>
-using lyx::support::atoi;
using lyx::support::LibFileSearch;
using boost::regex;
while (getline(ifs, line)) {
smatch sub;
if (regex_match(line, sub, reg)) {
- int const n = atoi(sub.str(1));
+ int const n = convert<int>(sub.str(1));
string const str = sub.str(2);
if (lyxerr.debugging(Debug::KBMAP))
lyxerr << "Chardef: " << n
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * debug.C: use convert<> instead of atoi,strToXXX and friends
+
2005-01-20 Asger Ottar Alstrup <aalstrup@laerdal.dk>
* pch.h: use the HAVE_UNISTD_H preprocessor guard.
#include "debug.h"
#include "gettext.h"
+#include "support/convert.h"
#include "support/lstrings.h"
#include <iostream>
using lyx::support::ascii_lowercase;
using lyx::support::bformat;
using lyx::support::isStrInt;
-using lyx::support::strToInt;
using std::setw;
using std::string;
break;
// Is it a number?
if (isStrInt(tmp))
- l |= static_cast<type>(strToInt(tmp));
+ l |= static_cast<type>(convert<int>(tmp));
else
// Search for an explicit name
for (int i = 0 ; i < numErrorTags ; ++i)
#include "debug.h"
#include "gettext.h"
+#include "support/convert.h"
#include "support/lstrings.h"
#include <iostream>
using lyx::support::ascii_lowercase;
using lyx::support::bformat;
using lyx::support::isStrInt;
-using lyx::support::strToInt;
using std::setw;
using std::string;
type l = Debug::NONE;
string v(val);
while (!v.empty()) {
- string::size_type st = v.find(',');
- string tmp(ascii_lowercase(v.substr(0, st)));
+ string::size_type const st = v.find(',');
+ string const tmp(ascii_lowercase(v.substr(0, st)));
if (tmp.empty())
break;
// Is it a number?
if (isStrInt(tmp))
- l |= static_cast<type>(strToInt(tmp));
+ l |= static_cast<type>(convert<int>(tmp));
else
// Search for an explicit name
for (int i = 0 ; i < numErrorTags ; ++i)
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * Several files: use convert<> instead of atoi,strToXXX and friends
+
2005-01-10 Angus Leeming <leeming@lyx.org>
* ghelpers.C:
#include "paper.h"
#include "lyxrc.h" // for lyxrc.default_papersize
+#include "support/convert.h"
#include "support/lyxlib.h" // for float_equal
#include "support/lstrings.h"
-#include "support/convert.h"
#include "debug.h"
namespace lyx {
using support::float_equal;
-using support::strToDbl;
using support::token;
namespace frontend {
displaycombo_->set_active(0);
}
- outputscalespin_->get_adjustment()->set_value(strToDbl(igp.scale));
+ outputscalespin_->get_adjustment()->set_value(convert<double>(igp.scale));
widthspin_->get_adjustment()->set_value(igp.width.value());
unitsComboFromLength(widthunitscombo_, stringcol_,
igp.width, defaultUnit);
igp.height, defaultUnit);
if (!igp.scale.empty()
- && !float_equal(strToDbl(igp.scale), 0.0, 0.05)) {
+ && !float_equal(convert<double>(igp.scale), 0.0, 0.05)) {
// scaling sizing mode
setscalingradio_->set_active(true);
} else {
clipcheck_->set_active(igp.clip);
// the extra section
- anglespin_->get_adjustment()->set_value(strToDbl(igp.rotateAngle));
+ anglespin_->get_adjustment()->set_value(convert<double>(igp.rotateAngle));
int origin_pos;
if (igp.rotateOrigin.empty()) {
#include "PrinterParams.h"
-#include "support/lstrings.h"
#include "support/convert.h"
+#include "support/lstrings.h"
#include <libglademm.h>
pp.all_pages = all_->get_active();
pp.from_page = pp.to_page = 0;
if (!fromEntry_->get_text().empty()) {
- pp.from_page = strToInt(fromEntry_->get_text());
+ pp.from_page = convert<int>(fromEntry_->get_text());
if (!toEntry_->get_text().empty())
- pp.to_page = strToInt(toEntry_->get_text());
+ pp.to_page = convert<int>(toEntry_->get_text());
}
pp.odd_pages = odd_->get_active();
pp.even_pages = even_->get_active();
if (fromTo_->get_active()) {
string from = fromEntry_->get_text();
string to = toEntry_->get_text();
- if (from.empty() || (!to.empty() && strToInt(from) > strToInt(to)))
+ if (from.empty() || (!to.empty() && convert<int>(from) > convert<int>(to)))
activate = ButtonPolicy::SMI_INVALID;
}
bool const enableCounter = printer_->get_active();
#include "frontends/LyXView.h"
#include "frontends/lyx_gui.h"
+#include "support/convert.h"
#include "support/lstrings.h"
#include "support/systemcall.h"
#include "support/filetools.h"
#include <cmath> // fabs()
#include <vector>
-using lyx::support::strToDbl;
-
using std::endl;
using std::string;
string ffamily;
int fweight;
int fslant;
- double fsize = strToDbl(lyxrc.font_sizes[size]) * lyxrc.zoom / 100.0;
+ double fsize = convert<double>(lyxrc.font_sizes[size]) * lyxrc.zoom / 100.0;
XftPattern *fpat = XftPatternCreate();
ffamily = familyString(family);
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * Several files: use convert<> instead of atoi,strToXXX and friends
+
2005-01-20 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* floatplacement.C (heredefinitelyClicked): remove bogus
- semicolon.
+ semicolon.
2005-01-15 Angus Leeming <leeming@lyx.org>
namespace external = lyx::external;
using lyx::support::isStrDbl;
-using lyx::support::strToDbl;
-using lyx::support::strToInt;
using lyx::support::token;
using lyx::support::trim;
if (!displayCB.isChecked())
display = external::NoDisplay;
- scale = strToInt(fromqstr(scaleED.text()));
+ scale = convert<int>(fromqstr(scaleED.text()));
}
if (isValidLength(width, &w))
data.width = w;
else if (isStrDbl(width))
- data.width = LyXLength(strToDbl(width),
+ data.width = LyXLength(convert<double>(width),
static_cast<LyXLength::UNIT>(unit));
else
data.width = LyXLength();
if (!bb_changed)
return;
- data.bbox.xl = strToInt(fromqstr(xlED.text()));
- data.bbox.yb = strToInt(fromqstr(ybED.text()));
- data.bbox.xr = strToInt(fromqstr(xrED.text()));
- data.bbox.yt = strToInt(fromqstr(ytED.text()));
+ data.bbox.xl = convert<int>(fromqstr(xlED.text()));
+ data.bbox.yb = convert<int>(fromqstr(ybED.text()));
+ data.bbox.xr = convert<int>(fromqstr(xrED.text()));
+ data.bbox.yt = convert<int>(fromqstr(ytED.text()));
}
#include "controllers/ButtonController.h"
#include "controllers/ControlExternal.h"
+#include "support/convert.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
using lyx::support::float_equal;
using lyx::support::isStrDbl;
-using lyx::support::strToDbl;
using std::string;
namespace lyx {
if (wstr.empty())
return false;
bool const wIsDbl = isStrDbl(wstr);
- if (wIsDbl && float_equal(strToDbl(wstr), 0.0, 0.05))
+ if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
return false;
LyXLength l;
if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
if (hstr.empty())
return false;
bool const hIsDbl = isStrDbl(hstr);
- if (hIsDbl && float_equal(strToDbl(hstr), 0.0, 0.05))
+ if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
return false;
if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
return false;
#include "insets/insetgraphicsParams.h"
-#include "support/lstrings.h"
#include "support/convert.h"
+#include "support/lstrings.h"
#include "support/lyxlib.h"
#include <qlineedit.h>
#include <cmath>
using lyx::support::float_equal;
-using lyx::support::strToDbl;
-using lyx::support::strToInt;
using lyx::support::token;
#ifndef CXX_GLOBAL_CSTD
dialog_->widthUnit->insertItem(unit_name_gui[i], -1);
if (!igp.scale.empty()
- && !float_equal(strToDbl(igp.scale), 0.0, 0.05)) {
+ && !float_equal(convert<double>(igp.scale), 0.0, 0.05)) {
dialog_->width->setText(toqstr(igp.scale));
dialog_->widthUnit->setCurrentItem(0);
} else {
string rtX(fromqstr(dialog_->rtX->text()));
string rtY(fromqstr(dialog_->rtY->text()));
int bb_sum =
- strToInt(lbX) + strToInt(lbY) +
- strToInt(rtX) + strToInt(rtX);
+ convert<int>(lbX) + convert<int>(lbY) +
+ convert<int>(rtX) + convert<int>(rtX);
if (bb_sum) {
if (lbX.empty())
bb = "0 ";
igp.noUnzip = dialog_->unzipCB->isChecked();
- igp.lyxscale = strToInt(fromqstr(dialog_->displayscale->text()));
+ igp.lyxscale = convert<int>(fromqstr(dialog_->displayscale->text()));
igp.rotateAngle = fromqstr(dialog_->angle->text());
- float rotAngle = strToDbl(igp.rotateAngle);
+ double rotAngle = convert<double>(igp.rotateAngle);
if (std::abs(rotAngle) > 360.0) {
rotAngle -= 360.0 * floor(rotAngle / 360.0);
igp.rotateAngle = convert<string>(rotAngle);
#include "ui/QPrefScreenFontsModule.h"
#include "ui/QPrefColorsModule.h"
#if defined(__CYGWIN__) || defined(__CYGWIN32__)
-#include "ui/QPrefCygwinPathModule.h"
+#include "ui/QPrefCygwinPathModule.h"
#endif
#include "ui/QPrefDisplayModule.h"
#include "ui/QPrefPathsModule.h"
#include <sstream>
using lyx::support::compare_no_case;
-using lyx::support::strToDbl;
using std::distance;
using std::endl;
#include <qlineedit.h>
#include <qpushbutton.h>
-using lyx::support::strToDbl;
using std::string;
void QWrap::apply()
{
- double const value = strToDbl(fromqstr(dialog_->widthED->text()));
+ double const value = convert<double>(fromqstr(dialog_->widthED->text()));
LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
if (dialog_->widthED->text().isEmpty())
unit = LyXLength::UNIT_NONE;
#include "frontends/lyx_gui.h"
+#include "support/convert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/systemcall.h"
using lyx::support::OnlyPath;
using lyx::support::QuoteName;
using lyx::support::Systemcall;
-using lyx::support::strToDbl;
using std::endl;
using std::make_pair;
}
}
- font.setPointSizeFloat(strToDbl(lyxrc.font_sizes[f.size()])
+ font.setPointSizeFloat(convert<double>(lyxrc.font_sizes[f.size()])
* lyxrc.zoom / 100.0);
switch (f.series()) {
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * Several files: use convert<> instead of atoi,strToXXX and friends
+
2005-01-20 Angus Leeming <leeming@lyx.org>
* FormPreferences.C: change the tooltip messages to reflect the
namespace lyx {
-using support::atoi;
using support::token;
namespace frontend {
string name(list[i]);
lyxerr[Debug::FONT] << "match #" << i << ' '
<< name << endl;
- sizes[i] = atoi(token(name, '-', 7));
+ sizes[i] = convert<int>(token(name, '-', 7));
strings[i] = name;
if (sizes[i] == 0) {
if (scaleindex == -1) {
scaleindex = i;
}
scalable = true;
- } else if (atoi(token(name, '-', 12)) == 0)
+ } else if (convert<int>(token(name, '-', 12)) == 0)
// Ignore bogus matches of scalable fonts.
sizes[i] = 0;
};
using support::float_equal;
using support::getStringFromVector;
using support::isStrDbl;
-using support::strToDbl;
-using support::strToInt;
using support::token;
using support::trim;
if (!fl_get_button(displayCB))
display = external::NoDisplay;
- scale = strToInt(getString(scaleED));
+ scale = convert<int>(getString(scaleED));
}
if (isValidLength(width, &w))
data.width = w;
else if (isStrDbl(width))
- data.width = LyXLength(strToDbl(width),
+ data.width = LyXLength(convert<double>(width),
static_cast<LyXLength::UNIT>(unit));
else
data.width = LyXLength();
- data.scale = string();
-
+ data.scale.erase();
} else {
// scaling instead of a width
data.scale = width;
if (!bb_changed)
return;
- data.bbox.xl = strToInt(getString(xlED));
- data.bbox.yb = strToInt(getString(ybED));
- data.bbox.xr = strToInt(getString(xrED));
- data.bbox.yt = strToInt(getString(ytED));
+ data.bbox.xl = convert<int>(getString(xlED));
+ data.bbox.yb = convert<int>(getString(ybED));
+ data.bbox.xr = convert<int>(getString(xrED));
+ data.bbox.yt = convert<int>(getString(ytED));
}
if (wstr.empty())
return false;
bool const wIsDbl = isStrDbl(wstr);
- if (wIsDbl && float_equal(strToDbl(wstr), 0.0, 0.05))
+ if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
return false;
LyXLength l;
if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
if (hstr.empty())
return false;
bool const hIsDbl = isStrDbl(hstr);
- if (hIsDbl && float_equal(strToDbl(hstr), 0.0, 0.05))
+ if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
return false;
if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
return false;
using support::bformat;
using support::float_equal;
using support::getStringFromVector;
-using support::strToDbl;
-using support::strToInt;
using support::token;
namespace frontend {
igp.filename.set(getString(file_->input_filename),
kernel().bufferFilepath());
- igp.lyxscale = strToInt(getString(file_->input_lyxscale));
+ igp.lyxscale = convert<int>(getString(file_->input_lyxscale));
if (igp.lyxscale == 0) {
igp.lyxscale = 100;
}
if (fl_get_choice(file_->choice_width) == 1) {
igp.scale = getString(file_->input_width);
if (igp.scale.empty()
- || float_equal(strToDbl(igp.scale), 0.0, 0.05)
- || float_equal(strToDbl(igp.scale), 100.0, 0.05)) {
- igp.scale = string();
+ || float_equal(convert<double>(igp.scale), 0.0, 0.05)
+ || float_equal(convert<double>(igp.scale), 100.0, 0.05)) {
+ igp.scale.erase();
}
igp.width = LyXLength();
} else {
- igp.scale = string();
+ igp.scale.erase();
igp.width = LyXLength(getLengthFromWidgets(file_->input_width,
file_->choice_width));
}
igp.rotateAngle = getString(extra_->input_rotate_angle);
// map angle into -360 (clock-wise) to +360 (counter clock-wise)
- float rotAngle = strToDbl(igp.rotateAngle);
+ double rotAngle = convert<double>(igp.rotateAngle);
if (std::abs(rotAngle) > 360.0) {
rotAngle -= 360.0 * floor(rotAngle / 360.0);
igp.rotateAngle = convert<string>(rotAngle);
}
// set width input fields according to scaling or width/height input
- if (!igp.scale.empty() && !float_equal(strToDbl(igp.scale), 0.0, 0.05)) {
+ if (!igp.scale.empty() && !float_equal(convert<double>(igp.scale), 0.0, 0.05)) {
fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
fl_set_input_maxchars(file_->input_width, 0);
fl_set_input(file_->input_width, igp.scale.c_str());
// disable height input in case of scaling
bool const disable_height = (!igp.scale.empty()
- && !float_equal(strToDbl(igp.scale), 0.0, 0.05));
+ && !float_equal(convert<double>(igp.scale), 0.0, 0.05));
setEnabled(file_->input_height, !disable_height);
setEnabled(file_->choice_height, !disable_height);
// the extra section
fl_set_input(extra_->input_rotate_angle, igp.rotateAngle.c_str());
- int origin_pos;
- if (igp.rotateOrigin.empty()) {
- origin_pos = 1;
- } else {
- origin_pos = 1 + findPos(origins_, igp.rotateOrigin);
+ int origin_pos = 1;
+ if (!igp.rotateOrigin.empty()) {
+ origin_pos += findPos(origins_, igp.rotateOrigin);
}
fl_set_choice(extra_->choice_origin, origin_pos);
#include "LColor.h"
#include "lyxfont.h"
+#include "support/convert.h"
#include "support/lstrings.h"
#include "support/package.h"
#include "support/filetools.h"
using support::ChangeExtension;
using support::package;
using support::rtrim;
-using support::strToDbl;
using support::trim;
namespace frontend {
// Make sure that all fonts all have positive entries
// Also note that an empty entry is returned as 0.0 by strToDbl
- if (0.0 >= strToDbl(getString(dialog_->input_tiny))
- || 0.0 >= strToDbl(getString(dialog_->input_script))
- || 0.0 >= strToDbl(getString(dialog_->input_footnote))
- || 0.0 >= strToDbl(getString(dialog_->input_small))
- || 0.0 >= strToDbl(getString(dialog_->input_normal))
- || 0.0 >= strToDbl(getString(dialog_->input_large))
- || 0.0 >= strToDbl(getString(dialog_->input_larger))
- || 0.0 >= strToDbl(getString(dialog_->input_largest))
- || 0.0 >= strToDbl(getString(dialog_->input_huge))
- || 0.0 >= strToDbl(getString(dialog_->input_huger))) {
+ if (0.0 >= convert<double>(fl_get_input(dialog_->input_tiny))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_script))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_footnote))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_small))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_normal))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_large))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_larger))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_largest))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_huge))
+ || 0.0 >= convert<double>(fl_get_input(dialog_->input_huger))) {
activate = false;
str = _("Fonts must be positive!");
-
- } else if (strToDbl(getString(dialog_->input_tiny)) >
+ } else if (convert<double>(fl_get_input(dialog_->input_tiny)) >
// Fontsizes -- tiny < script < footnote etc.
- strToDbl(getString(dialog_->input_script)) ||
- strToDbl(getString(dialog_->input_script)) >
- strToDbl(getString(dialog_->input_footnote)) ||
- strToDbl(getString(dialog_->input_footnote)) >
- strToDbl(getString(dialog_->input_small)) ||
- strToDbl(getString(dialog_->input_small)) >
- strToDbl(getString(dialog_->input_normal)) ||
- strToDbl(getString(dialog_->input_normal)) >
- strToDbl(getString(dialog_->input_large)) ||
- strToDbl(getString(dialog_->input_large)) >
- strToDbl(getString(dialog_->input_larger)) ||
- strToDbl(getString(dialog_->input_larger)) >
- strToDbl(getString(dialog_->input_largest)) ||
- strToDbl(getString(dialog_->input_largest)) >
- strToDbl(getString(dialog_->input_huge)) ||
- strToDbl(getString(dialog_->input_huge)) >
- strToDbl(getString(dialog_->input_huger))) {
+ convert<double>(fl_get_input(dialog_->input_script)) ||
+ convert<double>(fl_get_input(dialog_->input_script)) >
+ convert<double>(fl_get_input(dialog_->input_footnote)) ||
+ convert<double>(fl_get_input(dialog_->input_footnote)) >
+ convert<double>(fl_get_input(dialog_->input_small)) ||
+ convert<double>(fl_get_input(dialog_->input_small)) >
+ convert<double>(fl_get_input(dialog_->input_normal)) ||
+ convert<double>(fl_get_input(dialog_->input_normal)) >
+ convert<double>(fl_get_input(dialog_->input_large)) ||
+ convert<double>(fl_get_input(dialog_->input_large)) >
+ convert<double>(fl_get_input(dialog_->input_larger)) ||
+ convert<double>(fl_get_input(dialog_->input_larger)) >
+ convert<double>(fl_get_input(dialog_->input_largest)) ||
+ convert<double>(fl_get_input(dialog_->input_largest)) >
+ convert<double>(fl_get_input(dialog_->input_huge)) ||
+ convert<double>(fl_get_input(dialog_->input_huge)) >
+ convert<double>(fl_get_input(dialog_->input_huger))) {
activate = false;
str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
namespace lyx {
-using support::strToInt;
-
namespace frontend {
typedef FormController<ControlPrint, FormView<FD_print> > base_class;
pp.from_page = pp.to_page = 0;
if (!getString(dialog_->input_from_page).empty()) {
// we have at least one page requested
- pp.from_page = strToInt(fl_get_input(dialog_->input_from_page));
+ pp.from_page = convert<int>(fl_get_input(dialog_->input_from_page));
if (!getString(dialog_->input_to_page).empty()) {
// okay we have a range
- pp.to_page = strToInt(fl_get_input(dialog_->input_to_page));
+ pp.to_page = convert<int>(fl_get_input(dialog_->input_to_page));
} // else we only print one page.
}
bool const to_input = static_cast<bool>(*to);
setEnabled(dialog_->input_to_page, from_input);
- if (!from_input || (to_input && strToInt(from) > strToInt(to))) {
+ if (!from_input || (to_input && convert<int>(from) > convert<int>(to))) {
// Invalid input. Either 'from' is empty, or 'from' > 'to'.
// Probably editting these fields, so deactivate OK/Apply until input is valid again.
activate = ButtonPolicy::SMI_INVALID;
- } else if (!to_input || strToInt(from) == strToInt(to)) {
+ } else if (!to_input || convert<int>(from) == convert<int>(to)) {
// Valid input. Either there's only 'from' input, or 'from' == 'to'.
// Deactivate OK/Apply if odd/even selection implies no pages.
bool const odd_pages = static_cast<bool>(fl_get_button(dialog_->check_odd_pages));
bool const even_pages = static_cast<bool>(fl_get_button(dialog_->check_even_pages));
bool const odd_only = odd_pages && !even_pages;
bool const even_only = even_pages && !odd_pages;
- bool const from_is_odd = static_cast<bool>(strToInt(from) % 2);
+ bool const from_is_odd = static_cast<bool>(convert<int>(from) % 2);
if ( (from_is_odd && even_only) || (!from_is_odd && odd_only) ) {
activate = ButtonPolicy::SMI_INVALID;
}
#include "frontends/lyx_gui.h"
+#include "support/convert.h"
#include "support/filetools.h"
-#include "support/lstrings.h"
#include "support/systemcall.h"
#include "lyx_forms.h"
namespace lyx {
using support::LibFileSearch;
-using support::strToDbl;
using support::OnlyPath;
using support::Systemcall;
getFontinfo(family, series, shape);
// FIXME! CHECK! Should we use 72.0 or 72.27? (Lgb)
- int fsize = int((strToDbl(lyxrc.font_sizes[size]) * lyxrc.dpi *
+ int fsize = int((convert<double>(lyxrc.font_sizes[size]) * lyxrc.dpi *
(lyxrc.zoom/100.0)) / 72.27 + 0.5);
string font = fontinfo[family][series][shape]->getFontname(fsize);
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * PreviewLoader.C (Impl): use convert<> instead of atoi,strToXXX
+ and friends
+
+ * GraphicsParams.h (class Params): change angle from float to double
+
2005-01-06 Lars Gullik Bjonnes <larsbj@gullik.net>
* PreviewLoader.C (unique_filename): tostr -> convert
* image.
*/
/// Rotation angle.
- float angle;
+ double angle;
};
bool operator==(Params const &, Params const &);
: parent_(p), buffer_(b), font_scaling_factor_(0.0)
{
font_scaling_factor_ = 0.01 * lyxrc.dpi * lyxrc.zoom *
- support::strToDbl(lyxrc.preview_scale_factor);
+ convert<double>(lyxrc.preview_scale_factor);
lyxerr[Debug::GRAPHICS] << "The font scaling factor is "
<< font_scaling_factor_ << endl;
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * Several files: use convert<> instead of atoi,strToXXX and friends
+
2005-01-23 Angus Leeming <leeming@lyx.org>
* insetbibitem.h (bibitemWidest): declare the function.
#include <sstream>
using lyx::support::float_equal;
-using lyx::support::strToDbl;
using std::string;
bool ResizeData::usingScale() const
{
- return (!scale.empty() && !float_equal(strToDbl(scale), 0.0, 0.05));
+ return (!scale.empty() && !float_equal(convert<double>(scale), 0.0, 0.05));
}
bool RotationData::no_rotation() const
{
- return (angle.empty() || std::abs(strToDbl(angle)) < 0.1);
+ return (angle.empty() || std::abs(convert<double>(angle)) < 0.1);
}
string const RotationData::adjAngle() const
{
// Ensure that angle lies in the range -360 < angle < 360
- double rotAngle = strToDbl(angle);
+ double rotAngle = convert<double>(angle);
if (std::abs(rotAngle) > 360.0) {
rotAngle -= 360.0 * floor(rotAngle / 360.0);
return convert<string>(rotAngle);
std::ostringstream os;
if (data.usingScale()) {
- double const scl = strToDbl(data.scale) / 100.0;
+ double const scl = convert<double>(data.scale) / 100.0;
os << "\\scalebox{" << scl << "}[" << scl << "]{";
} else {
string width = "!";
std::ostringstream os;
if (data.usingScale()) {
- double scl = strToDbl(data.scale);
+ double const scl = convert<double>(data.scale);
if (!float_equal(scl, 100.0, 0.05))
os << "scale=" << scl / 100.0 << ',';
return os.str();
#include "support/convert.h"
using lyx::support::prefixIs;
-using lyx::support::strToInt;
using std::max;
using std::string;
lex.printError("InsetCommand: Parse error: `$$Token'");
if (prefixIs(getContents(), key_prefix)) {
- int key = strToInt(getContents().substr(key_prefix.length()));
+ int const key = convert<int>(getContents().substr(key_prefix.length()));
key_counter = max(key_counter, key);
}
}
y = yo();
return;
}
-
+
InsetText::getCursorPos(sl, x, y);
if (status_ == Open) {
if (openinlined_)
}
-void InsetCollapsable::scroll(BufferView & bv, float sx) const
+void InsetCollapsable::scroll(BufferView & bv, double sx) const
{
UpdatableInset::scroll(bv, sx);
}
{
UpdatableInset::scroll(bv, offset);
}
-
///
int scroll(bool recursive = true) const;
///
- void scroll(BufferView & bv, float sx) const;
+ void scroll(BufferView & bv, double sx) const;
///
void scroll(BufferView & bv, int offset) const;
///
if (!resizedata.no_resize()) {
using support::float_equal;
- double scl = support::strToDbl(resizedata.scale);
+ double const scl = convert<double>(resizedata.scale);
if (!float_equal(scl, 0.0, 0.05)) {
if (!float_equal(scl, 100.0, 0.05))
os << "\tscale "
gparams.scale = eparams.lyxscale;
if (eparams.clipdata.clip)
gparams.bb = eparams.clipdata.bbox;
- gparams.angle = lyx::support::strToDbl(eparams.rotationdata.adjAngle());
+ gparams.angle = convert<double>(eparams.rotationdata.adjAngle());
switch (eparams.display) {
case external::DefaultDisplay:
#include "frontends/Alert.h"
#include "frontends/LyXView.h"
+#include "support/convert.h"
#include "support/filetools.h"
#include "support/lyxalgo.h" // lyx::count
#include "support/lyxlib.h" // lyx::sum
using lyx::support::IsFileReadable;
using lyx::support::OnlyFilename;
using lyx::support::rtrim;
-using lyx::support::strToDbl;
using lyx::support::subst;
using lyx::support::Systemcall;
using lyx::support::unzipFile;
options << " draft,\n";
if (params().clip)
options << " clip,\n";
- double const scl = strToDbl(params().scale);
+ double const scl = convert<double>(params().scale);
if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
if (!float_equal(scl, 100.0, 0.05))
options << " scale=" << scl / 100.0
// Make sure rotation angle is not very close to zero;
// a float can be effectively zero but not exactly zero.
if (!params().rotateAngle.empty()
- && !float_equal(strToDbl(params().rotateAngle), 0.0, 0.001)) {
+ && !float_equal(convert<double>(params().rotateAngle), 0.0, 0.001)) {
options << " angle=" << params().rotateAngle << ",\n";
if (!params().rotateOrigin.empty()) {
options << " origin=" << params().rotateOrigin[0];
// Right now it only works with my version of db2latex :-)
ostringstream options;
- double const scl = strToDbl(params().scale);
+ double const scl = convert<double>(params().scale);
if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
if (!float_equal(scl, 100.0, 0.05))
options << " scale=\""
#include "graphics/GraphicsParams.h"
+#include "support/convert.h"
#include "support/filetools.h"
#include "support/lyxlib.h"
#include "support/lstrings.h"
using lyx::support::float_equal;
using lyx::support::readBB_from_PSFile;
-using lyx::support::strToDbl;
-using lyx::support::strToInt;
using lyx::support::token;
using std::string;
os << "\tlyxscale " << lyxscale << '\n';
if (display != lyx::graphics::DefaultDisplay)
os << "\tdisplay " << lyx::graphics::displayTranslator().find(display) << '\n';
- if (!scale.empty() && !float_equal(strToDbl(scale), 0.0, 0.05)) {
- if (!float_equal(strToDbl(scale), 100.0, 0.05))
+ if (!scale.empty() && !float_equal(convert<double>(scale), 0.0, 0.05)) {
+ if (!float_equal(convert<double>(scale), 100.0, 0.05))
os << "\tscale " << scale << '\n';
} else {
if (!width.zero())
os << "\tclip\n";
if (!rotateAngle.empty()
- && !float_equal(strToDbl(rotateAngle), 0.0, 0.001))
+ && !float_equal(convert<double>(rotateAngle), 0.0, 0.001))
os << "\trotateAngle " << rotateAngle << '\n';
if (!rotateOrigin.empty())
os << "\trotateOrigin " << rotateOrigin << '\n';
lyx::graphics::Params pars;
pars.filename = filename.absFilename();
pars.scale = lyxscale;
- pars.angle = lyx::support::strToDbl(rotateAngle);
+ pars.angle = convert<double>(rotateAngle);
if (clip) {
pars.bb = bb;
string const tmp = readBB_from_PSFile(filename.absFilename());
lyxerr[Debug::GRAPHICS] << "BB_from_File: " << tmp << std::endl;
if (!tmp.empty()) {
- unsigned int const bb_orig_xl = strToInt(token(tmp, ' ', 0));
- unsigned int const bb_orig_yb = strToInt(token(tmp, ' ', 1));
+#warning why not convert to unsigned int? (Lgb)
+ unsigned int const bb_orig_xl = convert<int>(token(tmp, ' ', 0));
+ unsigned int const bb_orig_yb = convert<int>(token(tmp, ' ', 1));
// new pars.bb values must be >= zero
if (pars.bb.xl > bb_orig_xl)
#include "ParagraphParameters.h"
#include "undo.h"
+#include "support/convert.h"
+
#include "frontends/Alert.h"
#include "frontends/font_metrics.h"
#include "frontends/LyXView.h"
using lyx::graphics::PreviewLoader;
using lyx::support::ltrim;
-using lyx::support::strToInt;
-using lyx::support::strToDbl;
using boost::shared_ptr;
if (cmd.argument.empty())
break;
if (cmd.argument.find('.') != cmd.argument.npos)
- scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
+ scroll(cur.bv(), static_cast<float>(convert<double>(cmd.argument)));
else
- scroll(cur.bv(), strToInt(cmd.argument));
+ scroll(cur.bv(), convert<int>(cmd.argument));
break;
case LFUN_RIGHTSEL:
break;
case LyXTabular::SET_USEBOX:
- status.setOnOff(strToInt(argument) == tabular.getUsebox(cur.idx()));
+ status.setOnOff(convert<int>(argument) == tabular.getUsebox(cur.idx()));
break;
case LyXTabular::SET_LTFIRSTHEAD:
break;
case LyXTabular::SET_USEBOX: {
- LyXTabular::BoxType val = LyXTabular::BoxType(strToInt(value));
+ LyXTabular::BoxType val = LyXTabular::BoxType(convert<int>(value));
if (val == tabular.getUsebox(cur.idx()))
val = LyXTabular::BOX_NONE;
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
using lyx::graphics::PreviewLoader;
using lyx::support::isStrUnsignedInt;
-using lyx::support::strToUnsignedInt;
using boost::bind;
using boost::ref;
#include "funcrequest.h"
#include "lyxtext.h"
-#include "support/lstrings.h"
+#include "support/convert.h"
#include <boost/assert.hpp>
-using lyx::support::strToDbl;
-using lyx::support::strToInt;
-
-
// An updatable inset is highly editable by definition
InsetBase::EDITABLE UpdatableInset::editable() const
}
-void UpdatableInset::scroll(BufferView & bv, float s) const
+void UpdatableInset::scroll(BufferView & bv, double s) const
{
if (!s) {
scx = 0;
if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
return;
- if (s > 0 && xo_ > 0)
+ if (s > 0.0 && xo_ > 0)
return;
scx = int(s * workW / 2);
case LFUN_SCROLL_INSET:
if (cmd.argument.empty()) {
if (cmd.argument.find('.') != cmd.argument.npos)
- scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
+ scroll(cur.bv(), static_cast<float>(convert<double>(cmd.argument)));
else
- scroll(cur.bv(), strToInt(cmd.argument));
+ scroll(cur.bv(), convert<int>(cmd.argument));
cur.bv().update();
}
break;
/// An updatable inset could handle lyx editing commands
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
/// scrolls to absolute position in bufferview-workwidth * sx units
- void scroll(BufferView &, float sx) const;
+ void scroll(BufferView &, double sx) const;
/// scrolls offset pixels
void scroll(BufferView &, int offset) const;
};
using lyx::support::QuoteName;
using lyx::support::rtrim;
using lyx::support::split;
-using lyx::support::strToInt;
-using lyx::support::strToUnsignedInt;
using lyx::support::subst;
using lyx::support::Systemcall;
using lyx::support::token;
/// Text that dictates the width of the indentation of indented pars
std::string parindent;
///
- float parskip;
+ double parskip;
///
- float itemsep;
+ double itemsep;
///
- float topsep;
+ double topsep;
///
- float bottomsep;
+ double bottomsep;
///
- float labelbottomsep;
+ double labelbottomsep;
///
- float parsep;
+ double parsep;
///
Spacing spacing;
///
#include "debug.h"
#include "lyxlex_pimpl.h"
+#include "support/convert.h"
#include "support/lstrings.h"
using lyx::support::compare_ascii_no_case;
using lyx::support::isStrInt;
using lyx::support::ltrim;
using lyx::support::prefixIs;
-using lyx::support::strToDbl;
-using lyx::support::strToInt;
using lyx::support::subst;
using lyx::support::trim;
int LyXLex::getInteger() const
{
if (isStrInt(pimpl_->getString()))
- return strToInt(pimpl_->getString());
+ return convert<int>(pimpl_->getString());
pimpl_->printError("Bad integer `$$Token'");
return -1;
}
-float LyXLex::getFloat() const
+double LyXLex::getFloat() const
{
// replace comma with dot in case the file was written with
// the wrong locale (should be rare, but is easy enough to
// avoid).
- string str = subst(pimpl_->getString(), ",", ".");
+ string const str = subst(pimpl_->getString(), ",", ".");
if (isStrDbl(str))
- return strToDbl(str);
+ return convert<double>(str);
pimpl_->printError("Bad float `$$Token'");
return -1;
}
}
-LyXLex & LyXLex::operator>>(float & s)
+LyXLex & LyXLex::operator>>(double & s)
{
if (isOK()) {
next();
///
bool getBool() const;
///
- float getFloat() const;
+ double getFloat() const;
///
std::string const getString() const;
/// extract string
LyXLex & operator>>(std::string &);
- /// extract float
- LyXLex & operator>>(float &);
/// extract double
LyXLex & operator>>(double &);
/// extract integer
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * math_parser.C,math_sizeinset.C: use convert<> instead of
+ atoi,strToXXX and friends
+
2005-01-20 Angus Leeming <leeming@lyx.org>
* math_spaceinset.C (validate):
#include "lyxlex.h"
#include "debug.h"
-#include "support/lyxlib.h"
-#include <sstream>
+#include "support/convert.h"
-using lyx::support::atoi;
+#include <sstream>
using std::endl;
using std::fill;
return;
}
- string arg = getArg('[', ']');
+ string const arg = getArg('[', ']');
if (!arg.empty())
- nargs = atoi(arg);
+ nargs = convert<int>(arg);
}
#include "math_parser.h"
#include "math_streamstr.h"
+#include "support/convert.h"
#include "support/std_ostream.h"
-#include "support/lyxlib.h"
-
-using lyx::support::atoi;
using std::auto_ptr;
MathSizeInset::MathSizeInset(latexkeys const * l)
- : MathNestInset(1), key_(l), style_(Styles(atoi(l->extra)))
+ : MathNestInset(1), key_(l), style_(Styles(convert<int>(l->extra)))
{}
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * tests: add some code for automatic regression testing, can be
+ improved or removed as we see fit
+
+ * lyxlib.h (atoi): delete func
+
+ * lstrings.[Ch] (strToInt): delete func
+ (strToUnsignedInt): delete func
+ (strToDbl): delete func
+
+ * Makefile.am: add subdir tests, delete atoi.C
+
+ * atoi.C: delete file
+
+ * convert.C: add specializations for converting to int, unsigned
+ int, double from string, and for converting to int and double from
+ char const *
+
+ * convert.h: remove commented code
+
2005-01-22 Angus Leeming <leeming@lyx.org>
* path.C (Path): revert the patch since the if statement has side
* filetools.[Ch] (LibScriptSearch): modify the code that replaces
the $$s placeholder with a path, so that it now inserts the path
of the lyx support directory, not the scripts subdirectory.
-
+
2005-01-19 Asger Ottar Alstrup <aalstrup@laerdal.dk>
* lyxsum.C, socktools.C, tempname.C, userinfo.C: use the
include $(top_srcdir)/config/common.am
+SUBDIRS = . tests
+
noinst_LTLIBRARIES = libsupport.la
CLEANFILES += path_defines.C
FileMonitor.h \
FileMonitor.C \
abort.C \
- atoi.C \
chdir.C \
convert.C \
convert.h \
+++ /dev/null
-/**
- * \file atoi.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- * \author Jean-Marc Lasgouttes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "support/lyxlib.h"
-
-#include <cstdlib>
-
-#ifndef CXX_GLOBAL_CSTD
-using std::atoi;
-#endif
-
-int lyx::support::atoi(std::string const & nstr)
-{
- return ::atoi(nstr.c_str());
-}
{
return lexical_cast<string>(d);
}
+
+
+template<>
+int convert<int>(string const s)
+{
+ return strtol(s.c_str(), 0, 10);
+}
+
+
+template<>
+unsigned int convert<unsigned int>(string const s)
+{
+ return strtoul(s.c_str(), 0, 10);
+}
+
+
+template<>
+double convert<double>(string const s)
+{
+ return strtod(s.c_str(), 0);
+}
+
+
+template<>
+int convert<int>(char const * cptr)
+{
+ return strtol(cptr, 0, 10);
+}
+
+
+template<>
+double convert<double>(char const * cptr)
+{
+ return strtod(cptr, 0);
+}
#ifndef CONVERT_H
#define CONVERT_H
-#if 0
-#include <boost/static_assert.hpp>
-
-// Commented out since BOOST_STATIC_ASSERT does not work with gcc 4.0
-template <class Target, class Source>
-Target convert(Source arg)
-{
- // We use a static assert here since we want all instances of
- // this template to be specializations.
- BOOST_STATIC_ASSERT(sizeof(bool) == 0);
- return Target();
-}
-#else
template <class Target, class Source>
Target convert(Source arg);
-#endif
#endif
using std::vector;
#ifndef CXX_GLOBAL_CSTD
-using std::atof;
using std::isdigit;
using std::tolower;
using std::toupper;
}
-int strToInt(string const & str)
-{
- if (isStrInt(str)) {
- // Remove leading and trailing white space chars.
- string const tmpstr = trim(str);
- // Do the conversion proper.
- return atoi(tmpstr);
- } else {
- return 0;
- }
-}
-
-
-unsigned int strToUnsignedInt(string const & str)
-{
- if (isStrUnsignedInt(str)) {
- // Remove leading and trailing white space chars.
- string const tmpstr = trim(str);
- // Do the conversion proper.
- return atoi(tmpstr);
- } else {
- return 0;
- }
-}
-
-
bool isStrDbl(string const & str)
{
if (str.empty()) return false;
}
-double strToDbl(string const & str)
-{
- if (isStrDbl(str)) {
- // Remove leading and trailing white space chars.
- string const tmpstr = trim(str);
- // Do the conversion proper.
- return ::atof(tmpstr.c_str());
- } else {
- return 0.0;
- }
-}
-
-
char lowercase(char c)
{
return char(tolower(c));
/// does the std::string represent an unsigned integer value ?
bool isStrUnsignedInt(std::string const & str);
-///
-int strToInt(std::string const & str);
-
-/// convert string to an unsigned integer
-unsigned int strToUnsignedInt(std::string const & str);
-
///
bool isStrDbl(std::string const & str);
-///
-double strToDbl(std::string const & str);
-
///
char lowercase(char c);
int unlink(std::string const & file);
/// remove the given directory
int rmdir(std::string const & file);
-/// convert the given string to an integer
-int atoi(std::string const & nstr);
/// (securely) create a temporary file in the given dir with the given prefix
std::string const tempName(std::string const & dir = std::string(),
std::string const & mask = std::string());
--- /dev/null
+Makefile
+Makefile.in
+.deps
+.libs
+convert
+lstrings
--- /dev/null
+include $(top_srcdir)/config/common.am
+
+TESTS = \
+ test_convert \
+ test_lstrings
+
+check_PROGRAMS = \
+ convert \
+ lstrings
+
+AM_CPPFLAGS = $(BOOST_INCLUDES)
+
+convert_LDADD = ../convert.o
+convert_SOURCES = \
+ convert.C \
+ boost.C
+
+lstrings_LDADD = ../lstrings.o
+lstrings_SOURCES = \
+ lstrings.C \
+ boost.C
+
+regfiles: ${check_PROGRAMS}
+ for all in ${check_PROGRAMS} ; do \
+ ./$$all > regfiles/$$all ; \
+ done
--- /dev/null
+/**
+ * \file boost.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include <boost/assert.hpp>
+
+#include <cstdlib>
+#include <exception>
+
+namespace boost {
+
+void throw_exception(std::exception const & /*e*/)
+{
+ BOOST_ASSERT(false);
+}
+
+
+void assertion_failed(char const * /*expr*/, char const * /*function*/,
+ char const * /*file*/, long /*line*/)
+{
+ ::abort();
+}
+
+
+}
--- /dev/null
+#include <config.h>
+
+#include "../convert.h"
+
+#include <iostream>
+
+using namespace std;
+
+void convert_int()
+{
+ cout << convert<int>("123") << '\n'
+ << convert<int>(" 123") << '\n'
+ << convert<int>("123 ") << '\n'
+ << convert<int>(" 123 ") << '\n'
+
+ << convert<int>("123 123") << '\n'
+ << convert<int>(" 123 123") << '\n'
+ << convert<int>("123 123 ") << '\n'
+ << convert<int>(" 123 123 ") << '\n'
+
+ << convert<int>("-123") << '\n'
+ << convert<int>(" -123") << '\n'
+ << convert<int>("-123 ") << '\n'
+ << convert<int>(" -123 ") << '\n'
+
+ << convert<int>("-123 123") << '\n'
+ << convert<int>(" -123 123") << '\n'
+ << convert<int>("-123 123 ") << '\n'
+ << convert<int>(" -123 123 ") << '\n'
+
+ << convert<int>("") << '\n'
+ << convert<int>("abc") << '\n'
+ << convert<int>(" abc") << '\n'
+ << convert<int>("abc ") << '\n'
+ << convert<int>(" abc ") << '\n'
+
+ << convert<int>(" 123 abc") << '\n'
+ << convert<int>("123 abc ") << '\n'
+ << convert<int>(" 123 abc ") << '\n'
+ << convert<int>("123 abc") << endl;
+}
+
+
+void convert_unsigned()
+{
+ cout << convert<unsigned int>(string("123")) << '\n'
+ << convert<unsigned int>(string(" 123")) << '\n'
+ << convert<unsigned int>(string("123 ")) << '\n'
+ << convert<unsigned int>(string(" 123 ")) << '\n'
+
+ << convert<unsigned int>(string("123 123")) << '\n'
+ << convert<unsigned int>(string(" 123 123")) << '\n'
+ << convert<unsigned int>(string("123 123 ")) << '\n'
+ << convert<unsigned int>(string(" 123 123 ")) << '\n'
+
+ << convert<unsigned int>(string()) << '\n'
+ << convert<unsigned int>(string("abc")) << '\n'
+ << convert<unsigned int>(string(" abc")) << '\n'
+ << convert<unsigned int>(string("abc ")) << '\n'
+ << convert<unsigned int>(string(" abc ")) << '\n'
+
+ << convert<unsigned int>(string(" 123 abc")) << '\n'
+ << convert<unsigned int>(string("123 abc ")) << '\n'
+ << convert<unsigned int>(string(" 123 abc ")) << '\n'
+ << convert<unsigned int>(string("123 abc")) << endl;
+}
+
+
+void convert_string()
+{
+ cout << convert<string>(123) << '\n'
+ << convert<string>(4294967173u) << '\n'
+ << convert<string>(true) << '\n'
+ << convert<string>(false) << '\n'
+
+ << convert<string>('a') << '\n'
+ << convert<string>(1.0) << '\n'
+ << convert<string>(1.1) << endl;
+}
+
+int main()
+{
+ convert_int();
+ convert_unsigned();
+ convert_string();
+}
--- /dev/null
+#include "../lstrings.h"
+
+#include <iostream>
+
+using namespace lyx::support;
+
+using namespace std;
+
+void test_lowercase()
+{
+ cout << lowercase('A') << endl;
+ cout << lowercase("AlLe") << endl;
+}
+
+void test_uppercase()
+{
+ cout << uppercase('a') << endl;
+ cout << uppercase("AlLe") << endl;
+}
+
+int main()
+{
+ test_lowercase();
+ test_uppercase();
+}
--- /dev/null
+123
+123
+123
+123
+123
+123
+123
+123
+-123
+-123
+-123
+-123
+-123
+-123
+-123
+-123
+0
+0
+0
+0
+0
+123
+123
+123
+123
+123
+123
+123
+123
+123
+123
+123
+123
+0
+0
+0
+0
+0
+123
+123
+123
+123
+123
+4294967173
+true
+false
+a
+1
+1.1
--- /dev/null
+a
+alle
+A
+ALLE
--- /dev/null
+#!/bin/bash
+
+regfile=`cat regfiles/convert`
+output=`./convert`
+
+test "$regfile" = "$output"
+exit $?
--- /dev/null
+#!/bin/bash
+
+regfile=`cat regfiles/lstrings`
+output=`./lstrings`
+
+test "$regfile" = "$output"
+exit $?
using lyx::support::ltrim;
using lyx::support::prefixIs;
using lyx::support::rtrim;
-using lyx::support::strToInt;
using lyx::support::suffixIs;
using boost::shared_ptr;
num = 0;
if (!getTokenValue(str, token, tmp))
return false;
- num = strToInt(tmp);
+ num = convert<int>(tmp);
return true;
}
+2005-01-27 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * Spacing (set): take double instead of float
+
+ * tex2lyx.C: convert stuff
+
2005-01-11 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* Spacing.h: remove unused parameters
Default
};
///
- void set(Spacing::Space, float = 1.0) {}
+ void set(Spacing::Space, double = 1.0) {}
///
void set(Spacing::Space, std::string const &) {}
};
#include "debug.h"
#include "lyxtextclass.h"
+
+#include "support/convert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
using lyx::support::isStrUnsignedInt;
using lyx::support::ltrim;
using lyx::support::rtrim;
-using lyx::support::strToUnsignedInt;
using lyx::support::IsFileReadable;
using lyx::support::IsFileWriteable;
string const opt1 = rtrim(ltrim(o1, "["), "]");
if (isStrUnsignedInt(opt1)) {
// The command has arguments
- nargs = strToUnsignedInt(opt1);
+ nargs = convert<unsigned int>(opt1);
if (nargs > 0 && o2) {
// The first argument is optional
arguments.push_back(optional);
using lyx::cap::replaceSelection;
using lyx::support::isStrUnsignedInt;
-using lyx::support::strToUnsignedInt;
-using lyx::support::atoi;
using lyx::support::token;
using std::endl;
#warning FIXME Check if the arg is in the domain of available selections.
#endif
if (isStrUnsignedInt(cmd.argument))
- pasteSelection(cur, strToUnsignedInt(cmd.argument));
+ pasteSelection(cur, convert<unsigned int>(cmd.argument));
else
pasteSelection(cur, 0);
cur.clearSelection(); // bug 393
else {
string s = cmd.argument;
string const s1 = token(s, ' ', 1);
- int const nargs = s1.empty() ? 0 : atoi(s1);
+ int const nargs = s1.empty() ? 0 : convert<int>(s1);
string const s2 = token(s, ' ', 2);
string const type = s2.empty() ? "newcommand" : s2;
cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, s2));
#include "lengthcommon.h"
#include "lyxtext.h"
+#include "support/convert.h"
#include "support/lstrings.h"
using lyx::support::compare;
using lyx::support::ltrim;
using lyx::support::prefixIs;
using lyx::support::rtrim;
-using lyx::support::strToDbl;
using std::string;
lyx_advance(data, i);
if (isStrDbl(buffer)) {
- number[number_index] = strToDbl(buffer);
+ number[number_index] = convert<double>(buffer);
++number_index;
return 'n';
}
// without units in added_space_top/bottom.
// Let unit default to centimeters here.
kind_ = LENGTH;
- len_ = LyXGlueLength(LyXLength(strToDbl(input), LyXLength::CM));
+ len_ = LyXGlueLength(LyXLength(convert<double>(input), LyXLength::CM));
}
}