From 92d522b7f1be6046adcac062c558bbf0bf021612 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 30 Jun 2003 23:56:22 +0000 Subject: [PATCH] introduce namespace lyx::support git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7224 a592a061-630c-0410-9148-cb99ea01b6c8 --- boost/boost/format/format_implementation.hpp | 68 +- boost/boost/format/parsing.hpp | 126 ++-- src/BufferView.C | 3 +- src/BufferView_pimpl.C | 10 +- src/Bullet.C | 20 +- src/ChangeLog | 3 + src/Chktex.C | 4 +- src/CutAndPaste.C | 15 +- src/DepTable.C | 6 +- src/LColor.C | 4 +- src/LString.h | 3 +- src/LaTeX.C | 12 +- src/LaTeXFeatures.C | 2 + src/LyXAction.C | 2 + src/MenuBackend.C | 10 +- src/ParagraphParameters.C | 2 + src/PrinterParams.h | 6 +- src/ToolbarBackend.C | 8 +- src/author.C | 6 +- src/boost.C | 4 +- src/buffer.C | 8 +- src/buffer_funcs.C | 16 +- src/bufferlist.C | 8 +- src/bufferparams.C | 2 + src/bufferview_funcs.C | 2 + src/changes.C | 8 +- src/chset.C | 4 +- src/converter.C | 10 +- src/counters.C | 4 +- src/debug.C | 2 + src/exporter.C | 3 +- src/factory.C | 2 + src/format.C | 2 + src/frontends/LyXView.C | 2 +- src/frontends/Timeout.C | 4 +- src/frontends/controllers/ButtonController.C | 5 +- src/frontends/controllers/ChangeLog | 4 + src/frontends/controllers/ControlAboutlyx.C | 2 + src/frontends/controllers/ControlBibtex.C | 2 + src/frontends/controllers/ControlButtons.C | 5 +- src/frontends/controllers/ControlChanges.C | 1 + .../controllers/ControlCommandBuffer.C | 2 + src/frontends/controllers/ControlDocument.C | 4 +- src/frontends/controllers/ControlExternal.C | 9 +- src/frontends/controllers/ControlForks.C | 2 + src/frontends/controllers/ControlGraphics.C | 2 + src/frontends/controllers/ControlInclude.C | 2 + src/frontends/controllers/ControlMath.C | 1 + src/frontends/controllers/ControlParagraph.C | 5 +- src/frontends/controllers/ControlPrefs.C | 2 + src/frontends/controllers/ControlPrint.C | 6 +- src/frontends/controllers/ControlRef.C | 2 + src/frontends/controllers/ControlSendto.C | 2 + src/frontends/controllers/ControlShowFile.C | 2 + .../controllers/ControlSpellchecker.C | 4 +- src/frontends/controllers/ControlTabular.C | 4 +- src/frontends/controllers/ControlVCLog.C | 4 +- src/frontends/controllers/Dialog.C | 13 +- src/frontends/controllers/ViewBase.C | 5 +- src/frontends/controllers/biblio.C | 8 +- src/frontends/controllers/helper_funcs.C | 2 + src/frontends/controllers/tex_helpers.C | 4 +- src/frontends/qt2/BulletsModule.C | 4 +- src/frontends/qt2/ChangeLog | 4 + src/frontends/qt2/FileDialog_private.C | 1 + src/frontends/qt2/QAbout.C | 2 + src/frontends/qt2/QBibtex.C | 2 + src/frontends/qt2/QBibtexDialog.C | 1 + src/frontends/qt2/QCitation.C | 1 + src/frontends/qt2/QCommandBuffer.C | 2 + src/frontends/qt2/QDocumentDialog.C | 3 +- src/frontends/qt2/QExternal.C | 2 + src/frontends/qt2/QGraphics.C | 5 +- src/frontends/qt2/QLImage.C | 2 + src/frontends/qt2/QLPopupMenu.C | 2 + src/frontends/qt2/QMinipage.C | 2 + src/frontends/qt2/QParagraph.C | 2 + src/frontends/qt2/QPrefs.C | 8 +- src/frontends/qt2/QTexinfo.C | 2 + src/frontends/qt2/QVCLog.C | 4 +- src/frontends/qt2/QWrap.C | 1 + src/frontends/qt2/QtView.C | 2 + src/frontends/qt2/floatplacement.C | 2 + src/frontends/qt2/lyx_gui.C | 2 + src/frontends/qt2/panelstack.C | 6 +- src/frontends/qt2/qfont_loader.C | 2 + src/frontends/screen.C | 4 +- src/frontends/xforms/ChangeLog | 3 + src/frontends/xforms/ColorHandler.C | 4 +- src/frontends/xforms/FileDialog.C | 1 + src/frontends/xforms/FontInfo.C | 6 +- src/frontends/xforms/FormBase.C | 23 +- src/frontends/xforms/FormBibitem.C | 2 + src/frontends/xforms/FormBibtex.C | 1 + src/frontends/xforms/FormCharacter.C | 7 +- src/frontends/xforms/FormCitation.C | 6 +- src/frontends/xforms/FormDialogView.C | 22 +- src/frontends/xforms/FormDocument.C | 2 + src/frontends/xforms/FormExternal.C | 2 + src/frontends/xforms/FormFiledialog.C | 6 +- src/frontends/xforms/FormFloat.C | 2 + src/frontends/xforms/FormForks.C | 2 + src/frontends/xforms/FormGraphics.C | 8 +- src/frontends/xforms/FormInclude.C | 6 +- src/frontends/xforms/FormMathsBitmap.C | 4 +- src/frontends/xforms/FormMathsMatrix.C | 6 +- src/frontends/xforms/FormMinipage.C | 2 + src/frontends/xforms/FormParagraph.C | 8 +- src/frontends/xforms/FormPreferences.C | 6 +- src/frontends/xforms/FormPrint.C | 1 + src/frontends/xforms/FormRef.C | 6 +- src/frontends/xforms/FormSendto.C | 3 +- src/frontends/xforms/FormTabular.C | 9 +- src/frontends/xforms/FormTexinfo.C | 2 + src/frontends/xforms/FormText.C | 2 + src/frontends/xforms/FormThesaurus.C | 4 +- src/frontends/xforms/FormToc.C | 2 + src/frontends/xforms/FormWrap.C | 1 + src/frontends/xforms/Menubar_pimpl.C | 4 +- src/frontends/xforms/RadioButtonGroup.C | 4 +- src/frontends/xforms/Tooltips.C | 4 +- src/frontends/xforms/XFormsView.C | 3 + src/frontends/xforms/XPainter.C | 5 +- src/frontends/xforms/checkedwidgets.C | 5 +- src/frontends/xforms/forms_gettext.C | 2 + src/frontends/xforms/input_validators.C | 2 + src/frontends/xforms/lyx_gui.C | 4 +- src/frontends/xforms/xfont_loader.C | 2 + src/frontends/xforms/xfont_metrics.C | 2 + src/frontends/xforms/xformsImage.C | 11 +- src/frontends/xforms/xforms_helpers.C | 12 +- src/frontends/xforms/xforms_resize.C | 10 +- src/graphics/ChangeLog | 22 +- src/graphics/GraphicsCache.C | 2 + src/graphics/GraphicsCacheItem.C | 19 +- src/graphics/GraphicsConverter.C | 12 +- src/graphics/GraphicsTypes.h | 1 + src/graphics/PreviewImage.C | 5 +- src/graphics/PreviewLoader.C | 10 +- src/graphics/PreviewedInset.C | 2 + src/graphics/Previews.C | 4 +- src/importer.C | 2 + src/insets/ChangeLog | 7 +- src/insets/ExternalTemplate.C | 4 +- src/insets/inset.C | 2 +- src/insets/inset.h | 2 +- src/insets/insetbibitem.C | 1 + src/insets/insetbibtex.C | 4 +- src/insets/insetcaption.C | 4 +- src/insets/insetcite.C | 2 + src/insets/insetcollapsable.C | 4 +- src/insets/insetert.C | 1 + src/insets/insetexternal.C | 18 +- src/insets/insetfloat.C | 2 + src/insets/insetfloatlist.C | 2 + src/insets/insetgraphics.C | 22 +- src/insets/insetgraphicsParams.C | 8 +- src/insets/insetinclude.C | 2 + src/insets/insetlabel.C | 2 + src/insets/insetlatexaccent.C | 2 + src/insets/insetquotes.C | 4 +- src/insets/insetref.C | 2 + src/insets/insettabular.C | 6 +- src/insets/insettext.C | 14 +- src/insets/inseturl.C | 2 + src/insets/mailinset.C | 5 +- src/insets/renderers.C | 10 +- src/insets/updatableinset.C | 1 + src/ispell.C | 6 +- src/ispell.h | 6 +- src/lastfiles.C | 2 + src/lyx_cb.C | 8 +- src/lyx_main.C | 10 +- src/lyxfind.C | 2 + src/lyxfont.C | 2 + src/lyxfunc.C | 6 +- src/lyxlayout.C | 2 + src/lyxlex.C | 2 + src/lyxlex_pimpl.C | 2 + src/lyxrc.C | 6 +- src/lyxserver.C | 7 +- src/lyxtextclass.C | 6 +- src/lyxtextclasslist.C | 2 + src/lyxvc.C | 4 +- src/main.C | 2 + src/mathed/ChangeLog | 4 + src/mathed/formulabase.C | 9 +- src/mathed/formulamacro.C | 2 + src/mathed/math_autocorrect.C | 3 +- src/mathed/math_cursor.C | 14 +- src/mathed/math_data.C | 7 +- src/mathed/math_exfuncinset.C | 3 +- src/mathed/math_extern.C | 2 + src/mathed/math_factory.C | 6 +- src/mathed/math_fontinset.C | 2 +- src/mathed/math_hullinset.C | 8 +- src/mathed/math_iterator.C | 8 +- src/mathed/math_pos.C | 8 +- src/mathed/math_scriptinset.C | 6 +- src/mathed/math_tabularinset.C | 2 +- src/messages.C | 2 + src/paragraph.C | 16 +- src/paragraph_funcs.C | 4 +- src/paragraph_pimpl.C | 17 +- src/pspell.C | 6 +- src/rowpainter.C | 8 +- src/support/ChangeLog | 3 + src/support/FileInfo.C | 40 +- src/support/FileInfo.h | 6 + src/support/FileMonitor.C | 12 +- src/support/FileMonitor.h | 6 + src/support/LAssert.C | 22 +- src/support/LAssert.h | 23 +- src/support/abort.C | 2 +- src/support/atoi.C | 2 +- src/support/chdir.C | 2 +- src/support/copy.C | 2 +- src/support/filetools.C | 42 +- src/support/filetools.h | 6 + src/support/forkedcall.C | 12 +- src/support/forkedcall.h | 6 + src/support/forkedcallqueue.C | 6 + src/support/forkedcallqueue.h | 22 +- src/support/forkedcontr.C | 6 + src/support/forkedcontr.h | 9 +- src/support/getcwd.C | 2 +- src/support/kill.C | 2 +- src/support/lstrings.C | 36 +- src/support/lstrings.h | 6 + src/support/lyxlib.h | 2 + src/support/lyxstring.C | 676 +++++++++--------- src/support/lyxstring.h | 194 ++--- src/support/lyxsum.C | 6 +- src/support/mkdir.C | 2 +- src/support/os.h | 76 +- src/support/os_unix.C | 7 +- src/support/path.C | 8 +- src/support/path.h | 10 +- src/support/putenv.C | 2 +- src/support/rename.C | 8 +- src/support/rmdir.C | 2 +- src/support/systemcall.C | 6 + src/support/systemcall.h | 6 + src/support/tempname.C | 3 +- src/support/translator.h | 4 +- src/support/unlink.C | 2 +- src/support/userinfo.C | 5 +- src/support/userinfo.h | 4 +- src/tabular.C | 12 +- src/tabular_funcs.C | 2 + src/text.C | 20 +- src/text2.C | 8 +- src/text3.C | 6 +- src/trans.C | 2 + src/trans_mgr.C | 2 + src/undo_funcs.C | 10 +- src/vc-backend.C | 2 + src/vspace.C | 2 + 258 files changed, 1551 insertions(+), 1029 deletions(-) diff --git a/boost/boost/format/format_implementation.hpp b/boost/boost/format/format_implementation.hpp index a41113a940..0ad23f88cb 100644 --- a/boost/boost/format/format_implementation.hpp +++ b/boost/boost/format/format_implementation.hpp @@ -58,7 +58,7 @@ basic_format ::basic_format(const string_t& s, const std::locale & loc) { oss_.imbue( loc ); state0_.set_by_stream(oss_); - parse(s); + parse(s); } #endif //BOOST_NO_STD_LOCALE @@ -68,18 +68,18 @@ basic_format ::basic_format(const string_t& s) items_(), oss_(), exceptions_(io::all_error_bits) { state0_.set_by_stream(oss_); - parse(s); + parse(s); } template< class Ch, class Tr> basic_format :: basic_format(const basic_format& x) - : style_(x.style_), cur_arg_(x.cur_arg_), num_args_(x.num_args_), dumped_(false), - items_(x.items_), prefix_(x.prefix_), bound_(x.bound_), + : style_(x.style_), cur_arg_(x.cur_arg_), num_args_(x.num_args_), dumped_(false), + items_(x.items_), prefix_(x.prefix_), bound_(x.bound_), oss_(), // <- we obviously can't copy x.oss_ state0_(x.state0_), exceptions_(x.exceptions_) -{ +{ state0_.apply_on(oss_); -} +} template< class Ch, class Tr> basic_format& basic_format ::operator= (const basic_format& x) @@ -94,8 +94,8 @@ basic_format& basic_format ::operator= (const basic_format& x) items_ = x.items_; prefix_ = x.prefix_; bound_=x.bound_; - style_=x.style_; - cur_arg_=x.cur_arg_; + style_=x.style_; + cur_arg_=x.cur_arg_; num_args_=x.num_args_; dumped_=x.dumped_; return *this; @@ -103,17 +103,17 @@ basic_format& basic_format ::operator= (const basic_format& x) template< class Ch, class Tr> -unsigned char basic_format ::exceptions() const +unsigned char basic_format ::exceptions() const { - return exceptions_; + return exceptions_; } template< class Ch, class Tr> -unsigned char basic_format ::exceptions(unsigned char newexcept) -{ - unsigned char swp = exceptions_; - exceptions_ = newexcept; - return swp; +unsigned char basic_format ::exceptions(unsigned char newexcept) +{ + unsigned char swp = exceptions_; + exceptions_ = newexcept; + return swp; } @@ -139,7 +139,7 @@ basic_format& basic_format ::clear() } template< class Ch, class Tr> -basic_format& basic_format ::clear_binds() +basic_format& basic_format ::clear_binds() // cancel all bindings, and clear() { bound_.resize(0); @@ -148,10 +148,10 @@ basic_format& basic_format ::clear_binds() } template< class Ch, class Tr> -basic_format& basic_format ::clear_bind(int argN) +basic_format& basic_format ::clear_bind(int argN) // cancel the binding of ONE argument, and clear() { - if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] ) + if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] ) { if( exceptions() & io::out_of_range_bit ) boost::throw_exception(io::out_of_range()); // arg not in range. @@ -176,18 +176,18 @@ std::basic_string basic_format ::str() const unsigned long sz = prefix_.size(); unsigned long i; - for(i=0; i < items_.size(); ++i) + for(i=0; i < items_.size(); ++i) sz += items_[i].res_.size() + items_[i].appendix_.size(); string_t res; res.reserve(sz); res += prefix_; - for(i=0; i < items_.size(); ++i) + for(i=0; i < items_.size(); ++i) { const format_item_t& item = items_[i]; res += item.res_; - if( item.argN_ == format_item_t::argN_tabulation) - { + if( item.argN_ == format_item_t::argN_tabulation) + { BOOST_ASSERT( item.pad_scheme_ & format_item_t::tabulation); std::streamsize n = item.state_.width_ - res.size(); if( n > 0 ) @@ -201,33 +201,33 @@ std::basic_string basic_format ::str() const namespace io { namespace detail { -template -basic_format& bind_arg_body( basic_format& self, - int argN, +template +basic_format& bind_arg_body( basic_format& self, + int argN, const T& val) // bind one argument to a fixed value // this is persistent over clear() calls, thus also over str() and << { if(self.dumped_) self.clear(); // needed, because we will modify cur_arg_.. - if(argN<1 || argN > self.num_args_) + if(argN<1 || argN > self.num_args_) { if( self.exceptions() & io::out_of_range_bit ) boost::throw_exception(io::out_of_range()); // arg not in range. else return self; } - if(self.bound_.size()==0) + if(self.bound_.size()==0) self.bound_.assign(self.num_args_,false); - else + else BOOST_ASSERT( self.num_args_ == static_cast(self.bound_.size()) ); int o_cur_arg = self.cur_arg_; self.cur_arg_ = argN-1; // arrays begin at 0 self.bound_[self.cur_arg_]=false; // if already set, we unset and re-sets.. self.operator%(val); // put val at the right place, because cur_arg is set - + // Now re-position cur_arg before leaving : - self.cur_arg_ = o_cur_arg; + self.cur_arg_ = o_cur_arg; self.bound_[argN-1]=true; if(self.cur_arg_ == argN-1 ) // hum, now this arg is bound, so move to next free arg @@ -239,16 +239,16 @@ basic_format& bind_arg_body( basic_format& self, return self; } -template +template basic_format& modify_item_body( basic_format& self, - int itemN, + int itemN, const T& manipulator) // applies a manipulator to the format_item describing a given directive. // this is a permanent change, clear or clear_binds won't cancel that. { - if(itemN<1 || itemN >= static_cast(self.items_.size() )) + if(itemN<1 || itemN >= static_cast(self.items_.size() )) { - if( self.exceptions() & io::out_of_range_bit ) + if( self.exceptions() & io::out_of_range_bit ) boost::throw_exception(io::out_of_range()); // item not in range. else return self; } diff --git a/boost/boost/format/parsing.hpp b/boost/boost/format/parsing.hpp index 1e8bd904c3..d745bb9af2 100644 --- a/boost/boost/format/parsing.hpp +++ b/boost/boost/format/parsing.hpp @@ -32,21 +32,21 @@ namespace io { namespace detail { template inline - bool wrap_isdigit(Ch c, Stream &os) + bool wrap_isdigit(Ch c, Stream &os) { #ifndef BOOST_NO_LOCALE_ISIDIGIT return std::isdigit(c, os.rdbuf()->getloc() ); # else using namespace std; - return isdigit(c); -#endif + return isdigit(c); +#endif } //end- wrap_isdigit(..) template inline - Res str2int(const std::basic_string& s, - typename std::basic_string::size_type start, + Res str2int(const std::basic_string& s, + typename std::basic_string::size_type start, BOOST_IO_STD basic_ios &os, - const Res = Res(0) ) + const Res = Res(0) ) // Input : char string, with starting index // a basic_ios& merely to call its widen/narrow member function in the desired locale. // Effects : reads s[start:] and converts digits into an integral n, of type Res @@ -64,7 +64,7 @@ namespace detail { } template - void skip_asterisk(const std::basic_string & buf, + void skip_asterisk(const std::basic_string & buf, typename std::basic_string::size_type * pos_p, BOOST_IO_STD basic_ios &os) // skip printf's "asterisk-fields" directives in the format-string buf @@ -92,7 +92,7 @@ namespace detail { if(exceptions & io::bad_format_string_bit) boost::throw_exception(io::bad_format_string()); } - + template @@ -104,15 +104,15 @@ namespace detail { // Input : a 'printf-directive' in the format-string, starting at buf[ *pos_p ] // a basic_ios& merely to call its widen/narrow member function in the desired locale. // a bitset'excpetions' telling whether to throw exceptions on errors. - // Returns : true if parse somehow succeeded (possibly ignoring errors if exceptions disabled) + // Returns : true if parse somehow succeeded (possibly ignoring errors if exceptions disabled) // false if it failed so bad that the directive should be printed verbatim // Effects : - *pos_p is incremented so that buf[*pos_p] is the first char after the directive // - *fpar is set with the parameters read in the directive { typedef format_item format_item_t; BOOST_ASSERT( pos_p != 0); - typename std::basic_string::size_type &i1 = *pos_p, - i0; + typename std::basic_string::size_type &i1 = *pos_p, + i0; fpar->argN_ = format_item_t::argN_no_posit; // if no positional-directive bool in_brackets=false; @@ -126,38 +126,38 @@ namespace detail { } // the flag '0' would be picked as a digit for argument order, but here it's a flag : - if(buf[i1]==os.widen('0')) + if(buf[i1]==os.widen('0')) goto parse_flags; // handle argument order (%2$d) or possibly width specification: %2d i0 = i1; // save position before digits while (i1 < buf.size() && wrap_isdigit(buf[i1], os)) ++i1; - if (i1!=i0) + if (i1!=i0) { if( i1 >= buf.size() ) { maybe_throw_exception(exceptions); return false; } int n=str2int(buf,i0, os, int(0) ); - + // %N% case : this is already the end of the directive - if( buf[i1] == os.widen('%') ) + if( buf[i1] == os.widen('%') ) { fpar->argN_ = n-1; ++i1; - if( in_brackets) - maybe_throw_exception(exceptions); + if( in_brackets) + maybe_throw_exception(exceptions); // but don't return. maybe "%" was used in lieu of '$', so we go on. else return true; } - if ( buf[i1]==os.widen('$') ) + if ( buf[i1]==os.widen('$') ) { fpar->argN_ = n-1; ++i1; - } - else + } + else { // non-positionnal directive fpar->ref_state_.width_ = n; @@ -165,13 +165,13 @@ namespace detail { goto parse_precision; } } - - parse_flags: + + parse_flags: // handle flags while ( i1 ref_state_.flags_ |= std::ios_base::showpos; break; case '0': - fpar->pad_scheme_ |= format_item_t::zeropad; + fpar->pad_scheme_ |= format_item_t::zeropad; // need to know alignment before really setting flags, // so just add 'zeropad' flag for now, it will be processed later. break; @@ -204,7 +204,7 @@ namespace detail { } // loop on flag. if( i1>=buf.size()) { maybe_throw_exception(exceptions); - return true; + return true; } parse_width: @@ -213,17 +213,17 @@ namespace detail { i0 = i1; // save position before digits while (i1ref_state_.width_ = str2int( buf,i0, os, std::streamsize(0) ); } parse_precision: - if( i1>=buf.size()) { + if( i1>=buf.size()) { maybe_throw_exception(exceptions); return true; } // handle precision spec - if (buf[i1]==os.widen('.')) + if (buf[i1]==os.widen('.')) { ++i1; skip_asterisk(buf, &i1, os); @@ -233,25 +233,25 @@ namespace detail { if(i1==i0) fpar->ref_state_.precision_ = 0; - else + else fpar->ref_state_.precision_ = str2int(buf,i0, os, std::streamsize(0) ); } - + // handle formatting-type flags : - while( i1=buf.size()) { maybe_throw_exception(exceptions); return true; } - - if( in_brackets && buf[i1]==os.widen('|') ) + + if( in_brackets && buf[i1]==os.widen('|') ) { ++i1; return true; } - switch (os.narrow(buf[i1], 0) ) + switch (os.narrow(buf[i1], 0) ) { case 'X': fpar->ref_state_.flags_ |= std::ios_base::uppercase; @@ -260,7 +260,7 @@ namespace detail { fpar->ref_state_.flags_ &= ~std::ios_base::basefield; fpar->ref_state_.flags_ |= std::ios_base::hex; break; - + case 'o': fpar->ref_state_.flags_ &= ~std::ios_base::basefield; fpar->ref_state_.flags_ |= std::ios_base::oct; @@ -275,7 +275,7 @@ namespace detail { fpar->ref_state_.flags_ &= ~std::ios_base::basefield; fpar->ref_state_.flags_ |= std::ios_base::dec; break; - + case 'f': fpar->ref_state_.flags_ &= ~std::ios_base::floatfield; fpar->ref_state_.flags_ |= std::ios_base::fixed; @@ -293,12 +293,12 @@ namespace detail { else fpar->ref_state_.fill_ = buf[i1]; fpar->pad_scheme_ |= format_item_t::tabulation; - fpar->argN_ = format_item_t::argN_tabulation; + fpar->argN_ = format_item_t::argN_tabulation; break; - case 't': + case 't': fpar->ref_state_.fill_ = os.widen(' '); fpar->pad_scheme_ |= format_item_t::tabulation; - fpar->argN_ = format_item_t::argN_tabulation; + fpar->argN_ = format_item_t::argN_tabulation; break; case 'G': @@ -309,29 +309,29 @@ namespace detail { fpar->ref_state_.flags_ |= std::ios_base::dec; // CLEAR all floatield flags, so stream will CHOOSE - fpar->ref_state_.flags_ &= ~std::ios_base::floatfield; + fpar->ref_state_.flags_ &= ~std::ios_base::floatfield; break; case 'C': - case 'c': + case 'c': fpar->truncate_ = 1; break; case 'S': - case 's': + case 's': fpar->truncate_ = fpar->ref_state_.precision_; fpar->ref_state_.precision_ = -1; break; - case 'n' : + case 'n' : fpar->argN_ = format_item_t::argN_ignored; break; - default: + default: maybe_throw_exception(exceptions); } ++i1; if( in_brackets ) { - if( i1 -void basic_format ::parse(const string_t & buf) +void basic_format ::parse(const string_t & buf) // parse the format-string { using namespace std; const Ch arg_mark = oss_.widen('%'); - bool ordered_args=true; + bool ordered_args=true; int max_argN=-1; typename string_t::size_type i1=0; int num_items=0; - + // A: find upper_bound on num_items and allocates arrays - i1=0; - while( (i1=buf.find(arg_mark,i1)) != string::npos ) + i1=0; + while( (i1=buf.find(arg_mark,i1)) != string_t::npos ) { if( i1+1 >= buf.size() ) { if(exceptions() & io::bad_format_string_bit) @@ -370,7 +370,7 @@ void basic_format ::parse(const string_t & buf) } if(buf[i1+1] == buf[i1] ) { i1+=2; continue; } // escaped "%%" / "##" ++i1; - + // in case of %N% directives, dont count it double (wastes allocations..) : while(i1 < buf.size() && io::detail::wrap_isdigit(buf[i1],oss_)) ++i1; if( i1 < buf.size() && buf[i1] == arg_mark ) ++ i1; @@ -378,28 +378,28 @@ void basic_format ::parse(const string_t & buf) ++num_items; } items_.assign( num_items, format_item_t() ); - + // B: Now the real parsing of the format string : num_items=0; i1 = 0; typename string_t::size_type i0 = i1; bool special_things=false; int cur_it=0; - while( (i1=buf.find(arg_mark,i1)) != string::npos ) + while( (i1=buf.find(arg_mark,i1)) != string_t::npos ) { string_t & piece = (cur_it==0) ? prefix_ : items_[cur_it-1].appendix_; if( buf[i1+1] == buf[i1] ) // escaped mark, '%%' { - piece += buf.substr(i0, i1-i0) + buf[i1]; + piece += buf.substr(i0, i1-i0) + buf[i1]; i1+=2; i0=i1; - continue; + continue; } BOOST_ASSERT( static_cast(cur_it) < items_.size() || cur_it==0); if(i1!=i0) piece += buf.substr(i0, i1-i0); ++i1; - + bool parse_ok; parse_ok = io::detail::parse_printf_directive(buf, &i1, &items_[cur_it], oss_, exceptions()); if( ! parse_ok ) continue; // the directive will be printed verbatim @@ -418,12 +418,12 @@ void basic_format ::parse(const string_t & buf) ++cur_it; } // loop on %'s BOOST_ASSERT(cur_it == num_items); - + // store the final piece of string string_t & piece = (cur_it==0) ? prefix_ : items_[cur_it-1].appendix_; piece += buf.substr(i0); - - if( !ordered_args) + + if( !ordered_args) { if(max_argN >= 0 ) // dont mix positional with non-positionnal directives { @@ -434,14 +434,14 @@ void basic_format ::parse(const string_t & buf) // set things like it would have been with positional directives : int non_ordered_items = 0; for(int i=0; i< num_items; ++i) - if(items_[i].argN_ == format_item_t::argN_no_posit) + if(items_[i].argN_ == format_item_t::argN_no_posit) { items_[i].argN_ = non_ordered_items; ++non_ordered_items; } max_argN = non_ordered_items-1; } - + // C: set some member data : items_.resize(num_items); diff --git a/src/BufferView.C b/src/BufferView.C index 697d85cc2b..5f34fa5885 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -3,7 +3,7 @@ * Copyright 1995-2002 the LyX Team * Read the file COPYING * - * \author unknown + * \author Lars Gullik Bjønnes * \author John Levon */ @@ -49,6 +49,7 @@ extern BufferList bufferlist; using lyx::pos_type; +using namespace lyx::support; using std::pair; using std::endl; diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 59c7df3c5a..9088f5c681 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -3,6 +3,7 @@ * Copyright 2002 the LyX Team * Read the file COPYING * + * \author Lars Gullik Bjønnes * \author various */ @@ -75,6 +76,7 @@ using std::make_pair; using std::min; using lyx::pos_type; +using namespace lyx::support; using namespace bv_funcs; extern BufferList bufferlist; @@ -168,7 +170,7 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles) Buffer * b = bufferlist.newBuffer(s); //attach to the error signal in the buffer - b->parseError.connect(boost::bind(&BufferView::Pimpl::addError, + b->parseError.connect(boost::bind(&BufferView::Pimpl::addError, this, _1)); bool loaded = ::loadLyXFile(b, s); @@ -187,7 +189,7 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles) else return false; - } + } buffer(b); @@ -358,7 +360,7 @@ int BufferView::Pimpl::resizeCurrentBuffer() mark_set = bv_->text->selection.mark(); the_locking_inset = bv_->theLockingInset(); buffer_->resizeInsets(bv_); - // I don't think the delete and new are necessary here we + // I don't think the delete and new are necessary here we // just could call only init! (Jug 20020419) delete bv_->text; bv_->text = new LyXText(bv_); @@ -720,7 +722,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i) b = bufferlist.newBuffer(fname); ::loadLyXFile(b, fname); // don't ask, just load it } - if (b != 0) + if (b != 0) buffer(b); } diff --git a/src/Bullet.C b/src/Bullet.C index 3d66257cbd..8493c0bd34 100644 --- a/src/Bullet.C +++ b/src/Bullet.C @@ -17,6 +17,8 @@ #include "Bullet.h" #include "support/LAssert.h" +using namespace lyx::support; + /** The four LaTeX itemize environment default bullets */ extern @@ -365,17 +367,17 @@ string const Bullet::bulletEntry(int f, int c) #ifdef ENABLE_ASSERTIONS void Bullet::testInvariant() const { - lyx::Assert(font >= MIN); - lyx::Assert(font < FONTMAX); - lyx::Assert(character >= MIN); - lyx::Assert(character < CHARMAX); - lyx::Assert(size >= MIN); - lyx::Assert(size < SIZEMAX); - lyx::Assert(user_text >= -1); - lyx::Assert(user_text <= 1); + Assert(font >= MIN); + Assert(font < FONTMAX); + Assert(character >= MIN); + Assert(character < CHARMAX); + Assert(size >= MIN); + Assert(size < SIZEMAX); + Assert(user_text >= -1); + Assert(user_text <= 1); // now some relational/operational tests if (user_text == 1) { - lyx::Assert(font == -1 && (character == -1 && size == -1)); + Assert(font == -1 && (character == -1 && size == -1)); // Assert(!text.empty()); // this isn't necessarily an error } // else if (user_text == -1) { diff --git a/src/ChangeLog b/src/ChangeLog index b92d163eae..82bc726070 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,6 @@ +2003-07-01 Lars Gullik Bjønnes + + * introduce namespace lyx::support 2003-06-30 André Pönitz diff --git a/src/Chktex.C b/src/Chktex.C index 7b728fc9d4..d3950f7595 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -29,6 +29,8 @@ #include +using namespace lyx::support; + using std::ifstream; using std::getline; @@ -80,7 +82,7 @@ int Chktex::scanLogFile(TeXErrors & terr) token = split(token, warno, ':'); token = split(token, warning, ':'); - int const lineno = lyx::atoi(line); + int const lineno = atoi(line); #if USE_BOOST_FORMAT msg % warno; diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 54ae59110b..cf6ba8e8ff 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -38,6 +38,7 @@ using std::make_pair; using std::for_each; using std::vector; +using namespace lyx::support; using lyx::pos_type; using lyx::textclass_type; @@ -180,11 +181,11 @@ bool CutAndPaste::copySelection(ParagraphList::iterator startpit, ParagraphList::iterator endpit, int start, int end, textclass_type tc) { - lyx::Assert(&*startpit); - lyx::Assert(&*endpit); - lyx::Assert(0 <= start && start <= startpit->size()); - lyx::Assert(0 <= end && end <= endpit->size()); - lyx::Assert(startpit != endpit || start <= end); + Assert(&*startpit); + Assert(&*endpit); + Assert(0 <= start && start <= startpit->size()); + Assert(0 <= end && end <= endpit->size()); + Assert(startpit != endpit || start <= end); ParagraphList paragraphs; @@ -229,7 +230,7 @@ CutAndPaste::pasteSelection(Buffer const & buffer, if (!checkPastePossible()) return make_pair(PitPosPair(pit, pos), pit); - lyx::Assert (pos <= pit->size()); + Assert (pos <= pit->size()); // Make a copy of the CaP paragraphs. ParagraphList simple_cut_clone = cuts[cut_index].first; @@ -384,7 +385,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1, ParagraphList & pars, ErrorList & errorlist) { - lyx::Assert(!pars.empty()); + Assert(!pars.empty()); int ret = 0; if (c1 == c2) diff --git a/src/DepTable.C b/src/DepTable.C index a23c091660..90849bb0d7 100644 --- a/src/DepTable.C +++ b/src/DepTable.C @@ -33,6 +33,8 @@ using std::time; #endif +using namespace lyx::support; + using std::make_pair; using std::ofstream; using std::ifstream; @@ -57,7 +59,7 @@ void DepTable::insert(string const & fi, bool upd) di.crc_prev = 0; if (upd) { lyxerr[Debug::DEPEND] << " CRC..." << flush; - di.crc_cur = lyx::sum(f); + di.crc_cur = sum(f); lyxerr[Debug::DEPEND] << "done." << endl; struct stat f_info; stat(fi.c_str(), &f_info); @@ -90,7 +92,7 @@ void DepTable::update() } else { di.crc_prev = di.crc_cur; lyxerr[Debug::DEPEND] << itr->first << " CRC... "; - di.crc_cur = lyx::sum(itr->first); + di.crc_cur = sum(itr->first); lyxerr[Debug::DEPEND] << "done"; } } else { diff --git a/src/LColor.C b/src/LColor.C index aa81477110..836f7744c6 100644 --- a/src/LColor.C +++ b/src/LColor.C @@ -17,6 +17,8 @@ #include +using namespace lyx::support; + using std::endl; @@ -198,7 +200,7 @@ void LColor::setColor(LColor::color col, string const & x11name) return; } lyxerr << "LyX internal error: color and such.\n"; - lyx::Assert(false); + Assert(false); } diff --git a/src/LString.h b/src/LString.h index 1e135594b3..95d20bdae0 100644 --- a/src/LString.h +++ b/src/LString.h @@ -31,8 +31,7 @@ using std::string; #define __STRING__ #endif #include "support/lyxstring.h" -// using lyx::string; -typedef lyxstring string; +using lyx::string; #define STRCONV(STR) STR.c_str() #endif diff --git a/src/LaTeX.C b/src/LaTeX.C index 53cf4e9241..d069babb2a 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -33,6 +33,8 @@ #include #include // sscanf +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::sscanf; #endif @@ -129,7 +131,7 @@ void LaTeX::deleteFilesOnError() const // What files do we have to delete? // This will at least make latex do all the runs - lyx::unlink(depfile); + unlink(depfile); // but the reason for the error might be in a generated file... @@ -137,15 +139,15 @@ void LaTeX::deleteFilesOnError() const // bibtex file string const bbl = ChangeExtension(ofname, ".bbl"); - lyx::unlink(bbl); + unlink(bbl); // makeindex file string const ind = ChangeExtension(ofname, ".ind"); - lyx::unlink(ind); + unlink(ind); // Also remove the aux file string const aux = ChangeExtension(ofname, ".aux"); - lyx::unlink(aux); + unlink(aux); } @@ -164,7 +166,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) bool rerun = false; // rerun requested // The class LaTeX does not know the temp path. - bufferlist.updateIncludedTeXfiles(lyx::getcwd(), runparams); + bufferlist.updateIncludedTeXfiles(getcwd(), runparams); // Never write the depfile if an error was encountered. diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index a8754d033f..5380932443 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -24,6 +24,8 @@ #include "support/filetools.h" #include "support/lstrings.h" +using namespace lyx::support; + using lyx::textclass_type; using std::endl; diff --git a/src/LyXAction.C b/src/LyXAction.C index 09e7c7c85b..89c883ed26 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -12,6 +12,8 @@ #include "gettext.h" #include "support/lstrings.h" +using namespace lyx::support; + using std::ostream; using std::endl; using std::pair; diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 3ce73b3636..9eb756c7f8 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -40,6 +40,8 @@ extern BufferList bufferlist; extern boost::scoped_ptr toplevel_keymap; +using namespace lyx::support; + using std::endl; using std::vector; using std::max; @@ -619,10 +621,10 @@ void expandPasteRecent(Menu & tomenu, LyXView const * view) { vector const selL = CutAndPaste::availableSelections(*view->buffer()); - + vector::const_iterator cit = selL.begin(); vector::const_iterator end = selL.end(); - + for (unsigned int index = 0; cit != end; ++cit, ++index) { int const action = lyxaction.getPseudoAction(LFUN_PASTE, tostr(index)); @@ -780,7 +782,7 @@ Menu const & MenuBackend::getMenu(string const & name) const lyx::compare_memfun(&Menu::name, name)); if (cit == end()) lyxerr << "No submenu named " << name << endl; - lyx::Assert(cit != end()); + Assert(cit != end()); return (*cit); } @@ -790,7 +792,7 @@ Menu & MenuBackend::getMenu(string const & name) MenuList::iterator it = find_if(menulist_.begin(), menulist_.end(), lyx::compare_memfun(&Menu::name, name)); - lyx::Assert(it != menulist_.end()); + Assert(it != menulist_.end()); return (*it); } diff --git a/src/ParagraphParameters.C b/src/ParagraphParameters.C index 2e95e9f564..958e3b1f41 100644 --- a/src/ParagraphParameters.C +++ b/src/ParagraphParameters.C @@ -19,6 +19,8 @@ #include +using namespace lyx::support; + using std::ostream; // Initialize static member var. diff --git a/src/PrinterParams.h b/src/PrinterParams.h index 06dd555d15..aa6d499664 100644 --- a/src/PrinterParams.h +++ b/src/PrinterParams.h @@ -87,13 +87,13 @@ struct PrinterParams { #ifdef ENABLE_ASSERTIONS switch (target) { case PRINTER: - //Assert(!printer_name.empty()); + //lyx::support::Assert(!printer_name.empty()); break; case FILE: - lyx::Assert(!file_name.empty()); + lyx::support::Assert(!file_name.empty()); break; default: - lyx::Assert(false); + lyx::support::Assert(false); break; } #endif diff --git a/src/ToolbarBackend.C b/src/ToolbarBackend.C index 69cddfe234..e4d4232bde 100644 --- a/src/ToolbarBackend.C +++ b/src/ToolbarBackend.C @@ -24,6 +24,8 @@ #include +using namespace lyx::support; + using std::endl; using std::vector; using std::make_pair; @@ -236,9 +238,9 @@ string const ToolbarBackend::getIcon(int action) << fullname << '\'' << endl; return fullname; } - - lyxerr[Debug::GUI] << "Cannot find icon for command \"" - << lyxaction.getActionName(f.action) + + lyxerr[Debug::GUI] << "Cannot find icon for command \"" + << lyxaction.getActionName(f.action) << ' ' << f.argument << '"' << endl; return LibFileSearch("images", "unknown", "xpm"); } diff --git a/src/author.C b/src/author.C index 45b36b4f15..9901659948 100644 --- a/src/author.C +++ b/src/author.C @@ -17,6 +17,8 @@ #include "support/LIstream.h" #include "support/lstrings.h" +using namespace lyx::support; + bool operator==(Author const & l, Author const & r) { return l.name() == r.name() && l.email() == r.email(); @@ -62,7 +64,7 @@ int AuthorList::record(Author const & a) void AuthorList::record(int id, Author const & a) { - lyx::Assert(unsigned(id) < authors_.size()); + Assert(unsigned(id) < authors_.size()); authors_[id] = a; } @@ -71,7 +73,7 @@ void AuthorList::record(int id, Author const & a) Author const & AuthorList::get(int id) { Authors::const_iterator it(authors_.find(id)); - lyx::Assert(it != authors_.end()); + Assert(it != authors_.end()); return it->second; } diff --git a/src/boost.C b/src/boost.C index ef997c801c..74c200bdbf 100644 --- a/src/boost.C +++ b/src/boost.C @@ -5,6 +5,8 @@ #include +using namespace lyx::support; + using std::endl; namespace boost { @@ -13,7 +15,7 @@ void throw_exception(std::exception const & e) { lyxerr << "Exception caught:\n" << e.what() << endl; - lyx::Assert(false); + Assert(false); } diff --git a/src/buffer.C b/src/buffer.C index 15d21658e1..b51a4762d4 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -86,6 +86,8 @@ #include #endif +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::pow; #endif @@ -543,7 +545,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename, // This code is reached if lyx2lyx failed (for // some reason) to change the file format of // the file. - lyx::Assert(false); + Assert(false); return false; } } @@ -627,7 +629,7 @@ bool Buffer::save() const } else { // Saving failed, so backup is not backup if (lyxrc.make_backup) { - lyx::rename(s, fileName()); + rename(s, fileName()); } return false; } @@ -1647,7 +1649,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) sgmlparam = style->latexparam(); c_params = split(sgmlparam, c_depth,'|'); - cmd_depth = lyx::atoi(c_depth); + cmd_depth = atoi(c_depth); if (command_flag) { if (cmd_depth < command_base) { diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index 0eaca7c0dd..0f039eaa9f 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -32,6 +32,8 @@ extern BufferList bufferlist; +using namespace lyx::support; + namespace { @@ -98,7 +100,7 @@ bool readFile(Buffer * b, string const & s) b->markDirty(); } else { // Here, we should delete the autosave - lyx::unlink(a); + unlink(a); } } } @@ -126,8 +128,8 @@ bool loadLyXFile(Buffer * b, string const & s) b->lyxvc.file_found_hook(s); return true; } - break; - case -1: + break; + case -1: string const file = MakeDisplayPath(s, 20); // Here we probably should run if (LyXVC::file_not_found_hook(s)) { @@ -150,7 +152,7 @@ bool loadLyXFile(Buffer * b, string const & s) } -Buffer * newFile(string const & filename, string const & templatename, +Buffer * newFile(string const & filename, string const & templatename, bool isNamed) { // get a free buffer @@ -198,7 +200,7 @@ Buffer * newFile(string const & filename, string const & templatename, } -void parseErrors(Buffer const & buf, TeXErrors const & terr) +void parseErrors(Buffer const & buf, TeXErrors const & terr) { TeXErrors::Errors::const_iterator cit = terr.begin(); TeXErrors::Errors::const_iterator end = terr.end(); @@ -217,12 +219,12 @@ void parseErrors(Buffer const & buf, TeXErrors const & terr) } -void parseErrors(Buffer const & buf, ErrorList const & el) +void parseErrors(Buffer const & buf, ErrorList const & el) { ErrorList::const_iterator it = el.begin(); ErrorList::const_iterator end = el.end(); - for (; it != end; ++it) + for (; it != end; ++it) buf.parseError(*it); } diff --git a/src/bufferlist.C b/src/bufferlist.C index 7d7b327b4e..0ae822582e 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -41,6 +41,8 @@ #include +using namespace lyx::support; + using std::vector; using std::find; using std::endl; @@ -118,7 +120,7 @@ bool BufferList::quitWriteAll() void BufferList::release(Buffer * buf) { - lyx::Assert(buf); + Assert(buf); BufferStorage::iterator it = find(bstore.begin(), bstore.end(), buf); if (it != bstore.end()) { // Make sure that we don't store a LyXText in @@ -157,7 +159,7 @@ void BufferList::closeAll() bool BufferList::close(Buffer * buf, bool ask) { - lyx::Assert(buf); + Assert(buf); // FIXME: is the quitting check still necessary ? if (!ask || buf->isClean() || quitting || buf->paragraphs.empty()) { @@ -316,7 +318,7 @@ bool BufferList::exists(string const & s) const bool BufferList::isLoaded(Buffer const * b) const { - lyx::Assert(b); + Assert(b); BufferStorage::const_iterator cit = find(bstore.begin(), bstore.end(), b); diff --git a/src/bufferparams.C b/src/bufferparams.C index 6ee643655c..bf70b6a66d 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -34,6 +34,8 @@ #include #include +using namespace lyx::support; + using std::ostream; using std::endl; using std::pair; diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index c1747beb64..a58c0c9e9c 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -36,6 +36,8 @@ #include "insets/updatableinset.h" +using namespace lyx::support; + namespace { diff --git a/src/changes.C b/src/changes.C index c60357718b..fe4b087680 100644 --- a/src/changes.C +++ b/src/changes.C @@ -17,6 +17,8 @@ #include "support/LAssert.h" #include "support/LOstream.h" +using namespace lyx::support; + using std::vector; using std::endl; using lyx::pos_type; @@ -325,7 +327,7 @@ Change const Changes::lookupFull(pos_type pos) const } check(); - lyx::Assert(0); + Assert(false); return Change(Change::UNCHANGED); } @@ -347,7 +349,7 @@ Change::Type Changes::lookup(pos_type pos) const } check(); - lyx::Assert(0); + Assert(0); return Change::UNCHANGED; } @@ -485,7 +487,7 @@ void Changes::check() const if (lyxerr.debugging(Debug::CHANGES)) lyxerr[Debug::CHANGES] << "End" << endl; - lyx::Assert(dont_assert); + Assert(dont_assert); } diff --git a/src/chset.C b/src/chset.C index 3b60e4ebd8..e8072d739e 100644 --- a/src/chset.C +++ b/src/chset.C @@ -9,6 +9,8 @@ #include +using namespace lyx::support; + using std::ifstream; using std::getline; using std::pair; @@ -58,7 +60,7 @@ bool CharacterSet::loadFile(string const & fname) cmatch sub; #endif if (regex_match(STRCONV(line), sub, reg)) { - int const n = lyx::atoi(STRCONV(sub.str(1))); + int const n = atoi(STRCONV(sub.str(1))); string const str = STRCONV(sub.str(2)); if (lyxerr.debugging(Debug::KBMAP)) lyxerr << "Chardef: " << n diff --git a/src/converter.C b/src/converter.C index 5061d37218..a39664e385 100644 --- a/src/converter.C +++ b/src/converter.C @@ -35,6 +35,8 @@ #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::isdigit; #endif @@ -344,7 +346,7 @@ bool Converters::convert(Buffer const * buffer, res = one.startscript(type, command); if (!real_outfile.empty()) { - if (!lyx::rename(outfile, real_outfile)) + if (!rename(outfile, real_outfile)) res = -1; else lyxerr[Debug::FILES] @@ -394,7 +396,7 @@ bool Converters::convert(Buffer const * buffer, token_base, from_base); string to = subst(conv.result_dir, token_base, to_base); - if (!lyx::rename(from, to)) { + if (!rename(from, to)) { Alert::error(_("Cannot convert file"), bformat(_("Could not move a temporary file from %1$s to %2$s."), from, to)); @@ -430,8 +432,8 @@ bool Converters::move(string const & from, string const & to, bool copy) lyxerr[Debug::FILES] << "moving " << from2 << " to " << to2 << endl; bool const moved = (copy) - ? lyx::copy(from2, to2) - : lyx::rename(from2, to2); + ? lyx::support::copy(from2, to2) + : rename(from2, to2); if (!moved && no_errors) { Alert::error(_("Cannot convert file"), bformat(_("Could not move a temporary file from %1$s to %2$s."), diff --git a/src/counters.C b/src/counters.C index 094dcd8bf7..a69b6a3c08 100644 --- a/src/counters.C +++ b/src/counters.C @@ -18,6 +18,8 @@ #include "support/lstrings.h" #include "support/LAssert.h" +using namespace lyx::support; + using std::endl; using std::vector; @@ -169,7 +171,7 @@ void Counters::reset() void Counters::reset(string const & match) { - lyx::Assert(!match.empty()); + Assert(!match.empty()); CounterList::iterator it = counterList.begin(); CounterList::iterator end = counterList.end(); diff --git a/src/debug.C b/src/debug.C index 9c7e8c58d0..ab90e5e3c4 100644 --- a/src/debug.C +++ b/src/debug.C @@ -15,6 +15,8 @@ #include +using namespace lyx::support; + using std::ostream; using std::setw; using std::endl; diff --git a/src/exporter.C b/src/exporter.C index 49e59e1949..ac661422b1 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -24,6 +24,8 @@ #include +using namespace lyx::support; + using std::vector; using std::find; @@ -157,4 +159,3 @@ Exporter::GetExportableFormats(Buffer const * buffer, bool only_viewable) } return result; } - diff --git a/src/factory.C b/src/factory.C index 44eb7c70f1..7d908149c6 100644 --- a/src/factory.C +++ b/src/factory.C @@ -54,6 +54,8 @@ #include +using namespace lyx::support; + using std::endl; Inset * createInset(FuncRequest const & cmd) diff --git a/src/format.C b/src/format.C index 73e037cc30..9404be7726 100644 --- a/src/format.C +++ b/src/format.C @@ -26,6 +26,8 @@ #include "support/systemcall.h" #include "support/lyxfunctional.h" +using namespace lyx::support; + namespace { diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index fd25d66e65..4b00b244fe 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -11,7 +11,6 @@ #include - #include "LyXView.h" #include "debug.h" #include "intl.h" @@ -40,6 +39,7 @@ #include #include +using namespace lyx::support; using std::endl; string current_layout; diff --git a/src/frontends/Timeout.C b/src/frontends/Timeout.C index 0cef024ee9..9d7052fe54 100644 --- a/src/frontends/Timeout.C +++ b/src/frontends/Timeout.C @@ -14,6 +14,8 @@ #include "Timeout.h" #include "support/LAssert.h" +using namespace lyx::support; + Timeout::~Timeout() { @@ -65,7 +67,7 @@ Timeout & Timeout::setType(Type t) Timeout & Timeout::setTimeout(unsigned int msec) { // Can't have a timeout of zero! - lyx::Assert(msec); + Assert(msec); timeout_ms = msec; return * this; diff --git a/src/frontends/controllers/ButtonController.C b/src/frontends/controllers/ButtonController.C index 8d63bd3cb9..5a0f785834 100644 --- a/src/frontends/controllers/ButtonController.C +++ b/src/frontends/controllers/ButtonController.C @@ -15,10 +15,11 @@ #include "support/LAssert.h" #include "debug.h" +using namespace lyx::support; BCView & ButtonController::view() const { - lyx::Assert(view_.get()); + Assert(view_.get()); return *view_.get(); } @@ -30,7 +31,7 @@ void ButtonController::view(BCView * view) ButtonPolicy & ButtonController::bp() const { - lyx::Assert(bp_.get()); + Assert(bp_.get()); return *bp_.get(); } diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index ee0c3ee78f..ccdcc247ab 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2003-07-01 Lars Gullik Bjønnes + + * introduce namespace lyx::support + 2003-06-28 Lars Gullik Bjønnes * Kernel.h: fix some \class issues diff --git a/src/frontends/controllers/ControlAboutlyx.C b/src/frontends/controllers/ControlAboutlyx.C index 1887f0f63a..4b456e47ab 100644 --- a/src/frontends/controllers/ControlAboutlyx.C +++ b/src/frontends/controllers/ControlAboutlyx.C @@ -22,6 +22,8 @@ #include +using namespace lyx::support; + using std::ostream; // needed for the browser diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index 8e8f076cb9..36d6778572 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -23,6 +23,8 @@ #include "support/filetools.h" +using namespace lyx::support; + using std::pair; using std::vector; diff --git a/src/frontends/controllers/ControlButtons.C b/src/frontends/controllers/ControlButtons.C index cf3745f1f3..505b45eb76 100644 --- a/src/frontends/controllers/ControlButtons.C +++ b/src/frontends/controllers/ControlButtons.C @@ -18,6 +18,7 @@ #include "lyxrc.h" #include "support/LAssert.h" +using namespace lyx::support; ControlButtons::ControlButtons() : emergency_exit_(false), is_closing_(false), @@ -68,14 +69,14 @@ bool ControlButtons::IconifyWithMain() const ButtonController & ControlButtons::bc() { - lyx::Assert(bc_ptr_.get()); + Assert(bc_ptr_.get()); return *bc_ptr_.get(); } ViewBase & ControlButtons::view() { - lyx::Assert(view_ptr_); + Assert(view_ptr_); return *view_ptr_; } diff --git a/src/frontends/controllers/ControlChanges.C b/src/frontends/controllers/ControlChanges.C index 25348a8532..1d5053ff1d 100644 --- a/src/frontends/controllers/ControlChanges.C +++ b/src/frontends/controllers/ControlChanges.C @@ -18,6 +18,7 @@ #include "author.h" #include "support/lstrings.h" +using namespace lyx::support; ControlChanges::ControlChanges(Dialog & parent) : Dialog::Controller(parent) diff --git a/src/frontends/controllers/ControlCommandBuffer.C b/src/frontends/controllers/ControlCommandBuffer.C index e3468234c0..adb454122f 100644 --- a/src/frontends/controllers/ControlCommandBuffer.C +++ b/src/frontends/controllers/ControlCommandBuffer.C @@ -21,6 +21,8 @@ #include "support/lyxalgo.h" #include "support/lstrings.h" +using namespace lyx::support; + using std::vector; using std::back_inserter; using std::transform; diff --git a/src/frontends/controllers/ControlDocument.C b/src/frontends/controllers/ControlDocument.C index 29f11a19dd..0e603f65aa 100644 --- a/src/frontends/controllers/ControlDocument.C +++ b/src/frontends/controllers/ControlDocument.C @@ -34,6 +34,8 @@ #include "support/lstrings.h" #include "support/filetools.h" +using namespace lyx::support; + using std::endl; @@ -48,7 +50,7 @@ ControlDocument::~ControlDocument() BufferParams & ControlDocument::params() { - lyx::Assert(bp_.get()); + Assert(bp_.get()); return *bp_; } diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C index 287cdaed1b..8874e85487 100644 --- a/src/frontends/controllers/ControlExternal.C +++ b/src/frontends/controllers/ControlExternal.C @@ -24,6 +24,7 @@ #include "support/LAssert.h" #include +using namespace lyx::support; using std::vector; @@ -55,21 +56,21 @@ void ControlExternal::dispatchParams() void ControlExternal::setParams(InsetExternal::Params const & p) { - lyx::Assert(params_.get()); + Assert(params_.get()); *params_ = p; } InsetExternal::Params const & ControlExternal::params() const { - lyx::Assert(params_.get()); + Assert(params_.get()); return *params_; } void ControlExternal::editExternal() { - lyx::Assert(params_.get()); + Assert(params_.get()); dialog().view().apply(); string const lfun = InsetExternalMailer::params2string(params()); @@ -129,7 +130,7 @@ ExternalTemplate const * getTemplatePtr(InsetExternal::Params const & params) return 0; return &templ; } - + } // namespace anon diff --git a/src/frontends/controllers/ControlForks.C b/src/frontends/controllers/ControlForks.C index 10052155eb..6f71ddf8b7 100644 --- a/src/frontends/controllers/ControlForks.C +++ b/src/frontends/controllers/ControlForks.C @@ -21,6 +21,8 @@ #include +using namespace lyx::support; + using std::vector; diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index d94cad7090..cd342c1ea6 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -32,6 +32,8 @@ #include "support/filetools.h" #include "support/FileInfo.h" +using namespace lyx::support; + using std::pair; using std::make_pair; using std::vector; diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C index 98a8819b55..3f4af1cece 100644 --- a/src/frontends/controllers/ControlInclude.C +++ b/src/frontends/controllers/ControlInclude.C @@ -23,6 +23,8 @@ #include +using namespace lyx::support; + using std::pair; diff --git a/src/frontends/controllers/ControlMath.C b/src/frontends/controllers/ControlMath.C index 11bfdefbf2..98997ad1f4 100644 --- a/src/frontends/controllers/ControlMath.C +++ b/src/frontends/controllers/ControlMath.C @@ -18,6 +18,7 @@ #include "support/lstrings.h" #include "support/filetools.h" +using namespace lyx::support; ControlMath::ControlMath(Dialog & dialog) : Dialog::Controller(dialog) diff --git a/src/frontends/controllers/ControlParagraph.C b/src/frontends/controllers/ControlParagraph.C index 3caf7a1946..ae9c3e9c85 100644 --- a/src/frontends/controllers/ControlParagraph.C +++ b/src/frontends/controllers/ControlParagraph.C @@ -20,6 +20,7 @@ #include "support/LAssert.h" #include "Lsstream.h" +using namespace lyx::support; ControlParagraph::ControlParagraph(Dialog & parent) : Dialog::Controller(parent), ininset_(false) @@ -125,14 +126,14 @@ void ControlParagraph::dispatchParams() ParagraphParameters & ControlParagraph::params() { - lyx::Assert(params_.get()); + Assert(params_.get()); return *params_; } ParagraphParameters const & ControlParagraph::params() const { - lyx::Assert(params_.get()); + Assert(params_.get()); return *params_; } diff --git a/src/frontends/controllers/ControlPrefs.C b/src/frontends/controllers/ControlPrefs.C index de6c73763b..ed442139e5 100644 --- a/src/frontends/controllers/ControlPrefs.C +++ b/src/frontends/controllers/ControlPrefs.C @@ -30,6 +30,8 @@ extern string system_lyxdir; extern string user_lyxdir; extern BufferList bufferlist; +using namespace lyx::support; + using std::endl; using std::pair; diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index c05d001dfe..66642c6a87 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -30,7 +30,9 @@ #include "support/path.h" #include "support/systemcall.h" -#include "debug.h" // for lyxerr +#include "debug.h" + +using namespace lyx::support; using std::endl; @@ -42,7 +44,7 @@ ControlPrint::ControlPrint(LyXView & lv, Dialogs & d) PrinterParams & ControlPrint::params() const { - lyx::Assert(params_); + Assert(params_); return *params_; } diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C index c47722477a..570f07fece 100644 --- a/src/frontends/controllers/ControlRef.C +++ b/src/frontends/controllers/ControlRef.C @@ -19,6 +19,8 @@ #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath +using namespace lyx::support; + using std::vector; extern BufferList bufferlist; diff --git a/src/frontends/controllers/ControlSendto.C b/src/frontends/controllers/ControlSendto.C index 4b414272b3..75f76fdc46 100644 --- a/src/frontends/controllers/ControlSendto.C +++ b/src/frontends/controllers/ControlSendto.C @@ -24,6 +24,8 @@ #include "support/lstrings.h" #include "support/systemcall.h" +using namespace lyx::support; + using std::vector; diff --git a/src/frontends/controllers/ControlShowFile.C b/src/frontends/controllers/ControlShowFile.C index b541dfd228..5a756c0ad2 100644 --- a/src/frontends/controllers/ControlShowFile.C +++ b/src/frontends/controllers/ControlShowFile.C @@ -13,6 +13,8 @@ #include "ControlShowFile.h" #include "support/filetools.h" +using namespace lyx::support; + ControlShowFile::ControlShowFile(Dialog & parent) : Dialog::Controller(parent) diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index 7406da6c97..19c1acf035 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -33,6 +33,8 @@ #include "frontends/Alert.h" +using namespace lyx::support; + using std::endl; @@ -271,5 +273,3 @@ void ControlSpellchecker::ignoreAll() speller_->accept(word_); check(); } - - diff --git a/src/frontends/controllers/ControlTabular.C b/src/frontends/controllers/ControlTabular.C index 0aa5551df1..d403a09de1 100644 --- a/src/frontends/controllers/ControlTabular.C +++ b/src/frontends/controllers/ControlTabular.C @@ -17,6 +17,8 @@ #include "insets/insettabular.h" #include "support/LAssert.h" +using namespace lyx::support; + ControlTabular::ControlTabular(Dialog & parent) : Dialog::Controller(parent), active_cell_(-1) @@ -54,7 +56,7 @@ int ControlTabular::getActiveCell() const LyXTabular const & ControlTabular::tabular() const { - lyx::Assert(params_.get()); + Assert(params_.get()); return *params_.get(); } diff --git a/src/frontends/controllers/ControlVCLog.C b/src/frontends/controllers/ControlVCLog.C index 5f79518a17..e10e9b757a 100644 --- a/src/frontends/controllers/ControlVCLog.C +++ b/src/frontends/controllers/ControlVCLog.C @@ -17,6 +17,8 @@ #include "support/lyxlib.h" #include +using namespace lyx::support; + using std::endl; using std::ostream; @@ -48,5 +50,5 @@ void ControlVCLog::getVCLogFile(ostream & ss) const if (!found) ss << _("No version control log file found.") << endl; - lyx::unlink(name); + unlink(name); } diff --git a/src/frontends/controllers/Dialog.C b/src/frontends/controllers/Dialog.C index 3873dbe208..95643a0b3f 100644 --- a/src/frontends/controllers/Dialog.C +++ b/src/frontends/controllers/Dialog.C @@ -18,6 +18,7 @@ #include "debug.h" #include "support/LAssert.h" +using namespace lyx::support; Dialog::Dialog(LyXView & lv, string const & name) : is_closing_(false), kernel_(lv), name_(name), @@ -123,7 +124,7 @@ void Dialog::apply() if (controller().disconnectOnApply() && !is_closing_) { kernel().disconnect(name()); - controller().initialiseParams(string()); + controller().initialiseParams(string()); view().update(); } } @@ -143,21 +144,21 @@ void Dialog::redraw() ButtonController & Dialog::bc() const { - lyx::Assert(bc_ptr_.get()); + Assert(bc_ptr_.get()); return *bc_ptr_.get(); } Dialog::Controller & Dialog::controller() const { - lyx::Assert(controller_ptr_.get()); + Assert(controller_ptr_.get()); return *controller_ptr_.get(); } Dialog::View & Dialog::view() const { - lyx::Assert(view_ptr_.get()); + Assert(view_ptr_.get()); return *view_ptr_.get(); } @@ -176,13 +177,13 @@ string const & Dialog::View::getTitle() const void Dialog::setController(Controller * i) { - lyx::Assert(i && !controller_ptr_.get()); + Assert(i && !controller_ptr_.get()); controller_ptr_.reset(i); } void Dialog::setView(View * v) { - lyx::Assert(v && !view_ptr_.get()); + Assert(v && !view_ptr_.get()); view_ptr_.reset(v); } diff --git a/src/frontends/controllers/ViewBase.C b/src/frontends/controllers/ViewBase.C index d4745470a1..54578e2090 100644 --- a/src/frontends/controllers/ViewBase.C +++ b/src/frontends/controllers/ViewBase.C @@ -14,6 +14,7 @@ #include "ControlButtons.h" #include "support/LAssert.h" +using namespace lyx::support; ViewBase::ViewBase(string const & t) : controller_ptr_(0), title_(t) @@ -40,14 +41,14 @@ string const & ViewBase::getTitle() const ControlButtons & ViewBase::getController() { - lyx::Assert(controller_ptr_); + Assert(controller_ptr_); return *controller_ptr_; } ControlButtons const & ViewBase::getController() const { - lyx::Assert(controller_ptr_); + Assert(controller_ptr_); return *controller_ptr_; } diff --git a/src/frontends/controllers/biblio.C b/src/frontends/controllers/biblio.C index 60ca6d2d8b..e689b2213d 100644 --- a/src/frontends/controllers/biblio.C +++ b/src/frontends/controllers/biblio.C @@ -26,6 +26,8 @@ #include +using namespace lyx::support; + using std::vector; @@ -57,7 +59,7 @@ string const familyName(string const & name) string const getAbbreviatedAuthor(InfoMap const & map, string const & key) { - lyx::Assert(!map.empty()); + Assert(!map.empty()); InfoMap::const_iterator it = map.find(key); if (it == map.end()) @@ -109,7 +111,7 @@ string const getAbbreviatedAuthor(InfoMap const & map, string const & key) string const getYear(InfoMap const & map, string const & key) { - lyx::Assert(!map.empty()); + Assert(!map.empty()); InfoMap::const_iterator it = map.find(key); if (it == map.end()) @@ -173,7 +175,7 @@ vector const getKeys(InfoMap const & map) string const getInfo(InfoMap const & map, string const & key) { - lyx::Assert(!map.empty()); + Assert(!map.empty()); InfoMap::const_iterator it = map.find(key); if (it == map.end()) diff --git a/src/frontends/controllers/helper_funcs.C b/src/frontends/controllers/helper_funcs.C index 235ec34706..28826ad9e7 100644 --- a/src/frontends/controllers/helper_funcs.C +++ b/src/frontends/controllers/helper_funcs.C @@ -21,6 +21,8 @@ #include "gettext.h" // _() #include "frontends/Alert.h" +using namespace lyx::support; + using std::pair; using std::vector; using std::make_pair; diff --git a/src/frontends/controllers/tex_helpers.C b/src/frontends/controllers/tex_helpers.C index 4bba95c08d..ad72098e15 100644 --- a/src/frontends/controllers/tex_helpers.C +++ b/src/frontends/controllers/tex_helpers.C @@ -26,6 +26,8 @@ #include #include +using namespace lyx::support; + using std::vector; using std::endl; using std::sort; @@ -71,7 +73,7 @@ void getTexFileList(string const & filename, std::vector & list) std::vector::iterator it = list.begin(); std::vector::iterator end = list.end(); for (; it != end; ++it) { - *it = STRCONV(regex.Merge(it->c_str(), "/")); + *it = STRCONV(regex.Merge(STRCONV((*it)), "/")); } lyx::eliminate_duplicates(list); diff --git a/src/frontends/qt2/BulletsModule.C b/src/frontends/qt2/BulletsModule.C index 4d2cb14b4f..8fb056f874 100644 --- a/src/frontends/qt2/BulletsModule.C +++ b/src/frontends/qt2/BulletsModule.C @@ -27,6 +27,8 @@ #include #include +using namespace lyx::support; + BulletsModule::BulletsModule(QWidget * parent, const char * name, WFlags fl) : BulletsModuleBase(parent, name, fl), tmpbulletset(0) { @@ -238,7 +240,7 @@ void BulletsModule::setBullet(int level, const Bullet & bullet) case 1: pb = bullet2PB; co = bulletsize2CO; break; case 2: pb = bullet3PB; co = bulletsize3CO; break; case 3: pb = bullet4PB; co = bulletsize4CO; break; - default: lyx::Assert(false); break; + default: Assert(false); break; } setBullet(pb, co, bullet); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 2053ef2544..a677c91bee 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2003-07-01 Lars Gullik Bjønnes + + * introduce namespace lyx::support + 2003-06-28 Lars Gullik Bjønnes * QLPopupMenu.C: fix \file diff --git a/src/frontends/qt2/FileDialog_private.C b/src/frontends/qt2/FileDialog_private.C index 67c57c71be..aa261b05bb 100644 --- a/src/frontends/qt2/FileDialog_private.C +++ b/src/frontends/qt2/FileDialog_private.C @@ -24,6 +24,7 @@ #include #include +using namespace lyx::support; namespace { diff --git a/src/frontends/qt2/QAbout.C b/src/frontends/qt2/QAbout.C index 0bf9ab2b8d..2eb6c43744 100644 --- a/src/frontends/qt2/QAbout.C +++ b/src/frontends/qt2/QAbout.C @@ -27,6 +27,8 @@ #include "Qt2BC.h" #include "QAbout.h" +using namespace lyx::support; + using std::getline; typedef QController > base_class; diff --git a/src/frontends/qt2/QBibtex.C b/src/frontends/qt2/QBibtex.C index 7925a9ba11..120f402281 100644 --- a/src/frontends/qt2/QBibtex.C +++ b/src/frontends/qt2/QBibtex.C @@ -32,6 +32,8 @@ #include "QBibtex.h" #include "Qt2BC.h" +using namespace lyx::support; + using std::vector; typedef QController > base_class; diff --git a/src/frontends/qt2/QBibtexDialog.C b/src/frontends/qt2/QBibtexDialog.C index a659786c8c..326ee65d79 100644 --- a/src/frontends/qt2/QBibtexDialog.C +++ b/src/frontends/qt2/QBibtexDialog.C @@ -32,6 +32,7 @@ #include +using namespace lyx::support; QBibtexDialog::QBibtexDialog(QBibtex * form) : QBibtexDialogBase(0, 0, false, 0), diff --git a/src/frontends/qt2/QCitation.C b/src/frontends/qt2/QCitation.C index 5f1aadf060..adb787bc5f 100644 --- a/src/frontends/qt2/QCitation.C +++ b/src/frontends/qt2/QCitation.C @@ -31,6 +31,7 @@ #include "support/lstrings.h" #include "helper_funcs.h" +using namespace lyx::support; using std::find; using std::max; diff --git a/src/frontends/qt2/QCommandBuffer.C b/src/frontends/qt2/QCommandBuffer.C index 13fc43db4b..37aa5e1148 100644 --- a/src/frontends/qt2/QCommandBuffer.C +++ b/src/frontends/qt2/QCommandBuffer.C @@ -29,6 +29,8 @@ #include "LString.h" +using namespace lyx::support; + using std::vector; using std::endl; diff --git a/src/frontends/qt2/QDocumentDialog.C b/src/frontends/qt2/QDocumentDialog.C index 5964d23d51..10956f6101 100644 --- a/src/frontends/qt2/QDocumentDialog.C +++ b/src/frontends/qt2/QDocumentDialog.C @@ -52,6 +52,7 @@ #include #include "lengthcombo.h" +using namespace lyx::support; QDocumentDialog::QDocumentDialog(QDocument * form) : QDocumentDialogBase(0, 0, false, 0), form_(form) @@ -309,7 +310,7 @@ void QDocumentDialog::updateFontsize(string const & items, string const & sel) textLayoutModule->fontsizeCO->clear(); textLayoutModule->fontsizeCO->insertItem("default"); - for (int n=0; !token(items,'|',n).empty(); ++n) + for (int n = 0; !token(items,'|',n).empty(); ++n) textLayoutModule->fontsizeCO-> insertItem(toqstr(token(items,'|',n))); diff --git a/src/frontends/qt2/QExternal.C b/src/frontends/qt2/QExternal.C index da958b70ef..399a9c7bce 100644 --- a/src/frontends/qt2/QExternal.C +++ b/src/frontends/qt2/QExternal.C @@ -31,6 +31,8 @@ #include +using namespace lyx::support; + typedef QController > base_class; diff --git a/src/frontends/qt2/QGraphics.C b/src/frontends/qt2/QGraphics.C index b33169037e..9ec47c7931 100644 --- a/src/frontends/qt2/QGraphics.C +++ b/src/frontends/qt2/QGraphics.C @@ -19,6 +19,7 @@ #include "support/tostr.h" #include "support/FileInfo.h" #include "support/filetools.h" +#include "support/lyxlib.h" #include "insets/insetgraphicsParams.h" #include "lyxrc.h" #include "lengthcombo.h" @@ -40,6 +41,8 @@ #include "QGraphics.h" #include "Qt2BC.h" +using namespace lyx::support; + using std::vector; using std::endl; @@ -242,7 +245,7 @@ void QGraphics::update_contents() for (int i = 0; i < num_units; i++) dialog_->widthUnit->insertItem(unit_name_gui[i], -1); - if (!lyx::float_equal(igp.scale, 0.0, 0.05)) { + if (!float_equal(igp.scale, 0.0, 0.05)) { // there is a scale value > 0.05 dialog_->width->setText(toqstr(tostr(igp.scale))); dialog_->widthUnit->setCurrentItem(0); diff --git a/src/frontends/qt2/QLImage.C b/src/frontends/qt2/QLImage.C index 4921ad6fa8..72dca212ba 100644 --- a/src/frontends/qt2/QLImage.C +++ b/src/frontends/qt2/QLImage.C @@ -27,6 +27,8 @@ #include +using namespace lyx::support; + using std::find_if; using std::endl; diff --git a/src/frontends/qt2/QLPopupMenu.C b/src/frontends/qt2/QLPopupMenu.C index f03836cc10..40b24685e1 100644 --- a/src/frontends/qt2/QLPopupMenu.C +++ b/src/frontends/qt2/QLPopupMenu.C @@ -23,6 +23,8 @@ #include +using namespace lyx::support; + using std::endl; using std::pair; using std::make_pair; diff --git a/src/frontends/qt2/QMinipage.C b/src/frontends/qt2/QMinipage.C index 08a41c076e..2b5ba7e41f 100644 --- a/src/frontends/qt2/QMinipage.C +++ b/src/frontends/qt2/QMinipage.C @@ -26,6 +26,8 @@ #include #include +using namespace lyx::support; + typedef QController > base_class; diff --git a/src/frontends/qt2/QParagraph.C b/src/frontends/qt2/QParagraph.C index 74cce8bc11..c7e6a4d2d3 100644 --- a/src/frontends/qt2/QParagraph.C +++ b/src/frontends/qt2/QParagraph.C @@ -35,6 +35,8 @@ #include +using namespace lyx::support; + using std::vector; using std::bind2nd; using std::remove_if; diff --git a/src/frontends/qt2/QPrefs.C b/src/frontends/qt2/QPrefs.C index 6832c844fc..77ce4bc0a2 100644 --- a/src/frontends/qt2/QPrefs.C +++ b/src/frontends/qt2/QPrefs.C @@ -54,6 +54,8 @@ #include #include "qcoloritem.h" +using namespace lyx::support; + using std::vector; using std::pair; using std::ostringstream; @@ -302,7 +304,7 @@ void QPrefs::apply() // FIXME: dubious, but it's what xforms does if (qcol != ci->color()) { ostringstream ostr; - + ostr << '#' << std::setbase(16) << setfill('0') << setw(2) << ci->color().red() << setw(2) << ci->color().green() @@ -352,7 +354,7 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry // Bleh, default fonts, and the names couldn't be found. Hack // for bug 1063. Qt makes baby Jesus cry. - + QFont font; if (family == lyx_gui::roman_font_name()) { @@ -501,7 +503,7 @@ void QPrefs::update_contents() } else if (rc.isp_command == "hspell") { spellmod->spellCommandCO->setCurrentItem(2); } - + if (rc.use_spell_lib) { #if defined(USE_ASPELL) || defined(USE_PSPELL) spellmod->spellCommandCO->setCurrentItem(3); diff --git a/src/frontends/qt2/QTexinfo.C b/src/frontends/qt2/QTexinfo.C index c19655c06c..07a626e750 100644 --- a/src/frontends/qt2/QTexinfo.C +++ b/src/frontends/qt2/QTexinfo.C @@ -25,6 +25,8 @@ #include #include +using namespace lyx::support; + using std::vector; typedef QController > base_class; diff --git a/src/frontends/qt2/QVCLog.C b/src/frontends/qt2/QVCLog.C index 5769148bb8..12dee158f8 100644 --- a/src/frontends/qt2/QVCLog.C +++ b/src/frontends/qt2/QVCLog.C @@ -26,6 +26,8 @@ #include "support/BoostFormat.h" +using namespace lyx::support; + typedef QController > base_class; @@ -45,7 +47,7 @@ void QVCLog::build_dialog() void QVCLog::update_contents() { - setTitle(bformat(_("Version control log for %1$s"), + setTitle(bformat(_("Version control log for %1$s"), controller().getBufferFileName())); dialog_->vclogTV->setText(""); diff --git a/src/frontends/qt2/QWrap.C b/src/frontends/qt2/QWrap.C index 0780f285c8..b8577b5a43 100644 --- a/src/frontends/qt2/QWrap.C +++ b/src/frontends/qt2/QWrap.C @@ -28,6 +28,7 @@ #include #include +using namespace lyx::support; typedef QController > base_class; diff --git a/src/frontends/qt2/QtView.C b/src/frontends/qt2/QtView.C index 437b85790a..8e03a98861 100644 --- a/src/frontends/qt2/QtView.C +++ b/src/frontends/qt2/QtView.C @@ -39,6 +39,8 @@ #include #include +using namespace lyx::support; + using std::endl; namespace { diff --git a/src/frontends/qt2/floatplacement.C b/src/frontends/qt2/floatplacement.C index 3cd0245bc4..8d83cc5929 100644 --- a/src/frontends/qt2/floatplacement.C +++ b/src/frontends/qt2/floatplacement.C @@ -21,6 +21,8 @@ #include #include +using namespace lyx::support; + // FIXME: set disabled doesn't work properly FloatPlacement::FloatPlacement(QWidget * parent, char * name) diff --git a/src/frontends/qt2/lyx_gui.C b/src/frontends/qt2/lyx_gui.C index ce6371da26..6b8038ad83 100644 --- a/src/frontends/qt2/lyx_gui.C +++ b/src/frontends/qt2/lyx_gui.C @@ -55,6 +55,8 @@ #include #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::exit; #endif diff --git a/src/frontends/qt2/panelstack.C b/src/frontends/qt2/panelstack.C index 32e0715f9d..44c0f3c420 100644 --- a/src/frontends/qt2/panelstack.C +++ b/src/frontends/qt2/panelstack.C @@ -18,6 +18,8 @@ #include #include +using namespace lyx::support; + using std::map; @@ -59,7 +61,7 @@ void PanelStack::addCategory(string const & n, string const & parent) if (!parent.empty()) { PanelMap::iterator it = panel_map_.find(parent); - lyx::Assert(it != panel_map_.end()); + Assert(it != panel_map_.end()); QListViewItem * before = it->second->firstChild(); if (before) { @@ -108,7 +110,7 @@ void PanelStack::addPanel(QWidget * panel, string const & name, string const & p void PanelStack::setCurrentPanel(string const & name) { PanelMap::const_iterator cit = panel_map_.find(name); - lyx::Assert(cit != panel_map_.end()); + Assert(cit != panel_map_.end()); // force on first set if (list_->currentItem() == cit->second) diff --git a/src/frontends/qt2/qfont_loader.C b/src/frontends/qt2/qfont_loader.C index 7a19c9f72c..dc68828150 100644 --- a/src/frontends/qt2/qfont_loader.C +++ b/src/frontends/qt2/qfont_loader.C @@ -35,6 +35,8 @@ #include "support/filetools.h" #endif +using namespace lyx::support; + using std::endl; using std::vector; using std::pair; diff --git a/src/frontends/screen.C b/src/frontends/screen.C index 8fb9f8e644..7bdee9bc08 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -42,6 +42,8 @@ #include #include +using namespace lyx::support; + using std::min; using std::max; using std::endl; @@ -266,7 +268,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText * text) - row->baseline() - vheight; } else { // scroll down, the scroll region must be so big!! - newtop = cursor.y() - vheight / 2; + newtop = cursor.y() - vheight / 2; } } else if (static_cast((cursor.y()) - row->baseline()) < diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 268340caa6..879ba05c76 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,6 @@ +2003-07-01 Lars Gullik Bjønnes + + * introcude namespace lyx::support 2003-06-30 André Pönitz diff --git a/src/frontends/xforms/ColorHandler.C b/src/frontends/xforms/ColorHandler.C index 65f45e7c28..3b5ba5d3f2 100644 --- a/src/frontends/xforms/ColorHandler.C +++ b/src/frontends/xforms/ColorHandler.C @@ -22,6 +22,8 @@ #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::pow; #endif @@ -158,7 +160,7 @@ GC LyXColorHandler::getGCForeground(LColor::color c) lyxerr << bformat( _(" Using closest allocated color with (r,g,b)=%1$s instead.\n" - "Pixel [%2$s] is used."), + "Pixel [%2$s] is used."), tostr(cmap[closest_pixel]), tostr(closest_pixel)) << endl; val.foreground = cmap[closest_pixel].pixel; diff --git a/src/frontends/xforms/FileDialog.C b/src/frontends/xforms/FileDialog.C index e39a253105..0f43d3ee7f 100644 --- a/src/frontends/xforms/FileDialog.C +++ b/src/frontends/xforms/FileDialog.C @@ -21,6 +21,7 @@ #include "support/lstrings.h" #include +using namespace lyx::support; using std::make_pair; using std::pair; diff --git a/src/frontends/xforms/FontInfo.C b/src/frontends/xforms/FontInfo.C index 9316c0b582..17f1475a46 100644 --- a/src/frontends/xforms/FontInfo.C +++ b/src/frontends/xforms/FontInfo.C @@ -23,6 +23,8 @@ #include // abs() +using namespace lyx::support; + using std::endl; using std::abs; @@ -134,14 +136,14 @@ void FontInfo::query() string name(list[i]); lyxerr[Debug::FONT] << "match #" << i << ' ' << name << endl; - sizes[i] = lyx::atoi(token(name, '-', 7)); + sizes[i] = atoi(token(name, '-', 7)); strings[i] = name; if (sizes[i] == 0) { if (scaleindex == -1) { scaleindex = i; } scalable = true; - } else if (lyx::atoi(token(name, '-', 12)) == 0) + } else if (atoi(token(name, '-', 12)) == 0) // Ignore bogus matches of scalable fonts. sizes[i] = 0; }; diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index 49821961ea..afb14a2770 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -27,6 +27,8 @@ #include "lyx_forms.h" +using namespace lyx::support; + extern "C" { #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0) @@ -123,7 +125,7 @@ void FormBase::show() { // build() is/should be called from the controller, so form() should // always exist. - lyx::Assert(form()); + Assert(form()); // we use minw_ to flag whether the dialog has ever been shown. // In turn, prepare_to_show() initialises various bits 'n' pieces @@ -182,14 +184,14 @@ void FormBase::hide() void FormBase::setPrehandler(FL_OBJECT * ob) { - lyx::Assert(ob); + Assert(ob); fl_set_object_prehandler(ob, C_PrehandlerCB); } void FormBase::setMessageWidget(FL_OBJECT * ob) { - lyx::Assert(ob && ob->objclass == FL_TEXT); + Assert(ob && ob->objclass == FL_TEXT); message_widget_ = ob; fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE); } @@ -216,7 +218,7 @@ ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long) // preemptive handler for feedback messages void FormBase::MessageCB(FL_OBJECT * ob, int event) { - lyx::Assert(ob); + Assert(ob); switch (event) { case FL_ENTER: @@ -243,7 +245,7 @@ void FormBase::MessageCB(FL_OBJECT * ob, int event) void FormBase::PrehandlerCB(FL_OBJECT * ob, int event, int key) { - lyx::Assert(ob); + Assert(ob); if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) { // Trigger an input event when pasting in an xforms input object @@ -295,7 +297,7 @@ void FormBase::postWarning(string const & warning) void FormBase::clearMessage() { - lyx::Assert(message_widget_); + Assert(message_widget_); warning_posted_ = false; @@ -312,10 +314,9 @@ void FormBase::clearMessage() void FormBase::postMessage(string const & message) { - lyx::Assert(message_widget_); + Assert(message_widget_); int const width = message_widget_->w - 10; - string const tmp = warning_posted_ ? bformat(_("WARNING! %1$s"), message) : message; @@ -335,7 +336,7 @@ namespace { FormBase * GetForm(FL_OBJECT * ob) { - lyx::Assert(ob && ob->form && ob->form->u_vdata); + Assert(ob && ob->form && ob->form->u_vdata); FormBase * ptr = static_cast(ob->form->u_vdata); return ptr; } @@ -379,7 +380,7 @@ void C_FormBaseInputCB(FL_OBJECT * ob, long d) static int C_WMHideCB(FL_FORM * form, void *) { // Close the dialog cleanly, even if the WM is used to do so. - lyx::Assert(form && form->u_vdata); + Assert(form && form->u_vdata); FormBase * ptr = static_cast(form->u_vdata); ptr->getController().CancelButton(); return FL_CANCEL; @@ -390,7 +391,7 @@ static int C_PrehandlerCB(FL_OBJECT * ob, int event, { // Note that the return value is important in the pre-emptive handler. // Don't return anything other than 0. - lyx::Assert(ob); + Assert(ob); // Don't Assert this one, as it can happen quite naturally when things // are being deleted in the d-tor. diff --git a/src/frontends/xforms/FormBibitem.C b/src/frontends/xforms/FormBibitem.C index 9e7d688b30..d4366205a8 100644 --- a/src/frontends/xforms/FormBibitem.C +++ b/src/frontends/xforms/FormBibitem.C @@ -20,6 +20,8 @@ #include "gettext.h" #include "support/lstrings.h" // compare +using namespace lyx::support; + typedef FormController > base_class; FormBibitem::FormBibitem(Dialog & parent) diff --git a/src/frontends/xforms/FormBibtex.C b/src/frontends/xforms/FormBibtex.C index 0211e226a7..91fc14de2f 100644 --- a/src/frontends/xforms/FormBibtex.C +++ b/src/frontends/xforms/FormBibtex.C @@ -27,6 +27,7 @@ #include "support/filetools.h" #include "support/lyxalgo.h" +using namespace lyx::support; using std::vector; using std::sort; diff --git a/src/frontends/xforms/FormCharacter.C b/src/frontends/xforms/FormCharacter.C index 62174044cd..a1c30d470e 100644 --- a/src/frontends/xforms/FormCharacter.C +++ b/src/frontends/xforms/FormCharacter.C @@ -9,9 +9,6 @@ * Full author contact details are available in file CREDITS */ -#include - - #include #include "xformsBC.h" @@ -29,6 +26,10 @@ #include "support/lstrings.h" +#include + +using namespace lyx::support; + using std::vector; using std::find; diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index dc3feea29c..a30dd7b30e 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -10,8 +10,6 @@ */ #include -#include - #include "xformsBC.h" #include "ControlCitation.h" @@ -27,6 +25,10 @@ #include "support/LAssert.h" #include "support/lstrings.h" +#include + +using namespace lyx::support; + using std::find; using std::max; using std::min; diff --git a/src/frontends/xforms/FormDialogView.C b/src/frontends/xforms/FormDialogView.C index f7e7d48088..6ff800fc53 100644 --- a/src/frontends/xforms/FormDialogView.C +++ b/src/frontends/xforms/FormDialogView.C @@ -28,6 +28,8 @@ #include "lyx_forms.h" +using namespace lyx::support; + extern "C" { #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0) @@ -184,14 +186,14 @@ void FormDialogView::hide() void FormDialogView::setPrehandler(FL_OBJECT * ob) { - lyx::Assert(ob); + Assert(ob); fl_set_object_prehandler(ob, C_PrehandlerCB); } void FormDialogView::setMessageWidget(FL_OBJECT * ob) { - lyx::Assert(ob && ob->objclass == FL_TEXT); + Assert(ob && ob->objclass == FL_TEXT); message_widget_ = ob; fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE); } @@ -218,7 +220,7 @@ ButtonPolicy::SMInput FormDialogView::input(FL_OBJECT *, long) // preemptive handler for feedback messages void FormDialogView::MessageCB(FL_OBJECT * ob, int event) { - lyx::Assert(ob); + Assert(ob); switch (event) { case FL_ENTER: @@ -245,7 +247,7 @@ void FormDialogView::MessageCB(FL_OBJECT * ob, int event) void FormDialogView::PrehandlerCB(FL_OBJECT * ob, int event, int key) { - lyx::Assert(ob); + Assert(ob); if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) { // Trigger an input event when pasting in an xforms input @@ -297,7 +299,7 @@ void FormDialogView::postWarning(string const & warning) void FormDialogView::clearMessage() { - lyx::Assert(message_widget_); + Assert(message_widget_); warning_posted_ = false; @@ -315,11 +317,9 @@ void FormDialogView::clearMessage() #warning isnt this the same as in FormBase? void FormDialogView::postMessage(string const & message) { - lyx::Assert(message_widget_); + Assert(message_widget_); int const width = message_widget_->w - 10; - - string const tmp = warning_posted_ ? bformat(_("WARNING! %1$s"), message) : message; @@ -339,7 +339,7 @@ namespace { FormDialogView * GetForm(FL_OBJECT * ob) { - lyx::Assert(ob && ob->form && ob->form->u_vdata); + Assert(ob && ob->form && ob->form->u_vdata); FormDialogView * ptr = static_cast(ob->form->u_vdata); return ptr; @@ -384,7 +384,7 @@ void C_FormDialogView_InputCB(FL_OBJECT * ob, long d) static int C_WMHideCB(FL_FORM * form, void *) { // Close the dialog cleanly, even if the WM is used to do so. - lyx::Assert(form && form->u_vdata); + Assert(form && form->u_vdata); FormDialogView * ptr = static_cast(form->u_vdata); ptr->dialog().CancelButton(); return FL_CANCEL; @@ -395,7 +395,7 @@ static int C_PrehandlerCB(FL_OBJECT * ob, int event, { // Note that the return value is important in the pre-emptive handler. // Don't return anything other than 0. - lyx::Assert(ob); + Assert(ob); // Don't Assert this one, as it can happen quite naturally when things // are being deleted in the d-tor. diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 576e7672a1..276c7d48ea 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -44,6 +44,8 @@ #include +using namespace lyx::support; + using std::bind2nd; using std::vector; diff --git a/src/frontends/xforms/FormExternal.C b/src/frontends/xforms/FormExternal.C index 8f259a3ae8..e48fba8b4c 100644 --- a/src/frontends/xforms/FormExternal.C +++ b/src/frontends/xforms/FormExternal.C @@ -30,6 +30,8 @@ #include "support/lstrings.h" #include "lyx_forms.h" +using namespace lyx::support; + typedef FormController > base_class; FormExternal::FormExternal(Dialog & parent) diff --git a/src/frontends/xforms/FormFiledialog.C b/src/frontends/xforms/FormFiledialog.C index 03599d8ac6..1ed9e2adab 100644 --- a/src/frontends/xforms/FormFiledialog.C +++ b/src/frontends/xforms/FormFiledialog.C @@ -61,6 +61,8 @@ using std::sort; #include "forms/form_filedialog.h" #include "lyx_forms.h" +using namespace lyx::support; + namespace { // six months, in seconds @@ -196,7 +198,7 @@ void FileDialog::Private::Reread() Alert::err_alert(_("Warning! Couldn't open directory."), directory_); #endif - directory_ = lyx::getcwd(); + directory_ = getcwd(); dir = ::opendir(directory_.c_str()); } @@ -356,7 +358,7 @@ void FileDialog::Private::SetDirectory(string const & path) { string tmp; if (path.empty()) - tmp = lyx::getcwd(); + tmp = getcwd(); else tmp = MakeAbsPath(ExpandPath(path), directory_); diff --git a/src/frontends/xforms/FormFloat.C b/src/frontends/xforms/FormFloat.C index d72294115e..df7c56cbd5 100644 --- a/src/frontends/xforms/FormFloat.C +++ b/src/frontends/xforms/FormFloat.C @@ -23,6 +23,8 @@ #include "support/lstrings.h" #include "lyx_forms.h" +using namespace lyx::support; + namespace { enum { diff --git a/src/frontends/xforms/FormForks.C b/src/frontends/xforms/FormForks.C index d2f1e84e22..1c1a9a7e4d 100644 --- a/src/frontends/xforms/FormForks.C +++ b/src/frontends/xforms/FormForks.C @@ -24,6 +24,8 @@ #include "lyx_forms.h" #include "support/tostr.h" +using namespace lyx::support; + using std::vector; using std::find; using std::find_if; diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 70a79a3e2a..8dd690560d 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -40,6 +40,8 @@ #include "lyx_forms.h" +using namespace lyx::support; + using std::endl; using std::vector; @@ -317,7 +319,7 @@ void FormGraphics::apply() // first item in choice_width means scaling if (fl_get_choice(file_->choice_width) == 1) { igp.scale = strToDbl(getString(file_->input_width)); - if (lyx::float_equal(igp.scale, 0.0, 0.05)) { + if (float_equal(igp.scale, 0.0, 0.05)) { igp.scale = 100.0; } igp.width = LyXLength(); @@ -443,7 +445,7 @@ void FormGraphics::update() { } // set width input fields according to scaling or width/height input - if (!lyx::float_equal(igp.scale, 0.0, 0.05)) { + if (!float_equal(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, tostr(igp.scale).c_str()); @@ -459,7 +461,7 @@ void FormGraphics::update() { igp.height, defaultUnit); // disable height input in case of scaling - bool const disable_height = !lyx::float_equal(igp.scale, 0.0, 0.05); + bool const disable_height = !float_equal(igp.scale, 0.0, 0.05); setEnabled(file_->input_height, !disable_height); setEnabled(file_->choice_height, !disable_height); diff --git a/src/frontends/xforms/FormInclude.C b/src/frontends/xforms/FormInclude.C index e51ca031d3..1ccfde20ce 100644 --- a/src/frontends/xforms/FormInclude.C +++ b/src/frontends/xforms/FormInclude.C @@ -11,8 +11,6 @@ */ #include -#include - #include "debug.h" @@ -26,6 +24,10 @@ #include "support/lstrings.h" // strip #include "lyx_forms.h" +#include + +using namespace lyx::support; + typedef FormController > base_class; FormInclude::FormInclude(Dialog & parent) diff --git a/src/frontends/xforms/FormMathsBitmap.C b/src/frontends/xforms/FormMathsBitmap.C index 0b9f8b8fd2..3ecc8792b2 100644 --- a/src/frontends/xforms/FormMathsBitmap.C +++ b/src/frontends/xforms/FormMathsBitmap.C @@ -29,6 +29,8 @@ extern "C" void C_FormDialogView_CancelCB(FL_OBJECT *, long); extern "C" void C_FormDialogView_InputCB(FL_OBJECT *, long); +using namespace lyx::support; + using std::vector; using std::max; @@ -76,7 +78,7 @@ void FormMathsBitmap::addBitmap(BitmapStore const & bm) void FormMathsBitmap::build() { - lyx::Assert(bitmaps_.size() > 0); + Assert(bitmaps_.size() > 0); h_+= 42; // Allow room for a Close button diff --git a/src/frontends/xforms/FormMathsMatrix.C b/src/frontends/xforms/FormMathsMatrix.C index b807ca1983..b071274b90 100644 --- a/src/frontends/xforms/FormMathsMatrix.C +++ b/src/frontends/xforms/FormMathsMatrix.C @@ -29,6 +29,8 @@ #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::strlen; #endif @@ -44,10 +46,10 @@ extern "C" { int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *, char const * cur, int c) { - lyx::Assert(ob); + Assert(ob); FormMathsMatrix * pre = static_cast(ob->u_vdata); - lyx::Assert(pre); + Assert(pre); return pre->AlignFilter(cur, c); } diff --git a/src/frontends/xforms/FormMinipage.C b/src/frontends/xforms/FormMinipage.C index 4c224ed4c3..780a52bee3 100644 --- a/src/frontends/xforms/FormMinipage.C +++ b/src/frontends/xforms/FormMinipage.C @@ -21,6 +21,8 @@ #include "xforms_helpers.h" #include "lyx_forms.h" +using namespace lyx::support; + typedef FormController > base_class; FormMinipage::FormMinipage(Dialog & parent) diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index 03e2cdb797..6b45eb0f25 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -35,6 +35,8 @@ #include +using namespace lyx::support; + using std::vector; using std::bind2nd; using std::remove_if; @@ -440,7 +442,7 @@ namespace { void validateVSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length) { // Paranoia check! - lyx::Assert(choice_type && choice_type->objclass == FL_CHOICE && + Assert(choice_type && choice_type->objclass == FL_CHOICE && input_length && input_length->objclass == FL_INPUT); if (fl_get_choice(choice_type) != 7) @@ -460,7 +462,7 @@ VSpace const setVSpaceFromWidgets(FL_OBJECT * choice_type, FL_OBJECT * check_keep) { // Paranoia check! - lyx::Assert(choice_type && choice_type->objclass == FL_CHOICE && + Assert(choice_type && choice_type->objclass == FL_CHOICE && input_length && input_length->objclass == FL_INPUT && choice_length && choice_length->objclass == FL_CHOICE && check_keep && check_keep->objclass == FL_CHECKBUTTON); @@ -508,7 +510,7 @@ void setWidgetsFromVSpace(VSpace const & space, FL_OBJECT * check_keep) { // Paranoia check! - lyx::Assert(choice_type && choice_type->objclass == FL_CHOICE && + Assert(choice_type && choice_type->objclass == FL_CHOICE && input_length && input_length->objclass == FL_INPUT && choice_length && choice_length->objclass == FL_CHOICE && check_keep && check_keep->objclass == FL_CHECKBUTTON); diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 4bb1d2c4f1..b6e87f7df4 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -66,6 +66,8 @@ using std::setfill; extern string system_lyxdir; extern string user_lyxdir; +using namespace lyx::support; + namespace { // These should probably go inside the class definition... @@ -336,7 +338,7 @@ void FormPreferences::apply() string const FormPreferences::getFeedback(FL_OBJECT * ob) { - lyx::Assert(ob); + Assert(ob); if (ob->form->fdui == colors_.dialog()) return colors_.feedback(ob); @@ -369,7 +371,7 @@ string const FormPreferences::getFeedback(FL_OBJECT * ob) ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long) { - lyx::Assert(ob); + Assert(ob); bool valid = true; diff --git a/src/frontends/xforms/FormPrint.C b/src/frontends/xforms/FormPrint.C index ed0c11debb..06da0e40d0 100644 --- a/src/frontends/xforms/FormPrint.C +++ b/src/frontends/xforms/FormPrint.C @@ -25,6 +25,7 @@ #include "lyx_forms.h" #include "support/tostr.h" +using namespace lyx::support; typedef FormCB > base_class; diff --git a/src/frontends/xforms/FormRef.C b/src/frontends/xforms/FormRef.C index 7fe982295b..85a3b1f192 100644 --- a/src/frontends/xforms/FormRef.C +++ b/src/frontends/xforms/FormRef.C @@ -9,8 +9,6 @@ */ #include -#include - #include "xformsBC.h" #include "ControlRef.h" @@ -23,6 +21,10 @@ #include "support/lstrings.h" // trim #include "lyx_forms.h" +#include + +using namespace lyx::support; + using std::find; using std::max; using std::sort; diff --git a/src/frontends/xforms/FormSendto.C b/src/frontends/xforms/FormSendto.C index ac97db71dc..c4ef555ef8 100644 --- a/src/frontends/xforms/FormSendto.C +++ b/src/frontends/xforms/FormSendto.C @@ -10,7 +10,6 @@ #include - #include "FormSendto.h" #include "forms/form_sendto.h" #include "ControlSendto.h" @@ -22,6 +21,8 @@ #include "lyx_forms.h" #include "support/lstrings.h" +using namespace lyx::support; + using std::vector; typedef FormCB > base_class; diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index f389621c18..0be76f3ff4 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -10,10 +10,6 @@ #include - -#include -#include - #include "ControlTabular.h" #include "xformsBC.h" #include "ButtonController.h" @@ -31,6 +27,11 @@ #include "lyx_forms.h" +#include +#include + +using namespace lyx::support; + using std::vector; using std::bind2nd; diff --git a/src/frontends/xforms/FormTexinfo.C b/src/frontends/xforms/FormTexinfo.C index e97ca915a4..70ca996736 100644 --- a/src/frontends/xforms/FormTexinfo.C +++ b/src/frontends/xforms/FormTexinfo.C @@ -23,6 +23,8 @@ #include "lyx_forms.h" +using namespace lyx::support; + typedef FormController > base_class; FormTexinfo::FormTexinfo(Dialog & parent) diff --git a/src/frontends/xforms/FormText.C b/src/frontends/xforms/FormText.C index e4bc3951ca..93e822aa72 100644 --- a/src/frontends/xforms/FormText.C +++ b/src/frontends/xforms/FormText.C @@ -21,6 +21,8 @@ #include "lyx_forms.h" +using namespace lyx::support; + typedef FormController > base_class; FormText::FormText(Dialog & parent, string const & title, string const & label) diff --git a/src/frontends/xforms/FormThesaurus.C b/src/frontends/xforms/FormThesaurus.C index b2b5ac3931..1a380b8127 100644 --- a/src/frontends/xforms/FormThesaurus.C +++ b/src/frontends/xforms/FormThesaurus.C @@ -10,7 +10,6 @@ #include - #include "ControlThesaurus.h" #include "FormThesaurus.h" #include "forms/form_thesaurus.h" @@ -19,8 +18,11 @@ #include "debug.h" #include "support/lstrings.h" #include "lyx_forms.h" + #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::isupper; using std::islower; diff --git a/src/frontends/xforms/FormToc.C b/src/frontends/xforms/FormToc.C index 45755c9ea3..9c35604e4b 100644 --- a/src/frontends/xforms/FormToc.C +++ b/src/frontends/xforms/FormToc.C @@ -23,6 +23,8 @@ #include +using namespace lyx::support; + using std::vector; using std::endl; diff --git a/src/frontends/xforms/FormWrap.C b/src/frontends/xforms/FormWrap.C index 2160905bb3..07e0eff8e3 100644 --- a/src/frontends/xforms/FormWrap.C +++ b/src/frontends/xforms/FormWrap.C @@ -25,6 +25,7 @@ #include "lyx_forms.h" #include "support/tostr.h" +using namespace lyx::support; typedef FormController > base_class; diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index 424b14a6a0..ea868c8dd1 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -26,6 +26,8 @@ #include +using namespace lyx::support; + using std::endl; using std::vector; using std::max; @@ -342,7 +344,7 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button) } // Paranoia check - lyx::Assert(item->kind() == MenuItem::Submenu); + Assert(item->kind() == MenuItem::Submenu); // set tabstop length fl_set_tabstop(menu_tabstop); diff --git a/src/frontends/xforms/RadioButtonGroup.C b/src/frontends/xforms/RadioButtonGroup.C index 374cb564bd..1f1eda9d40 100644 --- a/src/frontends/xforms/RadioButtonGroup.C +++ b/src/frontends/xforms/RadioButtonGroup.C @@ -24,6 +24,8 @@ #include #include +using namespace lyx::support; + using std::find_if; using std::endl; @@ -32,7 +34,7 @@ void RadioButtonGroup::init(FL_OBJECT * ob, size_type value) { // Object must be a ROUND3DBUTTON (let all radio buttons look the same) // and of type RADIO_BUTTON (otherwise it ain't work). - lyx::Assert(ob && ob->objclass == FL_ROUND3DBUTTON + Assert(ob && ob->objclass == FL_ROUND3DBUTTON && ob->type == FL_RADIO_BUTTON); map.push_back(ButtonValuePair(ob, value)); diff --git a/src/frontends/xforms/Tooltips.C b/src/frontends/xforms/Tooltips.C index fe1e3b554a..f921864d0b 100644 --- a/src/frontends/xforms/Tooltips.C +++ b/src/frontends/xforms/Tooltips.C @@ -26,6 +26,8 @@ #include +using namespace lyx::support; + bool Tooltips::enabled_ = true; boost::signal0 Tooltips::toggled; @@ -61,7 +63,7 @@ void Tooltips::set() void Tooltips::init(FL_OBJECT * ob, string const & tip) { - lyx::Assert(ob && ob->form); + Assert(ob && ob->form); // Store the tooltip string string const str = formatted(trim(tip), 400); diff --git a/src/frontends/xforms/XFormsView.C b/src/frontends/xforms/XFormsView.C index 3f104fecc5..a9fede2356 100644 --- a/src/frontends/xforms/XFormsView.C +++ b/src/frontends/xforms/XFormsView.C @@ -31,6 +31,9 @@ #include #include + +using namespace lyx::support; + using std::abs; using std::endl; diff --git a/src/frontends/xforms/XPainter.C b/src/frontends/xforms/XPainter.C index a4dd8d6cbc..a40e3342f3 100644 --- a/src/frontends/xforms/XPainter.C +++ b/src/frontends/xforms/XPainter.C @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author unknown + * \author Lars Gullik Bjønnes * \author John Levon * * Full author contact details are available in file CREDITS @@ -11,7 +11,6 @@ #include - #include "XPainter.h" #include "LString.h" #include "debug.h" @@ -31,6 +30,8 @@ #include +using namespace lyx::support; + using std::endl; using std::max; diff --git a/src/frontends/xforms/checkedwidgets.C b/src/frontends/xforms/checkedwidgets.C index 6b43aee35d..630a6e5098 100644 --- a/src/frontends/xforms/checkedwidgets.C +++ b/src/frontends/xforms/checkedwidgets.C @@ -21,6 +21,7 @@ #include "lyx_forms.h" +using namespace lyx::support; void addCheckedLyXLength(BCView & bcview, FL_OBJECT * input, FL_OBJECT * label) @@ -65,7 +66,7 @@ void setWidget(bool valid, FL_OBJECT * input, FL_OBJECT * label) CheckedLyXLength::CheckedLyXLength(FL_OBJECT * input, FL_OBJECT * label) : input_(input), label_(label ? label : input) { - lyx::Assert(input && input->objclass == FL_INPUT); + Assert(input && input->objclass == FL_INPUT); } @@ -85,7 +86,7 @@ bool CheckedLyXLength::check() const CheckedGlueLength::CheckedGlueLength(FL_OBJECT * input, FL_OBJECT * label) : input_(input), label_(label ? label : input) { - lyx::Assert(input && input->objclass == FL_INPUT); + Assert(input && input->objclass == FL_INPUT); } diff --git a/src/frontends/xforms/forms_gettext.C b/src/frontends/xforms/forms_gettext.C index cfa58ad6cb..e2e23e93bd 100644 --- a/src/frontends/xforms/forms_gettext.C +++ b/src/frontends/xforms/forms_gettext.C @@ -13,6 +13,8 @@ #include "forms_gettext.h" #include "support/lstrings.h" +using namespace lyx::support; + // Extract shortcut from "|" string string const scex(string const & str) { diff --git a/src/frontends/xforms/input_validators.C b/src/frontends/xforms/input_validators.C index 49bd062dd0..d1a29e1dd9 100644 --- a/src/frontends/xforms/input_validators.C +++ b/src/frontends/xforms/input_validators.C @@ -11,6 +11,8 @@ #include "support/lstrings.h" #include "input_validators.h" +using namespace lyx::support; + #if defined(__cplusplus) extern "C" { diff --git a/src/frontends/xforms/lyx_gui.C b/src/frontends/xforms/lyx_gui.C index 656d663579..e39db69e87 100644 --- a/src/frontends/xforms/lyx_gui.C +++ b/src/frontends/xforms/lyx_gui.C @@ -44,6 +44,8 @@ #include #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::exit; #endif @@ -117,7 +119,7 @@ int LyX_XErrHandler(Display * display, XErrorEvent * xeev) { XGetErrorText(display, xeev->error_code, etxt, 512); lyxerr << etxt << " id: " << xeev->resourceid << endl; // By doing an abort we get a nice backtrace. (hopefully) - lyx::abort(); + lyx::support::abort(); return 0; } diff --git a/src/frontends/xforms/xfont_loader.C b/src/frontends/xforms/xfont_loader.C index 15168c4c13..ecf875a286 100644 --- a/src/frontends/xforms/xfont_loader.C +++ b/src/frontends/xforms/xfont_loader.C @@ -25,6 +25,8 @@ #include "lyx_forms.h" +using namespace lyx::support; + using std::endl; // The global fontloader diff --git a/src/frontends/xforms/xfont_metrics.C b/src/frontends/xforms/xfont_metrics.C index 4412065a12..30b5acedb5 100644 --- a/src/frontends/xforms/xfont_metrics.C +++ b/src/frontends/xforms/xfont_metrics.C @@ -21,6 +21,8 @@ #include +using namespace lyx::support; + namespace { inline diff --git a/src/frontends/xforms/xformsImage.C b/src/frontends/xforms/xformsImage.C index 39feb72df7..52abc998b8 100644 --- a/src/frontends/xforms/xformsImage.C +++ b/src/frontends/xforms/xformsImage.C @@ -18,6 +18,7 @@ #include "support/LAssert.h" #include "support/lstrings.h" #include "support/lyxfunctional.h" // compare_memfun +#include "support/lyxlib.h" #include "lyx_forms.h" @@ -31,6 +32,8 @@ #include +using namespace lyx::support; + using std::find_if; namespace { @@ -296,7 +299,7 @@ void xformsImage::rotate(Params const & params) if (!image_) return ; - if (lyx::float_equal(params.angle, 0.0, 0.1)) + if (float_equal(params.angle, 0.0, 0.1)) // No rotation is necessary. return; @@ -306,7 +309,7 @@ void xformsImage::rotate(Params const & params) // Work around xforms bug when params.angle == 270 // the 'InternalError: bad special angle' error. // This bug fix is not needed in xforms 1.0 and greater. - if (lyx::float_equal(params.angle, 270.0, 0.1)) { + if (float_equal(params.angle, 270.0, 0.1)) { flimage_rotate(image_, 900, FLIMAGE_SUBPIXEL); flimage_rotate(image_, 1800, FLIMAGE_SUBPIXEL); } else { @@ -370,7 +373,7 @@ extern "C" { int status_report(FL_IMAGE * ob, const char *s) { - lyx::Assert(ob && ob->u_vdata); + Assert(ob && ob->u_vdata); string const str = s ? rtrim(s) : string(); if (str.empty()) @@ -389,7 +392,7 @@ int status_report(FL_IMAGE * ob, const char *s) static void error_report(FL_IMAGE * ob, const char *s) { - lyx::Assert(ob && ob->u_vdata); + Assert(ob && ob->u_vdata); string const str = s ? rtrim(s) : string(); if (str.empty()) diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 1d487f1208..be8833c603 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -29,6 +29,8 @@ #include +using namespace lyx::support; + using std::ofstream; using std::pair; using std::vector; @@ -100,7 +102,7 @@ vector const getVector(FL_OBJECT * ob) } break; default: - lyx::Assert(0); + Assert(0); } return vec; @@ -111,7 +113,7 @@ vector const getVector(FL_OBJECT * ob) string const getString(FL_OBJECT * ob, int line) { // Negative line value does not make sense. - lyx::Assert(line >= 0); + Assert(line >= 0); char const * tmp = 0; switch (ob->objclass) { @@ -140,7 +142,7 @@ string const getString(FL_OBJECT * ob, int line) break; default: - lyx::Assert(0); + Assert(0); } return tmp ? trim(tmp) : string(); @@ -149,7 +151,7 @@ string const getString(FL_OBJECT * ob, int line) string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice) { // Paranoia check - lyx::Assert(input && input->objclass == FL_INPUT && + Assert(input && input->objclass == FL_INPUT && choice && choice->objclass == FL_CHOICE); string const length = trim(fl_get_input(input)); @@ -190,7 +192,7 @@ void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice, string const & default_unit) { // Paranoia check - lyx::Assert(input && input->objclass == FL_INPUT && + Assert(input && input->objclass == FL_INPUT && choice && choice->objclass == FL_CHOICE); if (len.empty()) { diff --git a/src/frontends/xforms/xforms_resize.C b/src/frontends/xforms/xforms_resize.C index 936e7582a7..c8d5f32cef 100644 --- a/src/frontends/xforms/xforms_resize.C +++ b/src/frontends/xforms/xforms_resize.C @@ -16,6 +16,8 @@ #include // std::max. Use FL_max in .c code... #include "lyx_forms.h" +using namespace lyx::support; + namespace { /* This is hacked straight out of the xforms source. @@ -93,7 +95,7 @@ double get_scaling_factor(FL_FORM * form) double get_tabfolder_scale_to_fit(FL_OBJECT * folder) { - lyx::Assert(folder && folder->objclass == FL_TABFOLDER); + Assert(folder && folder->objclass == FL_TABFOLDER); fl_freeze_form(folder->form); int const saved_folder_id = fl_get_folder_number(folder); @@ -115,7 +117,7 @@ double get_tabfolder_scale_to_fit(FL_OBJECT * folder) void scale_tabfolder_horizontally(FL_OBJECT * folder, double factor) { - lyx::Assert(folder && folder->objclass == FL_TABFOLDER); + Assert(folder && folder->objclass == FL_TABFOLDER); fl_freeze_form(folder->form); int const saved_folder_id = fl_get_folder_number(folder); @@ -136,7 +138,7 @@ void scale_tabfolder_horizontally(FL_OBJECT * folder, double factor) double get_scale_to_fit(FL_FORM * form) { - lyx::Assert(form); + Assert(form); double factor = get_scaling_factor(form); for (FL_OBJECT * ob = form->first; ob; ob = ob->next) { @@ -150,7 +152,7 @@ double get_scale_to_fit(FL_FORM * form) void scale_form_horizontally(FL_FORM * form, double factor) { - lyx::Assert(form); + Assert(form); if (factor <= 1.0) return; diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index 48e67610cb..fb31eccd44 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,7 @@ +2003-07-01 Lars Gullik Bjønnes + + * introcude namespace lyx::support + 2003-06-04 Angus Leeming * GraphicsLoader.C (Loader copy c-tor): make it work as expected. ;-) @@ -38,7 +42,7 @@ 2003-05-12 André Pönitz - * PreviewLoader.C: boost::format -> bformat + * PreviewLoader.C: boost::format -> bformat 2003-04-15 Angus Leeming @@ -61,17 +65,17 @@ * GraphicsLoader.[Ch], * PreviewImage.[Ch], - * PreviewedInset.C: Removed unneeded list of owner insets + * PreviewedInset.C: Removed unneeded list of owner insets 2003-02-25 Alfredo Braunstein * GraphicsConverter (startConversion): add the call to - ForkedCallQueue::add + ForkedCallQueue::add * GraphicsLoader.[Ch], * PreviewImage.[Ch], - * PreviewedInset.C: Removed unneeded BufferView - + * PreviewedInset.C: Removed unneeded BufferView + 2003-02-25 Alfredo Braunstein * LoaderQueue.[Ch]: a simplification of the code, eliminated @@ -85,10 +89,10 @@ * PreviewLoader.C (FindFirst): use ==, not < with std::find. 2003-02-21 Alfredo Braunstein - + * LoaderQueue.[Ch] (setPriority): added - - * PreviewLoader.C (finishedGenerating): reversed the loading order so + + * PreviewLoader.C (finishedGenerating): reversed the loading order so first images get 'touched' last, and so load first. 2003-02-20 Alfredo Braunstein @@ -111,7 +115,7 @@ 2002-12-17 Lars Gullik Bjønnes - * Makefile.am (EXTRA_DIST): remove variable + * Makefile.am (EXTRA_DIST): remove variable 2002-12-13 Angus Leeming diff --git a/src/graphics/GraphicsCache.C b/src/graphics/GraphicsCache.C index d11315363d..107275cb62 100644 --- a/src/graphics/GraphicsCache.C +++ b/src/graphics/GraphicsCache.C @@ -23,6 +23,8 @@ #include +using namespace lyx::support; + namespace grfx { /** The cache contains one item per file, so use a map to find the diff --git a/src/graphics/GraphicsCacheItem.C b/src/graphics/GraphicsCacheItem.C index fe38fd16af..02c730d37a 100644 --- a/src/graphics/GraphicsCacheItem.C +++ b/src/graphics/GraphicsCacheItem.C @@ -22,11 +22,14 @@ #include "support/LAssert.h" #include "support/filetools.h" +#include "support/lyxlib.h" #include #include #include +using namespace lyx::support; + using std::endl; namespace grfx { @@ -207,11 +210,11 @@ void CacheItem::Impl::reset() { zipped_ = false; if (!unzipped_filename_.empty()) - lyx::unlink(unzipped_filename_); + unlink(unzipped_filename_); unzipped_filename_.erase(); if (remove_loaded_file_ && !file_to_load_.empty()) - lyx::unlink(file_to_load_); + unlink(file_to_load_); remove_loaded_file_ = false; file_to_load_.erase(); @@ -259,7 +262,7 @@ void CacheItem::Impl::imageConverted(bool success) setStatus(ErrorConverting); if (zipped_) - lyx::unlink(unzipped_filename_); + unlink(unzipped_filename_); return; } @@ -291,10 +294,10 @@ void CacheItem::Impl::imageLoaded(bool success) // Clean up after loading. if (zipped_) - lyx::unlink(unzipped_filename_); + unlink(unzipped_filename_); if (remove_loaded_file_ && unzipped_filename_ != file_to_load_) - lyx::unlink(file_to_load_); + unlink(file_to_load_); cl_.disconnect(); @@ -319,7 +322,7 @@ string const findTargetFormat(string const & from) FormatList const formats = grfx::Image::loadableFormats(); // There must be a format to load from. - lyx::Assert(!formats.empty()); + Assert(!formats.empty()); // First ascertain if we can load directly with no conversion FormatList::const_iterator it = formats.begin(); @@ -392,11 +395,11 @@ void CacheItem::Impl::convertToDisplayFormat() // Add some stuff to create a uniquely named temporary file. // This file is deleted in loadImage after it is loaded into memory. - string const to_file_base = lyx::tempName(string(), temp); + string const to_file_base = tempName(string(), temp); remove_loaded_file_ = true; // Remove the temp file, we only want the name... - lyx::unlink(to_file_base); + unlink(to_file_base); // Connect a signal to this->imageConverted and pass this signal to // the graphics converter so that we can load the modified file diff --git a/src/graphics/GraphicsConverter.C b/src/graphics/GraphicsConverter.C index baf4abe448..2333dde461 100644 --- a/src/graphics/GraphicsConverter.C +++ b/src/graphics/GraphicsConverter.C @@ -31,6 +31,8 @@ #include #include // needed for pid_t +using namespace lyx::support; + using std::endl; using std::ostream; @@ -195,7 +197,7 @@ void Converter::Impl::startConversion() return; } - Forkedcall::SignalTypePtr + Forkedcall::SignalTypePtr ptr = ForkedCallQueue::get().add(script_command_); ptr->connect(boost::bind(&Impl::converted, this, _1, _2)); @@ -210,10 +212,10 @@ void Converter::Impl::converted(pid_t /* pid */, int retval) finished_ = true; // Clean-up behind ourselves - lyx::unlink(script_file_); + unlink(script_file_); if (retval > 0) { - lyx::unlink(to_file_); + unlink(to_file_); to_file_.erase(); finishedConversion(false); } else { @@ -277,8 +279,8 @@ bool build_script(string const & from_file, // Remember to remove the temp file because we only want the name... static int counter = 0; string const tmp = "gconvert" + tostr(counter++); - string const to_base = lyx::tempName(string(), tmp); - lyx::unlink(to_base); + string const to_base = tempName(string(), tmp); + unlink(to_base); string outfile = from_file; diff --git a/src/graphics/GraphicsTypes.h b/src/graphics/GraphicsTypes.h index 455c26f1f7..7dc58035b4 100644 --- a/src/graphics/GraphicsTypes.h +++ b/src/graphics/GraphicsTypes.h @@ -15,6 +15,7 @@ #ifndef GRAPHICSTYPES_H #define GRAPHICSTYPES_H +#include "LString.h" #include "support/translator.h" namespace grfx { diff --git a/src/graphics/PreviewImage.C b/src/graphics/PreviewImage.C index bd96232e73..61e112836b 100644 --- a/src/graphics/PreviewImage.C +++ b/src/graphics/PreviewImage.C @@ -20,6 +20,7 @@ #include #include +using namespace lyx::support; namespace grfx { @@ -112,7 +113,7 @@ PreviewImage::Impl::Impl(PreviewImage & p, PreviewLoader & l, PreviewImage::Impl::~Impl() { - lyx::unlink(iloader_.filename()); + unlink(iloader_.filename()); } @@ -145,7 +146,7 @@ void PreviewImage::Impl::statusChanged() break; case Ready: - lyx::unlink(iloader_.filename()); + unlink(iloader_.filename()); ploader_.emitSignal(parent_); break; } diff --git a/src/graphics/PreviewLoader.C b/src/graphics/PreviewLoader.C index cf4ae4faaf..5e3ee3d09f 100644 --- a/src/graphics/PreviewLoader.C +++ b/src/graphics/PreviewLoader.C @@ -42,6 +42,8 @@ #include #include +using namespace lyx::support; + using std::endl; using std::find; using std::fill; @@ -291,13 +293,13 @@ void InProgress::stop() const ForkedcallsController::get().kill(pid, 0); if (!metrics_file.empty()) - lyx::unlink(metrics_file); + unlink(metrics_file); BitmapFile::const_iterator vit = snippets.begin(); BitmapFile::const_iterator vend = snippets.end(); for (; vit != vend; ++vit) { if (!vit->second.empty()) - lyx::unlink(vit->second); + unlink(vit->second); } } @@ -455,7 +457,7 @@ void PreviewLoader::Impl::startLoading() string directory = buffer_.tmppath; if (directory.empty()) directory = buffer_.filePath(); - + string const filename_base(unique_filename(directory)); // Create an InProgress instance to place in the map of all @@ -741,7 +743,7 @@ void setAscentFractions(vector & ascent_fractions, double const a = ascent + tp_ascent; double const d = descent - tp_descent; - if (!lyx::float_equal(a + d, 0, 0.1)) + if (!float_equal(a + d, 0, 0.1)) *it = a / (a + d); if (++it == end) diff --git a/src/graphics/PreviewedInset.C b/src/graphics/PreviewedInset.C index 468d1f65ce..5a9450a2ed 100644 --- a/src/graphics/PreviewedInset.C +++ b/src/graphics/PreviewedInset.C @@ -28,6 +28,8 @@ #include "debug.h" // temporary +using namespace lyx::support; + namespace grfx { bool PreviewedInset::activated() diff --git a/src/graphics/Previews.C b/src/graphics/Previews.C index 8881df2f1a..ce07495a3c 100644 --- a/src/graphics/Previews.C +++ b/src/graphics/Previews.C @@ -22,6 +22,8 @@ #include +using namespace lyx::support; + namespace grfx { bool Previews::activated() @@ -58,7 +60,7 @@ Previews::~Previews() PreviewLoader & Previews::loader(Buffer const * buffer) const { - lyx::Assert(buffer); + Assert(buffer); Impl::CacheType::iterator it = pimpl_->cache.find(buffer); diff --git a/src/importer.C b/src/importer.C index fc260837f0..3e6ccf69e0 100644 --- a/src/importer.C +++ b/src/importer.C @@ -26,6 +26,8 @@ #include +using namespace lyx::support; + using std::vector; using std::find; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 327fcea65a..d696383462 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,9 +1,12 @@ +2003-07-01 Lars Gullik Bjønnes + + * introduce namespace lyx::support 2003-06-30 André Pönitz - * insetcite.C (localDispatch): fix case of missing return value + * insetcite.C (localDispatch): fix case of missing return value - * insetcite.C (ascii): remove unneeded temporary + * insetcite.C (ascii): remove unneeded temporary 2003-06-28 Lars Gullik Bjønnes diff --git a/src/insets/ExternalTemplate.C b/src/insets/ExternalTemplate.C index bfa1e851b8..45e2362ac7 100644 --- a/src/insets/ExternalTemplate.C +++ b/src/insets/ExternalTemplate.C @@ -21,6 +21,8 @@ #include "support/LAssert.h" #include "support/filetools.h" +using namespace lyx::support; + using std::endl; using std::ostream; using std::for_each; @@ -248,7 +250,7 @@ void ExternalTemplate::readTemplate(LyXLex & lex) default: lex.printError("ExternalTemplate::readTemplate: " "Wrong tag: $$Token"); - lyx::Assert(false); + Assert(false); break; } } diff --git a/src/insets/inset.C b/src/insets/inset.C index 50d287d9a3..4d084c5dca 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -86,7 +86,7 @@ string const Inset::editMessage() const } -LyXText * Inset::getLyXText(BufferView const * bv, bool const recursive) const +LyXText * Inset::getLyXText(BufferView const * bv, bool /*recursive*/) const { if (owner()) return owner()->getLyXText(bv, false); diff --git a/src/insets/inset.h b/src/insets/inset.h index ff45c5eced..2e4165860e 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -229,7 +229,7 @@ public: // inside them without cast!!! /// virtual LyXText * getLyXText(BufferView const *, - bool const recursive = false) const; + bool recursive = false) const; /// virtual void deleteLyXText(BufferView *, bool = true) const {} /// diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 0a3eabb568..0ed0dc44be 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -20,6 +20,7 @@ #include "support/tostr.h" #include "support/lstrings.h" +using namespace lyx::support; using std::max; diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 2db291500a..ee54c840b5 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -27,6 +27,8 @@ #include #include +using namespace lyx::support; + using std::ostream; using std::ifstream; using std::getline; @@ -186,7 +188,7 @@ vector const InsetBibtex::getFiles(Buffer const & buffer) const void InsetBibtex::fillWithBibKeys(Buffer const * buffer, std::vector > & keys) const { - lyx::Assert(buffer); + Assert(buffer); vector const files = getFiles(*buffer); for (vector::const_iterator it = files.begin(); it != files.end(); ++ it) { diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index 93a579f8c9..3df418448a 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -26,6 +26,8 @@ #include "support/LAssert.h" #include "support/BoostFormat.h" +using namespace lyx::support; + using std::ostream; using std::endl; @@ -85,7 +87,7 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const else if (i2->lyxCode() == WRAP_CODE) type = static_cast(i2)->params().type; else - lyx::Assert(0); + Assert(0); FloatList const & floats = pi.base.bv->buffer()->params.getLyXTextClass().floats(); diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index b883efeeab..e7437b4804 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -23,6 +23,8 @@ #include +using namespace lyx::support; + using std::ostream; using std::vector; using std::map; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 9b1d4235d5..3377fe3236 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -34,6 +34,8 @@ #include "support/LAssert.h" #include "support/LOstream.h" +using namespace lyx::support; + using std::vector; using std::ostream; using std::endl; @@ -144,7 +146,7 @@ void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const { - lyx::Assert(pi.base.bv); + Assert(pi.base.bv); cache(pi.base.bv); if (nodraw()) diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 4940913e0f..4e0e832f63 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -33,6 +33,7 @@ #include "support/LAssert.h" #include "support/tostr.h" +using namespace lyx::support; using std::ostream; using std::min; diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 7bd7049575..c6f7552cbd 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -44,6 +44,8 @@ #include #include +using namespace lyx::support; + using std::ostream; using std::endl; @@ -68,8 +70,8 @@ InsetExternal::Params::Params() : display(defaultDisplayType), lyxscale(defaultLyxScale) { - tempname = lyx::tempName(string(), "lyxext"); - lyx::unlink(tempname); + tempname = tempName(string(), "lyxext"); + unlink(tempname); // must have an extension for the converter code to work correctly. tempname += ".tmp"; } @@ -77,7 +79,7 @@ InsetExternal::Params::Params() InsetExternal::Params::~Params() { - lyx::unlink(tempname); + unlink(tempname); } @@ -118,7 +120,7 @@ void InsetExternal::statusChanged() if (bv) bv->updateInset(this); } - + InsetExternal::Params const & InsetExternal::params() const { @@ -131,16 +133,16 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd) switch (cmd.action) { case LFUN_EXTERNAL_EDIT: { - lyx::Assert(cmd.view()); + Assert(cmd.view()); InsetExternal::Params p; InsetExternalMailer::string2params(cmd.argument, p); editExternal(p, cmd.view()->buffer()); return DISPATCHED_NOUPDATE; } - + case LFUN_INSET_MODIFY: { - lyx::Assert(cmd.view()); + Assert(cmd.view()); InsetExternal::Params p; InsetExternalMailer::string2params(cmd.argument, p); @@ -184,7 +186,7 @@ grfx::Params get_grfx_params(InsetExternal::Params const & eparams, grfx::Params gparams; if (!eparams.filename.empty()) { - lyx::Assert(AbsolutePath(filepath)); + Assert(AbsolutePath(filepath)); gparams.filename = MakeAbsPath(eparams.filename, filepath); } diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index cb84cd7386..13145d64e2 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -36,6 +36,8 @@ #include "frontends/LyXView.h" #include "frontends/Dialogs.h" +using namespace lyx::support; + using std::ostream; using std::endl; diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index 3a4aeee2e8..578b057acf 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -24,6 +24,8 @@ #include "support/lstrings.h" +using namespace lyx::support; + using std::ostream; using std::endl; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 23bc48e92e..9a60febe9f 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -85,6 +85,8 @@ TODO extern string system_tempdir; // set by Exporters +using namespace lyx::support; + using std::ostream; using std::endl; @@ -169,7 +171,7 @@ void InsetGraphics::statusChanged() if (bv) bv->updateInset(this); } - + dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd) { @@ -284,8 +286,8 @@ string const InsetGraphics::createLatexOptions() const options << " draft,\n"; if (params().clip) options << " clip,\n"; - if (!lyx::float_equal(params().scale, 0.0, 0.05)) { - if (!lyx::float_equal(params().scale, 100.0, 0.05)) + if (!float_equal(params().scale, 0.0, 0.05)) { + if (!float_equal(params().scale, 100.0, 0.05)) options << " scale=" << params().scale / 100.0 << ",\n"; } else { @@ -299,7 +301,7 @@ string const InsetGraphics::createLatexOptions() const // Make sure rotation angle is not very close to zero; // a float can be effectively zero but not exactly zero. - if (!lyx::float_equal(params().rotateAngle, 0, 0.001)) { + if (!float_equal(params().rotateAngle, 0, 0.001)) { options << " angle=" << params().rotateAngle << ",\n"; if (!params().rotateOrigin.empty()) { options << " origin=" << params().rotateOrigin[0]; @@ -361,8 +363,8 @@ string const InsetGraphics::prepareFile(Buffer const * buf, temp_file = MakeAbsPath(OnlyFilename(temp_file), buf->tmppath); lyxerr[Debug::GRAPHICS] << "\ttemp_file: " << temp_file << endl; - if (graphic_->hasFileChanged() || !IsFileReadable(temp_file)) { - bool const success = lyx::copy(orig_file, temp_file); + if (graphic_->hasFileChanged() || !IsFileReadable(temp_file)) { + bool const success = copy(orig_file, temp_file); lyxerr[Debug::GRAPHICS] << "\tCopying zipped file from " << orig_file << " to " << temp_file @@ -405,14 +407,14 @@ string const InsetGraphics::prepareFile(Buffer const * buf, << "\tthe orig file is: " << orig_file << endl; if (lyxrc.use_tempdir) { - temp_file = copyFileToDir(buf->tmppath, orig_file); + temp_file = copyFileToDir(buf->tmppath, orig_file); if (temp_file.empty()) { string str = bformat(_("Could not copy the file\n%1$s\n" "into the temporary directory."), orig_file); Alert::error(_("Graphics display failed"), str); return orig_file; - } + } if (from == to) { // No conversion is needed. LaTeX can handle the @@ -589,8 +591,8 @@ bool InsetGraphics::setParams(InsetGraphicsParams const & p) // Copy the new parameters. params_ = p; - // Update the display using the new parameters. - graphic_->update(params().as_grfxParams()); + // Update the display using the new parameters. + graphic_->update(params().as_grfxParams()); // We have changed data, report it. return true; diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 3f6a1b395b..53c5647d5a 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -26,6 +26,8 @@ #include "lyxlex.h" #include "frontends/lyx_gui.h" +using namespace lyx::support; + using std::ostream; @@ -118,7 +120,7 @@ bool operator==(InsetGraphicsParams const & left, left.bb == right.bb && left.clip == right.clip && - lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001) && + float_equal(left.rotateAngle, right.rotateAngle, 0.001) && left.rotateOrigin == right.rotateOrigin && left.subcaption == right.subcaption && left.subcaptionText == right.subcaptionText && @@ -148,8 +150,8 @@ void InsetGraphicsParams::Write(ostream & os, string const & bufpath) const os << "\tlyxscale " << lyxscale << '\n'; if (display != grfx::DefaultDisplay) os << "\tdisplay " << grfx::displayTranslator.find(display) << '\n'; - if (!lyx::float_equal(scale, 0.0, 0.05)) { - if (!lyx::float_equal(scale, 100.0, 0.05)) + if (!float_equal(scale, 0.0, 0.05)) { + if (!float_equal(scale, 100.0, 0.05)) os << "\tscale " << scale << '\n'; } else { if (!width.zero()) diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index e3edbbab4d..ecc71f332c 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -43,6 +43,8 @@ #include +using namespace lyx::support; + using std::ostream; using std::endl; using std::vector; diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 5f11669a59..cbe1721310 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -22,6 +22,8 @@ #include "support/LOstream.h" #include "support/lstrings.h" //frontStrip, strip +using namespace lyx::support; + using std::ostream; using std::vector; using std::pair; diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index ef1f473f52..76223c833d 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -22,6 +22,8 @@ #include "lyxlex.h" #include "metricsinfo.h" +using namespace lyx::support; + using std::ostream; using std::endl; diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 22eafe7cb0..14097c37de 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -29,6 +29,8 @@ #include "support/LAssert.h" #include "support/lstrings.h" +using namespace lyx::support; + using std::ostream; using std::endl; @@ -243,7 +245,7 @@ int InsetQuotes::latex(Buffer const * buf, ostream & os, { // How do we get the local language here?? lyx::pos_type curr_pos = parOwner()->getPositionOfInset(this); - lyx::Assert(curr_pos != -1); + Assert(curr_pos != -1); #warning FIXME. We _must_ find another way to get the language. (Lgb) #if 0 diff --git a/src/insets/insetref.C b/src/insets/insetref.C index e85a1e8655..8edc5ec140 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -21,6 +21,8 @@ #include "BufferView.h" #include "support/lstrings.h" +using namespace lyx::support; + using std::ostream; InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf) diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index fcca099378..5515a81331 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -49,6 +49,8 @@ //#include +using namespace lyx::support; + using std::vector; using std::ostream; using std::ifstream; @@ -367,7 +369,7 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int y, void InsetTabular::drawCellSelection(Painter & pain, int x, int y, int row, int column, int cell) const { - lyx::Assert(hasSelection()); + Assert(hasSelection()); int cs = tabular.column_of_cell(sel_cell_start); int ce = tabular.column_of_cell(sel_cell_end); if (cs > ce) { @@ -2580,7 +2582,7 @@ InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const WordLangTuple InsetTabular::selectNextWordInt(BufferView * bv, float & value) const { // when entering this function the inset should be ALWAYS locked! - lyx::Assert(the_locking_inset); + Assert(the_locking_inset); WordLangTuple word(the_locking_inset->selectNextWordToSpellcheck(bv, value)); if (!word.word().empty()) diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 08ae69cbea..6d67050e07 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -71,6 +71,8 @@ using std::vector; using std::pair; using std::for_each; +using namespace lyx::support; + using lyx::pos_type; using lyx::textclass_type; @@ -100,7 +102,7 @@ void InsetText::restoreLyXTextState(LyXText * t) const return; t->selection.set(true); - // at this point just to avoid the DEPM when setting the cursor + // at this point just to avoid the DEPM when setting the cursor t->selection.mark(sstate.selection.mark()); if (sstate.selection.set()) { t->setCursor(sstate.selection.start.par(), @@ -2079,7 +2081,7 @@ LyXText * InsetText::getLyXText(BufferView const * lbv, if (recursive && the_locking_inset) return the_locking_inset->getLyXText(lbv, true); LyXText * lt = cached_text.get(); - lyx::Assert(lt && lt->rows().begin()->par() == const_cast(paragraphs).begin()); + Assert(lt && lt->rows().begin()->par() == const_cast(paragraphs).begin()); return lt; } // Super UGLY! (Lgb) @@ -2095,7 +2097,7 @@ LyXText * InsetText::getLyXText(BufferView const * lbv, resizeLyXText(do_resize); } else { if (lt || !it->second.remove) { - lyx::Assert(it->second.text.get()); + Assert(it->second.text.get()); cached_text = it->second.text; if (recursive && the_locking_inset) { return the_locking_inset->getLyXText(bv, true); @@ -2147,7 +2149,7 @@ void InsetText::deleteLyXText(BufferView * bv, bool recursive) const return; } - lyx::Assert(it->second.text.get()); + Assert(it->second.text.get()); it->second.remove = true; if (recursive) { @@ -2187,7 +2189,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const return; } - lyx::Assert(it->second.text.get()); + Assert(it->second.text.get()); LyXText * t = it->second.text.get(); saveLyXTextState(t); @@ -2226,7 +2228,7 @@ void InsetText::reinitLyXText() const do_reinit = false; do_resize = 0; for (Cache::iterator it = cache.begin(); it != cache.end(); ++it) { - lyx::Assert(it->second.text.get()); + Assert(it->second.text.get()); LyXText * t = it->second.text.get(); BufferView * bv = it->first; diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 16eaf04797..91290519d7 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -21,6 +21,8 @@ #include "support/lstrings.h" #include "gettext.h" +using namespace lyx::support; + using std::ostream; diff --git a/src/insets/mailinset.C b/src/insets/mailinset.C index 8eb06f9964..2a5107389f 100644 --- a/src/insets/mailinset.C +++ b/src/insets/mailinset.C @@ -19,17 +19,18 @@ #include "support/LAssert.h" #include "Lsstream.h" +using namespace lyx::support; void MailInset::showDialog(BufferView * bv) const { - lyx::Assert(bv); + Assert(bv); bv->owner()->getDialogs().show(name(), inset2string(), &inset()); } void MailInset::updateDialog(BufferView * bv) const { - lyx::Assert(bv); + Assert(bv); if(bv->owner()->getDialogs().visible(name())) bv->owner()->getDialogs().update(name(), inset2string()); } diff --git a/src/insets/renderers.C b/src/insets/renderers.C index 656b7b0749..3325cabe4c 100644 --- a/src/insets/renderers.C +++ b/src/insets/renderers.C @@ -26,6 +26,8 @@ #include "support/filetools.h" +using namespace lyx::support; + RenderInset::RenderInset() {} @@ -73,7 +75,7 @@ void ButtonRenderer::update(string const & text, bool editable) void ButtonRenderer::metrics(MetricsInfo & mi, Dimension & dim) const { - lyx::Assert(mi.base.bv); + Assert(mi.base.bv); LyXFont font(LyXFont::ALL_SANE); font.decSize(); @@ -89,7 +91,7 @@ void ButtonRenderer::metrics(MetricsInfo & mi, Dimension & dim) const void ButtonRenderer::draw(PainterInfo & pi, int x, int y) const { - lyx::Assert(pi.base.bv); + Assert(pi.base.bv); view_ = pi.base.bv->owner()->view(); // Draw it as a box with the LaTeX text @@ -129,7 +131,7 @@ void GraphicRenderer::update(grfx::Params const & params) params_ = params; if (!params_.filename.empty()) { - lyx::Assert(AbsolutePath(params_.filename)); + Assert(AbsolutePath(params_.filename)); loader_.reset(params_.filename, params_); } } @@ -227,7 +229,7 @@ void GraphicRenderer::metrics(MetricsInfo & mi, Dimension & dim) const void GraphicRenderer::draw(PainterInfo & pi, int x, int y) const { - lyx::Assert(pi.base.bv); + Assert(pi.base.bv); view_ = pi.base.bv->owner()->view(); #if 0 diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index ec6fa2ba81..b8489ad5f3 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -22,6 +22,7 @@ #include "lyxtext.h" #include "support/lstrings.h" +using namespace lyx::support; // some stuff for inset locking diff --git a/src/ispell.C b/src/ispell.C index ee75bf507c..b2426296e7 100644 --- a/src/ispell.C +++ b/src/ispell.C @@ -27,6 +27,8 @@ #endif #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::strcpy; using std::strlen; @@ -39,14 +41,14 @@ using std::max; namespace { -class LaunchIspell : public ForkedProcess { +class LaunchIspell : public lyx::support::ForkedProcess { public: /// LaunchIspell(BufferParams const & p, string const & l, int * in, int * out, int * err) : params(p), lang(l), pipein(in), pipeout(out), pipeerr(err) {} /// - virtual ForkedProcess * clone() const { + virtual lyx::support::ForkedProcess * clone() const { return new LaunchIspell(*this); } /// diff --git a/src/ispell.h b/src/ispell.h index 23a75eb6ce..d201945c71 100644 --- a/src/ispell.h +++ b/src/ispell.h @@ -17,7 +17,11 @@ #include class BufferParams; +namespace lyx { +namespace support { class ForkedProcess; +} +} /// i/a spell process-based spellchecker class ISpell : public SpellBase { @@ -67,7 +71,7 @@ private: /// spell error string error_; - boost::scoped_ptr child_; + boost::scoped_ptr child_; // vileness below ... please FIXME /// str ??? diff --git a/src/lastfiles.C b/src/lastfiles.C index 9c5449fb2d..effdbc6cb9 100644 --- a/src/lastfiles.C +++ b/src/lastfiles.C @@ -20,6 +20,8 @@ #include +using namespace lyx::support; + using std::ifstream; using std::ofstream; using std::getline; diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 5348675679..fed5d7093a 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -43,6 +43,8 @@ #include #include +using namespace lyx::support; + using std::vector; using std::ifstream; using std::copy; @@ -238,16 +240,16 @@ int AutoSaveBuffer::generateChild() // anyway. bool failed = false; - string const tmp_ret = lyx::tempName(string(), "lyxauto"); + string const tmp_ret = tempName(string(), "lyxauto"); if (!tmp_ret.empty()) { bv_.buffer()->writeFile(tmp_ret); // assume successful write of tmp_ret - if (!lyx::rename(tmp_ret, fname_)) { + if (!rename(tmp_ret, fname_)) { failed = true; // most likely couldn't move between filesystems // unless write of tmp_ret failed // so remove tmp file (if it exists) - lyx::unlink(tmp_ret); + unlink(tmp_ret); } } else { failed = true; diff --git a/src/lyx_main.C b/src/lyx_main.C index 44cd30ab06..436ec5d808 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -48,6 +48,8 @@ #include #include +using namespace lyx::support; + using std::vector; using std::endl; @@ -147,7 +149,7 @@ LyX::LyX(int & argc, char * argv[]) vector::const_iterator end = files.end(); for (; it != end; ++it) { - // get absolute path of file and add ".lyx" to + // get absolute path of file and add ".lyx" to // the filename if necessary string s = FileSearch(string(), *it, "lyx"); if (s.empty()) { @@ -215,7 +217,7 @@ static void error_handler(int err_sig) lyxerr << "Bye." << endl; if (err_sig!= SIGHUP && (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV)) - lyx::abort(); + lyx::support::abort(); exit(0); } @@ -224,7 +226,7 @@ static void error_handler(int err_sig) void LyX::printError(ErrorItem const & ei) { - std::cerr << _("LyX: ") << ei.error + std::cerr << _("LyX: ") << ei.error << ':' << ei.description << std::endl; } @@ -454,7 +456,7 @@ void LyX::init(bool gui) system_lcolor = lcolor; string prefsfile = "preferences"; - // back compatibility to lyxs < 1.1.6 + // back compatibility to lyxs < 1.1.6 if (LibFileSearch(string(), prefsfile).empty()) prefsfile = "lyxrc"; if (!LibFileSearch(string(), prefsfile).empty()) diff --git a/src/lyxfind.C b/src/lyxfind.C index 91c00f72e4..a28129f97e 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -14,6 +14,8 @@ #include "insets/insettext.h" #include "changes.h" +using namespace lyx::support; + using lyx::pos_type; using std::endl; diff --git a/src/lyxfont.C b/src/lyxfont.C index f3247513e2..8708fb8319 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -22,6 +22,8 @@ #include "support/lstrings.h" #include "bufferparams.h" // stateText +using namespace lyx::support; + using std::ostream; using std::endl; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 7a2d17d98d..9036b814ee 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -78,6 +78,8 @@ #include #include +using namespace lyx::support; + using std::pair; using std::make_pair; using std::endl; @@ -537,7 +539,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const disable = !mathcursor; break; - case LFUN_DIALOG_SHOW: { + case LFUN_DIALOG_SHOW: { string const name = ev.getArg(0); if (!buf) { disable = !(name == "aboutlyx" || @@ -1937,6 +1939,6 @@ string const LyXFunc::view_status_message() BufferView * LyXFunc::view() const { - lyx::Assert(owner); + Assert(owner); return owner->view().get(); } diff --git a/src/lyxlayout.C b/src/lyxlayout.C index 6f20fc49e8..fc691697f7 100644 --- a/src/lyxlayout.C +++ b/src/lyxlayout.C @@ -18,6 +18,8 @@ #include "support/lstrings.h" +using namespace lyx::support; + using std::endl; // The order of the LayoutTags enum is no more important. [asierra300396] diff --git a/src/lyxlex.C b/src/lyxlex.C index c590c74c53..e77c893b08 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -18,6 +18,8 @@ #include "support/filetools.h" #include "support/lstrings.h" +using namespace lyx::support; + using std::ostream; using std::istream; using std::endl; diff --git a/src/lyxlex_pimpl.C b/src/lyxlex_pimpl.C index 90e68b8ecd..2962302d06 100644 --- a/src/lyxlex_pimpl.C +++ b/src/lyxlex_pimpl.C @@ -9,6 +9,8 @@ #include +using namespace lyx::support; + using std::sort; using std::ostream; using std::ios; diff --git a/src/lyxrc.C b/src/lyxrc.C index f9ec51b0dd..edea4b9dda 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -31,6 +31,8 @@ #include "support/lstrings.h" #include "support/userinfo.h" +using namespace lyx::support; + using std::ostream; using std::ofstream; using std::cout; @@ -260,9 +262,9 @@ void LyXRC::setDefaults() { preview_hashed_labels = false; preview_scale_factor = 0.9; - user_name = lyx::user_name(); + user_name = lyx::support::user_name(); - user_email = lyx::user_email(); + user_email = lyx::support::user_email(); if (user_email.empty()) user_email = _("email address unknown"); diff --git a/src/lyxserver.C b/src/lyxserver.C index d7044b146f..60dcf4085a 100644 --- a/src/lyxserver.C +++ b/src/lyxserver.C @@ -60,6 +60,9 @@ #include "support/os2_errortable.h" #endif + +using namespace lyx::support; + using std::endl; // provide an empty mkfifo() if we do not have one. This disables the @@ -190,7 +193,7 @@ int LyXComm::startPipe(string const & filename, bool write) if (fd < 0) { lyxerr << "LyXComm: Could not open pipe " << filename << '\n' << strerror(errno) << endl; - lyx::unlink(filename); + unlink(filename); return -1; } @@ -231,7 +234,7 @@ void LyXComm::endPipe(int & fd, string const & filename, bool write) // OS/2 pipes are deleted automatically #ifndef __EMX__ - if (lyx::unlink(filename) < 0) { + if (unlink(filename) < 0) { lyxerr << "LyXComm: Could not remove pipe " << filename << '\n' << strerror(errno) << endl; }; diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index 74be61056f..3df1271e40 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -24,6 +24,8 @@ #include +using namespace lyx::support; + using std::endl; using std::find_if; using std::remove_if; @@ -755,7 +757,7 @@ bool LyXTextClass::hasLayout(string const & n) const LyXLayout_ptr const & LyXTextClass::operator[](string const & name) const { - lyx::Assert(!name.empty()); + Assert(!name.empty()); LayoutList::const_iterator cit = find_if(layoutlist_.begin(), @@ -771,7 +773,7 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & name) const lyxerr << " " << it->get()->name() << endl; // we require the name to exist - lyx::Assert(false); + Assert(false); } return (*cit); diff --git a/src/lyxtextclasslist.C b/src/lyxtextclasslist.C index 71e7d1b23e..c17bca534d 100644 --- a/src/lyxtextclasslist.C +++ b/src/lyxtextclasslist.C @@ -24,6 +24,8 @@ #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::exit; #endif diff --git a/src/lyxvc.C b/src/lyxvc.C index 206250061b..9f6ce7e2bb 100644 --- a/src/lyxvc.C +++ b/src/lyxvc.C @@ -16,6 +16,8 @@ #include +using namespace lyx::support; + using std::endl; using std::pair; @@ -248,7 +250,7 @@ string const LyXVC::getLogFile() const if (!vcs) return string(); - string tmpf = lyx::tempName(string(), "lyxvclog"); + string tmpf = tempName(string(), "lyxvclog"); lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl; vcs->getLog(tmpf); return tmpf; diff --git a/src/main.C b/src/main.C index 1b21c24b6f..18413bf4f7 100644 --- a/src/main.C +++ b/src/main.C @@ -17,6 +17,8 @@ #include #endif +using namespace lyx::support; + int main(int argc, char * argv[]) { #ifdef HAVE_IOS diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index d812b9cb6a..19b01aea35 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,7 @@ +2003-07-01 Lars Gullik Bjønnes + + * introduce namespace lyx::support + 2003-06-28 Lars Gullik Bjønnes * math_symbolinset.C (MathSymbolInset): fix type const order diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 9078c9ffce..1ad521a45e 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -29,6 +29,7 @@ #include "metricsinfo.h" #include "math_data.h" #include "support/lstrings.h" +#include "support/lyxlib.h" #include "frontends/LyXView.h" #include "frontends/font_metrics.h" #include "frontends/mouse_state.h" @@ -52,6 +53,8 @@ #include +using namespace lyx::support; + using std::endl; using std::ostream; using std::vector; @@ -664,7 +667,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) bv->lockedInsetStoreUndo(Undo::EDIT); if (argument.size() == 1) result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT; - else + else mathcursor->insert(argument); } break; @@ -731,7 +734,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) mathcursor->normalize(); mathcursor->touch(); - lyx::Assert(mathcursor); + Assert(mathcursor); if (mathcursor->selection() || was_selection) toggleInsetSelection(bv); @@ -954,7 +957,7 @@ void mathDispatch(FuncRequest const & cmd) else { string s = cmd.argument; string const s1 = token(s, ' ', 1); - int const na = s1.empty() ? 0 : lyx::atoi(s1); + int const na = s1.empty() ? 0 : atoi(s1); openNewInset(bv, new InsetFormulaMacro(token(s, ' ', 0), na)); } break; diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index cd27204f09..da8943bacf 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -36,6 +36,8 @@ #include "lyxtext.h" #include "Lsstream.h" +using namespace lyx::support; + using std::ostream; extern MathCursor * mathcursor; diff --git a/src/mathed/math_autocorrect.C b/src/mathed/math_autocorrect.C index f5250436f8..6d6b1f3b14 100644 --- a/src/mathed/math_autocorrect.C +++ b/src/mathed/math_autocorrect.C @@ -1,4 +1,3 @@ - #include #include "LString.h" @@ -13,6 +12,8 @@ #include #include +using namespace lyx::support; + using std::ifstream; using std::istream; using std::ostream; diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 450d16614f..a8c143af4c 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -49,6 +49,8 @@ //#define FILEDEBUG 1 +using namespace lyx::support; + using std::endl; using std::min; using std::max; @@ -836,28 +838,28 @@ bool MathCursor::hasNextAtom() const MathAtom const & MathCursor::prevAtom() const { - lyx::Assert(pos() > 0); + Assert(pos() > 0); return array()[pos() - 1]; } MathAtom & MathCursor::prevAtom() { - lyx::Assert(pos() > 0); + Assert(pos() > 0); return array()[pos() - 1]; } MathAtom const & MathCursor::nextAtom() const { - lyx::Assert(pos() < size()); + Assert(pos() < size()); return array()[pos()]; } MathAtom & MathCursor::nextAtom() { - lyx::Assert(pos() < size()); + Assert(pos() < size()); return array()[pos()]; } @@ -923,14 +925,14 @@ void MathCursor::getSelection(CursorPos & i1, CursorPos & i2) const CursorPos & MathCursor::cursor() { - lyx::Assert(depth()); + Assert(depth()); return Cursor_.back(); } CursorPos const & MathCursor::cursor() const { - lyx::Assert(depth()); + Assert(depth()); return Cursor_.back(); } diff --git a/src/mathed/math_data.C b/src/mathed/math_data.C index 457a2ee918..5857e9d4c7 100644 --- a/src/mathed/math_data.C +++ b/src/mathed/math_data.C @@ -16,6 +16,7 @@ #include "frontends/Painter.h" #include "textpainter.h" +using namespace lyx::support; using std::max; using std::min; @@ -41,14 +42,14 @@ void MathArray::substitute(MathMacro const & m) MathAtom & MathArray::operator[](pos_type pos) { - lyx::Assert(pos < size()); + Assert(pos < size()); return base_type::operator[](pos); } MathAtom const & MathArray::operator[](pos_type pos) const { - lyx::Assert(pos < size()); + Assert(pos < size()); return base_type::operator[](pos); } @@ -61,7 +62,7 @@ void MathArray::insert(size_type pos, MathAtom const & t) void MathArray::insert(size_type pos, MathArray const & ar) { - lyx::Assert(pos <= size()); + Assert(pos <= size()); base_type::insert(begin() + pos, ar.begin(), ar.end()); } diff --git a/src/mathed/math_exfuncinset.C b/src/mathed/math_exfuncinset.C index 6033db4a6c..f19f96041a 100644 --- a/src/mathed/math_exfuncinset.C +++ b/src/mathed/math_exfuncinset.C @@ -1,4 +1,3 @@ - #include #include "math_exfuncinset.h" @@ -25,7 +24,7 @@ InsetBase * MathExFuncInset::clone() const } -void MathExFuncInset::metrics(MetricsInfo & mi, Dimension & dim) const +void MathExFuncInset::metrics(MetricsInfo & mi, Dimension & /*dim*/) const { mathed_string_dim(mi.base.font, name_, dim_); } diff --git a/src/mathed/math_extern.C b/src/mathed/math_extern.C index 899521bdb5..a296dd1867 100644 --- a/src/mathed/math_extern.C +++ b/src/mathed/math_extern.C @@ -30,6 +30,8 @@ #include +using namespace lyx::support; + using std::ostream; using std::istringstream; using std::find_if; diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index c9e8312a6d..b2a1681e94 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -1,4 +1,3 @@ - #include #include "math_parser.h" @@ -52,10 +51,12 @@ #include #include -bool has_math_fonts; +using namespace lyx::support; using std::endl; +bool has_math_fonts; + namespace { @@ -324,4 +325,3 @@ bool createMathInset_fromDialogStr(string const & str, MathArray & ar) return ar[0].nucleus(); } - diff --git a/src/mathed/math_fontinset.C b/src/mathed/math_fontinset.C index c8669f4f50..2982a9d268 100644 --- a/src/mathed/math_fontinset.C +++ b/src/mathed/math_fontinset.C @@ -49,7 +49,7 @@ void MathFontInset::draw(PainterInfo & pi, int x, int y) const } -void MathFontInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const +void MathFontInset::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const { cell(0).metricsT(mi, dim_); } diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 7792793337..7317155b6c 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -22,6 +22,8 @@ #include +using namespace lyx::support; + using std::vector; using std::max; using std::endl; @@ -251,7 +253,7 @@ void MathHullInset::drawT(TextPainter & pain, int x, int y) const string MathHullInset::label(row_type row) const { row_type n = nrows(); - lyx::Assert(row < n); + Assert(row < n); return label_[row]; } @@ -660,8 +662,8 @@ void MathHullInset::infoize(std::ostream & os) const void MathHullInset::check() const { - lyx::Assert(nonum_.size() == nrows()); - lyx::Assert(label_.size() == nrows()); + Assert(nonum_.size() == nrows()); + Assert(label_.size() == nrows()); } diff --git a/src/mathed/math_iterator.C b/src/mathed/math_iterator.C index bf20717181..0ee78e844e 100644 --- a/src/mathed/math_iterator.C +++ b/src/mathed/math_iterator.C @@ -1,4 +1,3 @@ - #include #include "math_iterator.h" @@ -6,6 +5,7 @@ #include "debug.h" #include "support/LAssert.h" +using namespace lyx::support; MathIterator::MathIterator() {} @@ -47,7 +47,7 @@ void MathIterator::push(MathInset * p) void MathIterator::pop() { //lyxerr << "pop: " << endl; - lyx::Assert(size()); + Assert(size()); pop_back(); } @@ -115,8 +115,8 @@ void MathIterator::operator++() void MathIterator::jump(difference_type i) { back().pos_ += i; - //lyx::Assert(back().pos_ >= 0); - lyx::Assert(back().pos_ <= cell().size()); + //Assert(back().pos_ >= 0); + Assert(back().pos_ <= cell().size()); } diff --git a/src/mathed/math_pos.C b/src/mathed/math_pos.C index a49bfa1a24..3caa88fd68 100644 --- a/src/mathed/math_pos.C +++ b/src/mathed/math_pos.C @@ -1,4 +1,3 @@ - #include "config.h" #include "math_pos.h" #include "math_inset.h" @@ -6,6 +5,7 @@ #include "support/LAssert.h" #include "support/LOstream.h" +using namespace lyx::support; CursorPos::CursorPos() : inset_(0), idx_(0), pos_(0) @@ -15,21 +15,21 @@ CursorPos::CursorPos() CursorPos::CursorPos(MathInset * p) : inset_(p), idx_(0), pos_(0) { - lyx::Assert(inset_); + Assert(inset_); } MathArray & CursorPos::cell(MathArray::idx_type idx) const { - lyx::Assert(inset_); + Assert(inset_); return inset_->cell(idx); } MathArray & CursorPos::cell() const { - lyx::Assert(inset_); + Assert(inset_); return inset_->cell(idx_); } diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 83d7c79896..4e4d9bfad2 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -1,4 +1,3 @@ - #include "math_scriptinset.h" #include "math_support.h" #include "math_symbolinset.h" @@ -7,6 +6,7 @@ #include "support/LAssert.h" #include "debug.h" +using namespace lyx::support; using std::max; @@ -144,14 +144,14 @@ int MathScriptInset::dy1() const int MathScriptInset::dx0() const { - lyx::Assert(hasDown()); + Assert(hasDown()); return hasLimits() ? (dim_.wid - down().width()) / 2 : nwid(); } int MathScriptInset::dx1() const { - lyx::Assert(hasUp()); + Assert(hasUp()); return hasLimits() ? (dim_.wid - up().width()) / 2 : nwid(); } diff --git a/src/mathed/math_tabularinset.C b/src/mathed/math_tabularinset.C index 31d24f176f..f32053f81f 100644 --- a/src/mathed/math_tabularinset.C +++ b/src/mathed/math_tabularinset.C @@ -39,7 +39,7 @@ InsetBase * MathTabularInset::clone() const } -void MathTabularInset::metrics(MetricsInfo & mi, Dimension & dim) const +void MathTabularInset::metrics(MetricsInfo & mi, Dimension & /*dim*/) const { FontSetChanger dummy(mi.base, "textnormal"); return MathGridInset::metrics(mi); diff --git a/src/messages.C b/src/messages.C index 18b30d0605..4302f41e65 100644 --- a/src/messages.C +++ b/src/messages.C @@ -13,6 +13,8 @@ #include "debug.h" #include "support/filetools.h" +using namespace lyx::support; + #ifdef ENABLE_NLS diff --git a/src/paragraph.C b/src/paragraph.C index fbedfeedc9..b766c4fb48 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -46,6 +46,8 @@ #include #include +using namespace lyx::support; + using std::ostream; using std::endl; using std::fstream; @@ -373,14 +375,14 @@ bool Paragraph::insetAllowed(Inset::Code code) Inset * Paragraph::getInset(pos_type pos) { - lyx::Assert(pos < size()); + Assert(pos < size()); return insetlist.get(pos); } Inset const * Paragraph::getInset(pos_type pos) const { - lyx::Assert(pos < size()); + Assert(pos < size()); return insetlist.get(pos); } @@ -389,7 +391,7 @@ Inset const * Paragraph::getInset(pos_type pos) const LyXFont const Paragraph::getFontSettings(BufferParams const & bparams, pos_type pos) const { - lyx::Assert(pos <= size()); + Assert(pos <= size()); Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin(); Pimpl::FontList::const_iterator end = pimpl_->fontlist.end(); @@ -428,7 +430,7 @@ LyXFont const Paragraph::getFirstFontSettings() const LyXFont const Paragraph::getFont(BufferParams const & bparams, pos_type pos, LyXFont const & outerfont) const { - lyx::Assert(pos >= 0); + Assert(pos >= 0); LyXLayout_ptr const & lout = layout(); @@ -553,7 +555,7 @@ Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const void Paragraph::setFont(pos_type pos, LyXFont const & font) { - lyx::Assert(pos <= size()); + Assert(pos <= size()); // First, reduce font against layout/label font // Update: The SetCharFont() routine in text2.C already @@ -1289,14 +1291,14 @@ void Paragraph::cleanChanges() Change::Type Paragraph::lookupChange(lyx::pos_type pos) const { - lyx::Assert(!size() || pos < size()); + Assert(!size() || pos < size()); return pimpl_->lookupChange(pos); } Change const Paragraph::lookupChangeFull(lyx::pos_type pos) const { - lyx::Assert(!size() || pos < size()); + Assert(!size() || pos < size()); return pimpl_->lookupChangeFull(pos); } diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 73de67f9c2..8c137d6868 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -36,6 +36,8 @@ extern string bibitemWidest(Buffer const *); +using namespace lyx::support; + using lyx::pos_type; //using lyx::layout_type; using std::endl; @@ -1007,7 +1009,7 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok string const s = bformat(_("Unknown token: %1$s %2$s\n"), token, lex.getString()); - buf.parseError(ErrorItem(_("Unknown token"), s, + buf.parseError(ErrorItem(_("Unknown token"), s, par.id(), 0, par.size())); return 1; } diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 75eb764983..1a253924af 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -24,6 +24,7 @@ #include "support/LAssert.h" +using namespace lyx::support; using lyx::pos_type; using std::endl; using std::ostream; @@ -170,7 +171,7 @@ Change const Paragraph::Pimpl::lookupChangeFull(pos_type pos) const void Paragraph::Pimpl::markErased() { - lyx::Assert(tracking()); + Assert(tracking()); // FIXME: we should actually remove INSERTED chars. // difficult because owning insettexts/tabulars need @@ -255,7 +256,7 @@ Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const // This is in the critical path for loading! pos_type const siz = size(); - lyx::Assert(pos <= siz); + Assert(pos <= siz); if (pos == siz) { lyxerr << "getChar() on pos " << pos << " in par id " @@ -266,7 +267,7 @@ Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const return text[pos]; #else - lyx::Assert(pos < size()); + Assert(pos < size()); return text[pos]; #endif } @@ -282,7 +283,7 @@ void Paragraph::Pimpl::setChar(pos_type pos, value_type c) void Paragraph::Pimpl::insertChar(pos_type pos, value_type c, LyXFont const & font, Change change) { - lyx::Assert(pos <= size()); + Assert(pos <= size()); if (tracking()) { changes_->record(change, pos); @@ -319,11 +320,11 @@ void Paragraph::Pimpl::insertChar(pos_type pos, value_type c, void Paragraph::Pimpl::insertInset(pos_type pos, Inset * inset, LyXFont const & font, Change change) { - lyx::Assert(inset); - lyx::Assert(pos <= size()); + Assert(inset); + Assert(pos <= size()); insertChar(pos, META_INSET, font, change); - lyx::Assert(text[pos] == META_INSET); + Assert(text[pos] == META_INSET); // Add a new entry in the insetlist. owner_->insetlist.insert(inset, pos); @@ -380,7 +381,7 @@ void Paragraph::Pimpl::eraseIntern(pos_type pos) bool Paragraph::Pimpl::erase(pos_type pos) { - lyx::Assert(pos < size()); + Assert(pos < size()); if (tracking()) { Change::Type changetype(changes_->lookup(pos)); diff --git a/src/pspell.C b/src/pspell.C index 832b3c1b51..db0e3924eb 100644 --- a/src/pspell.C +++ b/src/pspell.C @@ -23,6 +23,8 @@ extern "C" { #include "pspell.h" #include "WordLangTuple.h" +using namespace lyx::support; + using std::endl; PSpell::PSpell(BufferParams const &, string const & lang) @@ -92,14 +94,14 @@ enum PSpell::Result PSpell::check(WordLangTuple const & word) PspellManager * m = it->second.manager; int word_ok = pspell_manager_check(m, word.word().c_str()); - lyx::Assert(word_ok != -1); + Assert(word_ok != -1); if (word_ok) { res = OK; } else { PspellWordList const * sugs = pspell_manager_suggest(m, word.word().c_str()); - lyx::Assert(sugs != 0); + Assert(sugs != 0); els = pspell_word_list_elements(sugs); if (pspell_word_list_empty(sugs)) res = UNKNOWN; diff --git a/src/rowpainter.C b/src/rowpainter.C index 500c2293fc..b43895acc1 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -11,8 +11,6 @@ #include -#include - #include "frontends/Painter.h" #include "frontends/screen.h" #include "frontends/font_metrics.h" @@ -35,6 +33,10 @@ #include "lyxrow_funcs.h" #include "metricsinfo.h" +#include + +using namespace lyx::support; + using std::max; using lyx::pos_type; @@ -102,7 +104,7 @@ void RowPainter::paintInset(pos_type const pos) { Inset * inset = const_cast(pit_->getInset(pos)); - lyx::Assert(inset); + Assert(inset); #warning inset->update FIXME inset->update(perv(bv_), false); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index d279c8d563..b45780154b 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,6 @@ +2003-07-01 Lars Gullik Bjønnes + + * introduce namespace lyx::support 2003-06-30 André Pönitz diff --git a/src/support/FileInfo.C b/src/support/FileInfo.C index b367db42b7..1919c9c702 100644 --- a/src/support/FileInfo.C +++ b/src/support/FileInfo.C @@ -139,6 +139,9 @@ char typeLetter(mode_t i) } // namespace anon +namespace lyx { +namespace support { + FileInfo::FileInfo() { init(); @@ -204,7 +207,7 @@ FileInfo & FileInfo::newFile(int fildes) // should not be in FileInfo char FileInfo::typeIndicator() const { - lyx::Assert(isOK()); + Assert(isOK()); if (S_ISDIR(buf_.st_mode)) return '/'; #ifdef S_ISLNK @@ -227,7 +230,7 @@ char FileInfo::typeIndicator() const mode_t FileInfo::getMode() const { - lyx::Assert(isOK()); + Assert(isOK()); return buf_.st_mode; } @@ -235,7 +238,7 @@ mode_t FileInfo::getMode() const // should not be in FileInfo string FileInfo::modeString() const { - lyx::Assert(isOK()); + Assert(isOK()); char str[11]; str[0] = typeLetter(buf_.st_mode); flagRWX((buf_.st_mode & 0700) << 0, &str[1]); @@ -250,49 +253,49 @@ string FileInfo::modeString() const time_t FileInfo::getModificationTime() const { - lyx::Assert(isOK()); + Assert(isOK()); return buf_.st_mtime; } time_t FileInfo::getAccessTime() const { - lyx::Assert(isOK()); + Assert(isOK()); return buf_.st_atime; } time_t FileInfo::getStatusChangeTime() const { - lyx::Assert(isOK()); + Assert(isOK()); return buf_.st_ctime; } nlink_t FileInfo::getNumberOfLinks() const { - lyx::Assert(isOK()); + Assert(isOK()); return buf_.st_nlink; } uid_t FileInfo::getUid() const { - lyx::Assert(isOK()); + Assert(isOK()); return buf_.st_uid; } gid_t FileInfo::getGid() const { - lyx::Assert(isOK()); + Assert(isOK()); return buf_.st_gid; } off_t FileInfo::getSize() const { - lyx::Assert(isOK()); + Assert(isOK()); return buf_.st_size; } @@ -311,49 +314,49 @@ bool FileInfo::isOK() const bool FileInfo::isLink() const { - lyx::Assert(isOK()); + Assert(isOK()); return S_ISLNK(buf_.st_mode); } bool FileInfo::isRegular() const { - lyx::Assert(isOK()); + Assert(isOK()); return S_ISREG(buf_.st_mode); } bool FileInfo::isDir() const { - lyx::Assert(isOK()); + Assert(isOK()); return S_ISDIR(buf_.st_mode); } bool FileInfo::isChar() const { - lyx::Assert(isOK()); + Assert(isOK()); return S_ISCHR(buf_.st_mode); } bool FileInfo::isBlock() const { - lyx::Assert(isOK()); + Assert(isOK()); return S_ISBLK(buf_.st_mode); } bool FileInfo::isFifo() const { - lyx::Assert(isOK()); + Assert(isOK()); return S_ISFIFO(buf_.st_mode); } bool FileInfo::isSocket() const { - lyx::Assert(isOK()); + Assert(isOK()); #ifdef S_ISSOCK return S_ISSOCK(buf_.st_mode); #else @@ -373,3 +376,6 @@ bool FileInfo::access(int p) const // the file access failed. return ::access(fname_.c_str(), p) == 0; } + +} // namespace support +} // namespace lyx diff --git a/src/support/FileInfo.h b/src/support/FileInfo.h index 9babae989f..39551567a5 100644 --- a/src/support/FileInfo.h +++ b/src/support/FileInfo.h @@ -20,6 +20,9 @@ #include #include "LString.h" +namespace lyx { +namespace support { + /** Use objects of this class to get information about files. * * Users must make sure to check fi.isOK() before any operations @@ -135,4 +138,7 @@ private: string fname_; }; +} // namespace support +} // namespace lyx + #endif diff --git a/src/support/FileMonitor.C b/src/support/FileMonitor.C index 6ab2a18e2a..c96b4e6233 100644 --- a/src/support/FileMonitor.C +++ b/src/support/FileMonitor.C @@ -20,6 +20,9 @@ #include #include +namespace lyx { +namespace support { + struct FileMonitor::Impl : public boost::signals::trackable { /// @@ -87,7 +90,7 @@ void FileMonitor::start() const return; pimpl_->timestamp_ = finfo.getModificationTime(); - pimpl_->checksum_ = lyx::sum(pimpl_->filename_); + pimpl_->checksum_ = sum(pimpl_->filename_); if (pimpl_->timestamp_ && pimpl_->checksum_) { pimpl_->timer_.start(); @@ -117,7 +120,7 @@ unsigned long FileMonitor::checksum() const // If we aren't actively monitoring the file, then recompute the // checksum explicitly. if (!pimpl_->timer_.running() && !pimpl_->filename_.empty()) - return lyx::sum(pimpl_->filename_); + return sum(pimpl_->filename_); return pimpl_->checksum_; } @@ -160,7 +163,7 @@ void FileMonitor::Impl::monitorFile() if (new_timestamp != timestamp_) { timestamp_ = new_timestamp; - unsigned long const new_checksum = lyx::sum(filename_); + unsigned long const new_checksum = sum(filename_); if (new_checksum != checksum_) { checksum_ = new_checksum; changed = true; @@ -172,3 +175,6 @@ void FileMonitor::Impl::monitorFile() if (changed) fileChanged_(); } + +} // namespace support +} // namespace lyx diff --git a/src/support/FileMonitor.h b/src/support/FileMonitor.h index de9e9068e1..809403ad88 100644 --- a/src/support/FileMonitor.h +++ b/src/support/FileMonitor.h @@ -21,6 +21,9 @@ #include #include +namespace lyx { +namespace support { + class FileMonitor : boost::noncopyable { public: /** Once monitoring begins, the file will be monitored every @@ -63,4 +66,7 @@ private: boost::scoped_ptr const pimpl_; }; +} // namespace support +} // namespace lyx + #endif // FILEMONITOR_H diff --git a/src/support/LAssert.C b/src/support/LAssert.C index 980a1aa610..30248b0807 100644 --- a/src/support/LAssert.C +++ b/src/support/LAssert.C @@ -11,11 +11,18 @@ #include #include "LAssert.h" +#include "support/lyxlib.h" #ifdef ENABLE_ASSERTIONS #include "lyx_main.h" -void emergencyCleanup() { +namespace lyx { +namespace support { + +namespace { + +void emergencyCleanup() +{ static bool didCleanup; if (didCleanup) return; @@ -25,4 +32,17 @@ void emergencyCleanup() { LyX::emergencyCleanup(); } +} // namespace anon + +void Assert(bool assertion) +{ + if (!assertion) { + emergencyCleanup(); + lyx::support::abort(); + } +} + +} // namespace support +} // namespace lyx + #endif diff --git a/src/support/LAssert.h b/src/support/LAssert.h index 73ad96b7cf..e791820285 100644 --- a/src/support/LAssert.h +++ b/src/support/LAssert.h @@ -4,7 +4,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * * Full author contact details are available in file CREDITS */ @@ -12,11 +12,8 @@ #ifndef LASSERT_H #define LASSERT_H -#include "support/lyxlib.h" - -extern void emergencyCleanup(); - namespace lyx { +namespace support { #ifdef ENABLE_ASSERTIONS @@ -25,27 +22,19 @@ namespace lyx { we run #emergencyCleanup()# and then #lyx::abort". @param assertion this should evaluate to true unless you want an abort. */ -template -inline -void Assert(A assertion) -{ - if (!assertion) { - ::emergencyCleanup(); - lyx::abort(); - } -} +void Assert(bool assertion); #else /** Dummy assertion. When compiling without assertions we use this no-op function. */ -template inline -void Assert(A /*assertion*/) {} +void Assert(bool /*assertion*/) {} #endif /* ENABLE_ASSERTIONS */ -} // end of namespace LyX +} // namespace support +} // namespace lyx #endif /* LASSERT_H */ diff --git a/src/support/abort.C b/src/support/abort.C index 1362309185..588107e202 100644 --- a/src/support/abort.C +++ b/src/support/abort.C @@ -14,7 +14,7 @@ #include "support/lyxlib.h" -void lyx::abort() +void lyx::support::abort() { ::abort(); } diff --git a/src/support/atoi.C b/src/support/atoi.C index 69d759d8e0..be53d9afda 100644 --- a/src/support/atoi.C +++ b/src/support/atoi.C @@ -19,7 +19,7 @@ using std::atoi; #endif -int lyx::atoi(string const & nstr) +int lyx::support::atoi(string const & nstr) { return ::atoi(nstr.c_str()); } diff --git a/src/support/chdir.C b/src/support/chdir.C index e87552c12c..7005ef1b66 100644 --- a/src/support/chdir.C +++ b/src/support/chdir.C @@ -14,7 +14,7 @@ #include "support/lyxlib.h" -int lyx::chdir(string const & name) +int lyx::support::chdir(string const & name) { #ifndef __EMX__ return ::chdir(name.c_str()); diff --git a/src/support/copy.C b/src/support/copy.C index 98ddc399a3..f1b32f8c23 100644 --- a/src/support/copy.C +++ b/src/support/copy.C @@ -19,7 +19,7 @@ using std::ifstream; using std::ofstream; using std::ios; -bool lyx::copy(string const & from, string const & to) +bool lyx::support::copy(string const & from, string const & to) { ifstream ifs(from.c_str()); if (!ifs) diff --git a/src/support/filetools.C b/src/support/filetools.C index e27ef022bf..ed1875f482 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -83,6 +83,8 @@ extern string system_lyxdir; extern string build_lyxdir; extern string user_lyxdir; +namespace lyx { +namespace support { bool IsLyXFilename(string const & filename) { @@ -158,12 +160,12 @@ bool IsDirWriteable(string const & path) { lyxerr[Debug::FILES] << "IsDirWriteable: " << path << endl; - string const tmpfl(lyx::tempName(path, "lyxwritetest")); + string const tmpfl(tempName(path, "lyxwritetest")); if (tmpfl.empty()) return false; - lyx::unlink(tmpfl); + unlink(tmpfl); return true; } @@ -430,7 +432,7 @@ int DeleteAllFilesInDir(string const & path) FileInfo fi(unlinkpath); if (fi.isOK() && fi.isDir()) deleted = (DeleteAllFilesInDir(unlinkpath) == 0); - deleted &= (lyx::unlink(unlinkpath) == 0); + deleted &= (unlink(unlinkpath) == 0); if (!deleted) return_value = -1; } @@ -445,14 +447,14 @@ string const CreateTmpDir(string const & tempdir, string const & mask) << "CreateTmpDir: tempdir=`" << tempdir << "'\n" << "CreateTmpDir: mask=`" << mask << '\'' << endl; - string const tmpfl(lyx::tempName(tempdir, mask)); + string const tmpfl(tempName(tempdir, mask)); // lyx::tempName actually creates a file to make sure that it // stays unique. So we have to delete it before we can create // a dir with the same name. Note also that we are not thread // safe because of the gap between unlink and mkdir. (Lgb) - lyx::unlink(tmpfl.c_str()); + unlink(tmpfl); - if (tmpfl.empty() || lyx::mkdir(tmpfl, 0700)) + if (tmpfl.empty() || mkdir(tmpfl, 0700)) return string(); return MakeAbsPath(tmpfl); @@ -469,7 +471,7 @@ int destroyDir(string const & tmpdir) if (DeleteAllFilesInDir(tmpdir)) return -1; - if (lyx::rmdir(tmpdir)) + if (rmdir(tmpdir)) return -1; return 0; @@ -484,7 +486,7 @@ string const CreateBufferTmpDir(string const & pathfor) // In fact I wrote this code to circumvent a problematic behaviour (bug?) // of EMX mkstemp(). string const tmpfl = tmpdir + "/lyx_tmpbuf" + tostr(count++); - if (lyx::mkdir(tmpfl, 0777)) { + if (mkdir(tmpfl, 0777)) { return string(); } return tmpfl; @@ -494,7 +496,7 @@ string const CreateBufferTmpDir(string const & pathfor) string const CreateLyXTmpDir(string const & deflt) { if ((!deflt.empty()) && (deflt != "/tmp")) { - if (lyx::mkdir(deflt, 0777)) { + if (mkdir(deflt, 0777)) { #ifdef __EMX__ Path p(user_lyxdir); #endif @@ -514,9 +516,9 @@ bool createDirectory(string const & path, int permission) { string temp(rtrim(os::slashify_path(path), "/")); - lyx::Assert(!temp.empty()); + Assert(!temp.empty()); - if (lyx::mkdir(temp, permission)) + if (mkdir(temp, permission)) return false; return true; @@ -556,7 +558,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath) if (os::is_absolute_path(BasePath)) TempBase = BasePath; else - TempBase = AddPath(lyx::getcwd(), BasePath); + TempBase = AddPath(getcwd(), BasePath); // Handle /./ at the end of the path while (suffixIs(TempBase, "/./")) @@ -661,7 +663,7 @@ string const ExpandPath(string const & path) RTemp = split(RTemp, Temp, '/'); if (Temp == ".") { - return lyx::getcwd() /*GetCWD()*/ + '/' + RTemp; + return getcwd() + '/' + RTemp; } if (Temp == "~") { return GetEnvPath("HOME") + '/' + RTemp; @@ -1137,7 +1139,7 @@ bool zippedFile(string const & name) string const unzipFile(string const & zipped_file) { string const file = ChangeExtension(zipped_file, string()); - string const tempfile = lyx::tempName(string(), file); + string const tempfile = tempName(string(), file); // Run gunzip string const command = "gunzip -c " + zipped_file + " > " + tempfile; Systemcall one; @@ -1284,7 +1286,7 @@ void removeAutosaveFile(string const & filename) a += '#'; FileInfo const fileinfo(a); if (fileinfo.exist()) - lyx::unlink(a); + unlink(a); } @@ -1293,8 +1295,9 @@ void readBB_lyxerrMessage(string const & file, bool & zipped, { lyxerr[Debug::GRAPHICS] << "[readBB_from_PSFile] " << message << std::endl; +#warning Why is this func deleting a file? (Lgb) if (zipped) - lyx::unlink(file); + unlink(file); } @@ -1334,7 +1337,7 @@ string const readBB_from_PSFile(string const & file) string const copyFileToDir(string const & path, string const & file_in) { - lyx::Assert(AbsolutePath(path)); + Assert(AbsolutePath(path)); // First, make the file path relative to path. string file_out = MakeRelPath(path, NormalizePath(file_in)); @@ -1365,8 +1368,11 @@ string const copyFileToDir(string const & path, string const & file_in) if (!fi2.exist() || difftime(fi.getModificationTime(), fi2.getModificationTime()) >= 0) - success = lyx::copy(file_in, file_out); + success = copy(file_in, file_out); } return success ? file_out : string(); } + +} //namespace support +} // namespace lyx diff --git a/src/support/filetools.h b/src/support/filetools.h index 6dd1530ebf..709d5e256f 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -18,6 +18,9 @@ #include "os.h" +namespace lyx { +namespace support { + /// remove directory and all contents, returns 0 on success int destroyDir(string const & tmpdir); @@ -220,4 +223,7 @@ typedef std::pair cmd_ret; cmd_ret const RunCommand(string const & cmd); +} // namespace support +} // namespace lyx + #endif diff --git a/src/support/forkedcall.C b/src/support/forkedcall.C index a5e281cd97..4853e4c21a 100644 --- a/src/support/forkedcall.C +++ b/src/support/forkedcall.C @@ -48,6 +48,9 @@ using std::endl; using std::strerror; #endif +namespace lyx { +namespace support { + namespace { @@ -59,7 +62,7 @@ public: if (secs > 0) { new Murder(secs, pid); } else if (pid != 0) { - lyx::kill(pid, SIGKILL); + lyx::support::kill(pid, SIGKILL); } } @@ -67,7 +70,7 @@ public: void kill() { if (pid_ != 0) { - lyx::kill(pid_, SIGKILL); + lyx::support::kill(pid_, SIGKILL); } lyxerr << "Killed " << pid_ << std::endl; delete this; @@ -175,7 +178,7 @@ void ForkedProcess::kill(int tol) Murder::killItDead(0, pid()); } else { - int ret = lyx::kill(pid(), SIGHUP); + int ret = lyx::support::kill(pid(), SIGHUP); // The process is already dead if wait_for_death is false bool const wait_for_death = (ret == 0 && errno != ESRCH); @@ -299,3 +302,6 @@ int Forkedcall::generateChild() return cpid; } + +} // namespace support +} // namespace lyx diff --git a/src/support/forkedcall.h b/src/support/forkedcall.h index d053af3116..8da1a40cf8 100644 --- a/src/support/forkedcall.h +++ b/src/support/forkedcall.h @@ -34,6 +34,9 @@ #include +namespace lyx { +namespace support { + class ForkedProcess { public: /// @@ -164,4 +167,7 @@ private: virtual int generateChild(); }; +} // namespace support +} // namespace lyx + #endif // FORKEDCALL_H diff --git a/src/support/forkedcallqueue.C b/src/support/forkedcallqueue.C index fe9606772a..0e49713da4 100644 --- a/src/support/forkedcallqueue.C +++ b/src/support/forkedcallqueue.C @@ -20,6 +20,9 @@ using std::endl; using std::queue; +namespace lyx { +namespace support { + ForkedCallQueue & ForkedCallQueue::get() { static ForkedCallQueue singleton; @@ -90,3 +93,6 @@ bool ForkedCallQueue::running() const { return running_ ; } + +} // namespace support +} // namespace lyx diff --git a/src/support/forkedcallqueue.h b/src/support/forkedcallqueue.h index 817d7bb873..87a609f043 100644 --- a/src/support/forkedcallqueue.h +++ b/src/support/forkedcallqueue.h @@ -5,14 +5,14 @@ * Licence details can be found in the file COPYING. * * \author Alfredo Braunstein (based on an idea from Angus Leeming) - * + * * Full author contact details are available in file CREDITS - * - * This class implements a queue of forked processes. In order not to - * hose the system with multiple processes running simultaneously, you can - * request the addition of your process to this queue and it will be + * + * This class implements a queue of forked processes. In order not to + * hose the system with multiple processes running simultaneously, you can + * request the addition of your process to this queue and it will be * executed when its turn comes. - * + * */ #ifndef FORKEDCALLQUEUE_H @@ -24,6 +24,9 @@ #include #include "LString.h" +namespace lyx { +namespace support { + class ForkedCallQueue { public: /// A process in the queue @@ -41,11 +44,11 @@ public: private: - /** this class is a singleton class... use + /** this class is a singleton class... use * ForkedCallQueue::get() instead */ ForkedCallQueue(); - /// in-progress queue + /// in-progress queue std::queue callQueue_; /// bool running_; @@ -59,4 +62,7 @@ private: void callback(pid_t, int); }; +} // namespace support +} // namespace lyx + #endif // FORKEDCALLQUEUE_H diff --git a/src/support/forkedcontr.C b/src/support/forkedcontr.C index 8ed0035d9e..c11daa5669 100644 --- a/src/support/forkedcontr.C +++ b/src/support/forkedcontr.C @@ -36,6 +36,9 @@ using std::find_if; using std::strerror; #endif +namespace lyx { +namespace support { + // Ensure, that only one controller exists inside process ForkedcallsController & ForkedcallsController::get() { @@ -206,3 +209,6 @@ void ForkedcallsController::kill(pid_t pid, int tolerance) timeout_->stop(); } } + +} // namespace support +} // namespace lyx diff --git a/src/support/forkedcontr.h b/src/support/forkedcontr.h index 88ac92a2d1..bc98f0605a 100644 --- a/src/support/forkedcontr.h +++ b/src/support/forkedcontr.h @@ -26,9 +26,13 @@ #include #include -class ForkedProcess; class Timeout; +namespace lyx { +namespace support { + +class ForkedProcess; + class ForkedcallsController : public boost::signals::trackable { public: /// We need this to avoid warnings. @@ -81,4 +85,7 @@ private: Timeout * timeout_; }; +} // namespace support +} // namespace lyx + #endif // FORKEDCONTR_H diff --git a/src/support/getcwd.C b/src/support/getcwd.C index 305c8107b9..0214693005 100644 --- a/src/support/getcwd.C +++ b/src/support/getcwd.C @@ -31,7 +31,7 @@ char * l_getcwd(char * buffer, size_t size) // Returns current working directory -string const lyx::getcwd() +string const lyx::support::getcwd() { int n = 256; // Assume path is less than 256 chars char * err; diff --git a/src/support/kill.C b/src/support/kill.C index b307d28d53..d1b2376711 100644 --- a/src/support/kill.C +++ b/src/support/kill.C @@ -15,7 +15,7 @@ #include #include -int lyx::kill(int pid, int sig) +int lyx::support::kill(int pid, int sig) { return ::kill(pid, sig); } diff --git a/src/support/lstrings.C b/src/support/lstrings.C index fbb5b00013..e464daf2ac 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -17,6 +17,7 @@ #include "Lsstream.h" #include "debug.h" #include "BoostFormat.h" +#include "lyxlib.h" #include #include @@ -38,6 +39,8 @@ using std::tolower; using std::toupper; #endif +namespace lyx { +namespace support { int compare_no_case(string const & s, string const & s2) { @@ -156,7 +159,7 @@ int strToInt(string const & str) // Remove leading and trailing white space chars. string const tmpstr = trim(str); // Do the conversion proper. - return lyx::atoi(tmpstr); + return atoi(tmpstr); } else { return 0; } @@ -169,7 +172,7 @@ unsigned int strToUnsignedInt(string const & str) // Remove leading and trailing white space chars. string const tmpstr = trim(str); // Do the conversion proper. - return lyx::atoi(tmpstr); + return atoi(tmpstr); } else { return 0; } @@ -430,7 +433,7 @@ string const subst(string const & a, string const trim(string const & a, char const * p) { - lyx::Assert(p); + Assert(p); if (a.empty() || !*p) return a; @@ -448,7 +451,7 @@ string const trim(string const & a, char const * p) string const rtrim(string const & a, char const * p) { - lyx::Assert(p); + Assert(p); if (a.empty() || !*p) return a; @@ -465,7 +468,7 @@ string const rtrim(string const & a, char const * p) string const ltrim(string const & a, char const * p) { - lyx::Assert(p); + Assert(p); if (a.empty() || !*p) return a; @@ -652,7 +655,7 @@ string bformat(string const & fmt, string const & arg1, string const & arg2, string bformat(string const & fmt, string const & arg1) { - lyx::Assert(contains(fmt, "%1$s")); + Assert(contains(fmt, "%1$s")); string const str = subst(fmt, "%1$s", arg1); return subst(str, "%%", "%"); } @@ -660,8 +663,8 @@ string bformat(string const & fmt, string const & arg1) string bformat(string const & fmt, string const & arg1, string const & arg2) { - lyx::Assert(contains(fmt, "%1$s")); - lyx::Assert(contains(fmt, "%2$s")); + Assert(contains(fmt, "%1$s")); + Assert(contains(fmt, "%2$s")); string str = subst(fmt, "%1$s", arg1); str = subst(str, "%2$s", arg2); return subst(str, "%%", "%"); @@ -671,9 +674,9 @@ string bformat(string const & fmt, string const & arg1, string const & arg2) string bformat(string const & fmt, string const & arg1, string const & arg2, string const & arg3) { - lyx::Assert(contains(fmt, "%1$s")); - lyx::Assert(contains(fmt, "%2$s")); - lyx::Assert(contains(fmt, "%3$s")); + Assert(contains(fmt, "%1$s")); + Assert(contains(fmt, "%2$s")); + Assert(contains(fmt, "%3$s")); string str = subst(fmt, "%1$s", arg1); str = subst(str, "%2$s", arg2); str = subst(str, "%3$s", arg3); @@ -684,10 +687,10 @@ string bformat(string const & fmt, string const & arg1, string const & arg2, string bformat(string const & fmt, string const & arg1, string const & arg2, string const & arg3, string const & arg4) { - lyx::Assert(contains(fmt, "%1$s")); - lyx::Assert(contains(fmt, "%2$s")); - lyx::Assert(contains(fmt, "%3$s")); - lyx::Assert(contains(fmt, "%4$s")); + Assert(contains(fmt, "%1$s")); + Assert(contains(fmt, "%2$s")); + Assert(contains(fmt, "%3$s")); + Assert(contains(fmt, "%4$s")); string str = subst(fmt, "%1$s", arg1); str = subst(str, "%2$s", arg2); str = subst(str, "%3$s", arg3); @@ -713,3 +716,6 @@ string bformat(string const & fmt, string const & arg1, string const & arg2, } #endif + +} // namespace support +} // namespace lyx diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 771cba3d6f..254337d376 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -20,6 +20,9 @@ #include "LString.h" +namespace lyx { +namespace support { + /// int compare_no_case(string const & s, string const & s2); @@ -210,4 +213,7 @@ string bformat(string const & fmt, string const & arg1, string const & arg2, string bformat(string const & fmt, string const & arg1, string const & arg2, string const & arg3, string const & arg4); +} // namespace support +} // namespace lyx + #endif diff --git a/src/support/lyxlib.h b/src/support/lyxlib.h index b515f55670..ed702d357b 100644 --- a/src/support/lyxlib.h +++ b/src/support/lyxlib.h @@ -18,6 +18,7 @@ #include "LString.h" namespace lyx { +namespace support { /// get the current working directory string const getcwd(); @@ -64,6 +65,7 @@ inline bool float_equal(float var, float number, float error) return (number - error <= var && var <= number + error); } +} // namespace support } // namespace lyx #endif /* LYX_LIB_H */ diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index 2b3db80075..322cb39032 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -13,14 +13,16 @@ #endif #include "lyxstring.h" -#include -#include -#include #include "LAssert.h" #include "debug.h" +#include +#include +#include +#include + using std::min; using std::istream; using std::ostream; @@ -59,12 +61,15 @@ using std::ostream; // Lgb. +namespace lyx { + +using support::Assert; /////////////////////////////////////// // The internal string representation /////////////////////////////////////// -struct lyxstring::Srep { +struct string::Srep { /// size size_t sz; /// Reference count @@ -72,12 +77,12 @@ struct lyxstring::Srep { /// The total amount of data reserved for this representaion size_t res; /// Data. At least 1 char for trailing null. - lyxstring::value_type * s; + string::value_type * s; /// - Srep(lyxstring::size_type nsz, const lyxstring::value_type * p); + Srep(string::size_type nsz, const string::value_type * p); /// - Srep(lyxstring::size_type nsz, lyxstring::value_type ch); + Srep(string::size_type nsz, string::value_type ch); /// ~Srep() { delete[] s; } /// @@ -88,34 +93,34 @@ struct lyxstring::Srep { } /// - void assign(lyxstring::size_type nsz, const lyxstring::value_type * p); + void assign(string::size_type nsz, const string::value_type * p); /// - void assign(lyxstring::size_type nsz, lyxstring::value_type ch); + void assign(string::size_type nsz, string::value_type ch); /// - void append(lyxstring::size_type asz, const lyxstring::value_type * p); + void append(string::size_type asz, const string::value_type * p); /// - void push_back(lyxstring::value_type c); + void push_back(string::value_type c); /// - void insert(lyxstring::size_type pos, - const lyxstring::value_type * p, - lyxstring::size_type n); + void insert(string::size_type pos, + const string::value_type * p, + string::size_type n); /// - void resize(lyxstring::size_type n, lyxstring::value_type c); + void resize(string::size_type n, string::value_type c); /// - void reserve(lyxstring::size_type res_arg); + void reserve(string::size_type res_arg); /// - void replace(lyxstring::size_type i, lyxstring::size_type n, - lyxstring::value_type const * p, lyxstring::size_type n2); + void replace(string::size_type i, string::size_type n, + string::value_type const * p, string::size_type n2); private: Srep(const Srep &); Srep & operator=(const Srep &); }; -lyxstring::Srep::Srep(lyxstring::size_type nsz, const value_type * p) +string::Srep::Srep(string::size_type nsz, const value_type * p) { // can be called with p == 0 by - // lyxstring::assign(const value_type *, size_type) + // string::assign(const value_type *, size_type) sz = nsz; ref = 1; @@ -132,7 +137,7 @@ lyxstring::Srep::Srep(lyxstring::size_type nsz, const value_type * p) } -lyxstring::Srep::Srep(lyxstring::size_type nsz, value_type ch) +string::Srep::Srep(string::size_type nsz, value_type ch) { sz = nsz; ref = 1; @@ -140,17 +145,17 @@ lyxstring::Srep::Srep(lyxstring::size_type nsz, value_type ch) s = new value_type[res + 1]; // add space for terminator memset(s, ch, sz); if (!ch) { - // if ch == '\0' strlen(lyxstring.c_str()) == 0 so sz = 0 + // if ch == '\0' strlen(string.c_str()) == 0 so sz = 0 // allows for large but empty string sz = 0; } } -void lyxstring::Srep::assign(lyxstring::size_type nsz, const value_type * p) +void string::Srep::assign(string::size_type nsz, const value_type * p) { // can be called with p == 0 - // by lyxstring::assign(const value_type *, size_type) + // by string::assign(const value_type *, size_type) if (res < nsz) { delete[] s; @@ -171,7 +176,7 @@ void lyxstring::Srep::assign(lyxstring::size_type nsz, const value_type * p) } -void lyxstring::Srep::assign(lyxstring::size_type nsz, value_type ch) +void string::Srep::assign(string::size_type nsz, value_type ch) { sz = nsz; if (res < nsz) { @@ -181,14 +186,14 @@ void lyxstring::Srep::assign(lyxstring::size_type nsz, value_type ch) } memset(s, ch, sz); if (!ch) { - // if ch == '\0' strlen(lyxstring.c_str()) == 0 so sz = 0 + // if ch == '\0' strlen(string.c_str()) == 0 so sz = 0 // allows for a large empty string sz = 0; } } -void lyxstring::Srep::append(lyxstring::size_type asz, const value_type * p) +void string::Srep::append(string::size_type asz, const value_type * p) { register unsigned int const len = sz + asz; if (res < len) { @@ -208,7 +213,7 @@ void lyxstring::Srep::append(lyxstring::size_type asz, const value_type * p) } -void lyxstring::Srep::push_back(value_type c) +void string::Srep::push_back(value_type c) { s[sz] = c; // it is always room to put a value_type at the end ++sz; @@ -224,8 +229,8 @@ void lyxstring::Srep::push_back(value_type c) } -void lyxstring::Srep::insert(lyxstring::size_type pos, const value_type * p, - lyxstring::size_type n) +void string::Srep::insert(string::size_type pos, const value_type * p, + string::size_type n) { if (res < n + sz) { do { @@ -246,7 +251,7 @@ void lyxstring::Srep::insert(lyxstring::size_type pos, const value_type * p, } -void lyxstring::Srep::resize(size_type n, value_type c) +void string::Srep::resize(size_type n, value_type c) { // This resets sz to res_arg res = min(n, npos - 2); // We keep no xtra when we resize @@ -260,7 +265,7 @@ void lyxstring::Srep::resize(size_type n, value_type c) } -void lyxstring::Srep::reserve(lyxstring::size_type res_arg) +void string::Srep::reserve(string::size_type res_arg) { // This keeps the old sz, but // increases res with res_arg @@ -272,7 +277,7 @@ void lyxstring::Srep::reserve(lyxstring::size_type res_arg) } -void lyxstring::Srep::replace(lyxstring::size_type i, lyxstring::size_type n, +void string::Srep::replace(string::size_type i, string::size_type n, value_type const * p, size_type n2) { // can be called with p= 0 and n2= 0 @@ -298,24 +303,24 @@ void lyxstring::Srep::replace(lyxstring::size_type i, lyxstring::size_type n, /////////////////////////////////////// -// The lyxstring Invariant tester +// The string Invariant tester /////////////////////////////////////// -// There are no know bugs in lyxstring now, and it have been +// There are no know bugs in string now, and it have been // tested for a long time. so we disable the invariant checker. (Lgb) #undef ENABLE_ASSERTIONS #ifdef ENABLE_ASSERTIONS -/** Testing of the lyxstring invariant - * By creating an object that tests the lyxstring invariant during its +/** Testing of the string invariant + * By creating an object that tests the string invariant during its * construction *and* its deconstruction we greatly simplify our code. - * Calling TestlyxstringInvariant() upon entry to an lyxstring method + * Calling TeststringInvariant() upon entry to an string method * will test the invariant upon entry to the code. If the Asserts fail * then we know from the stack trace that the corruption occurred *before* * entry to this method. We can also be sure it didn't happen in any of - * the tested lyxstring methods. It is therefore likely to be due to some + * the tested string methods. It is therefore likely to be due to some * other external force. - * Several lyxstring methods have multiple exit points which would otherwise + * Several string methods have multiple exit points which would otherwise * require us to insert a separate test before each return. But since we * created an object its destructor will be called upon exit (any exit!). * We thus get testing at both start and end of a method with one line of @@ -323,46 +328,46 @@ void lyxstring::Srep::replace(lyxstring::size_type i, lyxstring::size_type n, * everytime we run the code. * NOTE: just because we test the invariant doesn't mean we can forget * about testing pre and post conditions specific to any given method. - * This test simply proves that the lyxstring/Srep is in a valid state it + * This test simply proves that the string/Srep is in a valid state it * does *not* prove that the method did what it was supposed to. */ -class lyxstringInvariant { +class stringInvariant { public: - lyxstringInvariant(lyxstring const *); - ~lyxstringInvariant(); + stringInvariant(string const *); + ~stringInvariant(); private: void helper() const; - lyxstring const * object; + string const * object; }; // To test if this scheme works "as advertised" uncomment the printf's in // the constructor and destructor below and then uncomment the printf and the -// call to TestlyxstringInvariant() in lyxstring::operator=(char const *). +// call to TestlyxstringInvariant() in string::operator=(char const *). // The correct output when LyX has been recompiled and run is: // lyxstringInvariant constructor -// lyxstring::operator=(char const *) +// string::operator=(char const *) // lyxstringInvariant constructor // lyxstringInvariant destructor completed // lyxstringInvariant destructor completed // NOTE: The easiest way to catch this snippet of the output is to wait for // the splash screen to disappear and then open and close Help->Credits // -lyxstringInvariant::lyxstringInvariant(lyxstring const * ls) : object(ls) +stringInvariant::stringInvariant(string const * ls) : object(ls) { - // printf("lyxstringInvariant constructor\n"); + // printf("stringInvariant constructor\n"); helper(); } -lyxstringInvariant::~lyxstringInvariant() +stringInvariant::~stringInvariant() { helper(); - // printf("lyxstringInvariant destructor completed\n"); + // printf("stringInvariant destructor completed\n"); } -void lyxstringInvariant::helper() const +void stringInvariant::helper() const { // Some of these tests might look pointless but they are // all part of the invariant and if we want to make sure @@ -370,7 +375,6 @@ void lyxstringInvariant::helper() const // test every last little thing we *know* should be true. // I may have missed a test or two, so feel free to fill // in the gaps. ARRae. - using lyx::Assert; Assert(object); Assert(object->rep); Assert(object->rep->s); // s is never 0 @@ -381,9 +385,9 @@ void lyxstringInvariant::helper() const // if it does ever == then we should be generating a new copy // and starting again. (Is char always 8-bits?) } -#define TestlyxstringInvariant(s) lyxstringInvariant lyxstring_invariant(s); +#define TeststringInvariant(s) stringInvariant string_invariant(s); #else -#define TestlyxstringInvariant(s) +#define TeststringInvariant(s) #endif /* ENABLE_ASSERTIONS */ @@ -391,11 +395,11 @@ void lyxstringInvariant::helper() const // Constructors and Deconstructors. /////////////////////////////////////// -lyxstring::size_type const lyxstring::npos = -static_cast(-1); +string::size_type const string::npos = +static_cast(-1); -lyxstring::lyxstring() +string::string() { static Srep empty_rep(0, ""); ++empty_rep.ref; @@ -403,9 +407,9 @@ lyxstring::lyxstring() } -lyxstring::lyxstring(lyxstring const & x, size_type pos, size_type n) +string::string(string const & x, size_type pos, size_type n) { - lyx::Assert(pos <= x.rep->sz); // STD! + Assert(pos <= x.rep->sz); // STD! if (pos == 0 && n >= x.length()) { // this is the default x.rep->ref++; rep = x.rep; @@ -415,9 +419,9 @@ lyxstring::lyxstring(lyxstring const & x, size_type pos, size_type n) } -lyxstring::lyxstring(value_type const * s, size_type n) +string::string(value_type const * s, size_type n) { - lyx::Assert(s && n < npos); // STD! + Assert(s && n < npos); // STD! static Srep empty_rep(0, ""); if (n) { // n > 0 rep = new Srep(n, s); @@ -428,9 +432,9 @@ lyxstring::lyxstring(value_type const * s, size_type n) } -lyxstring::lyxstring(value_type const * s) +string::string(value_type const * s) { - lyx::Assert(s); // STD! + Assert(s); // STD! static Srep empty_rep(0, ""); if (*s) { // s is not empty string rep = new Srep(strlen(s), s); @@ -441,24 +445,24 @@ lyxstring::lyxstring(value_type const * s) } -lyxstring::lyxstring(size_type n, value_type c) +string::string(size_type n, value_type c) { - lyx::Assert(n < npos); // STD! + Assert(n < npos); // STD! rep = new Srep(n, c); } -#warning lyxstring user, have a look here. (Lgb) +#warning string user, have a look here. (Lgb) #if 0 // Commented out to avoid warnings from doxygen. (Lgb) -lyxstring::lyxstring(const_iterator first, const_iterator last) +string::string(const_iterator first, const_iterator last) { rep = new Srep(last - first, first); } #endif -lyxstring::~lyxstring() +string::~string() { if (--rep->ref == 0) delete rep; } @@ -467,51 +471,51 @@ lyxstring::~lyxstring() // Iterators /////////////////////// -lyxstring::iterator lyxstring::begin() +string::iterator string::begin() { rep = rep->get_own_copy(); return rep->s; } -lyxstring::const_iterator lyxstring::begin() const +string::const_iterator string::begin() const { return rep->s; } -lyxstring::iterator lyxstring::end() +string::iterator string::end() { rep = rep->get_own_copy(); return rep->s + rep->sz; } -lyxstring::const_iterator lyxstring::end() const +string::const_iterator string::end() const { return rep->s + rep->sz; } #if 0 -reverse_iterator lyxstring::rbegin() +reverse_iterator string::rbegin() { return reverse_iterator( end() ); } -const_reverse_iterator lyxstring::rbegin() const +const_reverse_iterator string::rbegin() const { return const_reverse_iterator( end() ); } -reverse_iterator lyxstring::rend() +reverse_iterator string::rend() { return reverse_iterator( begin() ); } -const_reverse_iterator lyxstring::rend() const +const_reverse_iterator string::rend() const { return const_reverse_iterator( begin() ); } @@ -522,16 +526,16 @@ const_reverse_iterator lyxstring::rend() const // Size and Capacity /////////////////////// -lyxstring::size_type lyxstring::size() const +string::size_type string::size() const { return rep->sz; } -void lyxstring::resize(size_type n, value_type c) +void string::resize(size_type n, value_type c) { - lyx::Assert(n <= npos); // STD! - TestlyxstringInvariant(this); + Assert(n <= npos); // STD! + TeststringInvariant(this); // This resets sz to res_arg rep = rep->get_own_copy(); @@ -539,15 +543,15 @@ void lyxstring::resize(size_type n, value_type c) } -lyxstring::size_type lyxstring::capacity() const +string::size_type string::capacity() const { return rep->res; } -void lyxstring::reserve(size_type res_arg) +void string::reserve(size_type res_arg) { - TestlyxstringInvariant(this); + TeststringInvariant(this); rep = rep->get_own_copy(); rep->reserve(res_arg); @@ -558,27 +562,27 @@ void lyxstring::reserve(size_type res_arg) // Assignment //////////////// -lyxstring & lyxstring::operator=(lyxstring const & x) +string & string::operator=(string const & x) { - TestlyxstringInvariant(this); + TeststringInvariant(this); return assign(x); } -lyxstring & lyxstring::operator=(value_type const * s) +string & string::operator=(value_type const * s) { - lyx::Assert(s); // OURS! - TestlyxstringInvariant(this); -// printf("lyxstring::operator= (value_type const *)\n"); + Assert(s); // OURS! + TeststringInvariant(this); +// printf("string::operator= (value_type const *)\n"); return assign(s); } -lyxstring & lyxstring::operator=(value_type c) +string & string::operator=(value_type c) { - TestlyxstringInvariant(this); + TeststringInvariant(this); value_type s[1]; s[0] = c; @@ -592,9 +596,9 @@ lyxstring & lyxstring::operator=(value_type c) } -lyxstring & lyxstring::assign(lyxstring const & x) +string & string::assign(string const & x) { - TestlyxstringInvariant(this); + TeststringInvariant(this); x.rep->ref++; // protect against ``st = st'' if (--rep->ref == 0) delete rep; @@ -603,19 +607,19 @@ lyxstring & lyxstring::assign(lyxstring const & x) } -lyxstring & lyxstring::assign(lyxstring const & x, size_type pos, size_type n) +string & string::assign(string const & x, size_type pos, size_type n) { - lyx::Assert(pos <= x.rep->sz); // STD! - TestlyxstringInvariant(this); + Assert(pos <= x.rep->sz); // STD! + TeststringInvariant(this); return assign(x.substr(pos, n)); } -lyxstring & lyxstring::assign(value_type const * s, size_type n) +string & string::assign(value_type const * s, size_type n) { - lyx::Assert(s && n < npos); // STD! - TestlyxstringInvariant(this); + Assert(s && n < npos); // STD! + TeststringInvariant(this); if (rep->ref == 1) // recycle rep rep->assign(n, s); @@ -627,18 +631,18 @@ lyxstring & lyxstring::assign(value_type const * s, size_type n) } -lyxstring & lyxstring::assign(value_type const * s) +string & string::assign(value_type const * s) { - lyx::Assert(s); // OURS! - TestlyxstringInvariant(this); + Assert(s); // OURS! + TeststringInvariant(this); return assign(s, strlen(s)); } -lyxstring & lyxstring::assign(size_type n, value_type ch) +string & string::assign(size_type n, value_type ch) { - TestlyxstringInvariant(this); + TeststringInvariant(this); rep = rep->get_own_copy(); rep->assign(n, ch); @@ -646,9 +650,9 @@ lyxstring & lyxstring::assign(size_type n, value_type ch) } -lyxstring & lyxstring::assign(const_iterator first, const_iterator last) +string & string::assign(const_iterator first, const_iterator last) { - TestlyxstringInvariant(this); + TeststringInvariant(this); rep = rep->get_own_copy(); rep->assign(last - first, first); @@ -660,43 +664,43 @@ lyxstring & lyxstring::assign(const_iterator first, const_iterator last) // Element Access //////////////////// -lyxstring::const_reference lyxstring::operator[](size_type pos) const +string::const_reference string::operator[](size_type pos) const { #if 0 // This is actually what the standard requires, - lyx::Assert(pos <= rep->sz); // OURS! + Assert(pos <= rep->sz); // OURS! static char const helper = '\0'; return pos == rep->sz ? helper : rep->s[pos]; #else // but we use this one since it is stricter // and more according to the real intent of std::string. - lyx::Assert(pos < rep->sz); // OURS! + Assert(pos < rep->sz); // OURS! return rep->s[pos]; #endif } -lyxstring::reference lyxstring::operator[](size_type pos) +string::reference string::operator[](size_type pos) { - lyx::Assert(pos < rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(pos < rep->sz); // OURS! + TeststringInvariant(this); rep = rep->get_own_copy(); return rep->s[pos]; } -lyxstring::const_reference lyxstring::at(size_type n) const +string::const_reference string::at(size_type n) const { - lyx::Assert(n < rep->sz); // STD! + Assert(n < rep->sz); // STD! return rep->s[n]; } -lyxstring::reference lyxstring::at(size_type n) +string::reference string::at(size_type n) { - lyx::Assert(n < rep->sz); // STD! - TestlyxstringInvariant(this); + Assert(n < rep->sz); // STD! + TeststringInvariant(this); rep = rep->get_own_copy(); return rep->s[n]; @@ -707,44 +711,44 @@ lyxstring::reference lyxstring::at(size_type n) // Insert ///////////// -lyxstring & lyxstring::operator+=(lyxstring const & x) +string & string::operator+=(string const & x) { - TestlyxstringInvariant(this); + TeststringInvariant(this); return append(x); } -lyxstring & lyxstring::operator+=(value_type const * x) +string & string::operator+=(value_type const * x) { - lyx::Assert(x); // OURS! - TestlyxstringInvariant(this); + Assert(x); // OURS! + TeststringInvariant(this); return append(x); } -lyxstring & lyxstring::operator+=(value_type c) +string & string::operator+=(value_type c) { - TestlyxstringInvariant(this); + TeststringInvariant(this); push_back(c); return *this; } -void lyxstring::push_back(value_type c) +void string::push_back(value_type c) { - TestlyxstringInvariant(this); + TeststringInvariant(this); rep = rep->get_own_copy(); rep->push_back(c); } -lyxstring & lyxstring::append(lyxstring const & x) +string & string::append(string const & x) { - TestlyxstringInvariant(this); + TeststringInvariant(this); if (x.empty()) return *this; rep = rep->get_own_copy(); @@ -753,19 +757,19 @@ lyxstring & lyxstring::append(lyxstring const & x) } -lyxstring & lyxstring::append(lyxstring const & x, size_type pos, size_type n) +string & string::append(string const & x, size_type pos, size_type n) { - lyx::Assert(pos <= x.rep->sz); // STD! - TestlyxstringInvariant(this); + Assert(pos <= x.rep->sz); // STD! + TeststringInvariant(this); return append(x.substr(pos, n)); } -lyxstring & lyxstring::append(value_type const * p, size_type n) +string & string::append(value_type const * p, size_type n) { - lyx::Assert(p); // OURS! - TestlyxstringInvariant(this); + Assert(p); // OURS! + TeststringInvariant(this); if (!*p || !n) return *this; rep = rep->get_own_copy(); @@ -774,16 +778,16 @@ lyxstring & lyxstring::append(value_type const * p, size_type n) } -lyxstring & lyxstring::append(value_type const * p) +string & string::append(value_type const * p) { - lyx::Assert(p); // OURS! + Assert(p); // OURS! return append(p, strlen(p)); } -lyxstring & lyxstring::append(size_type n, value_type c) +string & string::append(size_type n, value_type c) { - TestlyxstringInvariant(this); + TeststringInvariant(this); value_type * tmp = new value_type[n]; memset(tmp, c, n); @@ -794,9 +798,9 @@ lyxstring & lyxstring::append(size_type n, value_type c) } -lyxstring & lyxstring::append(iterator first, iterator last) +string & string::append(iterator first, iterator last) { - TestlyxstringInvariant(this); + TeststringInvariant(this); rep = rep->get_own_copy(); rep->append(last - first, first); @@ -805,19 +809,19 @@ lyxstring & lyxstring::append(iterator first, iterator last) // insert characters before (*this)[pos] -lyxstring & lyxstring::insert(size_type pos, lyxstring const & x) +string & string::insert(size_type pos, string const & x) { - TestlyxstringInvariant(this); + TeststringInvariant(this); return insert(pos, x, 0, x.rep->sz); } -lyxstring & lyxstring::insert(size_type pos, lyxstring const & x, +string & string::insert(size_type pos, string const & x, size_type pos2, size_type n) { - lyx::Assert(pos <= rep->sz && pos2 <= x.rep->sz); // STD! - TestlyxstringInvariant(this); + Assert(pos <= rep->sz && pos2 <= x.rep->sz); // STD! + TeststringInvariant(this); rep = rep->get_own_copy(); rep->insert(pos, &(x.rep->s[pos2]), min(n, x.rep->sz)); @@ -825,10 +829,10 @@ lyxstring & lyxstring::insert(size_type pos, lyxstring const & x, } -lyxstring & lyxstring::insert(size_type pos, value_type const * p, size_type n) +string & string::insert(size_type pos, value_type const * p, size_type n) { - lyx::Assert(p); // OURS! - TestlyxstringInvariant(this); + Assert(p); // OURS! + TeststringInvariant(this); if (*p && n) { // insert nothing and you change nothing @@ -839,16 +843,16 @@ lyxstring & lyxstring::insert(size_type pos, value_type const * p, size_type n) } -lyxstring & lyxstring::insert(size_type pos, value_type const * p) +string & string::insert(size_type pos, value_type const * p) { - lyx::Assert(p); // OURS! + Assert(p); // OURS! return insert(pos, p, strlen(p)); } -lyxstring & lyxstring::insert(size_type pos, size_type n, value_type c) +string & string::insert(size_type pos, size_type n, value_type c) { - TestlyxstringInvariant(this); + TeststringInvariant(this); rep = rep->get_own_copy(); value_type * tmp = new value_type[n]; @@ -859,9 +863,9 @@ lyxstring & lyxstring::insert(size_type pos, size_type n, value_type c) } -lyxstring::iterator lyxstring::insert(iterator p, value_type c) +string::iterator string::insert(iterator p, value_type c) { - TestlyxstringInvariant(this); + TeststringInvariant(this); // what iterator is this supposed to return?? size_type tmp = p - begin(); @@ -870,17 +874,17 @@ lyxstring::iterator lyxstring::insert(iterator p, value_type c) } -void lyxstring::insert(iterator p, size_type n , value_type c) +void string::insert(iterator p, size_type n , value_type c) { - TestlyxstringInvariant(this); + TeststringInvariant(this); insert(p - begin(), n , c); } -void lyxstring::insert(iterator p, iterator first, iterator last) +void string::insert(iterator p, iterator first, iterator last) { - TestlyxstringInvariant(this); + TeststringInvariant(this); insert(p - begin(), first, last - first); } @@ -895,11 +899,11 @@ void lyxstring::insert(iterator p, iterator first, iterator last) // some of the parameters wrong, also some of the funcs can surely // be written more effectively. -lyxstring::size_type lyxstring::find(lyxstring const & a, size_type i) const +string::size_type string::find(string const & a, size_type i) const { if (!rep->sz || i >= rep->sz) return npos; - TestlyxstringInvariant(this); + TeststringInvariant(this); size_type n = a.length(); if (!n) return npos; @@ -921,13 +925,13 @@ lyxstring::size_type lyxstring::find(lyxstring const & a, size_type i) const } -lyxstring::size_type lyxstring::find(value_type const * ptr, size_type i, +string::size_type string::find(value_type const * ptr, size_type i, size_type n) const { - lyx::Assert(ptr); // OURS! + Assert(ptr); // OURS! if (!rep->sz || !*ptr || i >= rep->sz) return npos; - TestlyxstringInvariant(this); + TeststringInvariant(this); // What is "n" here? is it the number of value_types to use in ptr // or does "i" and "n" togeter form a substring to search @@ -953,23 +957,23 @@ lyxstring::size_type lyxstring::find(value_type const * ptr, size_type i, } -lyxstring::size_type lyxstring::find(value_type const * s, size_type i) const +string::size_type string::find(value_type const * s, size_type i) const { - lyx::Assert(s); // OURS! + Assert(s); // OURS! if (!rep->sz || i >= rep->sz) return npos; - TestlyxstringInvariant(this); + TeststringInvariant(this); if (!s || !*s) return npos; return find(s, i, strlen(s)); } -lyxstring::size_type lyxstring::find(value_type c, size_type i) const +string::size_type string::find(value_type c, size_type i) const { if (!rep->sz || i >= rep->sz) return npos; - TestlyxstringInvariant(this); + TeststringInvariant(this); for (size_type t = 0; t + i < rep->sz; ++t) { if (rep->s[t + i] == c) return t + i; @@ -978,9 +982,9 @@ lyxstring::size_type lyxstring::find(value_type c, size_type i) const } -lyxstring::size_type lyxstring::rfind(lyxstring const & a, size_type i) const +string::size_type string::rfind(string const & a, size_type i) const { - TestlyxstringInvariant(this); + TeststringInvariant(this); size_type n = a.length(); if (!n || rep->sz < n) @@ -1004,11 +1008,11 @@ lyxstring::size_type lyxstring::rfind(lyxstring const & a, size_type i) const } -lyxstring::size_type lyxstring::rfind(value_type const * ptr, size_type i, +string::size_type string::rfind(value_type const * ptr, size_type i, size_type n) const { - lyx::Assert(ptr); // OURS! - TestlyxstringInvariant(this); + Assert(ptr); // OURS! + TeststringInvariant(this); n = min(n, strlen(ptr)); if (!n || rep->sz < n) @@ -1032,19 +1036,19 @@ lyxstring::size_type lyxstring::rfind(value_type const * ptr, size_type i, } -lyxstring::size_type lyxstring::rfind(value_type const * ptr, +string::size_type string::rfind(value_type const * ptr, size_type i) const { - lyx::Assert(ptr); // OURS! + Assert(ptr); // OURS! if (!ptr || !*ptr) return npos; return rfind(ptr, i, strlen(ptr)); } -lyxstring::size_type lyxstring::rfind(value_type c, size_type i) const +string::size_type string::rfind(value_type c, size_type i) const { - TestlyxstringInvariant(this); + TeststringInvariant(this); size_type const sz = rep->sz; if (sz < 1) return npos; @@ -1056,11 +1060,11 @@ lyxstring::size_type lyxstring::rfind(value_type c, size_type i) const } -lyxstring::size_type lyxstring::find_first_of(lyxstring const & a, +string::size_type string::find_first_of(string const & a, size_type i) const { - lyx::Assert(i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(i <= rep->sz); // OURS! + TeststringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { if (a.find(rep->s[t]) != npos) return t; @@ -1069,12 +1073,12 @@ lyxstring::size_type lyxstring::find_first_of(lyxstring const & a, } -lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, +string::size_type string::find_first_of(value_type const * ptr, size_type i, size_type n) const { - lyx::Assert(ptr && i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(ptr && i <= rep->sz); // OURS! + TeststringInvariant(this); if (!n) return npos; for (size_type t = i; t < rep->sz; ++t) { @@ -1084,11 +1088,11 @@ lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, } -lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, +string::size_type string::find_first_of(value_type const * ptr, size_type i) const { - lyx::Assert(ptr && i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(ptr && i <= rep->sz); // OURS! + TeststringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { if (strchr(ptr, rep->s[t]) != 0) return t; @@ -1097,10 +1101,10 @@ lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, } -lyxstring::size_type lyxstring::find_first_of(value_type c, size_type i) const +string::size_type string::find_first_of(value_type c, size_type i) const { - lyx::Assert(i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(i <= rep->sz); // OURS! + TeststringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { if (rep->s[t] == c) return t; @@ -1109,10 +1113,10 @@ lyxstring::size_type lyxstring::find_first_of(value_type c, size_type i) const } -lyxstring::size_type lyxstring::find_last_of(lyxstring const & a, +string::size_type string::find_last_of(string const & a, size_type i) const { - TestlyxstringInvariant(this); + TeststringInvariant(this); size_type ii = min(rep->sz - 1, i); for (int t = ii; t >= 0; --t) { @@ -1122,12 +1126,12 @@ lyxstring::size_type lyxstring::find_last_of(lyxstring const & a, } -lyxstring::size_type lyxstring::find_last_of(value_type const * ptr, +string::size_type string::find_last_of(value_type const * ptr, size_type i, size_type n) const { - lyx::Assert(ptr); // OURS! - TestlyxstringInvariant(this); + Assert(ptr); // OURS! + TeststringInvariant(this); if (!n) return npos; size_type ii = min(rep->sz - 1, i); @@ -1138,11 +1142,11 @@ lyxstring::size_type lyxstring::find_last_of(value_type const * ptr, } -lyxstring::size_type lyxstring::find_last_of(value_type const * ptr, +string::size_type string::find_last_of(value_type const * ptr, size_type i) const { - lyx::Assert(ptr); // OURS! - TestlyxstringInvariant(this); + Assert(ptr); // OURS! + TeststringInvariant(this); size_type ii = min(rep->sz - 1, i); for (int t = ii; t >= 0; --t) { @@ -1152,9 +1156,9 @@ lyxstring::size_type lyxstring::find_last_of(value_type const * ptr, } -lyxstring::size_type lyxstring::find_last_of(value_type c, size_type i) const +string::size_type string::find_last_of(value_type c, size_type i) const { - TestlyxstringInvariant(this); + TeststringInvariant(this); if (!rep->sz) return npos; size_type ii = min(rep->sz - 1, i); @@ -1165,13 +1169,13 @@ lyxstring::size_type lyxstring::find_last_of(value_type c, size_type i) const } -lyxstring::size_type lyxstring::find_first_not_of(lyxstring const & a, +string::size_type string::find_first_not_of(string const & a, size_type i) const { - TestlyxstringInvariant(this); + TeststringInvariant(this); if (!rep->sz) return npos; - lyx::Assert(i <= rep->sz); + Assert(i <= rep->sz); for (size_type t = i; t < rep->sz; ++t) { if (a.find(rep->s[t]) == npos) return t; } @@ -1179,12 +1183,12 @@ lyxstring::size_type lyxstring::find_first_not_of(lyxstring const & a, } -lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr, +string::size_type string::find_first_not_of(value_type const * ptr, size_type i, size_type n) const { - lyx::Assert(ptr && i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(ptr && i <= rep->sz); // OURS! + TeststringInvariant(this); if (!n) return (i < rep->sz) ? i : npos; for (size_type t = i; t < rep->sz; ++t) { @@ -1194,11 +1198,11 @@ lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr, } -lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr, +string::size_type string::find_first_not_of(value_type const * ptr, size_type i) const { - lyx::Assert(ptr && i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(ptr && i <= rep->sz); // OURS! + TeststringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { if (strchr(ptr, rep->s[t]) == 0) return t; @@ -1207,12 +1211,12 @@ lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr, } -lyxstring::size_type lyxstring::find_first_not_of(value_type c, +string::size_type string::find_first_not_of(value_type c, size_type i) const { if (!rep->sz) return npos; - lyx::Assert(i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(i <= rep->sz); // OURS! + TeststringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { if (rep->s[t] != c) return t; @@ -1221,10 +1225,10 @@ lyxstring::size_type lyxstring::find_first_not_of(value_type c, } -lyxstring::size_type lyxstring::find_last_not_of(lyxstring const & a, +string::size_type string::find_last_not_of(string const & a, size_type i) const { - TestlyxstringInvariant(this); + TeststringInvariant(this); size_type ii = min(rep->sz - 1, i); for (int t = ii; t >= 0; --t) { @@ -1234,12 +1238,12 @@ lyxstring::size_type lyxstring::find_last_not_of(lyxstring const & a, } -lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr, +string::size_type string::find_last_not_of(value_type const * ptr, size_type i, size_type n) const { - lyx::Assert(ptr); // OURS! - TestlyxstringInvariant(this); + Assert(ptr); // OURS! + TeststringInvariant(this); if (!n) return npos; size_type ii = min(rep->sz - 1, i); @@ -1251,11 +1255,11 @@ lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr, } -lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr, +string::size_type string::find_last_not_of(value_type const * ptr, size_type i) const { - lyx::Assert(ptr); // OURS! - TestlyxstringInvariant(this); + Assert(ptr); // OURS! + TeststringInvariant(this); size_type ii = min(rep->sz - 1, i); for (int t = ii; t >= 0; --t) { @@ -1265,10 +1269,10 @@ lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr, } -lyxstring::size_type lyxstring::find_last_not_of(value_type c, +string::size_type string::find_last_not_of(value_type c, size_type i) const { - TestlyxstringInvariant(this); + TeststringInvariant(this); size_type ii = min(rep->sz - 1, i); for (int t = ii; t >= 0; --t) { @@ -1282,20 +1286,20 @@ lyxstring::size_type lyxstring::find_last_not_of(value_type c, // Replace ///////////////// -lyxstring & lyxstring::replace(size_type i, size_type n, lyxstring const & x) +string & string::replace(size_type i, size_type n, string const & x) { - lyx::Assert(i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(i <= rep->sz); // OURS! + TeststringInvariant(this); return replace(i, n, x, 0, x.rep->sz); } -lyxstring & lyxstring::replace(size_type i, size_type n, lyxstring const & x, +string & string::replace(size_type i, size_type n, string const & x, size_type i2, size_type n2) { - lyx::Assert(i <= rep->sz && i2 <= x.rep->sz); // STD! - TestlyxstringInvariant(this); + Assert(i <= rep->sz && i2 <= x.rep->sz); // STD! + TeststringInvariant(this); rep = rep->get_own_copy(); rep->replace(i, min(n, rep->sz), &(x.rep->s[i2]), min(n2, x.rep->sz)); @@ -1303,11 +1307,11 @@ lyxstring & lyxstring::replace(size_type i, size_type n, lyxstring const & x, } -lyxstring & lyxstring::replace(size_type i, size_type n, +string & string::replace(size_type i, size_type n, value_type const * p, size_type n2) { - lyx::Assert(p && i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(p && i <= rep->sz); // OURS! + TeststringInvariant(this); rep = rep->get_own_copy(); rep->replace(i, min(n, rep->sz), p, min(n2, strlen(p))); @@ -1315,20 +1319,20 @@ lyxstring & lyxstring::replace(size_type i, size_type n, } -lyxstring & lyxstring::replace(size_type i, size_type n, value_type const * p) +string & string::replace(size_type i, size_type n, value_type const * p) { - lyx::Assert(p && i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(p && i <= rep->sz); // OURS! + TeststringInvariant(this); return replace(i, min(n, rep->sz), p, (!p) ? 0 : strlen(p)); } -lyxstring & lyxstring::replace(size_type i, size_type n, +string & string::replace(size_type i, size_type n, size_type n2, value_type c) { - lyx::Assert(i <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(i <= rep->sz); // OURS! + TeststringInvariant(this); rep = rep->get_own_copy(); value_type * tmp = new value_type[n2]; @@ -1340,58 +1344,58 @@ lyxstring & lyxstring::replace(size_type i, size_type n, /// FY! FY! FY! go away ! -lyxstring & lyxstring::replace(size_type i, size_type n, value_type c) +string & string::replace(size_type i, size_type n, value_type c) { return replace(i, n, 1, c); } -lyxstring & lyxstring::replace(iterator i, iterator i2, const lyxstring & str) +string & string::replace(iterator i, iterator i2, const string & str) { - TestlyxstringInvariant(this); + TeststringInvariant(this); return replace(i - begin(), i2 - i, str); } -lyxstring & lyxstring::replace(iterator i, iterator i2, +string & string::replace(iterator i, iterator i2, value_type const * p, size_type n) { - lyx::Assert(p); // OURS! - TestlyxstringInvariant(this); + Assert(p); // OURS! + TeststringInvariant(this); return replace(i - begin(), i2 - i, p, n); } -lyxstring & lyxstring::replace(iterator i, iterator i2, value_type const * p) +string & string::replace(iterator i, iterator i2, value_type const * p) { - lyx::Assert(p); // OURS! - TestlyxstringInvariant(this); + Assert(p); // OURS! + TeststringInvariant(this); return replace(i - begin(), i2 - i, p); } -lyxstring & lyxstring::replace(iterator i, iterator i2, +string & string::replace(iterator i, iterator i2, size_type n , value_type c) { - TestlyxstringInvariant(this); + TeststringInvariant(this); return replace(i - begin(), i2 - i, n, c); } -lyxstring & lyxstring::replace(iterator i, iterator i2, +string & string::replace(iterator i, iterator i2, iterator j, iterator j2) { - TestlyxstringInvariant(this); + TeststringInvariant(this); return replace(i - begin(), i2 - i, j, j2 - j); } -void lyxstring::swap(lyxstring & str) +void string::swap(string & str) { if (rep == str.rep) return; Srep * tmp = str.rep; @@ -1400,10 +1404,10 @@ void lyxstring::swap(lyxstring & str) } -lyxstring & lyxstring::erase(size_type i, size_type n) +string & string::erase(size_type i, size_type n) { - lyx::Assert(i <= rep->sz); // STD! - TestlyxstringInvariant(this); + Assert(i <= rep->sz); // STD! + TeststringInvariant(this); rep = rep->get_own_copy(); if (i == 0 && n >= rep->sz) { @@ -1417,9 +1421,9 @@ lyxstring & lyxstring::erase(size_type i, size_type n) } -lyxstring::iterator lyxstring::erase(iterator i) +string::iterator string::erase(iterator i) { - TestlyxstringInvariant(this); + TeststringInvariant(this); // what iterator is this supposed to return? // the iterator after the one erased @@ -1428,9 +1432,9 @@ lyxstring::iterator lyxstring::erase(iterator i) } -lyxstring::iterator lyxstring::erase(iterator first, iterator last) +string::iterator string::erase(iterator first, iterator last) { - TestlyxstringInvariant(this); + TeststringInvariant(this); erase(first - begin(), last - first); return begin(); // BUG @@ -1441,25 +1445,25 @@ lyxstring::iterator lyxstring::erase(iterator first, iterator last) // Conversion to C-style Strings ///////////////////////////////////// -lyxstring::value_type const * lyxstring::c_str() const +string::value_type const * string::c_str() const { rep->s[length()] = '\0'; return rep->s; } -lyxstring::value_type const * lyxstring::data() const +string::value_type const * string::data() const { return rep->s; } -lyxstring::size_type lyxstring::copy(value_type * buf, size_type len, +string::size_type string::copy(value_type * buf, size_type len, size_type pos) const { - lyx::Assert(buf); // OURS! - lyx::Assert(pos <= rep->sz); // STD! - TestlyxstringInvariant(this); + Assert(buf); // OURS! + Assert(pos <= rep->sz); // STD! + TeststringInvariant(this); register int nn = min(len, length() - pos); memcpy(buf, &(rep->s[pos]), nn); @@ -1473,7 +1477,7 @@ lyxstring::size_type lyxstring::copy(value_type * buf, size_type len, // Compare funcs should be verified. -int lyxstring::internal_compare(size_type pos, size_type n, +int string::internal_compare(size_type pos, size_type n, value_type const * s, size_type slen, size_type n2) const { @@ -1496,49 +1500,49 @@ int lyxstring::internal_compare(size_type pos, size_type n, } -int lyxstring::compare(lyxstring const & str) const +int string::compare(string const & str) const { - TestlyxstringInvariant(this); + TeststringInvariant(this); return internal_compare(0, rep->sz, str.rep->s, str.rep->sz, str.rep->sz); } -int lyxstring::compare(value_type const * s) const +int string::compare(value_type const * s) const { - lyx::Assert(s); //OURS! - TestlyxstringInvariant(this); + Assert(s); //OURS! + TeststringInvariant(this); int n = (!s) ? 0 : strlen(s); return internal_compare(0, rep->sz, s, n, n); } -int lyxstring::compare(size_type pos, size_type n, - lyxstring const & str) const +int string::compare(size_type pos, size_type n, + string const & str) const { - lyx::Assert(pos <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(pos <= rep->sz); // OURS! + TeststringInvariant(this); return internal_compare(pos, n, str.rep->s, str.rep->sz, str.rep->sz); } -int lyxstring::compare(size_type pos, size_type n, lyxstring const & str, +int string::compare(size_type pos, size_type n, string const & str, size_type pos2, size_type n2) const { - lyx::Assert(pos <= rep->sz); // OURS! - lyx::Assert(pos2 <= str.rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(pos <= rep->sz); // OURS! + Assert(pos2 <= str.rep->sz); // OURS! + TeststringInvariant(this); return internal_compare(pos, n, str.rep->s + pos2, str.rep->sz - pos2, n2); } -int lyxstring::compare(size_type pos, size_type n, value_type const * s, +int string::compare(size_type pos, size_type n, value_type const * s, size_type n2) const { - lyx::Assert(s && pos <= rep->sz); // OURS! - TestlyxstringInvariant(this); + Assert(s && pos <= rep->sz); // OURS! + TeststringInvariant(this); return internal_compare(pos, n, s, (!s) ? 0 : strlen(s), n2); } @@ -1548,12 +1552,12 @@ int lyxstring::compare(size_type pos, size_type n, value_type const * s, ///////////////// // i = index, n = length -lyxstring lyxstring::substr(size_type i, size_type n) const +string string::substr(size_type i, size_type n) const { - lyx::Assert(i <= rep->sz); // STD! - TestlyxstringInvariant(this); + Assert(i <= rep->sz); // STD! + TeststringInvariant(this); - return lyxstring(*this, i, n); + return string(*this, i, n); } @@ -1561,184 +1565,182 @@ lyxstring lyxstring::substr(size_type i, size_type n) const // String operators, non member functions ///////////////////////////////////////////// -bool operator==(lyxstring const & a, lyxstring const & b) +bool operator==(string const & a, string const & b) { return a.compare(b) == 0; } -bool operator==(lyxstring::value_type const * a, lyxstring const & b) +bool operator==(string::value_type const * a, string const & b) { - lyx::Assert(a); // OURS! + Assert(a); // OURS! return b.compare(a) == 0; } -bool operator==(lyxstring const & a, lyxstring::value_type const * b) +bool operator==(string const & a, string::value_type const * b) { - lyx::Assert(b); // OURS! + Assert(b); // OURS! return a.compare(b) == 0; } -bool operator!=(lyxstring const & a, lyxstring const & b) +bool operator!=(string const & a, string const & b) { return a.compare(b) != 0; } -bool operator!=(lyxstring::value_type const * a, lyxstring const & b) +bool operator!=(string::value_type const * a, string const & b) { - lyx::Assert(a); // OURS! + Assert(a); // OURS! return b.compare(a) != 0; } -bool operator!=(lyxstring const & a, lyxstring::value_type const * b) +bool operator!=(string const & a, string::value_type const * b) { - lyx::Assert(b); // OURS! + Assert(b); // OURS! return a.compare(b) != 0; } -bool operator>(lyxstring const & a, lyxstring const & b) +bool operator>(string const & a, string const & b) { return a.compare(b) > 0; } -bool operator>(lyxstring::value_type const * a, lyxstring const & b) +bool operator>(string::value_type const * a, string const & b) { - lyx::Assert(a); // OURS! + Assert(a); // OURS! return b.compare(a) < 0; // since we reverse the parameters } -bool operator>(lyxstring const & a, lyxstring::value_type const * b) +bool operator>(string const & a, string::value_type const * b) { - lyx::Assert(b); // OURS! + Assert(b); // OURS! return a.compare(b) > 0; } -bool operator<(lyxstring const & a, lyxstring const & b) +bool operator<(string const & a, string const & b) { return a.compare(b) < 0; } -bool operator<(lyxstring::value_type const * a, lyxstring const & b) +bool operator<(string::value_type const * a, string const & b) { - lyx::Assert(a); // OURS! + Assert(a); // OURS! return b.compare(a) > 0; // since we reverse the parameters } -bool operator<(lyxstring const & a, lyxstring::value_type const * b) +bool operator<(string const & a, string::value_type const * b) { - lyx::Assert(b); // OURS! + Assert(b); // OURS! return a.compare(b) < 0; } -bool operator>=(lyxstring const & a, lyxstring const & b) +bool operator>=(string const & a, string const & b) { return a.compare(b) >= 0; } -bool operator>=(lyxstring::value_type const * a, lyxstring const & b) +bool operator>=(string::value_type const * a, string const & b) { - lyx::Assert(a); // OURS! + Assert(a); // OURS! return b.compare(a) <= 0; // since we reverse the parameters } -bool operator>=(lyxstring const & a, lyxstring::value_type const * b) +bool operator>=(string const & a, string::value_type const * b) { - lyx::Assert(b); // OURS! + Assert(b); // OURS! return a.compare(b) >= 0; } -bool operator<=(lyxstring const & a, lyxstring const & b) +bool operator<=(string const & a, string const & b) { return a.compare(b) <= 0; } -bool operator<=(lyxstring::value_type const * a, lyxstring const & b) +bool operator<=(string::value_type const * a, string const & b) { - lyx::Assert(a); // OURS! + Assert(a); // OURS! return b.compare(a) >= 0; // since we reverse the parameters } -bool operator<=(lyxstring const & a, lyxstring::value_type const * b) +bool operator<=(string const & a, string::value_type const * b) { - lyx::Assert(b); // OURS! + Assert(b); // OURS! return a.compare(b) <= 0; } -lyxstring operator+(lyxstring const & a, lyxstring const & b) +string operator+(string const & a, string const & b) { - lyxstring tmp(a); + string tmp(a); tmp += b; return tmp; } -lyxstring operator+(lyxstring::value_type const * a, lyxstring const & b) +string operator+(string::value_type const * a, string const & b) { - lyx::Assert(a); // OURS! - lyxstring tmp(a); + Assert(a); // OURS! + string tmp(a); tmp += b; return tmp; } -lyxstring operator+(lyxstring::value_type a, lyxstring const & b) +string operator+(string::value_type a, string const & b) { - lyxstring tmp; + string tmp; tmp += a; tmp += b; return tmp; } -lyxstring operator+(lyxstring const & a, lyxstring::value_type const * b) +string operator+(string const & a, string::value_type const * b) { - lyx::Assert(b); // OURS! - lyxstring tmp(a); + Assert(b); // OURS! + string tmp(a); tmp += b; return tmp; } -lyxstring operator+(lyxstring const & a, lyxstring::value_type b) +string operator+(string const & a, string::value_type b) { - lyxstring tmp(a); + string tmp(a); tmp += b; return tmp; } -void swap(lyxstring & str1, lyxstring & str2) +void swap(string & str1, string & str2) { str1.swap(str2); } -#include - -istream & operator>>(istream & is, lyxstring & s) +istream & operator>>(istream & is, string & s) { #if 0 // very bad solution char * nome = new char[1024]; is >> nome; - lyxstring tmp(nome); + string tmp(nome); delete [] nome; if (!tmp.empty()) s = tmp; #else @@ -1765,14 +1767,14 @@ istream & operator>>(istream & is, lyxstring & s) } -ostream & operator<<(ostream & o, lyxstring const & s) +ostream & operator<<(ostream & o, string const & s) { return o.write(s.data(), s.length()); } -istream & getline(istream & is, lyxstring & s, - lyxstring::value_type delim) +istream & getline(istream & is, string & s, + string::value_type delim) { // very bad solution char tmp = 0; @@ -1788,9 +1790,11 @@ istream & getline(istream & is, lyxstring & s, return is; } +} // namespace lyx + #ifdef TEST_MAIN int main() { - lyxstring a = "abcac"; + lyx::string a = "abcac"; cout << a.rfind("ab") << endl; cout << a.rfind("c") << endl; cout << a.rfind("d") << endl; diff --git a/src/support/lyxstring.h b/src/support/lyxstring.h index 508a066143..6ff86e65d3 100644 --- a/src/support/lyxstring.h +++ b/src/support/lyxstring.h @@ -29,6 +29,8 @@ #include // for size_t +namespace lyx { + /** A string class for LyX This is a permanent String class. It is modeled closely after the C++ STL @@ -84,7 +86,7 @@ When you want to copy an lyxstring, just do The class automatically handles deep copying when required. */ -class lyxstring { +class string { public: /* Typedefs */ @@ -146,28 +148,28 @@ public: /// "all characters" marker static const size_type npos; - /// #lyxstring x;# - lyxstring(); + /// #string x;# + string(); - /// #lyxstring x(lyxstring ...)# - lyxstring(lyxstring const &, size_type pos = 0, size_type n = npos); + /// #string x(string ...)# + string(string const &, size_type pos = 0, size_type n = npos); - /// #lyxstring x("abc", 2) -> "ab"# - lyxstring(value_type const *, size_type n); + /// #string x("abc", 2) -> "ab"# + string(value_type const *, size_type n); - // #lyxstring x("abc")# - lyxstring(value_type const *); + // #string x("abc")# + string(value_type const *); - /// lyxstring(5, 'n') -> "nnnnn" - lyxstring(size_type n, value_type c); + /// string(5, 'n') -> "nnnnn" + string(size_type n, value_type c); #if 0 /// - lyxstring(const_iterator first, const_iterator last); + string(const_iterator first, const_iterator last); #else /// template - lyxstring::lyxstring(InputIterator begin, InputIterator end) { + string(InputIterator begin, InputIterator end) { while (begin != end) { push_back(*begin); ++begin; @@ -175,7 +177,7 @@ public: } #endif /// - ~lyxstring(); + ~string(); /// number of characters size_type size() const; @@ -202,36 +204,36 @@ public: void reserve(size_type res_arg = 0); /// - lyxstring & operator=(lyxstring const &); + string & operator=(string const &); /// - lyxstring & operator=(value_type const *); + string & operator=(value_type const *); /// - lyxstring & operator=(value_type); + string & operator=(value_type); /// - lyxstring & assign(lyxstring const &); + string & assign(string const &); /// - lyxstring & assign(lyxstring const &, size_type pos, size_type n); + string & assign(string const &, size_type pos, size_type n); /// - lyxstring & assign(value_type const * p, size_type n); + string & assign(value_type const * p, size_type n); /// - lyxstring & assign(value_type const * p); + string & assign(value_type const * p); /// - lyxstring & assign(size_type n, value_type c); + string & assign(size_type n, value_type c); #if 1 /// - lyxstring & assign(const_iterator first, const_iterator last); + string & assign(const_iterator first, const_iterator last); #else /// template - lyxstring & assign(InputIterator begin, InputIterator end) { + string & assign(InputIterator begin, InputIterator end) { clear; while (begin != end) { push_back((*begin)); @@ -255,39 +257,39 @@ public: // add characters after (*this)[length()-1]: /// - lyxstring & operator+=(lyxstring const &); + string & operator+=(string const &); /// - lyxstring & operator+=(value_type const *); + string & operator+=(value_type const *); /// - lyxstring & operator+=(value_type); + string & operator+=(value_type); /// void push_back(value_type); /// - lyxstring & append(lyxstring const &); + string & append(string const &); /// - lyxstring & append(lyxstring const &, size_type pos, size_type n); + string & append(string const &, size_type pos, size_type n); /// - lyxstring & append(value_type const *, size_type n); + string & append(value_type const *, size_type n); /// - lyxstring & append(value_type const *); + string & append(value_type const *); /// - lyxstring & append(size_type n, value_type); + string & append(size_type n, value_type); #if 1 /// - lyxstring & append(iterator first, iterator last); + string & append(iterator first, iterator last); #else /// template - lyxstring & append(InputIterator begin, InputIterator end) { + string & append(InputIterator begin, InputIterator end) { while (begin != end) { push_back((*begin)); ++begin; @@ -298,21 +300,21 @@ public: // insert characters before (*this)[pos]: /// - lyxstring & insert(size_type pos, lyxstring const &); + string & insert(size_type pos, string const &); /// - lyxstring & insert(size_type pos, lyxstring const &, + string & insert(size_type pos, string const &, size_type pos2, size_type n); /// - lyxstring & insert(size_type pos, value_type const * p, + string & insert(size_type pos, value_type const * p, size_type n); /// - lyxstring & insert(size_type pos, value_type const * p); + string & insert(size_type pos, value_type const * p); /// - lyxstring & insert(size_type pos, size_type n, value_type c); + string & insert(size_type pos, size_type n, value_type c); // insert characters before p @@ -338,7 +340,7 @@ public: #endif /// - size_type find(lyxstring const &, size_type i = 0) const; + size_type find(string const &, size_type i = 0) const; /// size_type find(value_type const * p, @@ -351,7 +353,7 @@ public: size_type find(value_type c, size_type i = 0) const; /// - size_type rfind(lyxstring const &, size_type i = npos) const; + size_type rfind(string const &, size_type i = npos) const; /// size_type rfind(value_type const * p, size_type i, size_type n) const; @@ -363,7 +365,7 @@ public: size_type rfind(value_type c, size_type i = npos) const; /// - size_type find_first_of(lyxstring const &, size_type i = 0) const; + size_type find_first_of(string const &, size_type i = 0) const; /// size_type find_first_of(value_type const * p, size_type i, @@ -376,7 +378,7 @@ public: size_type find_first_of(value_type c, size_type i = 0) const; /// - size_type find_last_of(lyxstring const &, size_type i = npos) const; + size_type find_last_of(string const &, size_type i = npos) const; /// size_type find_last_of(value_type const * p, size_type i, @@ -389,7 +391,7 @@ public: size_type find_last_of(value_type c, size_type i = npos) const; /// - size_type find_first_not_of(lyxstring const &, size_type i = 0) const; + size_type find_first_not_of(string const &, size_type i = 0) const; /// size_type find_first_not_of(value_type const * p, size_type i, @@ -403,7 +405,7 @@ public: size_type find_first_not_of(value_type c, size_type i = 0) const; /// - size_type find_last_not_of(lyxstring const &, + size_type find_last_not_of(string const &, size_type i = npos) const; /// @@ -420,52 +422,52 @@ public: // replace [(*this)[i], (*this)[i+n]] with other characters: /// - lyxstring & replace(size_type i, size_type n, lyxstring const & str); + string & replace(size_type i, size_type n, string const & str); /// - lyxstring & replace(size_type i, size_type n, lyxstring const & s, + string & replace(size_type i, size_type n, string const & s, size_type i2, size_type n2); /// - lyxstring & replace(size_type i, size_type n, value_type const * p, + string & replace(size_type i, size_type n, value_type const * p, size_type n2); /// - lyxstring & replace(size_type i, size_type n, value_type const * p); + string & replace(size_type i, size_type n, value_type const * p); /// - lyxstring & replace(size_type i, size_type n, + string & replace(size_type i, size_type n, size_type n2, value_type c); /// FY! FY! FY! go away ! - lyxstring & replace(size_type i, size_type n, + string & replace(size_type i, size_type n, value_type c); /// - lyxstring & replace(iterator i, iterator i2, const lyxstring & str); + string & replace(iterator i, iterator i2, const string & str); /// - lyxstring & replace(iterator i, iterator i2, + string & replace(iterator i, iterator i2, value_type const * p, size_type n); /// - lyxstring & replace(iterator i, iterator i2, value_type const * p); + string & replace(iterator i, iterator i2, value_type const * p); /// - lyxstring & replace(iterator i, iterator i2, + string & replace(iterator i, iterator i2, size_type n , value_type c); /// - lyxstring & replace(iterator i, iterator i2, iterator j, iterator j2); + string & replace(iterator i, iterator i2, iterator j, iterator j2); /// - void swap(lyxstring & str); + void swap(string & str); /// Erase n chars from position i. - lyxstring & erase(size_type i = 0, size_type n = npos); + string & erase(size_type i = 0, size_type n = npos); /// - lyxstring & clear() { + string & clear() { return erase(0, npos); } @@ -490,16 +492,16 @@ public: /// - int compare(lyxstring const & str) const; + int compare(string const & str) const; /// int compare(value_type const * p) const; /// - int compare(size_type pos, size_type n, lyxstring const & str) const; + int compare(size_type pos, size_type n, string const & str) const; /// - int compare(size_type pos, size_type n, lyxstring const & str, + int compare(size_type pos, size_type n, string const & str, size_type pos2, size_type n2) const; /// @@ -508,7 +510,7 @@ public: /// - lyxstring substr(size_type i = 0, size_type n = npos) const; + string substr(size_type i = 0, size_type n = npos) const; private: // These three operators can be used to discover erronous use of @@ -517,11 +519,11 @@ private: // in. Use them for debugging only (or perhaps not even then.) // Lgb. // - //lyxstring & operator+(int); + //string & operator+(int); // - //lyxstring & operator=(int); + //string & operator=(int); // - //lyxstring & operator+=(int); + //string & operator+=(int); /// Compare this with s. works with embedded '\0' chars also. int internal_compare(size_type pos, size_type n, @@ -537,7 +539,7 @@ private: Srep * rep; /* Note: The empty_rep is a local static in each function that - benefits from one. There is no "global" empty srep but lyxstring + benefits from one. There is no "global" empty srep but string doesn't need one (no code actually relies upon a single empty srep). This overcomes *all* "static initialization" problems, @@ -547,55 +549,57 @@ private: #ifdef ENABLE_ASSERTIONS /// lyxstringInvariant is used to test the lyxstring Invariant - friend class lyxstringInvariant; + friend class stringInvariant; #endif }; // The usual comparison operators ==, !=, >, <, >=, <= are // provided for lyxstrings -bool operator==(lyxstring const &, lyxstring const &); -bool operator==(lyxstring::value_type const *, lyxstring const &); -bool operator==(lyxstring const &, lyxstring::value_type const *); +bool operator==(string const &, string const &); +bool operator==(string::value_type const *, string const &); +bool operator==(string const &, string::value_type const *); -bool operator!=(lyxstring const &, lyxstring const &); -bool operator!=(lyxstring::value_type const *, lyxstring const &); -bool operator!=(lyxstring const &, lyxstring::value_type const *); +bool operator!=(string const &, string const &); +bool operator!=(string::value_type const *, string const &); +bool operator!=(string const &, string::value_type const *); -bool operator>(lyxstring const &, lyxstring const &); -bool operator>(lyxstring::value_type const *, lyxstring const &); -bool operator>(lyxstring const &, lyxstring::value_type const *); +bool operator>(string const &, string const &); +bool operator>(string::value_type const *, string const &); +bool operator>(string const &, string::value_type const *); -bool operator<(lyxstring const &, lyxstring const &); -bool operator<(lyxstring::value_type const *, lyxstring const &); -bool operator<(lyxstring const &, lyxstring::value_type const *); +bool operator<(string const &, string const &); +bool operator<(string::value_type const *, string const &); +bool operator<(string const &, string::value_type const *); -bool operator>=(lyxstring const &, lyxstring const &); -bool operator>=(lyxstring::value_type const *, lyxstring const &); -bool operator>=(lyxstring const &, lyxstring::value_type const *); +bool operator>=(string const &, string const &); +bool operator>=(string::value_type const *, string const &); +bool operator>=(string const &, string::value_type const *); -bool operator<=(lyxstring const &, lyxstring const &); -bool operator<=(lyxstring::value_type const *, lyxstring const &); -bool operator<=(lyxstring const &, lyxstring::value_type const *); +bool operator<=(string const &, string const &); +bool operator<=(string::value_type const *, string const &); +bool operator<=(string const &, string::value_type const *); // Concatenation -lyxstring operator+(lyxstring const & a, lyxstring const & b); -lyxstring operator+(char const * a, lyxstring const & b); -lyxstring operator+(lyxstring::value_type a, lyxstring const & b); -lyxstring operator+(lyxstring const & a, lyxstring::value_type const * b); -lyxstring operator+(lyxstring const & a, lyxstring::value_type b); +string operator+(string const & a, string const & b); +string operator+(char const * a, string const & b); +string operator+(string::value_type a, string const & b); +string operator+(string const & a, string::value_type const * b); +string operator+(string const & a, string::value_type b); + +void swap(string & s1, string & s2); -void swap(lyxstring & s1, lyxstring & s2); +std::istream & operator>>(std::istream &, string &); +std::ostream & operator<<(std::ostream &, string const &); +std::istream & getline(std::istream &, string &, string::value_type delim = '\n'); -std::istream & operator>>(std::istream &, lyxstring &); -std::ostream & operator<<(std::ostream &, lyxstring const &); -std::istream & getline(std::istream &, lyxstring &, lyxstring::value_type delim = '\n'); +} // namespace lyx #endif diff --git a/src/support/lyxsum.C b/src/support/lyxsum.C index f7e89fa200..6d6bbb5f02 100644 --- a/src/support/lyxsum.C +++ b/src/support/lyxsum.C @@ -42,7 +42,7 @@ template class boost::detail::crc_table_t<32, 0x04C11DB7, true>; #include -unsigned long lyx::sum(string const & file) +unsigned long lyx::support::sum(string const & file) { lyxerr[Debug::FILES] << "lyx::sum() using mmap (lightning fast)" << endl; @@ -98,7 +98,7 @@ unsigned long do_crc(InputIterator first, InputIterator last) using std::ifstream; using std::istreambuf_iterator; -unsigned long lyx::sum(string const & file) +unsigned long lyx::support::sum(string const & file) { lyxerr[Debug::FILES] << "lyx::sum() using istreambuf_iterator (fast)" << endl; @@ -116,7 +116,7 @@ unsigned long lyx::sum(string const & file) using std::istream_iterator; using std::ios; -unsigned long lyx::sum(string const & file) +unsigned long lyx::support::sum(string const & file) { lyxerr[Debug::FILES] << "lyx::sum() using istream_iterator (slow as a snail)" diff --git a/src/support/mkdir.C b/src/support/mkdir.C index 577b3a0613..e45d46728e 100644 --- a/src/support/mkdir.C +++ b/src/support/mkdir.C @@ -19,7 +19,7 @@ #include "lyxlib.h" -int lyx::mkdir(string const & pathname, unsigned long int mode) +int lyx::support::mkdir(string const & pathname, unsigned long int mode) { // FIXME: why don't we have mode_t in lyx::mkdir prototype ?? return ::mkdir(pathname.c_str(), mode_t(mode)); diff --git a/src/support/os.h b/src/support/os.h index 6edc511786..5d6c47f729 100644 --- a/src/support/os.h +++ b/src/support/os.h @@ -15,43 +15,49 @@ #include "LString.h" /// wrap OS specific stuff +namespace lyx { +namespace support { namespace os { - // - enum shell_type { - UNIX, // Do we have to distinguish sh and csh? - CMD_EXE - }; - // do some work just once - void init(int * argc, char ** argv[]); - // returns path of LyX binary - string binpath(); - // returns name of LyX binary - string binname(); - // system_tempdir actually doesn't belong here - // I put it here only to avoid a global variable. - void setTmpDir(string const & p); - // - string getTmpDir(); - // - string current_root(); - // - shell_type shell(); - // DBCS aware! - string::size_type common_path(string const & p1, string const & p2); - // no-op on UNIX, '\\'->'/' on OS/2 and Win32, ':'->'/' on MacOS, etc. - string slashify_path(string const & p); - // converts a host OS path to unix style - string external_path(string const & p); - // converts a unix path to host OS style - string internal_path(string const & p); - // is path absolute? - bool is_absolute_path(string const & p); - // returns a string suitable to be passed to popen when - // same for popen(). +// +enum shell_type { + UNIX, // Do we have to distinguish sh and csh? + CMD_EXE +}; + +// do some work just once +void init(int * argc, char ** argv[]); +// returns path of LyX binary +string binpath(); +// returns name of LyX binary +string binname(); +// system_tempdir actually doesn't belong here +// I put it here only to avoid a global variable. +void setTmpDir(string const & p); +// +string getTmpDir(); +// +string current_root(); +// +shell_type shell(); +// DBCS aware! +string::size_type common_path(string const & p1, string const & p2); +// no-op on UNIX, '\\'->'/' on OS/2 and Win32, ':'->'/' on MacOS, etc. +string slashify_path(string const & p); +// converts a host OS path to unix style +string external_path(string const & p); +// converts a unix path to host OS style +string internal_path(string const & p); +// is path absolute? +bool is_absolute_path(string const & p); +// returns a string suitable to be passed to popen when +// same for popen(). char const * popen_read_mode(); - // - void warn(string const & mesg); -} +// +void warn(string const & mesg); + +} // namespace os +} // namespace support +} // namespace lyx #endif diff --git a/src/support/os_unix.C b/src/support/os_unix.C index ddff701f52..716dce17f4 100644 --- a/src/support/os_unix.C +++ b/src/support/os_unix.C @@ -24,7 +24,8 @@ string tmpdir_; } - +namespace lyx { +namespace support { namespace os { void init(int * /*argc*/, char ** argv[]) @@ -144,4 +145,6 @@ shell_type shell() return UNIX; } -} // end namespace os +} // namespace os +} // namespace support +} // namespace lyx diff --git a/src/support/path.C b/src/support/path.C index 23f13dcbb1..31e2842019 100644 --- a/src/support/path.C +++ b/src/support/path.C @@ -12,6 +12,9 @@ #include "path.h" +namespace lyx { +namespace support { + int Path::pop() { if (popped_) { @@ -20,7 +23,7 @@ int Path::pop() return 0; } - if (lyx::chdir(pushedDir_)) { + if (chdir(pushedDir_)) { // should throw an exception // throw DirChangeError(); } @@ -28,3 +31,6 @@ int Path::pop() return 0; } + +} // namespace support +} // namespace lyx diff --git a/src/support/path.h b/src/support/path.h index 55b7c2bdb7..1e71fbad88 100644 --- a/src/support/path.h +++ b/src/support/path.h @@ -16,6 +16,9 @@ #include "lyxlib.h" #include +namespace lyx { +namespace support { + /** * Path - utility closs for stackable working directories * @@ -37,8 +40,8 @@ public: : popped_(false) { if (!path.empty()) { - pushedDir_ = lyx::getcwd(); - if (pushedDir_.empty() || lyx::chdir(path)) + pushedDir_ = getcwd(); + if (pushedDir_.empty() || chdir(path)) /* FIXME: throw */; } else { popped_ = true; @@ -68,4 +71,7 @@ private: #define Path(x) unnamed_Path; // Tip gotten from Bobby Schmidt's column in C/C++ Users Journal +} // namespace support +} // namespace lyx + #endif // PATH_H diff --git a/src/support/putenv.C b/src/support/putenv.C index 828517d09f..68c37b692f 100644 --- a/src/support/putenv.C +++ b/src/support/putenv.C @@ -14,7 +14,7 @@ #include -int lyx::putenv(char const * str) +int lyx::support::putenv(char const * str) { return ::putenv(const_cast(str)); } diff --git a/src/support/rename.C b/src/support/rename.C index 4a927fdf71..a8cb72c5c2 100644 --- a/src/support/rename.C +++ b/src/support/rename.C @@ -14,14 +14,14 @@ #include "support/lyxlib.h" -bool lyx::rename(string const & from, string const & to) +bool lyx::support::rename(string const & from, string const & to) { #ifdef __EMX__ - lyx::unlink(to.c_str()); + unlink(to); #endif if (::rename(from.c_str(), to.c_str()) == -1) - if (lyx::copy(from, to)) { - lyx::unlink(from); + if (copy(from, to)) { + unlink(from); return true; } else return false; diff --git a/src/support/rmdir.C b/src/support/rmdir.C index a2aeeb8a08..68529657fd 100644 --- a/src/support/rmdir.C +++ b/src/support/rmdir.C @@ -14,7 +14,7 @@ #include "lyxlib.h" -int lyx::rmdir(string const & dir) +int lyx::support::rmdir(string const & dir) { return ::rmdir(dir.c_str()); } diff --git a/src/support/systemcall.C b/src/support/systemcall.C index b9a196d2ca..939d9dcba5 100644 --- a/src/support/systemcall.C +++ b/src/support/systemcall.C @@ -22,6 +22,9 @@ using std::system; #endif +namespace lyx { +namespace support { + // Reuse of instance int Systemcall::startscript(Starttype how, string const & what) { @@ -37,3 +40,6 @@ int Systemcall::startscript(Starttype how, string const & what) return ::system(command.c_str()); } + +} // namespace support +} // namespace lyx diff --git a/src/support/systemcall.h b/src/support/systemcall.h index d993b08f33..fda1b12bf1 100644 --- a/src/support/systemcall.h +++ b/src/support/systemcall.h @@ -17,6 +17,9 @@ #include "LString.h" +namespace lyx { +namespace support { + /** * An instance of Class Systemcall represents a single child process. * @@ -42,4 +45,7 @@ public: int startscript(Starttype how, string const & what); }; +} // namespace support +} // namespace lyx + #endif // SYSTEMCALL_H diff --git a/src/support/tempname.C b/src/support/tempname.C index 780b1939c2..8dea9a6adf 100644 --- a/src/support/tempname.C +++ b/src/support/tempname.C @@ -22,7 +22,6 @@ using std::endl; - namespace { inline @@ -42,7 +41,7 @@ int make_tempfile(char * templ) } // namespace anon -string const lyx::tempName(string const & dir, string const & mask) +string const lyx::support::tempName(string const & dir, string const & mask) { string const tmpdir(dir.empty() ? os::getTmpDir() : dir); string tmpfl(AddName(tmpdir, mask)); diff --git a/src/support/translator.h b/src/support/translator.h index 17d2bae887..bdd9d83434 100644 --- a/src/support/translator.h +++ b/src/support/translator.h @@ -50,7 +50,7 @@ public: /// Find the mapping for the first argument T2 const & find(T1 const & first) const { - lyx::Assert(!map.empty()); + Assert(!map.empty()); // For explanation see the next find() function. typename Map::const_iterator it = @@ -67,7 +67,7 @@ public: /// Find the mapping for the second argument T1 const & find(T2 const & second) const { - lyx::Assert(!map.empty()); + Assert(!map.empty()); // The idea is as follows: // find_if() will try to compare the data in the vector with diff --git a/src/support/unlink.C b/src/support/unlink.C index dd7e16e3b1..2c5d78f8f1 100644 --- a/src/support/unlink.C +++ b/src/support/unlink.C @@ -14,7 +14,7 @@ #include "lyxlib.h" -int lyx::unlink(string const & pathname) +int lyx::support::unlink(string const & pathname) { return ::unlink(pathname.c_str()); } diff --git a/src/support/userinfo.C b/src/support/userinfo.C index 3024743383..24a84637df 100644 --- a/src/support/userinfo.C +++ b/src/support/userinfo.C @@ -19,11 +19,12 @@ #include namespace lyx { +namespace support { string const user_name() { struct passwd * pw(getpwuid(geteuid())); - lyx::Assert(pw); + Assert(pw); string name = pw->pw_gecos; if (name.empty()) @@ -40,5 +41,5 @@ string const user_email() return email; } - +} // namespace support } // namespace lyx diff --git a/src/support/userinfo.h b/src/support/userinfo.h index 4e2042a145..a451a588c4 100644 --- a/src/support/userinfo.h +++ b/src/support/userinfo.h @@ -15,6 +15,7 @@ #include "LString.h" namespace lyx { +namespace support { /// return the current user's real name string const user_name(); @@ -22,6 +23,7 @@ string const user_name(); /// return the current user's e-mail address string const user_email(); -}; // namespace lyx +} // namespace support +} // namespace lyx #endif // USERINFO_H diff --git a/src/tabular.C b/src/tabular.C index b2a60adc34..6496fbae99 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -37,6 +37,8 @@ #include #include +using namespace lyx::support; + using std::abs; using std::ostream; using std::istream; @@ -149,7 +151,7 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt) // If this and lt is not of the same size we have a serious bug // So then it is ok to throw an exception, or for now // call abort() - lyx::Assert(rows_ == lt.rows_ && columns_ == lt.columns_); + Assert(rows_ == lt.rows_ && columns_ == lt.columns_); cur_cell = -1; cell_info = lt.cell_info; row_info = lt.row_info; @@ -426,7 +428,7 @@ int LyXTabular::numberOfCellsInRow(int cell) const } -// returns 1 if there is a topline, returns 0 if not +// returns 1 if there is a topline, returns 0 if not bool LyXTabular::topLine(int cell, bool onlycolumn) const { int const row = row_of_cell(cell); @@ -1169,14 +1171,14 @@ void LyXTabular::read(Buffer const * buf, LyXLex & lex) l_getline(is, line); if (!prefixIs(line, "= 2); + Assert(version >= 2); int rows_arg; if (!getTokenValue(line, "rows", rows_arg)) @@ -1479,7 +1481,7 @@ int LyXTabular::getCellNumber(int row, int column) const else if (row < 0) row = 0; #else - lyx::Assert(column >= 0 || column < columns_ || row >= 0 || row < rows_); + Assert(column >= 0 || column < columns_ || row >= 0 || row < rows_); #endif return cell_info[row][column].cellno; } diff --git a/src/tabular_funcs.C b/src/tabular_funcs.C index ac2e2fbfe2..4d88ecd75c 100644 --- a/src/tabular_funcs.C +++ b/src/tabular_funcs.C @@ -17,6 +17,8 @@ #include "support/LIstream.h" #include "support/lstrings.h" +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::strlen; #endif diff --git a/src/text.C b/src/text.C index 4396e19894..3109fcbe4c 100644 --- a/src/text.C +++ b/src/text.C @@ -43,6 +43,8 @@ #include +using namespace lyx::support; + using std::max; using std::min; using std::endl; @@ -62,14 +64,14 @@ extern int bibitemMaxWidth(BufferView *, LyXFont const &); BufferView * LyXText::bv() { - lyx::Assert(bv_owner != 0); + Assert(bv_owner != 0); return bv_owner; } BufferView * LyXText::bv() const { - lyx::Assert(bv_owner != 0); + Assert(bv_owner != 0); return bv_owner; } @@ -150,10 +152,10 @@ int LyXText::workWidth(Inset const * inset) const ParagraphList::iterator par = std::find(ownerParagraphs().begin(), ownerParagraphs().end(), *inset->parOwner()); - //lyx::Assert(par); + //Assert(par); pos_type pos = par->getPositionOfInset(inset); - lyx::Assert(pos != -1); + Assert(pos != -1); LyXLayout_ptr const & layout = par->layout(); @@ -971,7 +973,7 @@ int LyXText::labelFill(Row const & row) const pos_type last = pit->beginningOfBody(); - lyx::Assert(last > 0); + Assert(last > 0); // -1 because a label ends either with a space that is in the label, // or with the beginning of a footnote that is outside the label. @@ -1011,7 +1013,7 @@ LColor::color LyXText::backgroundColor() const void LyXText::setHeightOfRow(RowList::iterator rit) { - lyx::Assert(rit != rows().end()); + Assert(rit != rows().end()); // get the maximum ascent and the maximum descent float layoutasc = 0; @@ -1323,7 +1325,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit) // start at the implicit given position void LyXText::appendParagraph(RowList::iterator rowit) { - lyx::Assert(rowit != rowlist_.end()); + Assert(rowit != rowlist_.end()); pos_type const last = rowit->par()->size(); bool done = false; @@ -1353,7 +1355,7 @@ void LyXText::appendParagraph(RowList::iterator rowit) void LyXText::breakAgain(RowList::iterator rit) { - lyx::Assert(rit != rows().end()); + Assert(rit != rows().end()); bool not_ready = true; @@ -1406,7 +1408,7 @@ void LyXText::breakAgain(RowList::iterator rit) // this is just a little changed version of break again void LyXText::breakAgainOneRow(RowList::iterator rit) { - lyx::Assert(rit != rows().end()); + Assert(rit != rows().end()); pos_type z = rowBreakPoint(*rit); RowList::iterator tmprit = rit; diff --git a/src/text2.C b/src/text2.C index 1b805a5140..dcc78c48ae 100644 --- a/src/text2.C +++ b/src/text2.C @@ -47,6 +47,8 @@ #include +using namespace lyx::support; + using std::vector; using std::copy; using std::endl; @@ -115,7 +117,7 @@ void LyXText::init(BufferView * bview, bool reinit) LyXFont const LyXText::getFont(Buffer const * buf, ParagraphList::iterator pit, pos_type pos) const { - lyx::Assert(pos >= 0); + Assert(pos >= 0); LyXLayout_ptr const & layout = pit->layout(); @@ -1128,7 +1130,7 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit) else if (in->lyxCode() == Inset::WRAP_CODE) type = static_cast(in)->params().type; else - lyx::Assert(0); + Assert(0); Floating const & fl = textclass.floats().getType(type); @@ -1567,7 +1569,7 @@ bool LyXText::setCursor(ParagraphList::iterator pit, void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit, pos_type pos, bool boundary) { - lyx::Assert(pit != ownerParagraphs().end()); + Assert(pit != ownerParagraphs().end()); cur.par(pit); cur.pos(pos); diff --git a/src/text3.C b/src/text3.C index 33284bc3e9..81952f4355 100644 --- a/src/text3.C +++ b/src/text3.C @@ -43,6 +43,8 @@ #include #include +using namespace lyx::support; + using std::endl; using std::find; using std::vector; @@ -107,7 +109,7 @@ namespace { return 0; // get inset dimensions - lyx::Assert(par->getInset(pos)); + Assert(par->getInset(pos)); LyXFont const & font = text.getFont(bv->buffer(), par, pos); @@ -920,7 +922,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) } case LFUN_INSET_SETTINGS: - lyx::Assert(bv->theLockingInset()); + Assert(bv->theLockingInset()); bv->theLockingInset()->getLockingInset()->showInsetDialog(bv); break; diff --git a/src/trans.C b/src/trans.C index 3c191cdd9e..3ef8608c77 100644 --- a/src/trans.C +++ b/src/trans.C @@ -8,6 +8,8 @@ #include "debug.h" #include "trans_mgr.h" +using namespace lyx::support; + using std::map; using std::endl; diff --git a/src/trans_mgr.C b/src/trans_mgr.C index d4cc80fce2..496bdd7394 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -12,6 +12,8 @@ #include "lyxrc.h" #include "support/lstrings.h" +using namespace lyx::support; + using std::endl; using std::pair; diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 92304179a4..b0233213c7 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -62,7 +62,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo) // Set the right(new) inset-owner of the paragraph if there is any. UpdatableInset * inset = static_cast(buf->getInsetFromID(undo.inset_id)); - + ParagraphList::iterator pit = undo.pars.begin(); ParagraphList::iterator end = undo.pars.end(); for ( ; pit != end; ++pit) @@ -130,7 +130,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo) inset->localDispatch(cmd); } } - + if (inset) { lyxerr << "fit cursor...\n"; bv->fitCursor(); @@ -192,10 +192,10 @@ void createUndo(BufferView * bv, Undo::undo_kind kind, plist = &buf->paragraphs; // this is what we'd like to have in the end for small grained undo for (ParIterator it = buf->par_iterator_begin(); it != null; ++it) { - if (it->id() == first->id()) - first = it.outerPar(); + if (it->id() == first->id()) + first = it.outerPar(); if (it->id() == last->id()) - last = it.outerPar(); + last = it.outerPar(); } #endif diff --git a/src/vc-backend.C b/src/vc-backend.C index f862d67356..5c3e6f3731 100644 --- a/src/vc-backend.C +++ b/src/vc-backend.C @@ -17,6 +17,8 @@ #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::asctime; using std::gmtime; diff --git a/src/vspace.C b/src/vspace.C index a87181a6d3..9b35ac7943 100644 --- a/src/vspace.C +++ b/src/vspace.C @@ -20,6 +20,8 @@ #include +using namespace lyx::support; + #ifndef CXX_GLOBAL_CSTD using std::sscanf; #endif -- 2.39.2