This is the convert patch I am going to commit unless I hear a lot of bad language. (There are some testing code that is not visible here that will also be committed)
? Config ? convert-1.diff ? convert-2.diff ? convert-3.diff ? cppflags-1.diff ? idxupdown2-1.diff ? includes-1.diff ? src/support/package.C ? src/support/tests Index: configure.ac =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/configure.ac,v retrieving revision 1.39 diff -u -p -B -b -w -r1.39 configure.ac --- configure.ac 21 Jan 2005 13:48:12 -0000 1.39 +++ configure.ac 27 Jan 2005 18:33:17 -0000 @@ -413,6 +413,7 @@ AC_CONFIG_FILES([Makefile m4/Makefile \ src/graphics/Makefile \ src/insets/Makefile \ src/support/Makefile \ + src/support/tests/Makefile \ src/frontends/Makefile \ src/frontends/controllers/Makefile \ src/frontends/xforms/Makefile \ Index: po/POTFILES.in =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/po/POTFILES.in,v retrieving revision 1.403 diff -u -p -B -b -w -r1.403 POTFILES.in --- po/POTFILES.in 12 Jan 2005 12:25:29 -0000 1.403 +++ po/POTFILES.in 27 Jan 2005 18:33:19 -0000 @@ -206,6 +206,7 @@ src/paragraph.C 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 Index: src/BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.568 diff -u -p -B -b -w -r1.568 BufferView_pimpl.C --- src/BufferView_pimpl.C 24 Jan 2005 17:12:16 -0000 1.568 +++ src/BufferView_pimpl.C 27 Jan 2005 18:33:20 -0000 @@ -88,7 +88,6 @@ using lyx::support::IsDirWriteable; using lyx::support::MakeDisplayPath; using lyx::support::MakeAbsPath; using lyx::support::package; -using lyx::support::strToUnsignedInt; using std::endl; using std::istringstream; @@ -966,7 +965,7 @@ FuncStatus BufferView::Pimpl::getStatus( 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); @@ -1052,11 +1051,11 @@ bool BufferView::Pimpl::dispatch(FuncReq 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: { Index: src/Chktex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Chktex.C,v retrieving revision 1.33 diff -u -p -B -b -w -r1.33 Chktex.C --- src/Chktex.C 6 Jan 2004 19:32:05 -0000 1.33 +++ src/Chktex.C 27 Jan 2005 18:33:20 -0000 @@ -15,16 +15,15 @@ #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; @@ -82,7 +81,7 @@ int Chktex::scanLogFile(TeXErrors & terr 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; Index: src/Spacing.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Spacing.C,v retrieving revision 1.40 diff -u -p -B -b -w -r1.40 Spacing.C --- src/Spacing.C 6 Jan 2005 16:39:21 -0000 1.40 +++ src/Spacing.C 27 Jan 2005 18:33:20 -0000 @@ -18,9 +18,7 @@ #include <sstream> #include <string> -using lyx::support::strToDbl; -//using std::ios; using std::ostream; using std::ostringstream; using std::string; @@ -45,11 +43,11 @@ string const Spacing::getValueAsString() 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)); } @@ -59,7 +57,7 @@ void Spacing::set(Spacing::Space sp, str { 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; Index: src/Spacing.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Spacing.h,v retrieving revision 1.28 diff -u -p -B -b -w -r1.28 Spacing.h --- src/Spacing.h 6 Jan 2005 13:48:07 -0000 1.28 +++ src/Spacing.h 27 Jan 2005 18:33:20 -0000 @@ -35,7 +35,7 @@ public: /// 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) { @@ -52,7 +52,7 @@ public: /// 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); /// Index: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.607 diff -u -p -B -b -w -r1.607 buffer.C --- src/buffer.C 24 Jan 2005 17:12:15 -0000 1.607 +++ src/buffer.C 27 Jan 2005 18:33:22 -0000 @@ -111,7 +111,6 @@ using lyx::support::removeAutosaveFile; 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; @@ -609,7 +608,7 @@ bool Buffer::readFile(LyXLex & lex, stri //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) { @@ -650,7 +649,7 @@ bool Buffer::readFile(LyXLex & lex, stri 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; } Index: src/chset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/chset.C,v retrieving revision 1.33 diff -u -p -B -b -w -r1.33 chset.C --- src/chset.C 6 Oct 2003 15:42:07 -0000 1.33 +++ src/chset.C 27 Jan 2005 18:33:22 -0000 @@ -15,14 +15,13 @@ #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; @@ -66,7 +65,7 @@ bool CharacterSet::loadFile(string const 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 Index: src/debug.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/debug.C,v retrieving revision 1.42 diff -u -p -B -b -w -r1.42 debug.C --- src/debug.C 18 Jun 2004 13:31:53 -0000 1.42 +++ src/debug.C 27 Jan 2005 18:33:22 -0000 @@ -14,6 +14,7 @@ #include "debug.h" #include "gettext.h" +#include "support/convert.h" #include "support/lstrings.h" #include <iostream> @@ -22,7 +23,6 @@ using lyx::support::ascii_lowercase; using lyx::support::bformat; using lyx::support::isStrInt; -using lyx::support::strToInt; using std::setw; using std::string; @@ -78,13 +78,13 @@ lyx_debug_trait::type lyx_debug_trait::v 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) Index: src/lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.640 diff -u -p -B -b -w -r1.640 lyxfunc.C --- src/lyxfunc.C 16 Jan 2005 21:01:38 -0000 1.640 +++ src/lyxfunc.C 27 Jan 2005 18:33:23 -0000 @@ -113,8 +113,6 @@ using lyx::support::Path; 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; Index: src/lyxlayout.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlayout.h,v retrieving revision 1.18 diff -u -p -B -b -w -r1.18 lyxlayout.h --- src/lyxlayout.h 25 Nov 2003 17:23:33 -0000 1.18 +++ src/lyxlayout.h 27 Jan 2005 18:33:23 -0000 @@ -110,17 +110,17 @@ public: /// 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; /// Index: src/lyxlex.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlex.C,v retrieving revision 1.52 diff -u -p -B -b -w -r1.52 lyxlex.C --- src/lyxlex.C 20 Aug 2004 13:06:33 -0000 1.52 +++ src/lyxlex.C 27 Jan 2005 18:33:24 -0000 @@ -18,6 +18,7 @@ #include "debug.h" #include "lyxlex_pimpl.h" +#include "support/convert.h" #include "support/lstrings.h" using lyx::support::compare_ascii_no_case; @@ -25,8 +26,6 @@ using lyx::support::isStrDbl; 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; @@ -121,20 +120,20 @@ int LyXLex::lex() 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; } @@ -256,7 +255,7 @@ LyXLex & LyXLex::operator>>(std::string } -LyXLex & LyXLex::operator>>(float & s) +LyXLex & LyXLex::operator>>(double & s) { if (isOK()) { next(); Index: src/lyxlex.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlex.h,v retrieving revision 1.42 diff -u -p -B -b -w -r1.42 lyxlex.h --- src/lyxlex.h 19 Jan 2005 15:03:29 -0000 1.42 +++ src/lyxlex.h 27 Jan 2005 18:33:24 -0000 @@ -96,7 +96,7 @@ public: /// bool getBool() const; /// - float getFloat() const; + double getFloat() const; /// std::string const getString() const; @@ -131,8 +131,6 @@ public: /// extract string LyXLex & operator>>(std::string &); - /// extract float - LyXLex & operator>>(float &); /// extract double LyXLex & operator>>(double &); /// extract integer Index: src/tabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tabular.C,v retrieving revision 1.220 diff -u -p -B -b -w -r1.220 tabular.C --- src/tabular.C 6 Jan 2005 16:39:28 -0000 1.220 +++ src/tabular.C 27 Jan 2005 18:33:25 -0000 @@ -37,7 +37,6 @@ using lyx::support::ltrim; using lyx::support::prefixIs; using lyx::support::rtrim; -using lyx::support::strToInt; using lyx::support::suffixIs; using boost::shared_ptr; @@ -249,7 +248,7 @@ bool getTokenValue(string const & str, c num = 0; if (!getTokenValue(str, token, tmp)) return false; - num = strToInt(tmp); + num = convert<int>(tmp); return true; } Index: src/text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.279 diff -u -p -B -b -w -r1.279 text3.C --- src/text3.C 6 Jan 2005 16:39:31 -0000 1.279 +++ src/text3.C 27 Jan 2005 18:33:26 -0000 @@ -70,8 +70,6 @@ using lyx::cap::pasteSelection; using lyx::cap::replaceSelection; using lyx::support::isStrUnsignedInt; -using lyx::support::strToUnsignedInt; -using lyx::support::atoi; using lyx::support::token; using std::endl; @@ -886,7 +884,7 @@ void LyXText::dispatch(LCursor & cur, Fu #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 @@ -1331,7 +1329,7 @@ void LyXText::dispatch(LCursor & cur, Fu 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)); Index: src/vspace.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/vspace.C,v retrieving revision 1.82 diff -u -p -B -b -w -r1.82 vspace.C --- src/vspace.C 14 Nov 2004 10:20:11 -0000 1.82 +++ src/vspace.C 27 Jan 2005 18:33:28 -0000 @@ -17,6 +17,7 @@ #include "lengthcommon.h" #include "lyxtext.h" +#include "support/convert.h" #include "support/lstrings.h" using lyx::support::compare; @@ -24,7 +25,6 @@ using lyx::support::isStrDbl; using lyx::support::ltrim; using lyx::support::prefixIs; using lyx::support::rtrim; -using lyx::support::strToDbl; using std::string; @@ -117,7 +117,7 @@ char nextToken(string & data) lyx_advance(data, i); if (isStrDbl(buffer)) { - number[number_index] = strToDbl(buffer); + number[number_index] = convert<double>(buffer); ++number_index; return 'n'; } @@ -388,7 +388,7 @@ VSpace::VSpace(string const & data) // 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)); } } Index: src/client/debug.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/client/debug.C,v retrieving revision 1.1 diff -u -p -B -b -w -r1.1 debug.C --- src/client/debug.C 4 Sep 2004 12:13:50 -0000 1.1 +++ src/client/debug.C 27 Jan 2005 18:33:28 -0000 @@ -14,6 +14,7 @@ #include "debug.h" #include "gettext.h" +#include "support/convert.h" #include "support/lstrings.h" #include <iostream> @@ -22,7 +23,6 @@ using lyx::support::ascii_lowercase; using lyx::support::bformat; using lyx::support::isStrInt; -using lyx::support::strToInt; using std::setw; using std::string; @@ -61,7 +61,7 @@ lyx_debug_trait::type lyx_debug_trait::v 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) Index: src/frontends/xforms/FontInfo.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FontInfo.C,v retrieving revision 1.21 diff -u -p -B -b -w -r1.21 FontInfo.C --- src/frontends/xforms/FontInfo.C 6 Jan 2005 16:39:33 -0000 1.21 +++ src/frontends/xforms/FontInfo.C 27 Jan 2005 18:33:31 -0000 @@ -32,7 +32,6 @@ using std::string; namespace lyx { -using support::atoi; using support::token; namespace frontend { @@ -143,14 +142,14 @@ void FontInfo::query() 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; }; Index: src/frontends/xforms/FormExternal.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormExternal.C,v retrieving revision 1.58 diff -u -p -B -b -w -r1.58 FormExternal.C --- src/frontends/xforms/FormExternal.C 6 Jan 2005 16:39:34 -0000 1.58 +++ src/frontends/xforms/FormExternal.C 27 Jan 2005 18:33:31 -0000 @@ -47,8 +47,6 @@ using support::bformat; using support::float_equal; using support::getStringFromVector; using support::isStrDbl; -using support::strToDbl; -using support::strToInt; using support::token; using support::trim; @@ -145,7 +143,7 @@ void getDisplay(external::DisplayType & if (!fl_get_button(displayCB)) display = external::NoDisplay; - scale = strToInt(getString(scaleED)); + scale = convert<int>(getString(scaleED)); } @@ -243,13 +241,12 @@ void getSize(external::ResizeData & data 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; @@ -299,10 +296,10 @@ void getCrop(external::ClipData & data, 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)); } @@ -696,7 +693,7 @@ bool FormExternal::activateAspectratio() 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())) @@ -706,7 +703,7 @@ bool FormExternal::activateAspectratio() 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; Index: src/frontends/xforms/FormGraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormGraphics.C,v retrieving revision 1.130 diff -u -p -B -b -w -r1.130 FormGraphics.C --- src/frontends/xforms/FormGraphics.C 6 Jan 2005 16:39:34 -0000 1.130 +++ src/frontends/xforms/FormGraphics.C 27 Jan 2005 18:33:31 -0000 @@ -51,8 +51,6 @@ namespace lyx { using support::bformat; using support::float_equal; using support::getStringFromVector; -using support::strToDbl; -using support::strToInt; using support::token; namespace frontend { @@ -306,7 +304,7 @@ void FormGraphics::apply() 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; } @@ -332,13 +330,13 @@ void FormGraphics::apply() 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)); } @@ -411,7 +409,7 @@ void FormGraphics::apply() 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); @@ -461,7 +459,7 @@ void FormGraphics::update() { } // 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()); @@ -478,7 +476,7 @@ void FormGraphics::update() { // 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); @@ -502,11 +500,9 @@ void FormGraphics::update() { // 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); Index: src/frontends/xforms/FormPreferences.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormPreferences.C,v retrieving revision 1.197 diff -u -p -B -b -w -r1.197 FormPreferences.C --- src/frontends/xforms/FormPreferences.C 20 Jan 2005 15:02:16 -0000 1.197 +++ src/frontends/xforms/FormPreferences.C 27 Jan 2005 18:33:33 -0000 @@ -28,6 +28,7 @@ #include "LColor.h" #include "lyxfont.h" +#include "support/convert.h" #include "support/lstrings.h" #include "support/package.h" #include "support/filetools.h" @@ -52,7 +53,6 @@ using support::AddName; using support::ChangeExtension; using support::package; using support::rtrim; -using support::strToDbl; using support::trim; namespace frontend { @@ -2825,38 +2825,37 @@ bool FormPreferences::ScreenFonts::input // 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."); Index: src/frontends/xforms/FormPrint.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormPrint.C,v retrieving revision 1.67 diff -u -p -B -b -w -r1.67 FormPrint.C --- src/frontends/xforms/FormPrint.C 6 Jan 2005 16:39:34 -0000 1.67 +++ src/frontends/xforms/FormPrint.C 27 Jan 2005 18:33:33 -0000 @@ -31,8 +31,6 @@ using std::string; namespace lyx { -using support::strToInt; - namespace frontend { typedef FormController<ControlPrint, FormView<FD_print> > base_class; @@ -128,10 +126,10 @@ void FormPrint::apply() 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. } @@ -228,18 +226,18 @@ ButtonPolicy::SMInput FormPrint::input(F 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; } Index: src/frontends/xforms/xfont_loader.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/xfont_loader.C,v retrieving revision 1.30 diff -u -p -B -b -w -r1.30 xfont_loader.C --- src/frontends/xforms/xfont_loader.C 5 Jan 2005 10:54:31 -0000 1.30 +++ src/frontends/xforms/xfont_loader.C 27 Jan 2005 18:33:33 -0000 @@ -19,8 +19,8 @@ #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" @@ -33,7 +33,6 @@ using std::string; namespace lyx { using support::LibFileSearch; -using support::strToDbl; using support::OnlyPath; using support::Systemcall; @@ -333,7 +332,7 @@ XFontStruct * xfont_loader::doLoad(LyXFo 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); Index: src/graphics/GraphicsParams.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsParams.h,v retrieving revision 1.28 diff -u -p -B -b -w -r1.28 GraphicsParams.h --- src/graphics/GraphicsParams.h 19 Jan 2005 15:03:30 -0000 1.28 +++ src/graphics/GraphicsParams.h 27 Jan 2005 18:33:33 -0000 @@ -69,7 +69,7 @@ public: * image. */ /// Rotation angle. - float angle; + double angle; }; bool operator==(Params const &, Params const &); Index: src/graphics/PreviewLoader.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/PreviewLoader.C,v retrieving revision 1.85 diff -u -p -B -b -w -r1.85 PreviewLoader.C --- src/graphics/PreviewLoader.C 19 Jan 2005 15:03:30 -0000 1.85 +++ src/graphics/PreviewLoader.C 27 Jan 2005 18:33:34 -0000 @@ -320,7 +320,7 @@ PreviewLoader::Impl::Impl(PreviewLoader : 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; Index: src/insets/ExternalTransforms.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ExternalTransforms.C,v retrieving revision 1.12 diff -u -p -B -b -w -r1.12 ExternalTransforms.C --- src/insets/ExternalTransforms.C 6 Jan 2005 16:39:34 -0000 1.12 +++ src/insets/ExternalTransforms.C 27 Jan 2005 18:33:34 -0000 @@ -25,7 +25,6 @@ #include <sstream> using lyx::support::float_equal; -using lyx::support::strToDbl; using std::string; @@ -54,20 +53,20 @@ bool ResizeData::no_resize() const 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); @@ -103,7 +102,7 @@ string const ResizeLatexCommand::front_i 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 = "!"; @@ -235,7 +234,7 @@ string const ResizeLatexOption::option_i 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(); Index: src/insets/insetbibitem.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibitem.C,v retrieving revision 1.54 diff -u -p -B -b -w -r1.54 insetbibitem.C --- src/insets/insetbibitem.C 6 Jan 2005 16:39:34 -0000 1.54 +++ src/insets/insetbibitem.C 27 Jan 2005 18:33:34 -0000 @@ -28,7 +28,6 @@ #include "support/convert.h" using lyx::support::prefixIs; -using lyx::support::strToInt; using std::max; using std::string; @@ -103,7 +102,7 @@ void InsetBibitem::read(Buffer const &, 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); } } Index: src/insets/insetcollapsable.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v retrieving revision 1.264 diff -u -p -B -b -w -r1.264 insetcollapsable.C --- src/insets/insetcollapsable.C 30 Nov 2004 01:59:47 -0000 1.264 +++ src/insets/insetcollapsable.C 27 Jan 2005 18:33:34 -0000 @@ -408,7 +408,7 @@ void InsetCollapsable::setLabelFont(LyXF } -void InsetCollapsable::scroll(BufferView & bv, float sx) const +void InsetCollapsable::scroll(BufferView & bv, double sx) const { UpdatableInset::scroll(bv, sx); } Index: src/insets/insetcollapsable.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v retrieving revision 1.179 diff -u -p -B -b -w -r1.179 insetcollapsable.h --- src/insets/insetcollapsable.h 30 Nov 2004 01:59:47 -0000 1.179 +++ src/insets/insetcollapsable.h 27 Jan 2005 18:33:34 -0000 @@ -73,7 +73,7 @@ public: /// 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; /// Index: src/insets/insetexternal.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.C,v retrieving revision 1.157 diff -u -p -B -b -w -r1.157 insetexternal.C --- src/insets/insetexternal.C 6 Jan 2005 16:39:34 -0000 1.157 +++ src/insets/insetexternal.C 27 Jan 2005 18:33:36 -0000 @@ -228,7 +228,7 @@ void InsetExternalParams::write(Buffer c 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 " @@ -524,7 +524,7 @@ graphics::Params get_grfx_params(InsetEx 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: Index: src/insets/insetgraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v retrieving revision 1.271 diff -u -p -B -b -w -r1.271 insetgraphics.C --- src/insets/insetgraphics.C 14 Jan 2005 19:13:17 -0000 1.271 +++ src/insets/insetgraphics.C 27 Jan 2005 18:33:36 -0000 @@ -74,6 +74,7 @@ TODO #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 @@ -99,7 +100,6 @@ using lyx::support::GetExtension; 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; @@ -299,7 +299,7 @@ string const InsetGraphics::createLatexO 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 @@ -316,7 +316,7 @@ string const InsetGraphics::createLatexO // 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]; @@ -405,7 +405,7 @@ string const InsetGraphics::createDocBoo // 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=\"" Index: src/insets/insetgraphicsParams.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphicsParams.C,v retrieving revision 1.72 diff -u -p -B -b -w -r1.72 insetgraphicsParams.C --- src/insets/insetgraphicsParams.C 12 Jan 2005 10:30:45 -0000 1.72 +++ src/insets/insetgraphicsParams.C 27 Jan 2005 18:33:36 -0000 @@ -21,6 +21,7 @@ #include "graphics/GraphicsParams.h" +#include "support/convert.h" #include "support/filetools.h" #include "support/lyxlib.h" #include "support/lstrings.h" @@ -28,8 +29,6 @@ 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; @@ -155,8 +154,8 @@ void InsetGraphicsParams::Write(ostream 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()) @@ -178,7 +177,7 @@ void InsetGraphicsParams::Write(ostream 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'; @@ -267,7 +266,7 @@ lyx::graphics::Params InsetGraphicsParam 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; @@ -276,8 +275,9 @@ lyx::graphics::Params InsetGraphicsParam 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) Index: src/insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.451 diff -u -p -B -b -w -r1.451 insettabular.C --- src/insets/insettabular.C 18 Jan 2005 14:15:56 -0000 1.451 +++ src/insets/insettabular.C 27 Jan 2005 18:33:37 -0000 @@ -33,6 +33,8 @@ #include "ParagraphParameters.h" #include "undo.h" +#include "support/convert.h" + #include "frontends/Alert.h" #include "frontends/font_metrics.h" #include "frontends/LyXView.h" @@ -46,8 +48,6 @@ using lyx::graphics::PreviewLoader; using lyx::support::ltrim; -using lyx::support::strToInt; -using lyx::support::strToDbl; using boost::shared_ptr; @@ -496,9 +496,9 @@ void InsetTabular::doDispatch(LCursor & 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: @@ -878,7 +878,7 @@ bool InsetTabular::getStatus(LCursor & c 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: @@ -1496,7 +1496,7 @@ void InsetTabular::tabularFeatures(LCurs 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) Index: src/insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.604 diff -u -p -B -b -w -r1.604 insettext.C --- src/insets/insettext.C 29 Dec 2004 11:39:17 -0000 1.604 +++ src/insets/insettext.C 27 Jan 2005 18:33:38 -0000 @@ -57,7 +57,6 @@ using lyx::pos_type; using lyx::graphics::PreviewLoader; using lyx::support::isStrUnsignedInt; -using lyx::support::strToUnsignedInt; using boost::bind; using boost::ref; Index: src/insets/updatableinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/updatableinset.C,v retrieving revision 1.49 diff -u -p -B -b -w -r1.49 updatableinset.C --- src/insets/updatableinset.C 18 Jan 2005 14:15:56 -0000 1.49 +++ src/insets/updatableinset.C 27 Jan 2005 18:33:38 -0000 @@ -23,14 +23,10 @@ #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 @@ -39,7 +35,7 @@ InsetBase::EDITABLE UpdatableInset::edit } -void UpdatableInset::scroll(BufferView & bv, float s) const +void UpdatableInset::scroll(BufferView & bv, double s) const { if (!s) { scx = 0; @@ -52,7 +48,7 @@ void UpdatableInset::scroll(BufferView & 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); @@ -100,9 +96,9 @@ void UpdatableInset::doDispatch(LCursor 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; Index: src/insets/updatableinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/updatableinset.h,v retrieving revision 1.36 diff -u -p -B -b -w -r1.36 updatableinset.h --- src/insets/updatableinset.h 24 Nov 2004 21:58:41 -0000 1.36 +++ src/insets/updatableinset.h 27 Jan 2005 18:33:38 -0000 @@ -40,7 +40,7 @@ protected: /// 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; }; Index: src/mathed/math_parser.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v retrieving revision 1.309 diff -u -p -B -b -w -r1.309 math_parser.C --- src/mathed/math_parser.C 10 Jan 2005 08:38:28 -0000 1.309 +++ src/mathed/math_parser.C 27 Jan 2005 18:33:38 -0000 @@ -62,11 +62,10 @@ following hack as starting point to writ #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; @@ -854,9 +853,9 @@ void Parser::parse1(MathGridInset & grid return; } - string arg = getArg('[', ']'); + string const arg = getArg('[', ']'); if (!arg.empty()) - nargs = atoi(arg); + nargs = convert<int>(arg); } Index: src/mathed/math_sizeinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sizeinset.C,v retrieving revision 1.44 diff -u -p -B -b -w -r1.44 math_sizeinset.C --- src/mathed/math_sizeinset.C 23 Nov 2004 23:04:52 -0000 1.44 +++ src/mathed/math_sizeinset.C 27 Jan 2005 18:33:38 -0000 @@ -16,16 +16,14 @@ #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))) {} Index: src/support/Makefile.am =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/Makefile.am,v retrieving revision 1.85 diff -u -p -B -b -w -r1.85 Makefile.am --- src/support/Makefile.am 10 Jan 2005 19:17:43 -0000 1.85 +++ src/support/Makefile.am 27 Jan 2005 18:33:38 -0000 @@ -1,5 +1,7 @@ include $(top_srcdir)/config/common.am +SUBDIRS = . tests + noinst_LTLIBRARIES = libsupport.la CLEANFILES += path_defines.C @@ -20,7 +22,6 @@ libsupport_la_SOURCES = \ FileMonitor.h \ FileMonitor.C \ abort.C \ - atoi.C \ chdir.C \ convert.C \ convert.h \ Index: src/support/atoi.C =================================================================== RCS file: src/support/atoi.C diff -N src/support/atoi.C --- src/support/atoi.C 7 Nov 2004 13:22:51 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/** - * \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()); -} Index: src/support/convert.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/convert.C,v retrieving revision 1.3 diff -u -p -B -b -w -r1.3 convert.C --- src/support/convert.C 7 Jan 2005 17:54:12 -0000 1.3 +++ src/support/convert.C 27 Jan 2005 18:33:38 -0000 @@ -83,3 +83,38 @@ string convert<string>(double d) { 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); +} Index: src/support/convert.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/convert.h,v retrieving revision 1.3 diff -u -p -B -b -w -r1.3 convert.h --- src/support/convert.h 7 Jan 2005 13:32:26 -0000 1.3 +++ src/support/convert.h 27 Jan 2005 18:33:38 -0000 @@ -16,21 +16,7 @@ #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 Index: src/support/lstrings.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/lstrings.C,v retrieving revision 1.89 diff -u -p -B -b -w -r1.89 lstrings.C --- src/support/lstrings.C 6 Jan 2005 16:39:35 -0000 1.89 +++ src/support/lstrings.C 27 Jan 2005 18:33:38 -0000 @@ -37,7 +37,6 @@ using std::string; using std::vector; #ifndef CXX_GLOBAL_CSTD -using std::atof; using std::isdigit; using std::tolower; using std::toupper; @@ -158,32 +157,6 @@ bool isStrUnsignedInt(string const & str } -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; @@ -211,19 +184,6 @@ bool isStrDbl(string const & str) } } return true; -} - - -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; - } } Index: src/support/lstrings.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/lstrings.h,v retrieving revision 1.57 diff -u -p -B -b -w -r1.57 lstrings.h --- src/support/lstrings.h 6 Jan 2005 15:40:49 -0000 1.57 +++ src/support/lstrings.h 27 Jan 2005 18:33:38 -0000 @@ -61,16 +61,7 @@ bool isStrInt(std::string const & str); 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); Index: src/support/lyxlib.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/lyxlib.h,v retrieving revision 1.36 diff -u -p -B -b -w -r1.36 lyxlib.h --- src/support/lyxlib.h 20 Jan 2005 19:30:14 -0000 1.36 +++ src/support/lyxlib.h 27 Jan 2005 18:33:38 -0000 @@ -46,8 +46,6 @@ bool putenv(std::string const & varname, 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()); Index: src/tex2lyx/Spacing.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/Spacing.h,v retrieving revision 1.6 diff -u -p -B -b -w -r1.6 Spacing.h --- src/tex2lyx/Spacing.h 12 Jan 2005 17:01:35 -0000 1.6 +++ src/tex2lyx/Spacing.h 27 Jan 2005 18:33:38 -0000 @@ -29,7 +29,7 @@ public: Default }; /// - void set(Spacing::Space, float = 1.0) {} + void set(Spacing::Space, double = 1.0) {} /// void set(Spacing::Space, std::string const &) {} }; Index: src/tex2lyx/tex2lyx.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/tex2lyx.C,v retrieving revision 1.63 diff -u -p -B -b -w -r1.63 tex2lyx.C --- src/tex2lyx/tex2lyx.C 12 Jan 2005 10:30:46 -0000 1.63 +++ src/tex2lyx/tex2lyx.C 27 Jan 2005 18:33:39 -0000 @@ -17,6 +17,8 @@ #include "debug.h" #include "lyxtextclass.h" + +#include "support/convert.h" #include "support/filetools.h" #include "support/lstrings.h" #include "support/lyxlib.h" @@ -50,7 +52,6 @@ using std::map; using lyx::support::isStrUnsignedInt; using lyx::support::ltrim; using lyx::support::rtrim; -using lyx::support::strToUnsignedInt; using lyx::support::IsFileReadable; using lyx::support::IsFileWriteable; @@ -137,7 +138,7 @@ void add_known_command(string const & co 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);
-- Lgb