mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +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)
|
otexstream & operator<<(otexstream & ots, docstring const & s)
|
||||||
{
|
{
|
||||||
size_t const len = s.length();
|
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.canBreakLine(true);
|
||||||
ots.protectSpace(false);
|
ots.protectSpace(false);
|
||||||
return ots;
|
return ots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template otexstream & operator<< <SetEnc>(otexstream & os, SetEnc);
|
||||||
otexstream & operator<<(otexstream & ots, int i)
|
template otexstream & operator<< <double>(otexstream &, double);
|
||||||
{
|
template otexstream & operator<< <int>(otexstream &, int);
|
||||||
ots.os() << i;
|
template otexstream & operator<< <unsigned int>(otexstream &, unsigned int);
|
||||||
ots.canBreakLine(true);
|
template otexstream & operator<< <unsigned long>(otexstream &, unsigned long);
|
||||||
ots.protectSpace(false);
|
|
||||||
return ots;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
otexstream & operator<<(otexstream & ots, unsigned int i)
|
|
||||||
{
|
|
||||||
ots.os() << i;
|
|
||||||
ots.canBreakLine(true);
|
|
||||||
ots.protectSpace(false);
|
|
||||||
return ots;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public:
|
|||||||
///
|
///
|
||||||
void protectSpace(bool protectspace) { protectspace_ = protectspace; }
|
void protectSpace(bool protectspace) { protectspace_ = protectspace; }
|
||||||
///
|
///
|
||||||
bool protectSpace() const { return protectspace_; };
|
bool protectSpace() const { return protectspace_; }
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
odocstream & os_;
|
odocstream & os_;
|
||||||
@ -147,11 +147,8 @@ otexstream & operator<<(otexstream &, char const *);
|
|||||||
///
|
///
|
||||||
otexstream & operator<<(otexstream &, char);
|
otexstream & operator<<(otexstream &, char);
|
||||||
///
|
///
|
||||||
otexstream & operator<<(otexstream &, double);
|
template <typename Type>
|
||||||
///
|
otexstream & operator<<(otexstream & ots, Type value);
|
||||||
otexstream & operator<<(otexstream &, int);
|
|
||||||
///
|
|
||||||
otexstream & operator<<(otexstream &, unsigned int);
|
|
||||||
|
|
||||||
/// Helper struct for changing stream encoding
|
/// Helper struct for changing stream encoding
|
||||||
struct SetEnc {
|
struct SetEnc {
|
||||||
@ -171,7 +168,6 @@ SetEnc setEncoding(std::string const & encoding);
|
|||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
odocstream & operator<<(odocstream & os, SetEnc e);
|
odocstream & operator<<(odocstream & os, SetEnc e);
|
||||||
otexstream & operator<<(otexstream & os, SetEnc e);
|
|
||||||
idocstream & operator<<(idocstream & os, SetEnc e);
|
idocstream & operator<<(idocstream & os, SetEnc e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user