mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
In order to avoid code replication, use a template-based solution for
all types requiring the exact same code, as suggested by Tommaso. This allows to simply add a single-line instantiation declaration if there's the need of adding another type requiring the same code. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37366 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
195d1c681b
commit
ab9548d06d
@ -447,15 +447,6 @@ otexstream & operator<<(otexstream & ots, SafeBreakLine)
|
||||
}
|
||||
|
||||
|
||||
otexstream & operator<<(otexstream & ots, SetEnc e)
|
||||
{
|
||||
ots.os() << e;
|
||||
ots.canBreakLine(true);
|
||||
ots.protectSpace(false);
|
||||
return ots;
|
||||
}
|
||||
|
||||
|
||||
otexstream & operator<<(otexstream & ots, docstring const & s)
|
||||
{
|
||||
size_t const len = s.length();
|
||||
@ -511,31 +502,20 @@ otexstream & operator<<(otexstream & ots, char c)
|
||||
}
|
||||
|
||||
|
||||
otexstream & operator<<(otexstream & ots, double d)
|
||||
template <typename Type>
|
||||
otexstream & operator<<(otexstream & ots, Type value)
|
||||
{
|
||||
ots.os() << d;
|
||||
ots.os() << value;
|
||||
ots.canBreakLine(true);
|
||||
ots.protectSpace(false);
|
||||
return ots;
|
||||
}
|
||||
|
||||
|
||||
otexstream & operator<<(otexstream & ots, int i)
|
||||
{
|
||||
ots.os() << i;
|
||||
ots.canBreakLine(true);
|
||||
ots.protectSpace(false);
|
||||
return ots;
|
||||
}
|
||||
|
||||
|
||||
otexstream & operator<<(otexstream & ots, unsigned int i)
|
||||
{
|
||||
ots.os() << i;
|
||||
ots.canBreakLine(true);
|
||||
ots.protectSpace(false);
|
||||
return ots;
|
||||
}
|
||||
template otexstream & operator<< <SetEnc>(otexstream & os, SetEnc);
|
||||
template otexstream & operator<< <double>(otexstream &, double);
|
||||
template otexstream & operator<< <int>(otexstream &, int);
|
||||
template otexstream & operator<< <unsigned int>(otexstream &, unsigned int);
|
||||
template otexstream & operator<< <unsigned long>(otexstream &, unsigned long);
|
||||
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
///
|
||||
void protectSpace(bool protectspace) { protectspace_ = protectspace; }
|
||||
///
|
||||
bool protectSpace() const { return protectspace_; };
|
||||
bool protectSpace() const { return protectspace_; }
|
||||
private:
|
||||
///
|
||||
odocstream & os_;
|
||||
@ -147,11 +147,8 @@ otexstream & operator<<(otexstream &, char const *);
|
||||
///
|
||||
otexstream & operator<<(otexstream &, char);
|
||||
///
|
||||
otexstream & operator<<(otexstream &, double);
|
||||
///
|
||||
otexstream & operator<<(otexstream &, int);
|
||||
///
|
||||
otexstream & operator<<(otexstream &, unsigned int);
|
||||
template <typename Type>
|
||||
otexstream & operator<<(otexstream & ots, Type value);
|
||||
|
||||
/// Helper struct for changing stream encoding
|
||||
struct SetEnc {
|
||||
@ -171,7 +168,6 @@ SetEnc setEncoding(std::string const & encoding);
|
||||
\endcode
|
||||
*/
|
||||
odocstream & operator<<(odocstream & os, SetEnc e);
|
||||
otexstream & operator<<(otexstream & os, SetEnc e);
|
||||
idocstream & operator<<(idocstream & os, SetEnc e);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user