Skip to content

Commit 675feae

Browse files
authored
Merge pull request #24 from elsid/3.6_fix_endl
Do not rely on std::endl function address and fix warnings
2 parents 68c5c57 + f976e1c commit 675feae

File tree

100 files changed

+471
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+471
-480
lines changed

examples/osgframerenderer/CaptureSettings.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ static bool writeEventHandlers( osgDB::OutputStream& os, const gsc::CaptureSetti
104104
{
105105
const gsc::CaptureSettings::EventHandlers& pl = cs.getEventHandlers();
106106
unsigned int size = pl.size();
107-
os << size << os.BEGIN_BRACKET << std::endl;
107+
os << size << os.BEGIN_BRACKET << osgDB::OutputStream::Endl{};
108108
for ( unsigned int i=0; i<size; ++i )
109109
{
110110
os << pl[i].get();
111111
}
112-
os << os.END_BRACKET << std::endl;
112+
os << os.END_BRACKET << osgDB::OutputStream::Endl{};
113113
return true;
114114
}
115115

@@ -135,12 +135,12 @@ static bool writeProperties( osgDB::OutputStream& os, const gsc::CaptureSettings
135135
{
136136
const gsc::CaptureSettings::Properties& pl = cs.getProperties();
137137
unsigned int size = pl.size();
138-
os << size << os.BEGIN_BRACKET << std::endl;
138+
os << size << os.BEGIN_BRACKET << osgDB::OutputStream::Endl{};
139139
for ( unsigned int i=0; i<size; ++i )
140140
{
141141
os << pl[i].get();
142142
}
143-
os << os.END_BRACKET << std::endl;
143+
os << os.END_BRACKET << osgDB::OutputStream::Endl{};
144144
return true;
145145
}
146146

include/osg/Plane

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,13 @@ class OSG_EXPORT Plane
241241

242242
int noAbove = 0;
243243
int noBelow = 0;
244-
int noOn = 0;
245244
for(std::vector<Vec3f>::const_iterator itr=vertices.begin();
246245
itr != vertices.end();
247246
++itr)
248247
{
249248
float d = distance(*itr);
250249
if (d>0.0f) ++noAbove;
251250
else if (d<0.0f) ++noBelow;
252-
else ++noOn;
253251
}
254252

255253
if (noAbove>0)
@@ -270,15 +268,13 @@ class OSG_EXPORT Plane
270268

271269
int noAbove = 0;
272270
int noBelow = 0;
273-
int noOn = 0;
274271
for(std::vector<Vec3d>::const_iterator itr=vertices.begin();
275272
itr != vertices.end();
276273
++itr)
277274
{
278275
double d = distance(*itr);
279276
if (d>0.0) ++noAbove;
280277
else if (d<0.0) ++noBelow;
281-
else ++noOn;
282278
}
283279

284280
if (noAbove>0)

include/osgDB/OutputStream

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public:
7676
WRITE_EXTERNAL_FILE /*!< Write Image::data() to disk and use it as external file */
7777
};
7878

79+
struct Endl {};
80+
7981
OutputStream( const osgDB::Options* options );
8082
virtual ~OutputStream();
8183

@@ -108,6 +110,7 @@ public:
108110
OutputStream& operator<<( const char* s ) { _out->writeString(s); return *this; }
109111
OutputStream& operator<<( std::ostream& (*fn)(std::ostream&) ) { _out->writeStream(fn); return *this; }
110112
OutputStream& operator<<( std::ios_base& (*fn)(std::ios_base&) ) { _out->writeBase(fn); return *this; }
113+
OutputStream& operator<<( Endl ) { _out->writeEndl(); return *this; }
111114

112115
OutputStream& operator<<( const ObjectGLenum& value ) { _out->writeGLenum(value); return *this; }
113116
OutputStream& operator<<( const ObjectProperty& prop ) { _out->writeProperty(prop); return *this; }

include/osgDB/Serializer

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public:
314314
if ( _useHex ) { os << std::hex << std::showbase; }
315315
os << value;
316316
if ( _useHex ) os << std::dec << std::noshowbase;
317-
os << std::endl;
317+
os << OutputStream::Endl{};
318318
}
319319
return true;
320320
}
@@ -368,7 +368,7 @@ public:
368368
}
369369
else if ( ParentType::_defaultValue!=value )
370370
{
371-
os << os.PROPERTY((ParentType::_name).c_str()) << value << std::endl;
371+
os << os.PROPERTY((ParentType::_name).c_str()) << value << OutputStream::Endl{};
372372
}
373373
return true;
374374
}
@@ -419,7 +419,7 @@ public:
419419
}
420420
else if ( ParentType::_defaultValue!=value )
421421
{
422-
os << os.PROPERTY((ParentType::_name).c_str()) << value << std::endl;
422+
os << os.PROPERTY((ParentType::_name).c_str()) << value << OutputStream::Endl{};
423423
}
424424
return true;
425425
}
@@ -487,7 +487,7 @@ public:
487487
}
488488
else if ( ParentType::_defaultValue!=value )
489489
{
490-
os << os.PROPERTY((ParentType::_name).c_str()) << GLENUM(value) << std::endl;
490+
os << os.PROPERTY((ParentType::_name).c_str()) << GLENUM(value) << OutputStream::Endl{};
491491
}
492492
return true;
493493
}
@@ -540,7 +540,7 @@ public:
540540
{
541541
os << os.PROPERTY((ParentType::_name).c_str());
542542
os.writeWrappedString( value );
543-
os << std::endl;
543+
os << OutputStream::Endl{};
544544
}
545545
return true;
546546
}
@@ -614,11 +614,11 @@ public:
614614
os << os.PROPERTY(_name.c_str()) << hasObject;
615615
if ( hasObject )
616616
{
617-
os << os.BEGIN_BRACKET << std::endl;
617+
os << os.BEGIN_BRACKET << OutputStream::Endl{};
618618
os.writeObject( value );
619619
os << os.END_BRACKET;
620620
}
621-
os << std::endl;
621+
os << OutputStream::Endl{};
622622
}
623623
return true;
624624
}
@@ -691,11 +691,11 @@ public:
691691
os << os.PROPERTY((ParentType::_name).c_str()) << hasObject;
692692
if ( hasObject )
693693
{
694-
os << os.BEGIN_BRACKET << std::endl;
694+
os << os.BEGIN_BRACKET << OutputStream::Endl{};
695695
os.writeImage( value );
696696
os << os.END_BRACKET;
697697
}
698-
os << std::endl;
698+
os << OutputStream::Endl{};
699699
}
700700
return true;
701701
}
@@ -756,7 +756,7 @@ public:
756756
}
757757
else if ( ParentType::_defaultValue!=value )
758758
{
759-
os << os.PROPERTY((ParentType::_name).c_str()) << getString(value) << std::endl;
759+
os << os.PROPERTY((ParentType::_name).c_str()) << getString(value) << OutputStream::Endl{};
760760
}
761761
return true;
762762
}
@@ -836,14 +836,14 @@ public:
836836
}
837837
else if ( size>0 )
838838
{
839-
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << std::endl;
839+
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << OutputStream::Endl{};
840840
for ( ConstIterator itr=list.begin();
841841
itr!=list.end(); ++itr )
842842
{
843843
os << (*itr);
844844
}
845-
os << std::endl;
846-
os << os.END_BRACKET << std::endl;
845+
os << OutputStream::Endl{};
846+
os << os.END_BRACKET << OutputStream::Endl{};
847847
}
848848
return true;
849849
}
@@ -1011,7 +1011,7 @@ public:
10111011
}
10121012
else if ( size>0 )
10131013
{
1014-
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << std::endl;
1014+
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << OutputStream::Endl{};
10151015
if (_numElementsOnRow==0)
10161016
{
10171017
for ( ConstIterator itr=list.begin(); itr!=list.end(); ++itr )
@@ -1023,7 +1023,7 @@ public:
10231023
{
10241024
for ( ConstIterator itr=list.begin(); itr!=list.end(); ++itr )
10251025
{
1026-
os << (*itr); os << std::endl;
1026+
os << (*itr); os << OutputStream::Endl{};
10271027
}
10281028
}
10291029
else
@@ -1032,12 +1032,12 @@ public:
10321032
for (ConstIterator itr=list.begin(); itr!=list.end(); ++itr)
10331033
{
10341034
os << (*itr);
1035-
if (i==0) { os << std::endl; i = _numElementsOnRow-1; }
1035+
if (i==0) { os << OutputStream::Endl{}; i = _numElementsOnRow-1; }
10361036
else --i;
10371037
}
1038-
if (i!=_numElementsOnRow) os << std::endl;
1038+
if (i!=_numElementsOnRow) os << OutputStream::Endl{};
10391039
}
1040-
os << os.END_BRACKET << std::endl;
1040+
os << os.END_BRACKET << OutputStream::Endl{};
10411041
}
10421042
return true;
10431043
}
@@ -1165,7 +1165,7 @@ public:
11651165
}
11661166
else if ( size>0 )
11671167
{
1168-
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << std::endl;
1168+
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << OutputStream::Endl{};
11691169
if (_numElementsOnRow==0)
11701170
{
11711171
for ( ConstIterator itr=list.begin(); itr!=list.end(); ++itr )
@@ -1177,7 +1177,7 @@ public:
11771177
{
11781178
for ( ConstIterator itr=list.begin(); itr!=list.end(); ++itr )
11791179
{
1180-
os << (*itr); os << std::endl;
1180+
os << (*itr); os << OutputStream::Endl{};
11811181
}
11821182
}
11831183
else
@@ -1186,12 +1186,12 @@ public:
11861186
for (ConstIterator itr=list.begin(); itr!=list.end(); ++itr)
11871187
{
11881188
os << (*itr);
1189-
if (i==0) { os << std::endl; i = _numElementsOnRow-1; }
1189+
if (i==0) { os << OutputStream::Endl{}; i = _numElementsOnRow-1; }
11901190
else --i;
11911191
}
1192-
if (i!=_numElementsOnRow) os << std::endl;
1192+
if (i!=_numElementsOnRow) os << OutputStream::Endl{};
11931193
}
1194-
os << os.END_BRACKET << std::endl;
1194+
os << os.END_BRACKET << OutputStream::Endl{};
11951195
}
11961196
return true;
11971197
}
@@ -1431,12 +1431,12 @@ public:
14311431
}
14321432
else if ( size>0 )
14331433
{
1434-
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << std::endl;
1434+
os << os.PROPERTY((_name).c_str()) << size << os.BEGIN_BRACKET << OutputStream::Endl{};
14351435
for ( ConstIterator itr=map.begin(); itr!=map.end(); ++itr )
14361436
{
1437-
os << itr->first << itr->second; os << std::endl;
1437+
os << itr->first << itr->second; os << OutputStream::Endl{};
14381438
}
1439-
os << os.END_BRACKET << std::endl;
1439+
os << os.END_BRACKET << OutputStream::Endl{};
14401440
}
14411441
return true;
14421442
}
@@ -1531,7 +1531,7 @@ public:
15311531
if ( !maskString.size() )
15321532
maskString = std::string("NONE|");
15331533
maskString.erase(maskString.size()-1,1);
1534-
os << maskString << std::endl; //remove last "|"
1534+
os << maskString << OutputStream::Endl{}; //remove last "|"
15351535
}
15361536
return true;
15371537
}

include/osgDB/StreamOperator

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public:
4949
virtual void writeString( const std::string& s ) = 0;
5050
virtual void writeStream( std::ostream& (*fn)(std::ostream&) ) = 0;
5151
virtual void writeBase( std::ios_base& (*fn)(std::ios_base&) ) = 0;
52+
virtual void writeEndl() = 0;
5253

5354
virtual void writeGLenum( const ObjectGLenum& value ) = 0;
5455
virtual void writeProperty( const ObjectProperty& prop ) = 0;
@@ -59,21 +60,6 @@ public:
5960
virtual void flush() { _out->flush(); }
6061

6162
protected:
62-
// Return true if the manipulator is std::endl
63-
bool isEndl( std::ostream& (*fn)(std::ostream&) )
64-
{
65-
#if defined (__sun) || (defined _WIN32 && !defined OSG_LIBRARY_STATIC)
66-
// What a mess, but solaris does not like taking the address below
67-
// windows std::endl is a template with different adresses in different dll's
68-
std::stringstream ss;
69-
ss << fn;
70-
std::string s = ss.str();
71-
return !s.empty() && s[0] == '\n';
72-
#else
73-
return fn==static_cast<std::ostream& (*)(std::ostream&)>(std::endl);
74-
#endif
75-
}
76-
7763
std::ostream* _out;
7864
osgDB::OutputStream* _outputStream;
7965
bool _supportBinaryBrackets;

src/osg/dxtctool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// dxtctool.cpp: implementation of DXTC Tools functions.
22
//
3-
// Copyright (C) 2002 Tanguy Fautré.
3+
// Copyright (C) 2002 Tanguy Fautré.
44
// For conditions of distribution and use,
55
// see copyright notice in dxtctool.h
66
//

src/osg/dxtctool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
//////////////////////////////////////////////////////////////////////
44
//
5-
// Copyright (C) 2002 Tanguy Fautr.
5+
// Copyright (C) 2002 Tanguy Fautré.
66
//
77
// This software is provided 'as-is', without any express or implied
88
// warranty. In no event will the authors be held liable for any damages

src/osgDB/ClassInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class PropertyOutputIterator : public osgDB::OutputIterator
6363
virtual void writeString( const std::string& s ) { _str.insert(_str.end(), s.begin(), s.end()); }
6464
virtual void writeStream( std::ostream& (*)(std::ostream&) ) {}
6565
virtual void writeBase( std::ios_base& (*)(std::ios_base&) ) {}
66+
virtual void writeEndl() {}
6667
virtual void writeGLenum( const osgDB::ObjectGLenum& value ) { writeInt(value.get()); }
6768
virtual void writeProperty( const osgDB::ObjectProperty& prop ) { _propertyName = prop._name; }
6869
virtual void writeMark( const osgDB::ObjectMark& mark ) { _markName = mark._name; }

0 commit comments

Comments
 (0)