From a8cd9a4b8fd325b00c75f601c66c6d618ba276db Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 1 Nov 2007 22:17:22 +0000 Subject: [PATCH] cosmetics. mainly replace #include "dostring.h" by #include "strfwd.h" in header files when possible. Adjust .cpp files. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21358 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Author.h | 54 ++++++++--------- src/BiblioInfo.cpp | 1 + src/Bidi.cpp | 9 ++- src/Bidi.h | 3 +- src/Box.h | 2 +- src/Buffer.cpp | 19 ++++-- src/Buffer.h | 7 +-- src/BufferParams.cpp | 1 + src/Changes.cpp | 32 ++++------ src/Changes.h | 2 +- src/CmdDef.h | 3 +- src/Cursor.cpp | 2 +- src/Cursor.h | 1 - src/CursorSlice.h | 4 +- src/DocIterator.h | 9 --- src/Font.h | 2 +- src/FontIterator.h | 2 +- src/FuncRequest.h | 2 - src/KeyMap.cpp | 1 + src/KeyMap.h | 2 +- src/Lexer.h | 2 - src/LyXFunc.cpp | 10 ++-- src/LyXRC.h | 3 +- src/MenuBackend.cpp | 3 +- src/MenuBackend.h | 30 +++------- src/PDFOptions.cpp | 2 +- src/PDFOptions.h | 6 +- src/Paragraph.h | 3 - src/ParagraphParameters.h | 3 - src/Spacing.h | 2 +- src/Text.cpp | 1 + src/TocBackend.h | 7 +-- src/frontends/qt4/GuiViewSource.cpp | 2 + src/insets/Inset.cpp | 6 +- src/insets/Inset.h | 14 ++--- src/insets/InsetBibitem.cpp | 1 + src/insets/InsetBibtex.cpp | 1 + src/insets/InsetFloat.cpp | 1 + src/insets/InsetFootlike.cpp | 4 +- src/insets/InsetGraphics.cpp | 4 +- src/insets/InsetHyperlink.cpp | 9 ++- src/insets/InsetInclude.cpp | 1 + src/insets/InsetInfo.cpp | 2 + src/insets/InsetLine.cpp | 3 + src/insets/InsetListings.cpp | 6 +- src/insets/InsetNewline.cpp | 1 + src/insets/InsetNomencl.cpp | 2 + src/insets/InsetNote.cpp | 1 + src/insets/InsetOptArg.cpp | 2 + src/insets/InsetQuotes.cpp | 41 ++++++++----- src/insets/InsetQuotes.h | 5 +- src/insets/InsetRef.cpp | 1 + src/insets/InsetRef.h | 6 +- src/insets/InsetSpace.cpp | 4 +- src/insets/InsetSpecialChar.cpp | 1 + src/insets/InsetTabular.cpp | 3 +- src/insets/InsetVSpace.cpp | 1 + src/insets/InsetWrap.cpp | 1 + src/lfuns.h | 2 +- src/mathed/InsetMathNest.cpp | 13 ++--- src/output_docbook.h | 2 +- src/output_plaintext.h | 2 +- src/pch.h | 25 -------- src/sgml.cpp | 2 +- src/sgml.h | 7 +-- src/support/docstring.h | 64 ++++++++++++++++++++ src/support/environment.cpp | 2 + src/support/getcwd.cpp | 1 + src/support/strfwd.h | 91 +++++++---------------------- src/support/userinfo.cpp | 3 +- 70 files changed, 277 insertions(+), 290 deletions(-) diff --git a/src/Author.h b/src/Author.h index 6842cf35ca..0f1e49e7a7 100644 --- a/src/Author.h +++ b/src/Author.h @@ -15,65 +15,59 @@ #include "support/docstring.h" #include -#include namespace lyx { - class Author { public: + /// Author() {} - + /// Author(docstring const & name, docstring const & email) : name_(name), email_(email), used_(true) {} - - docstring const name() const { - return name_; - } - - docstring const email() const { - return email_; - } - - void used(bool u) const { - used_ = u; - } - - bool used() const { - return used_; - } - + /// + docstring name() const { return name_; } + /// + docstring email() const { return email_; } + /// + void setUsed(bool u) const { used_ = u; } + /// + bool used() const { return used_; } + /// friend std::istream & operator>>(std::istream & os, Author & a); private: + /// The author's name docstring name_; - + /// The author's email address docstring email_; - + /// mutable bool used_; }; class AuthorList { public: + /// AuthorList(); - + /// int record(Author const & a); - + /// void record(int id, Author const & a); - + /// Author const & get(int id) const; - + /// typedef std::map Authors; - + /// Authors::const_iterator begin() const; - + /// Authors::const_iterator end() const; - + /// private: + /// int last_id_; - + /// Authors authors_; }; diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 6f6f3ee68a..a6113cf509 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -26,6 +26,7 @@ #include "insets/InsetInclude.h" #include "support/lstrings.h" +#include "support/docstream.h" #include "boost/regex.hpp" diff --git a/src/Bidi.cpp b/src/Bidi.cpp index 00aa9fcd7c..d00b8eb72d 100644 --- a/src/Bidi.cpp +++ b/src/Bidi.cpp @@ -13,6 +13,7 @@ #include "Bidi.h" #include "Buffer.h" #include "BufferView.h" +#include "Cursor.h" #include "Font.h" #include "Row.h" #include "LyXRC.h" @@ -127,10 +128,11 @@ void Bidi::computeTables(Paragraph const & par, new_level = rtl_par ? 1 : 0; new_rtl0 = rtl_par; new_rtl = rtl_par; - } else if (new_rtl0) + } else if (new_rtl0) { new_level = new_rtl ? 1 : 2; - else + } else { new_level = rtl_par ? 2 : 0; + } if (is_space && new_level >= lev) { new_level = lev; @@ -147,8 +149,9 @@ void Bidi::computeTables(Paragraph const & par, log2vis_list_[lpos - start_] = rtl ? -1 : 1; if (new_level > 0 && !rtl_par) same_direction_ = false; - } else + } else { log2vis_list_[lpos - start_] = new_rtl ? -1 : 1; + } rtl = new_rtl; rtl0 = new_rtl0; levels_[lpos - start_] = new_level; diff --git a/src/Bidi.h b/src/Bidi.h index 2fdb3abad3..dfa779ae49 100644 --- a/src/Bidi.h +++ b/src/Bidi.h @@ -13,13 +13,14 @@ #define BIDI_H #include "support/types.h" -#include "Cursor.h" + #include namespace lyx { class Buffer; +class Cursor; class Paragraph; class Row; class Font; diff --git a/src/Box.h b/src/Box.h index 7b9bb819bd..c362fa6a38 100644 --- a/src/Box.h +++ b/src/Box.h @@ -12,7 +12,7 @@ #ifndef BOX_H #define BOX_H -#include +#include "support/strfwd.h" namespace lyx { diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 2e2dc5fc4f..fa6dc704f8 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -401,12 +401,15 @@ string Buffer::latexName(bool const no_path) const } -pair Buffer::logName() const +string Buffer::logName(LogType * type) const { string const filename = latexName(false); - if (filename.empty()) - return make_pair(Buffer::latexlog, string()); + if (filename.empty()) { + if (type) + *type = latexlog; + return string(); + } string const path = temppath(); @@ -423,10 +426,14 @@ pair Buffer::logName() const if (bname.exists() && (!fname.exists() || fname.lastModified() < bname.lastModified())) { LYXERR(Debug::FILES) << "Log name calculated as: " << bname << endl; - return make_pair(Buffer::buildlog, bname.absFilename()); + if (type) + *type = buildlog; + return bname.absFilename(); } LYXERR(Debug::FILES) << "Log name calculated as: " << fname << endl; - return make_pair(Buffer::latexlog, fname.absFilename()); + if (type) + *type = latexlog; + return fname.absFilename(); } @@ -947,7 +954,7 @@ bool Buffer::write(ostream & ofs) const AuthorList::Authors::const_iterator a_it = params().authors().begin(); AuthorList::Authors::const_iterator a_end = params().authors().end(); for (; a_it != a_end; ++a_it) - a_it->second.used(false); + a_it->second.setUsed(false); ParIterator const end = par_iterator_end(); ParIterator it = par_iterator_begin(); diff --git a/src/Buffer.h b/src/Buffer.h index d713c8ac0f..568a28d162 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -15,13 +15,10 @@ #include "insets/InsetCode.h" #include "support/FileName.h" -#include "support/docstring.h" -#include "support/docstream.h" +#include "support/strfwd.h" #include "support/types.h" -#include #include -#include #include @@ -252,7 +249,7 @@ public: std::string latexName(bool no_path = true) const; /// Get thee name and type of the log. - std::pair logName() const; + std::string logName(LogType * type = 0) const; /// Change name of buffer. Updates "read-only" flag. void setFileName(std::string const & newfile); diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 3fff39e20b..b2dd1da257 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -42,6 +42,7 @@ #include "insets/InsetListingsParams.h" #include "support/convert.h" +#include "support/docstream.h" #include "support/filetools.h" #include "support/Translator.h" #include "support/lstrings.h" diff --git a/src/Changes.cpp b/src/Changes.cpp index d0356b8895..ea99b7fc6d 100644 --- a/src/Changes.cpp +++ b/src/Changes.cpp @@ -41,13 +41,11 @@ namespace lyx { bool Change::isSimilarTo(Change const & change) { - if (type != change.type) { + if (type != change.type) return false; - } - if (type == Change::UNCHANGED) { + if (type == Change::UNCHANGED) return true; - } return author == change.author; } @@ -55,17 +53,14 @@ bool Change::isSimilarTo(Change const & change) bool operator==(Change const & l, Change const & r) { - if (l.type != r.type) { + if (l.type != r.type) return false; - } // two changes of type UNCHANGED are always equal - if (l.type == Change::UNCHANGED) { + if (l.type == Change::UNCHANGED) return true; - } - return l.author == r.author && - l.changetime == r.changetime; + return l.author == r.author && l.changetime == r.changetime; } @@ -154,9 +149,8 @@ void Changes::set(Change const & change, pos_type const start, pos_type const en } // new change precedes existing change - if (it->range.start >= end) { + if (it->range.start >= end) break; - } // new change intersects with existing change it->range.start = end; @@ -179,13 +173,11 @@ void Changes::erase(pos_type const pos) for (; it != end; ++it) { // range (pos,pos+x) becomes (pos,pos+x-1) - if (it->range.start > pos) { + if (it->range.start > pos) --(it->range.start); - } // range (pos-x,pos) stays (pos-x,pos) - if (it->range.end > pos) { + if (it->range.end > pos) --(it->range.end); - } } merge(); @@ -204,14 +196,12 @@ void Changes::insert(Change const & change, lyx::pos_type pos) for (; it != end; ++it) { // range (pos,pos+x) becomes (pos+1,pos+x+1) - if (it->range.start >= pos) { + if (it->range.start >= pos) ++(it->range.start); - } // range (pos-x,pos) stays as it is - if (it->range.end > pos) { + if (it->range.end > pos) ++(it->range.end); - } } set(change, pos, pos + 1); // set will call merge @@ -362,7 +352,7 @@ void Changes::checkAuthors(AuthorList const & authorList) ChangeTable::const_iterator endit = table_.end(); for ( ; it != endit ; ++it) if (it->change.type != Change::UNCHANGED) - authorList.get(it->change.author).used(true); + authorList.get(it->change.author).setUsed(true); } } // namespace lyx diff --git a/src/Changes.h b/src/Changes.h index e08221e338..395e6e8d65 100644 --- a/src/Changes.h +++ b/src/Changes.h @@ -15,7 +15,7 @@ #ifndef CHANGES_H #define CHANGES_H -#include "support/docstream.h" +#include "support/strfwd.h" #include "support/types.h" #include "support/lyxtime.h" diff --git a/src/CmdDef.h b/src/CmdDef.h index 9ef25fa5fe..d7fe72e7d2 100644 --- a/src/CmdDef.h +++ b/src/CmdDef.h @@ -14,11 +14,12 @@ #include "FuncRequest.h" -#include "support/docstream.h" +#include "support/strfwd.h" #include #include +#include namespace lyx { diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 2d8f777c6d..ac230a15e0 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -675,7 +675,7 @@ bool Cursor::openable(MathAtom const & t) const // we can't move into anything new during selection if (depth() >= anchor_.depth()) return false; - if (!ptr_cmp(t.nucleus(), &anchor_[depth()].inset())) + if (t.nucleus() != &anchor_[depth()].inset()) return false; return true; diff --git a/src/Cursor.h b/src/Cursor.h index 750b801fc7..1ee104cd52 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -17,7 +17,6 @@ #include "Font.h" #include "Undo.h" -#include #include diff --git a/src/CursorSlice.h b/src/CursorSlice.h index 94a2cb3251..be31f56a99 100644 --- a/src/CursorSlice.h +++ b/src/CursorSlice.h @@ -18,11 +18,9 @@ #define CURSORSLICE_H #include "support/types.h" +#include "support/strfwd.h" #include "insets/Inset.h" -#include -#include - namespace lyx { diff --git a/src/DocIterator.h b/src/DocIterator.h index 1ffc262a4e..0531a23c68 100644 --- a/src/DocIterator.h +++ b/src/DocIterator.h @@ -15,7 +15,6 @@ #include "CursorSlice.h" #include -#include namespace lyx { @@ -25,14 +24,6 @@ class MathAtom; class Paragraph; -// only needed for gcc 2.95, remove when support terminated -template -bool ptr_cmp(A const * a, B const * b) -{ - return a == b; -} - - // The public inheritance should go in favour of a suitable data member // (or maybe private inheritance) at some point of time. class DocIterator // : public std::vector diff --git a/src/Font.h b/src/Font.h index c306daa75c..49c8f31b5b 100644 --- a/src/Font.h +++ b/src/Font.h @@ -22,7 +22,7 @@ #include "ColorCode.h" #include "FontInfo.h" -#include "support/docstream.h" +#include "support/strfwd.h" namespace lyx { diff --git a/src/FontIterator.h b/src/FontIterator.h index 44ecb37908..ce5d9369cf 100644 --- a/src/FontIterator.h +++ b/src/FontIterator.h @@ -31,7 +31,7 @@ class Paragraph; class TextMetrics; -class FontIterator : std::iterator +class FontIterator { public: /// diff --git a/src/FuncRequest.h b/src/FuncRequest.h index 9ea6dc4344..3083f007ac 100644 --- a/src/FuncRequest.h +++ b/src/FuncRequest.h @@ -17,8 +17,6 @@ #include "support/docstring.h" -#include - namespace lyx { diff --git a/src/KeyMap.cpp b/src/KeyMap.cpp index dbfbb54b7d..04a3bbcb33 100644 --- a/src/KeyMap.cpp +++ b/src/KeyMap.cpp @@ -20,6 +20,7 @@ #include "LyXAction.h" #include "Lexer.h" +#include "support/docstream.h" #include "support/filetools.h" #include diff --git a/src/KeyMap.h b/src/KeyMap.h index 05709e6905..f52fabb425 100644 --- a/src/KeyMap.h +++ b/src/KeyMap.h @@ -19,7 +19,7 @@ #include "frontends/KeyModifier.h" #include "frontends/KeySymbol.h" -#include "support/docstream.h" +#include "support/strfwd.h" #include #include diff --git a/src/Lexer.h b/src/Lexer.h index fbe27602c8..d4e440121c 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -19,8 +19,6 @@ #include "support/strfwd.h" -#include - namespace lyx { diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 1bf8931031..0300b52b75 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -652,7 +652,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const } } else if (name == "latexlog") - enable = FileName(buf->logName().second).isFileReadable(); + enable = FileName(buf->logName()).isFileReadable(); else if (name == "spellchecker") #if defined (USE_ASPELL) || defined (USE_ISPELL) || defined (USE_PSPELL) enable = !buf->isReadonly(); @@ -1456,9 +1456,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd) if (!data.empty()) lyx_view_->getDialogs().show("character", data); } else if (name == "latexlog") { - pair const logfile = - lyx_view_->buffer()->logName(); - switch (logfile.first) { + Buffer::LogType type; + string const logfile = lyx_view_->buffer()->logName(&type); + switch (type) { case Buffer::latexlog: data = "latex "; break; @@ -1466,7 +1466,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) data = "literate "; break; } - data += Lexer::quoteString(logfile.second); + data += Lexer::quoteString(logfile); lyx_view_->getDialogs().show("log", data); } else if (name == "vclog") { string const data = "vc " + diff --git a/src/LyXRC.h b/src/LyXRC.h index b9d7e5c6d4..20eedd914d 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -20,7 +20,8 @@ #include "paper.h" -#include +#include "support/strfwd.h" + #include diff --git a/src/MenuBackend.cpp b/src/MenuBackend.cpp index 2dd4efb731..25d9f74412 100644 --- a/src/MenuBackend.cpp +++ b/src/MenuBackend.cpp @@ -72,8 +72,7 @@ class MenuNamesEqual : public std::unary_function { public: MenuNamesEqual(docstring const & name) : name_(name) {} - bool operator()(Menu const & menu) const - { + bool operator()(Menu const & menu) const { return menu.name() == name_; } private: diff --git a/src/MenuBackend.h b/src/MenuBackend.h index c9f3e8de01..76f4ca3722 100644 --- a/src/MenuBackend.h +++ b/src/MenuBackend.h @@ -160,8 +160,7 @@ public: /// typedef ItemList::size_type size_type; /// - explicit Menu(docstring const & name = docstring()) - : name_(name) {} + explicit Menu(docstring const & name = docstring()) : name_(name) {} /// Add the menu item unconditionally Menu & add(MenuItem const &); /// Checks the associated FuncRequest status before adding the @@ -182,13 +181,9 @@ public: /// bool hasFunc(FuncRequest const &) const; /// - const_iterator begin() const { - return items_.begin(); - } + const_iterator begin() const { return items_.begin(); } /// - const_iterator end() const { - return items_.end(); - } + const_iterator end() const { return items_.end(); } // Check whether the menu shortcuts are unique void checkShortcuts() const; @@ -247,21 +242,14 @@ public: void expand(Menu const & frommenu, Menu & tomenu, Buffer const *) const; /// - const_iterator begin() const { - return menulist_.begin(); - } + const_iterator begin() const { return menulist_.begin(); } /// - iterator begin() { - return menulist_.begin(); - } + iterator begin() { return menulist_.begin(); } /// - const_iterator end() const { - return menulist_.end(); - } + const_iterator end() const { return menulist_.end(); } /// - iterator end() { - return menulist_.end(); - } + iterator end() { return menulist_.end(); } + private: /// MenuList menulist_; @@ -277,4 +265,4 @@ extern MenuBackend menubackend; } // namespace lyx -#endif /* MENUBACKEND_H */ +#endif // MENUBACKEND_H diff --git a/src/PDFOptions.cpp b/src/PDFOptions.cpp index aaf7141e7a..149d85b3db 100644 --- a/src/PDFOptions.cpp +++ b/src/PDFOptions.cpp @@ -86,7 +86,7 @@ void PDFOptions::writeFile(ostream & os) const os << "\\pdf_quoted_options \"" << quoted_options << "\"\n"; } -void PDFOptions::writeLaTeX(odocstringstream & os, bool hyper_required) const +void PDFOptions::writeLaTeX(odocstream & os, bool hyper_required) const { if (!use_hyperref && !hyper_required) return; diff --git a/src/PDFOptions.h b/src/PDFOptions.h index c8fc16e131..13f83b9436 100644 --- a/src/PDFOptions.h +++ b/src/PDFOptions.h @@ -12,7 +12,9 @@ #ifndef PDFOPTIONS_H #define PDFOPTIONS_H -#include "support/docstream.h" +#include "support/strfwd.h" + +#include namespace lyx { @@ -28,7 +30,7 @@ public: /// output to lyx header void writeFile(std::ostream &) const; /// output to tex header - void writeLaTeX(odocstringstream &, bool hyper_required) const; + void writeLaTeX(odocstream &, bool hyper_required) const; /// read tokens from lyx header std::string readToken(Lexer &lex, std::string const & token); /// set implicit settings for hyperref diff --git a/src/Paragraph.h b/src/Paragraph.h index d59753dece..30c033b487 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -23,9 +23,6 @@ #include "support/strfwd.h" #include "support/types.h" -// FIXME: would be nice to forward declare odocstream instead of -// including this: -#include "support/docstream.h" namespace lyx { diff --git a/src/ParagraphParameters.h b/src/ParagraphParameters.h index 977049d202..9c5a52df3e 100644 --- a/src/ParagraphParameters.h +++ b/src/ParagraphParameters.h @@ -21,9 +21,6 @@ #include "support/types.h" #include "support/docstring.h" -#include -#include - namespace lyx { diff --git a/src/Spacing.h b/src/Spacing.h index 8b00a4a327..7761bbf9aa 100644 --- a/src/Spacing.h +++ b/src/Spacing.h @@ -16,7 +16,7 @@ #include "tex2lyx/Spacing.h" #else -#include +#include "support/strfwd.h" #include diff --git a/src/Text.cpp b/src/Text.cpp index fe75838f49..d7745e4203 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -63,6 +63,7 @@ #include "insets/InsetSpecialChar.h" #include "insets/InsetTabular.h" +#include "support/docstream.h" #include "support/lstrings.h" #include "support/textutils.h" #include "support/convert.h" diff --git a/src/TocBackend.h b/src/TocBackend.h index 60b4e51122..30ed9de75f 100644 --- a/src/TocBackend.h +++ b/src/TocBackend.h @@ -22,7 +22,7 @@ #include "ParIterator.h" -#include "support/docstream.h" +#include "support/strfwd.h" namespace lyx { @@ -74,11 +74,10 @@ protected: /// typedef std::vector Toc; typedef Toc::const_iterator TocIterator; + /// The ToC list. /// A class and no typedef because we want to forward declare it. -class TocList : public std::map -{ -}; +class TocList : public std::map {}; /// diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index d6b141b969..85dc747767 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -24,6 +24,8 @@ #include "Paragraph.h" #include "TexRow.h" +#include "support/docstream.h" + #include #include #include diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index cc2f6d6e18..10a2e04ebc 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -119,8 +119,10 @@ static TranslatorMap const build_translator() } -Inset::Inset() -{} +docstring Inset::name() const +{ + return from_ascii("unknown"); +} Dimension const Inset::dimension(BufferView const & bv) const diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 2486d09115..aae34f8695 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -18,11 +18,8 @@ #include "ColorCode.h" #include "InsetCode.h" -#include "Dimension.h" +#include "support/strfwd.h" -#include "support/docstream.h" - -#include #include namespace lyx { @@ -34,6 +31,7 @@ class BufferView; class Change; class Cursor; class CursorSlice; +class Dimension; class FuncRequest; class FuncStatus; class InsetIterator; @@ -280,7 +278,7 @@ public: virtual bool hasFixedWidth() const { return false; } /// - virtual docstring name() const { return from_ascii("unknown"); } + virtual docstring name() const; /// virtual InsetLayout const & getLayout(BufferParams const & bp) const; /// used to toggle insets @@ -339,12 +337,12 @@ public: /// pit is the ParConstIterator of the paragraph containing the inset virtual void addToToc(TocList &, Buffer const &, ParConstIterator const &) const {} /// report files that can be embedded with the lyx file - virtual void registerEmbeddedFiles(Buffer const &, EmbeddedFiles &) const {}; + virtual void registerEmbeddedFiles(Buffer const &, EmbeddedFiles &) const {} /// use embedded or external file after the embedding status of a file is changed virtual void updateEmbeddedFile(Buffer const &, EmbeddedFile const &) {} /// Fill keys with BibTeX information virtual void fillWithBibKeys(Buffer const &, - BiblioInfo &, InsetIterator const &) const { return; } + BiblioInfo &, InsetIterator const &) const {} /// Update the counters of this inset and of its contents virtual void updateLabels(Buffer const &, ParIterator const &) {} @@ -393,7 +391,7 @@ public: enum { TEXT_TO_INSET_OFFSET = 4 }; protected: - Inset(); + Inset() {} /// replicate ourselves friend class InsetList; diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 50e1cb1c8a..b4a88a7d05 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -26,6 +26,7 @@ #include "support/lstrings.h" #include "support/std_ostream.h" +#include "support/docstream.h" #include "support/convert.h" diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 174f81c622..d5a076671f 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -27,6 +27,7 @@ #include "frontends/alert.h" #include "support/ExceptionMessage.h" +#include "support/docstream.h" #include "support/filetools.h" #include "support/lstrings.h" #include "support/lyxlib.h" diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index bb81f519f9..437a95010b 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -30,6 +30,7 @@ #include "OutputParams.h" #include "support/lstrings.h" +#include "support/docstream.h" #include "support/convert.h" diff --git a/src/insets/InsetFootlike.cpp b/src/insets/InsetFootlike.cpp index d752c9c44b..c0647b0824 100644 --- a/src/insets/InsetFootlike.cpp +++ b/src/insets/InsetFootlike.cpp @@ -17,6 +17,7 @@ #include "BufferParams.h" #include "MetricsInfo.h" +#include namespace lyx { @@ -58,8 +59,7 @@ void InsetFootlike::write(Buffer const & buf, std::ostream & os) const bool InsetFootlike::insetAllowed(InsetCode code) const { - if (code == FOOT_CODE || code == MARGIN_CODE - || code == FLOAT_CODE) + if (code == FOOT_CODE || code == MARGIN_CODE || code == FLOAT_CODE) return false; return InsetCollapsable::insetAllowed(code); } diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 62e8d80775..7d1ea0bd4d 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -76,6 +76,7 @@ TODO #include "frontends/alert.h" #include "support/convert.h" +#include "support/docstream.h" #include "support/filetools.h" #include "support/lyxlib.h" // sum #include "support/lstrings.h" @@ -449,7 +450,8 @@ docstring const InsetGraphics::createDocBookAttributes() const // Calculate the options part of the command, we must do it to a string // stream since we copied the code from createLatexParams() ;-) - // FIXME: av: need to translate spec -> Docbook XSL spec (http://www.sagehill.net/docbookxsl/ImageSizing.html) + // FIXME: av: need to translate spec -> Docbook XSL spec + // (http://www.sagehill.net/docbookxsl/ImageSizing.html) // Right now it only works with my version of db2latex :-) odocstringstream options; diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp index dfb9e94aef..6bf31aa36c 100644 --- a/src/insets/InsetHyperlink.cpp +++ b/src/insets/InsetHyperlink.cpp @@ -20,8 +20,7 @@ #include "OutputParams.h" #include "support/lstrings.h" - -#include "support/std_ostream.h" +#include "support/docstream.h" namespace lyx { @@ -88,7 +87,7 @@ int InsetHyperlink::latex(Buffer const &, odocstream & os, if (!url.empty()) { // the chars_url[] characters must be handled for both, url and href for (int k = 0; k < 2; k++) { - for (int i = 0, pos; + for (size_t i = 0, pos; (pos = url.find(chars_url[k], i)) != string::npos; i = pos + 2) { url.replace(pos,1,backslash + chars_url[k]); @@ -104,14 +103,14 @@ int InsetHyperlink::latex(Buffer const &, odocstream & os, // handle the "\" character, but only when the following character // is not also a "\", because "\\" is valid code - for (int i = 0, pos; + for (size_t i = 0, pos; (pos = name.find("\\", i)) != string::npos; i = pos + 2) { if (name[pos+1] != '\\') name.replace(pos,1,"\\textbackslash{}"); } for (int k = 0; k < 6; k++) { - for (int i = 0, pos; + for (size_t i = 0, pos; (pos = name.find(chars_name[k], i)) != string::npos; i = pos + 2) { name.replace(pos,1,backslash + chars_name[k] + braces); diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 129f0b7757..e236ad7036 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -42,6 +42,7 @@ #include "insets/RenderPreview.h" #include "insets/InsetListingsParams.h" +#include "support/docstream.h" #include "support/filetools.h" #include "support/lstrings.h" // contains #include "support/lyxalgo.h" diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 031d00e5c0..8bb9624f67 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -29,6 +29,8 @@ #include "MetricsInfo.h" #include "ParagraphParameters.h" #include "TextClassList.h" + +#include "support/docstream.h" #include "support/lstrings.h" #include "support/ExceptionMessage.h" diff --git a/src/insets/InsetLine.cpp b/src/insets/InsetLine.cpp index 22f4aa316a..f34ae4259c 100644 --- a/src/insets/InsetLine.cpp +++ b/src/insets/InsetLine.cpp @@ -13,12 +13,15 @@ #include "InsetLine.h" #include "debug.h" +#include "Dimension.h" #include "Font.h" #include "MetricsInfo.h" #include "LaTeXFeatures.h" #include "OutputParams.h" #include "Text.h" +#include "support/docstream.h" + #include "frontends/Painter.h" diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index b52e9fb9af..fb41bd0fe1 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -26,6 +26,7 @@ #include "Language.h" #include "MetricsInfo.h" +#include "support/docstream.h" #include "support/lstrings.h" #include @@ -220,8 +221,7 @@ int InsetListings::latex(Buffer const & buf, odocstream & os, os << from_utf8(param_string) << "]\n"; } lines += 4; - os << code - << "\n\\end{lstlisting}\n\\endgroup\n"; + os << code << "\n\\end{lstlisting}\n\\endgroup\n"; lines += 3; } @@ -296,7 +296,7 @@ bool InsetListings::showInsetDialog(BufferView * bv) const docstring InsetListings::getCaption(Buffer const & buf, - OutputParams const & runparams) const + OutputParams const & runparams) const { if (paragraphs().empty()) return docstring(); diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index 77978bcf96..5a1af78d3e 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -13,6 +13,7 @@ #include "InsetNewline.h" #include "debug.h" +#include "Dimension.h" #include "MetricsInfo.h" #include "OutputParams.h" diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp index c3e7aefb2d..c2fdade285 100644 --- a/src/insets/InsetNomencl.cpp +++ b/src/insets/InsetNomencl.cpp @@ -22,6 +22,8 @@ #include "MetricsInfo.h" #include "sgml.h" +#include "support/docstream.h" + namespace lyx { diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 50382349bd..de060487de 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -31,6 +31,7 @@ #include "MetricsInfo.h" #include "OutputParams.h" +#include "support/docstream.h" #include "support/Translator.h" #include diff --git a/src/insets/InsetOptArg.cpp b/src/insets/InsetOptArg.cpp index 9dbedbd55d..89e0e33f26 100644 --- a/src/insets/InsetOptArg.cpp +++ b/src/insets/InsetOptArg.cpp @@ -15,6 +15,8 @@ #include "debug.h" #include "gettext.h" +#include "support/docstream.h" + namespace lyx { diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp index c51c891846..eff96ac264 100644 --- a/src/insets/InsetQuotes.cpp +++ b/src/insets/InsetQuotes.cpp @@ -26,6 +26,7 @@ #include "frontends/FontMetrics.h" #include "frontends/Painter.h" +#include "support/docstring.h" #include "support/lstrings.h" @@ -59,23 +60,27 @@ char const * const quote_char = ",'`<>"; // Index of chars used for the quote. Index is [side, language] int quote_index[2][6] = { { 2, 1, 0, 0, 3, 4 }, // "'',,<>" - { 1, 1, 2, 1, 4, 3 } }; // "`'`'><" + { 1, 1, 2, 1, 4, 3 } // "`'`'><" +}; // Corresponding LaTeX code, for double and single quotes. -char const * const latex_quote_t1[2][5] = -{ { "\\quotesinglbase ", "'", "`", +char const * const latex_quote_t1[2][5] = { + { "\\quotesinglbase ", "'", "`", "\\guilsinglleft{}", "\\guilsinglright{}" }, - { ",,", "''", "``", "<<", ">>" } }; + { ",,", "''", "``", "<<", ">>" } +}; -char const * const latex_quote_ot1[2][5] = -{ { "\\quotesinglbase ", "'", "`", +char const * const latex_quote_ot1[2][5] = { + { "\\quotesinglbase ", "'", "`", "\\guilsinglleft{}", "\\guilsinglright{}" }, { "\\quotedblbase ", "''", "``", - "\\guillemotleft{}", "\\guillemotright{}" } }; + "\\guillemotleft{}", "\\guillemotright{}" } +}; -char const * const latex_quote_babel[2][5] = -{ { "\\glq ", "'", "`", "\\flq{}", "\\frq{}" }, - { "\\glqq ", "''", "``", "\\flqq{}", "\\frqq{}" } }; +char const * const latex_quote_babel[2][5] = { + { "\\glq ", "'", "`", "\\flq{}", "\\frq{}" }, + { "\\glqq ", "''", "``", "\\flqq{}", "\\frqq{}" } +}; } // namespace anon @@ -106,11 +111,19 @@ InsetQuotes::InsetQuotes(char_type c, quote_language l, quote_times t) } +docstring InsetQuotes::name() const +{ + return from_ascii("Quotes"); +} + + void InsetQuotes::getPosition(char_type c) { // Decide whether left or right switch (c) { - case ' ': case '(': case '[': + case ' ': + case '(': + case '[': side_ = LeftQ; // left quote break; default: @@ -201,14 +214,14 @@ docstring const InsetQuotes::dispString(Language const * loclang) const retdisp = docstring(1, 0x2018); #endif else - retdisp = lyx::from_ascii(disp); + retdisp = from_ascii(disp); // in french, spaces are added inside double quotes if (times_ == DoubleQ && prefixIs(loclang->code(), "fr")) { if (side_ == LeftQ) retdisp += ' '; else - retdisp.insert(docstring::size_type(0), 1, ' '); + retdisp.insert(size_t(0), 1, ' '); } return retdisp; @@ -355,7 +368,7 @@ void InsetQuotes::validate(LaTeXFeatures & features) const && lyxrc.fontenc != "T1") { if (times_ == SingleQ) switch (type) { - case ',': features.require("quotesinglbase"); break; + case ',': features.require("quotesinglbase"); break; case '<': features.require("guilsinglleft"); break; case '>': features.require("guilsinglright"); break; default: break; diff --git a/src/insets/InsetQuotes.h b/src/insets/InsetQuotes.h index 94f2d65c6a..118768bdcd 100644 --- a/src/insets/InsetQuotes.h +++ b/src/insets/InsetQuotes.h @@ -67,14 +67,13 @@ public: \item etc. \end{itemize} */ - explicit - InsetQuotes(std::string const & str = "eld"); + explicit InsetQuotes(std::string const & str = "eld"); /// Create the right quote inset after character c InsetQuotes(char_type c, BufferParams const & params); /// Direct access to inner/outer quotation marks InsetQuotes(char_type c, quote_language l, quote_times t); /// - docstring name() const { return from_ascii("Quotes"); } + docstring name() const; /// void metrics(MetricsInfo &, Dimension &) const; /// diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 2cccc2931f..5fb240a95d 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -21,6 +21,7 @@ #include "OutputParams.h" #include "sgml.h" +#include "support/docstream.h" #include "support/lstrings.h" diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index f4ec7b493d..23789a97ba 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -64,14 +64,14 @@ public: /// static bool isCompatibleCommand(std::string const & s); protected: + /// InsetRef(InsetRef const &); /// virtual void doDispatch(Cursor & cur, FuncRequest & cmd); private: - virtual Inset * clone() const { - return new InsetRef(*this); - } + /// + Inset * clone() const { return new InsetRef(*this); } /// bool isLatex; }; diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index 55aa3fd3fa..50b620333f 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -16,6 +16,7 @@ #include "InsetSpace.h" #include "debug.h" +#include "Dimension.h" #include "Lexer.h" #include "MetricsInfo.h" #include "OutputParams.h" @@ -48,8 +49,7 @@ InsetSpace::Kind InsetSpace::kind() const void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const { - frontend::FontMetrics const & fm = - theFontMetrics(mi.base.font); + frontend::FontMetrics const & fm = theFontMetrics(mi.base.font); dim.asc = fm.maxAscent(); dim.des = fm.maxDescent(); diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp index d7bf5d52c1..ad5a8f33ee 100644 --- a/src/insets/InsetSpecialChar.cpp +++ b/src/insets/InsetSpecialChar.cpp @@ -15,6 +15,7 @@ #include "InsetSpecialChar.h" #include "debug.h" +#include "Dimension.h" #include "LaTeXFeatures.h" #include "Lexer.h" #include "MetricsInfo.h" diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 6eb171d4b6..a0c0317927 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -46,6 +46,7 @@ #include "TextMetrics.h" #include "support/convert.h" +#include "support/docstream.h" #include "support/lstrings.h" #include "frontends/alert.h" @@ -3068,7 +3069,7 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const if (!cur.selection()) return; - if (!ptr_cmp(&cur.inset(), this)) + if (&cur.inset() != this) return; //resetPos(cur); diff --git a/src/insets/InsetVSpace.cpp b/src/insets/InsetVSpace.cpp index 371c726682..08ff46c3e1 100644 --- a/src/insets/InsetVSpace.cpp +++ b/src/insets/InsetVSpace.cpp @@ -15,6 +15,7 @@ #include "Buffer.h" #include "Cursor.h" +#include "Dimension.h" #include "DispatchResult.h" #include "FuncRequest.h" #include "gettext.h" diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index e35bd702fb..008c3250b9 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -31,6 +31,7 @@ #include "TocBackend.h" #include "support/convert.h" +#include "support/docstream.h" namespace lyx { diff --git a/src/lfuns.h b/src/lfuns.h index 2ca33d7338..7d4563d3e4 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -16,7 +16,7 @@ #ifndef LFUNS_H #define LFUNS_H -#include +#include "support/strfwd.h" namespace lyx { diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index d8c8365279..d26813843c 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -20,7 +20,6 @@ #include "InsetMathComment.h" #include "InsetMathDelim.h" #include "InsetMathHull.h" -//#include "InsetMathMBox.h" #include "InsetMathRef.h" #include "InsetMathScript.h" #include "InsetMathSpace.h" @@ -111,7 +110,7 @@ void InsetMathNest::cursorPos(BufferView const & bv, // to touch all (math)inset's draw() methods. Right now, we'll store // absolute value, and make them here relative, only to make them // absolute again when actually drawing the cursor. What a mess. - BOOST_ASSERT(ptr_cmp(&sl.inset(), this)); + BOOST_ASSERT(&sl.inset() == this); MathData const & ar = sl.cell(); CoordCache const & coord_cache = bv.coordCache(); if (!coord_cache.getArrays().has(&ar)) { @@ -156,7 +155,7 @@ void InsetMathNest::metrics(MetricsInfo const & mi) const bool InsetMathNest::idxNext(Cursor & cur) const { - BOOST_ASSERT(ptr_cmp(&cur.inset(), this)); + BOOST_ASSERT(&cur.inset() == this); if (cur.idx() == cur.lastidx()) return false; ++cur.idx(); @@ -173,7 +172,7 @@ bool InsetMathNest::idxRight(Cursor & cur) const bool InsetMathNest::idxPrev(Cursor & cur) const { - BOOST_ASSERT(ptr_cmp(&cur.inset(), this)); + BOOST_ASSERT(&cur.inset() == this); if (cur.idx() == 0) return false; --cur.idx(); @@ -190,7 +189,7 @@ bool InsetMathNest::idxLeft(Cursor & cur) const bool InsetMathNest::idxFirst(Cursor & cur) const { - BOOST_ASSERT(ptr_cmp(&cur.inset(), this)); + BOOST_ASSERT(&cur.inset() == this); if (nargs() == 0) return false; cur.idx() = 0; @@ -201,7 +200,7 @@ bool InsetMathNest::idxFirst(Cursor & cur) const bool InsetMathNest::idxLast(Cursor & cur) const { - BOOST_ASSERT(ptr_cmp(&cur.inset(), this)); + BOOST_ASSERT(&cur.inset() == this); if (nargs() == 0) return false; cur.idx() = cur.lastidx(); @@ -242,7 +241,7 @@ void InsetMathNest::drawSelection(PainterInfo & pi, int x, int y) const Cursor & cur = bv.cursor(); if (!cur.selection()) return; - if (!ptr_cmp(&cur.inset(), this)) + if (&cur.inset() != this) return; // FIXME: hack to get position cache warm diff --git a/src/output_docbook.h b/src/output_docbook.h index b0f6326883..c1bc5f9ebf 100644 --- a/src/output_docbook.h +++ b/src/output_docbook.h @@ -13,7 +13,7 @@ #ifndef OUTPUT_DOCBOOK_H #define OUTPUT_DOCBOOK_H -#include "support/docstream.h" +#include "support/strfwd.h" namespace lyx { diff --git a/src/output_plaintext.h b/src/output_plaintext.h index 5e88d0e765..c32a4a2c19 100644 --- a/src/output_plaintext.h +++ b/src/output_plaintext.h @@ -12,7 +12,7 @@ #ifndef OUTPUT_PLAINTEXT_H #define OUTPUT_PLAINTEXT_H -#include "support/docstream.h" +#include "support/strfwd.h" namespace lyx { diff --git a/src/pch.h b/src/pch.h index fbfa76b594..41bb9e794f 100644 --- a/src/pch.h +++ b/src/pch.h @@ -1,31 +1,6 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include -#include -#include -#include -#include -#include -#include -#include #include #include #include diff --git a/src/sgml.cpp b/src/sgml.cpp index e1709a9a8d..b7871e195b 100644 --- a/src/sgml.cpp +++ b/src/sgml.cpp @@ -21,7 +21,7 @@ #include "OutputParams.h" #include "Paragraph.h" -#include "support/docstring.h" +#include "support/docstream.h" #include "support/lstrings.h" #include "support/std_ostream.h" #include "support/convert.h" diff --git a/src/sgml.h b/src/sgml.h index d32b799b49..ed8cbf314d 100644 --- a/src/sgml.h +++ b/src/sgml.h @@ -14,12 +14,7 @@ #define SGML_H #include "support/types.h" -#include "support/docstream.h" - -#include -#include -#include - +#include "support/docstring.h" namespace lyx { diff --git a/src/support/docstring.h b/src/support/docstring.h index 165772cdf2..e84ba6f2d0 100644 --- a/src/support/docstring.h +++ b/src/support/docstring.h @@ -22,6 +22,70 @@ namespace lyx { /// String type for storing the main text in UCS4 encoding typedef std::basic_string docstring; +/// Creates a docstring from a C string of ASCII characters +docstring const from_ascii(char const *); + +/// Creates a docstring from a std::string of ASCII characters +docstring const from_ascii(std::string const &); + +/// Creates a std::string of ASCII characters from a docstring +std::string const to_ascii(docstring const &); + +/// Creates a docstring from a UTF8 string. This should go eventually. +docstring const from_utf8(std::string const &); + +/// Creates a UTF8 string from a docstring. This should go eventually. +std::string const to_utf8(docstring const &); + +/// convert \p s from the encoding of the locale to ucs4. +docstring const from_local8bit(std::string const & s); + +/** + * Convert \p s from ucs4 to the encoding of the locale. + * This may fail and throw an exception, the caller is expected to act + * appropriately. + */ +std::string const to_local8bit(docstring const & s); + +/// convert \p s from the encoding of the file system to ucs4. +docstring const from_filesystem8bit(std::string const & s); + +/// convert \p s from ucs4 to the encoding of the file system. +std::string const to_filesystem8bit(docstring const & s); + +/// normalize \p s to precomposed form c +docstring const normalize_c(docstring const & s); + +/// Compare a docstring with a C string of ASCII characters +bool operator==(docstring const &, char const *); + +/// Compare a C string of ASCII characters with a docstring +inline bool operator==(char const * l, docstring const & r) { return r == l; } + +/// Compare a docstring with a C string of ASCII characters +inline bool operator!=(docstring const & l, char const * r) { return !(l == r); } + +/// Compare a C string of ASCII characters with a docstring +inline bool operator!=(char const * l, docstring const & r) { return !(r == l); } + +/// Concatenate a docstring and a C string of ASCII characters +docstring operator+(docstring const &, char const *); + +/// Concatenate a C string of ASCII characters and a docstring +docstring operator+(char const *, docstring const &); + +/// Concatenate a docstring and a single ASCII character +docstring operator+(docstring const & l, char r); + +/// Concatenate a single ASCII character and a docstring +docstring operator+(char l, docstring const & r); + +/// Append a C string of ASCII characters to a docstring +docstring & operator+=(docstring &, char const *); + +/// Append a single ASCII character to a docstring +docstring & operator+=(docstring & l, char r); + } // namespace lyx diff --git a/src/support/environment.cpp b/src/support/environment.cpp index 3e1494e016..552f1b0f1f 100644 --- a/src/support/environment.cpp +++ b/src/support/environment.cpp @@ -13,6 +13,8 @@ #include #include "support/environment.h" + +#include "support/docstring.h" #include "support/os.h" #include diff --git a/src/support/getcwd.cpp b/src/support/getcwd.cpp index 6d42222e86..c3ab5f3229 100644 --- a/src/support/getcwd.cpp +++ b/src/support/getcwd.cpp @@ -11,6 +11,7 @@ #include #include "support/lyxlib.h" +#include "support/docstring.h" #include "support/os.h" #include diff --git a/src/support/strfwd.h b/src/support/strfwd.h index b85ea242e0..ed22874c7d 100644 --- a/src/support/strfwd.h +++ b/src/support/strfwd.h @@ -13,21 +13,6 @@ #ifndef STRFWD_H #define STRFWD_H -namespace std { - -template struct char_traits; -template<> struct char_traits; -template<> struct char_traits; - -template class allocator; - -template class basic_string; - -typedef basic_string, allocator > string; - -} - - #ifdef USE_WCHAR_T // Prefer this if possible because GNU libstdc++ has usable @@ -44,74 +29,40 @@ namespace lyx { typedef boost::uint32_t char_type; } #endif -namespace lyx { - -typedef std::basic_string, - std::allocator > docstring; - -/// Creates a docstring from a C string of ASCII characters -docstring const from_ascii(char const *); - -/// Creates a docstring from a std::string of ASCII characters -docstring const from_ascii(std::string const &); - -/// Creates a std::string of ASCII characters from a docstring -std::string const to_ascii(docstring const &); - -/// Creates a docstring from a UTF8 string. This should go eventually. -docstring const from_utf8(std::string const &); - -/// Creates a UTF8 string from a docstring. This should go eventually. -std::string const to_utf8(docstring const &); - -/// convert \p s from the encoding of the locale to ucs4. -docstring const from_local8bit(std::string const & s); - -/** - * Convert \p s from ucs4 to the encoding of the locale. - * This may fail and throw an exception, the caller is expected to act - * appropriately. - */ -std::string const to_local8bit(docstring const & s); +namespace std { -/// convert \p s from the encoding of the file system to ucs4. -docstring const from_filesystem8bit(std::string const & s); +template struct char_traits; +template<> struct char_traits; +template<> struct char_traits; -/// convert \p s from ucs4 to the encoding of the file system. -std::string const to_filesystem8bit(docstring const & s); +template class allocator; -/// normalize \p s to precomposed form c -docstring const normalize_c(docstring const & s); +template class basic_string; -/// Compare a docstring with a C string of ASCII characters -bool operator==(docstring const &, char const *); +typedef basic_string, allocator > string; -/// Compare a C string of ASCII characters with a docstring -inline bool operator==(char const * l, docstring const & r) { return r == l; } +template class basic_istream; +template class basic_ostream; -/// Compare a docstring with a C string of ASCII characters -inline bool operator!=(docstring const & l, char const * r) { return !(l == r); } +typedef basic_istream > istream; +typedef basic_ostream > ostream; -/// Compare a C string of ASCII characters with a docstring -inline bool operator!=(char const * l, docstring const & r) { return !(r == l); } +} -/// Concatenate a docstring and a C string of ASCII characters -docstring operator+(docstring const &, char const *); -/// Concatenate a C string of ASCII characters and a docstring -docstring operator+(char const *, docstring const &); +namespace lyx { -/// Concatenate a docstring and a single ASCII character -docstring operator+(docstring const & l, char r); +typedef std::basic_string, + std::allocator > docstring; -/// Concatenate a single ASCII character and a docstring -docstring operator+(char l, docstring const & r); +/// Base class for UCS4 input streams +typedef std::basic_istream > + idocstream; -/// Append a C string of ASCII characters to a docstring -docstring & operator+=(docstring &, char const *); +/// Base class for UCS4 output streams +typedef std::basic_ostream > + odocstream; -/// Append a single ASCII character to a docstring -docstring & operator+=(docstring & l, char r); } // namespace lyx diff --git a/src/support/userinfo.cpp b/src/support/userinfo.cpp index c68d55ac3e..da86eb3355 100644 --- a/src/support/userinfo.cpp +++ b/src/support/userinfo.cpp @@ -12,6 +12,7 @@ #include "support/userinfo.h" #include "support/environment.h" +#include "support/docstring.h" #include @@ -44,7 +45,7 @@ docstring const user_name() return _("Unknown user"); return from_local8bit(name); #else - struct passwd * pw(getpwuid(geteuid())); + struct passwd * pw = getpwuid(geteuid()); BOOST_ASSERT(pw); string name = pw->pw_gecos; -- 2.39.2