Merge branch 'rm_stream_include' into 'master'

Remove redundant ostream, istream, iostream and sstream includes

See merge request OpenMW/openmw!2097
LTO-timing^2
jvoisin 3 years ago
commit f451b09f10

@ -5,7 +5,6 @@
#include <algorithm> #include <algorithm>
#include <random> #include <random>
#include <iostream>
namespace namespace
{ {

@ -2,7 +2,6 @@
#define OPENMW_ESSIMPORT_CONVERTER_H #define OPENMW_ESSIMPORT_CONVERTER_H
#include <limits> #include <limits>
#include <sstream>
#include <osg/Image> #include <osg/Image>
#include <osg/ref_ptr> #include <osg/ref_ptr>
@ -544,9 +543,7 @@ public:
} }
else else
{ {
std::stringstream error; throw std::runtime_error("Invalid weather ID: " + std::to_string(weatherID));
error << "Invalid weather ID:" << weatherID << std::endl;
throw std::runtime_error(error.str());
} }
} }

@ -1,7 +1,5 @@
#include "andnode.hpp" #include "andnode.hpp"
#include <sstream>
CSMFilter::AndNode::AndNode (const std::vector<std::shared_ptr<Node> >& nodes) CSMFilter::AndNode::AndNode (const std::vector<std::shared_ptr<Node> >& nodes)
: NAryNode (nodes, "and") : NAryNode (nodes, "and")
{} {}

@ -1,7 +1,5 @@
#include "ornode.hpp" #include "ornode.hpp"
#include <sstream>
CSMFilter::OrNode::OrNode (const std::vector<std::shared_ptr<Node> >& nodes) CSMFilter::OrNode::OrNode (const std::vector<std::shared_ptr<Node> >& nodes)
: NAryNode (nodes, "or") : NAryNode (nodes, "or")
{} {}

@ -1,8 +1,5 @@
#include "mergestages.hpp" #include "mergestages.hpp"
#include <sstream>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include "mergestate.hpp" #include "mergestate.hpp"

@ -1,5 +1,7 @@
#include "scriptcheck.hpp" #include "scriptcheck.hpp"
#include <sstream>
#include <components/compiler/tokenloc.hpp> #include <components/compiler/tokenloc.hpp>
#include <components/compiler/scanner.hpp> #include <components/compiler/scanner.hpp>
#include <components/compiler/fileparser.hpp> #include <components/compiler/fileparser.hpp>

@ -1,6 +1,7 @@
#include "scriptcontext.hpp" #include "scriptcontext.hpp"
#include <algorithm> #include <algorithm>
#include <sstream>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>

@ -1,6 +1,5 @@
#include "universalid.hpp" #include "universalid.hpp"
#include <ostream>
#include <stdexcept> #include <stdexcept>
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
@ -405,8 +404,3 @@ bool CSMWorld::operator< (const UniversalId& left, const UniversalId& right)
{ {
return left.isLess (right); return left.isLess (right);
} }
std::ostream& CSMWorld::operator< (std::ostream& stream, const CSMWorld::UniversalId& universalId)
{
return stream << universalId.toString();
}

@ -2,7 +2,6 @@
#define CSM_WOLRD_UNIVERSALID_H #define CSM_WOLRD_UNIVERSALID_H
#include <string> #include <string>
#include <iosfwd>
#include <vector> #include <vector>
#include <QMetaType> #include <QMetaType>
@ -199,8 +198,6 @@ namespace CSMWorld
bool operator!= (const UniversalId& left, const UniversalId& right); bool operator!= (const UniversalId& left, const UniversalId& right);
bool operator< (const UniversalId& left, const UniversalId& right); bool operator< (const UniversalId& left, const UniversalId& right);
std::ostream& operator< (std::ostream& stream, const UniversalId& universalId);
} }
Q_DECLARE_METATYPE (CSMWorld::UniversalId) Q_DECLARE_METATYPE (CSMWorld::UniversalId)

@ -1,7 +1,6 @@
#include "terraintexturemode.hpp" #include "terraintexturemode.hpp"
#include <string> #include <string>
#include <sstream>
#include <QWidget> #include <QWidget>
#include <QIcon> #include <QIcon>

@ -1,5 +1,7 @@
#include "scripterrortable.hpp" #include "scripterrortable.hpp"
#include <sstream>
#include <QHeaderView> #include <QHeaderView>
#include <components/compiler/tokenloc.hpp> #include <components/compiler/tokenloc.hpp>

@ -2,6 +2,7 @@
#include <algorithm> #include <algorithm>
#include <list> #include <list>
#include <sstream>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>

@ -19,6 +19,8 @@
#include "filter.hpp" #include "filter.hpp"
#include <sstream>
namespace namespace
{ {

@ -1,7 +1,6 @@
#include "journalviewmodel.hpp" #include "journalviewmodel.hpp"
#include <map> #include <map>
#include <sstream>
#include <MyGUI_LanguageManager.h> #include <MyGUI_LanguageManager.h>

@ -11,6 +11,8 @@
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include <string>
namespace MWGui namespace MWGui
{ {
// mWatchedTimeToStartDrowning = -1 for correct drowning state check, // mWatchedTimeToStartDrowning = -1 for correct drowning state check,
@ -36,11 +38,8 @@ namespace MWGui
{ {
if (stats.getAttribute(i) != mWatchedAttributes[i] || mWatchedStatsEmpty) if (stats.getAttribute(i) != mWatchedAttributes[i] || mWatchedStatsEmpty)
{ {
std::stringstream attrname;
attrname << "AttribVal"<<(i+1);
mWatchedAttributes[i] = stats.getAttribute(i); mWatchedAttributes[i] = stats.getAttribute(i);
setValue(attrname.str(), stats.getAttribute(i)); setValue("AttribVal" + std::to_string(i + 1), stats.getAttribute(i));
} }
} }

@ -19,7 +19,7 @@
#include "character.hpp" #include "character.hpp"
#include <iostream> #include <sstream>
#include <components/misc/mathutil.hpp> #include <components/misc/mathutil.hpp>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>

@ -1,6 +1,7 @@
#include "npcstats.hpp" #include "npcstats.hpp"
#include <iomanip> #include <iomanip>
#include <sstream>
#include <components/esm3/loadclas.hpp> #include <components/esm3/loadclas.hpp>
#include <components/esm3/loadgmst.hpp> #include <components/esm3/loadgmst.hpp>

@ -1,6 +1,7 @@
#include "ripplesimulation.hpp" #include "ripplesimulation.hpp"
#include <iomanip> #include <iomanip>
#include <sstream>
#include <osg/PolygonOffset> #include <osg/PolygonOffset>
#include <osg/Texture2D> #include <osg/Texture2D>

@ -3,6 +3,7 @@
#include <cstdlib> #include <cstdlib>
#include <iomanip> #include <iomanip>
#include <chrono> #include <chrono>
#include <sstream>
#include <components/compiler/extensions.hpp> #include <components/compiler/extensions.hpp>
#include <components/compiler/opcodes.hpp> #include <components/compiler/opcodes.hpp>

@ -27,7 +27,6 @@ extern "C"
#include <components/files/constrainedfilestream.hpp> #include <components/files/constrainedfilestream.hpp>
#include <string> #include <string>
#include <istream>
#include "sound_decoder.hpp" #include "sound_decoder.hpp"

@ -3,6 +3,7 @@
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <numeric> #include <numeric>
#include <sstream>
#include <osg/Matrixf> #include <osg/Matrixf>

@ -65,11 +65,7 @@ namespace MWWorld
} }
if (it == invStore.end()) if (it == invStore.end())
{ throw std::runtime_error("ActionEquip can't find item " + object.getCellRef().getRefId());
std::stringstream error;
error << "ActionEquip can't find item " << object.getCellRef().getRefId();
throw std::runtime_error(error.str());
}
// equip the item in the first free slot // equip the item in the first free slot
std::vector<int>::const_iterator slot=slots_.first.begin(); std::vector<int>::const_iterator slot=slots_.first.begin();

@ -2,7 +2,6 @@
#define OPENMW_MWWORLD_ESMSTORE_H #define OPENMW_MWWORLD_ESMSTORE_H
#include <memory> #include <memory>
#include <sstream>
#include <stdexcept> #include <stdexcept>
#include <unordered_map> #include <unordered_map>

@ -1,5 +1,7 @@
#include "livecellref.hpp" #include "livecellref.hpp"
#include <sstream>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/esm3/objectstate.hpp> #include <components/esm3/objectstate.hpp>
@ -78,3 +80,20 @@ unsigned int MWWorld::LiveCellRefBase::getType() const
{ {
return mClass->getType(); return mClass->getType();
} }
namespace MWWorld
{
std::string makeDynamicCastErrorMessage(const LiveCellRefBase* value, std::string_view recordType)
{
std::stringstream message;
message << "Bad LiveCellRef cast to " << recordType << " from ";
if (value != nullptr)
message << value->getTypeDescription();
else
message << "an empty object";
return message.str();
}
}

@ -5,6 +5,8 @@
#include "refdata.hpp" #include "refdata.hpp"
#include <stdexcept>
namespace ESM namespace ESM
{ {
struct ObjectState; struct ObjectState;
@ -16,6 +18,9 @@ namespace MWWorld
class ESMStore; class ESMStore;
class Class; class Class;
template <typename X>
struct LiveCellRef;
/// Used to create pointers to hold any type of LiveCellRef<> object. /// Used to create pointers to hold any type of LiveCellRef<> object.
struct LiveCellRefBase struct LiveCellRefBase
{ {
@ -46,6 +51,12 @@ namespace MWWorld
unsigned int getType() const; unsigned int getType() const;
///< @see MWWorld::Class::getType ///< @see MWWorld::Class::getType
template <class T>
static const LiveCellRef<T>* dynamicCast(const LiveCellRefBase* value);
template <class T>
static LiveCellRef<T>* dynamicCast(LiveCellRefBase* value);
protected: protected:
void loadImp (const ESM::ObjectState& state); void loadImp (const ESM::ObjectState& state);
@ -70,6 +81,24 @@ namespace MWWorld
return cellRef.mRef.getRefNum()==refNum; return cellRef.mRef.getRefNum()==refNum;
} }
std::string makeDynamicCastErrorMessage(const LiveCellRefBase* value, std::string_view recordType);
template <class T>
const LiveCellRef<T>* LiveCellRefBase::dynamicCast(const LiveCellRefBase* value)
{
if (const LiveCellRef<T>* ref = dynamic_cast<const LiveCellRef<T>*>(value))
return ref;
throw std::runtime_error(makeDynamicCastErrorMessage(value, T::getRecordType()));
}
template <class T>
LiveCellRef<T>* LiveCellRefBase::dynamicCast(LiveCellRefBase* value)
{
if (LiveCellRef<T>* ref = dynamic_cast<LiveCellRef<T>*>(value))
return ref;
throw std::runtime_error(makeDynamicCastErrorMessage(value, T::getRecordType()));
}
/// A reference to one object (of any type) in a cell. /// A reference to one object (of any type) in a cell.
/// ///
/// Constructing this with a CellRef instance in the constructor means that /// Constructing this with a CellRef instance in the constructor means that
@ -125,7 +154,6 @@ namespace MWWorld
{ {
return checkStateImp (state); return checkStateImp (state);
} }
} }
#endif #endif

@ -1,9 +1,10 @@
#include "projectilemanager.hpp" #include "projectilemanager.hpp"
#include <iomanip> #include <iomanip>
#include <sstream>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <osg/PositionAttitudeTransform> #include <osg/PositionAttitudeTransform>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>

@ -5,7 +5,6 @@
#include <type_traits> #include <type_traits>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <sstream>
#include "livecellref.hpp" #include "livecellref.hpp"
@ -76,19 +75,8 @@ namespace MWWorld
throw std::runtime_error("Cannot get class of an empty object"); throw std::runtime_error("Cannot get class of an empty object");
} }
template<typename T> template <class T>
TypeTransform<MWWorld::LiveCellRef<T>> *get() const auto* get() const { return LiveCellRefBase::dynamicCast<T>(mRef); }
{
TypeTransform<MWWorld::LiveCellRef<T>> *ref = dynamic_cast<TypeTransform<MWWorld::LiveCellRef<T>>*>(mRef);
if(ref) return ref;
std::stringstream str;
str<< "Bad LiveCellRef cast to "<<T::getRecordType()<<" from ";
if(mRef != nullptr) str<< getTypeDescription();
else str<< "an empty object";
throw std::runtime_error(str.str());
}
LiveCellRefBaseType *getBase() const LiveCellRefBaseType *getBase() const
{ {

@ -6,9 +6,7 @@
#include <deque> #include <deque>
#include <iomanip> #include <iomanip>
#include <iostream>
#include <limits> #include <limits>
#include <sstream>
#include <gtest/gtest.h> #include <gtest/gtest.h>

@ -27,7 +27,7 @@
#define BSA_MEMORY_STREAM_H #define BSA_MEMORY_STREAM_H
#include <vector> #include <vector>
#include <iostream> #include <istream>
#include <components/files/memorystream.hpp> #include <components/files/memorystream.hpp>
namespace Bsa namespace Bsa

@ -1,6 +1,7 @@
#include "scanner.hpp" #include "scanner.hpp"
#include <cassert> #include <cassert>
#include <sstream>
#include "exception.hpp" #include "exception.hpp"
#include "errorhandler.hpp" #include "errorhandler.hpp"

@ -5,7 +5,7 @@
#include <string> #include <string>
#include <iosfwd> #include <iosfwd>
#include <vector> #include <vector>
#include <sstream> #include <istream>
#include "tokenloc.hpp" #include "tokenloc.hpp"

@ -1,8 +1,6 @@
#ifndef COMPILER_STREAMERRORHANDLER_H_INCLUDED #ifndef COMPILER_STREAMERRORHANDLER_H_INCLUDED
#define COMPILER_STREAMERRORHANDLER_H_INCLUDED #define COMPILER_STREAMERRORHANDLER_H_INCLUDED
#include <ostream>
#include "errorhandler.hpp" #include "errorhandler.hpp"
namespace Compiler namespace Compiler

@ -2,7 +2,6 @@
#include <cassert> #include <cassert>
#include <cwchar> #include <cwchar>
#include <iostream>
#include <sstream> #include <sstream>
#include <thread> #include <thread>

@ -5,9 +5,7 @@
#include <DbgHelp.h> #include <DbgHelp.h>
#include <iostream>
#include <memory> #include <memory>
#include <sstream>
#include <thread> #include <thread>
#include <SDL_messagebox.h> #include <SDL_messagebox.h>

@ -2,6 +2,9 @@
#include <components/esm/esmcommon.hpp> #include <components/esm/esmcommon.hpp>
#include <istream>
#include <stdexcept>
namespace ESM namespace ESM
{ {
namespace namespace

@ -4,7 +4,7 @@
#include "defs.hpp" #include "defs.hpp"
#include <cstdint> #include <cstdint>
#include <istream> #include <iosfwd>
#include <string_view> #include <string_view>
namespace ESM namespace ESM

@ -4,7 +4,7 @@
#include "constrainedfilestreambuf.hpp" #include "constrainedfilestreambuf.hpp"
#include "streamwithbuffer.hpp" #include "streamwithbuffer.hpp"
#include <istream> #include <iosfwd>
#include <memory> #include <memory>
#include <limits> #include <limits>
#include <string> #include <string>

@ -3,7 +3,7 @@
#include <array> #include <array>
#include <cstdint> #include <cstdint>
#include <istream> #include <iosfwd>
#include <string> #include <string>
namespace Files namespace Files

@ -3,7 +3,6 @@
#include <array> #include <array>
#include <string> #include <string>
#include <sstream>
#include <cstdint> #include <cstdint>
#include <unordered_set> #include <unordered_set>
#include <optional> #include <optional>

@ -5,7 +5,6 @@
#include "nifstream.hpp" #include "nifstream.hpp"
#include <sstream>
#include <map> #include <map>
#include "niffile.hpp" #include "niffile.hpp"
@ -103,9 +102,7 @@ struct KeyMapT {
} }
else if (count != 0) else if (count != 0)
{ {
std::stringstream error; nif->file->fail("Unhandled interpolation type: " + std::to_string(mInterpolationType));
error << "Unhandled interpolation type: " << mInterpolationType;
nif->file->fail(error.str());
} }
if (morph && nif->getVersion() > NIFStream::generateVersion(10,1,0,0)) if (morph && nif->getVersion() > NIFStream::generateVersion(10,1,0,0))

@ -130,9 +130,7 @@ struct NiBoundingVolume
} }
default: default:
{ {
std::stringstream error; nif->file->fail("Unhandled NiBoundingVolume type: " + std::to_string(type));
error << "Unhandled NiBoundingVolume type: " << type;
nif->file->fail(error.str());
} }
} }
} }

@ -3,6 +3,7 @@
#include <cassert> #include <cassert>
#include <vector> #include <vector>
#include <variant> #include <variant>
#include <sstream>
#include <BulletCollision/CollisionShapes/btBoxShape.h> #include <BulletCollision/CollisionShapes/btBoxShape.h>
#include <BulletCollision/CollisionShapes/btTriangleMesh.h> #include <BulletCollision/CollisionShapes/btTriangleMesh.h>

@ -4,12 +4,10 @@
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
#include <regex> #include <regex>
#include <filesystem>
#include <osg/Program> #include <osg/Program>
#include <filesystem>
#include <fstream>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>

@ -13,7 +13,6 @@
#include <osgViewer/Renderer> #include <osgViewer/Renderer>
#include <osgViewer/Viewer> #include <osgViewer/Viewer>
#include <iostream>
#include <map> #include <map>
#include <string> #include <string>

@ -14,7 +14,6 @@
#include <osgViewer/Renderer> #include <osgViewer/Renderer>
#include <osgViewer/Viewer> #include <osgViewer/Viewer>
#include <iostream>
#include <map> #include <map>
#include <string> #include <string>

@ -1,7 +1,5 @@
#include "chunkmanager.hpp" #include "chunkmanager.hpp"
#include <sstream>
#include <osg/Texture2D> #include <osg/Texture2D>
#include <osg/Material> #include <osg/Material>

@ -1,8 +1,8 @@
#include "registerarchives.hpp" #include "registerarchives.hpp"
#include <set> #include <set>
#include <sstream>
#include <filesystem> #include <filesystem>
#include <stdexcept>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
@ -33,9 +33,7 @@ namespace VFS
} }
else else
{ {
std::stringstream message; throw std::runtime_error("Archive '" + *archive + "' not found");
message << "Archive '" << *archive << "' not found";
throw std::runtime_error(message.str());
} }
} }

Loading…
Cancel
Save