Remove redundant ostream, istream, iostream and sstream includes

* Replace by std::to_string and operator+ where possible.
* Move the code requiring to include <sstream> from .hpp to .cpp files.
LTO-timing^2
elsid 2 years ago
parent cec7f1e7bc
commit bef15edf0b
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

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

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

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

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

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

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

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

@ -1,6 +1,5 @@
#include "universalid.hpp"
#include <ostream>
#include <stdexcept>
#include <sstream>
#include <iostream>
@ -405,8 +404,3 @@ bool CSMWorld::operator< (const UniversalId& left, const UniversalId& 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
#include <string>
#include <iosfwd>
#include <vector>
#include <QMetaType>
@ -199,8 +198,6 @@ namespace CSMWorld
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)

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

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

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

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

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

@ -11,6 +11,8 @@
#include "../mwworld/esmstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include <string>
namespace MWGui
{
// mWatchedTimeToStartDrowning = -1 for correct drowning state check,
@ -36,11 +38,8 @@ namespace MWGui
{
if (stats.getAttribute(i) != mWatchedAttributes[i] || mWatchedStatsEmpty)
{
std::stringstream attrname;
attrname << "AttribVal"<<(i+1);
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 <iostream>
#include <sstream>
#include <components/misc/mathutil.hpp>
#include <components/misc/rng.hpp>

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

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

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

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

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

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

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

@ -1,5 +1,7 @@
#include "livecellref.hpp"
#include <sstream>
#include <components/debug/debuglog.hpp>
#include <components/esm3/objectstate.hpp>
@ -78,3 +80,20 @@ unsigned int MWWorld::LiveCellRefBase::getType() const
{
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 <stdexcept>
namespace ESM
{
struct ObjectState;
@ -16,6 +18,9 @@ namespace MWWorld
class ESMStore;
class Class;
template <typename X>
struct LiveCellRef;
/// Used to create pointers to hold any type of LiveCellRef<> object.
struct LiveCellRefBase
{
@ -46,6 +51,12 @@ namespace MWWorld
unsigned int getType() const;
///< @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:
void loadImp (const ESM::ObjectState& state);
@ -70,6 +81,24 @@ namespace MWWorld
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.
///
/// Constructing this with a CellRef instance in the constructor means that
@ -125,7 +154,6 @@ namespace MWWorld
{
return checkStateImp (state);
}
}
#endif

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

@ -5,7 +5,6 @@
#include <type_traits>
#include <string>
#include <string_view>
#include <sstream>
#include "livecellref.hpp"
@ -76,19 +75,8 @@ namespace MWWorld
throw std::runtime_error("Cannot get class of an empty object");
}
template<typename T>
TypeTransform<MWWorld::LiveCellRef<T>> *get() const
{
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());
}
template <class T>
auto* get() const { return LiveCellRefBase::dynamicCast<T>(mRef); }
LiveCellRefBaseType *getBase() const
{

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save