Base: cppcoreguidelines
This commit is contained in:
@@ -313,8 +313,8 @@ void InventorFieldWriter::write<int>(const char* fieldName,
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
LabelItem::LabelItem(const std::string& text)
|
||||
: text(text)
|
||||
LabelItem::LabelItem(std::string text)
|
||||
: text(std::move(text))
|
||||
{}
|
||||
|
||||
void LabelItem::write(InventorOutput& out) const
|
||||
@@ -326,8 +326,8 @@ void LabelItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
InfoItem::InfoItem(const std::string& text)
|
||||
: text(text)
|
||||
InfoItem::InfoItem(std::string text)
|
||||
: text(std::move(text))
|
||||
{}
|
||||
|
||||
void InfoItem::write(InventorOutput& out) const
|
||||
@@ -403,10 +403,8 @@ void LineItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
MultiLineItem::MultiLineItem(const std::vector<Vector3f>& points,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb)
|
||||
: points {points}
|
||||
MultiLineItem::MultiLineItem(std::vector<Vector3f> points, DrawStyle drawStyle, const ColorRGB& rgb)
|
||||
: points {std::move(points)}
|
||||
, drawStyle {drawStyle}
|
||||
, rgb {rgb}
|
||||
{}
|
||||
@@ -670,7 +668,6 @@ void ShapeHintsItem::setShapeType(ShapeType::Type value)
|
||||
shapeType.type = value;
|
||||
}
|
||||
|
||||
|
||||
void ShapeHintsItem::write(InventorOutput& out) const
|
||||
{
|
||||
out.write() << "ShapeHints {\n";
|
||||
@@ -699,8 +696,8 @@ void PolygonOffsetItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Coordinate3Item::Coordinate3Item(const std::vector<Vector3f>& points)
|
||||
: points(points)
|
||||
Coordinate3Item::Coordinate3Item(std::vector<Vector3f> points)
|
||||
: points(std::move(points))
|
||||
{}
|
||||
|
||||
void Coordinate3Item::write(InventorOutput& out) const
|
||||
@@ -739,8 +736,8 @@ void LineSetItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
FaceSetItem::FaceSetItem(const std::vector<int>& indices)
|
||||
: indices(indices)
|
||||
FaceSetItem::FaceSetItem(std::vector<int> indices)
|
||||
: indices(std::move(indices))
|
||||
{}
|
||||
|
||||
void FaceSetItem::write(InventorOutput& out) const
|
||||
@@ -755,8 +752,8 @@ void FaceSetItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
IndexedLineSetItem::IndexedLineSetItem(const std::vector<int>& indices)
|
||||
: indices(indices)
|
||||
IndexedLineSetItem::IndexedLineSetItem(std::vector<int> indices)
|
||||
: indices(std::move(indices))
|
||||
{}
|
||||
|
||||
void IndexedLineSetItem::write(InventorOutput& out) const
|
||||
@@ -771,8 +768,8 @@ void IndexedLineSetItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
IndexedFaceSetItem::IndexedFaceSetItem(const std::vector<int>& indices)
|
||||
: indices(indices)
|
||||
IndexedFaceSetItem::IndexedFaceSetItem(std::vector<int> indices)
|
||||
: indices(std::move(indices))
|
||||
{}
|
||||
|
||||
void IndexedFaceSetItem::write(InventorOutput& out) const
|
||||
@@ -787,8 +784,8 @@ void IndexedFaceSetItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
NormalItem::NormalItem(const std::vector<Base::Vector3f>& vec)
|
||||
: vector(vec)
|
||||
NormalItem::NormalItem(std::vector<Base::Vector3f> vec)
|
||||
: vector(std::move(vec))
|
||||
{}
|
||||
|
||||
void NormalItem::write(InventorOutput& out) const
|
||||
@@ -903,8 +900,8 @@ void NurbsSurfaceItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Text2Item::Text2Item(const std::string& string)
|
||||
: string(string)
|
||||
Text2Item::Text2Item(std::string string)
|
||||
: string(std::move(string))
|
||||
{}
|
||||
|
||||
void Text2Item::write(InventorOutput& out) const
|
||||
@@ -915,6 +912,7 @@ void Text2Item::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
TransformItem::TransformItem(const Base::Placement& placement)
|
||||
: placement(placement)
|
||||
{}
|
||||
|
||||
@@ -260,7 +260,7 @@ protected:
|
||||
class BaseExport LabelItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit LabelItem(const std::string& text);
|
||||
explicit LabelItem(std::string text);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -273,7 +273,7 @@ private:
|
||||
class BaseExport InfoItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit InfoItem(const std::string& text);
|
||||
explicit InfoItem(std::string text);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -326,7 +326,7 @@ class BaseExport MultiLineItem: public NodeItem
|
||||
public:
|
||||
/// add a line defined by a list of points whereat always a pair (i.e. a point and the following
|
||||
/// point) builds a line.
|
||||
explicit MultiLineItem(const std::vector<Vector3f>& points,
|
||||
explicit MultiLineItem(std::vector<Vector3f> points,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F});
|
||||
void write(InventorOutput& out) const override;
|
||||
@@ -466,7 +466,7 @@ private:
|
||||
class BaseExport Coordinate3Item: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit Coordinate3Item(const std::vector<Vector3f>& points);
|
||||
explicit Coordinate3Item(std::vector<Vector3f> points);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -499,7 +499,7 @@ public:
|
||||
class BaseExport FaceSetItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit FaceSetItem(const std::vector<int>&);
|
||||
explicit FaceSetItem(std::vector<int>);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -512,7 +512,7 @@ private:
|
||||
class BaseExport IndexedLineSetItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit IndexedLineSetItem(const std::vector<int>&);
|
||||
explicit IndexedLineSetItem(std::vector<int>);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -525,7 +525,7 @@ private:
|
||||
class BaseExport IndexedFaceSetItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit IndexedFaceSetItem(const std::vector<int>&);
|
||||
explicit IndexedFaceSetItem(std::vector<int>);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -538,7 +538,7 @@ private:
|
||||
class BaseExport NormalItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit NormalItem(const std::vector<Base::Vector3f>& vec);
|
||||
explicit NormalItem(std::vector<Base::Vector3f> vec);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -627,7 +627,7 @@ private:
|
||||
class BaseExport Text2Item: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit Text2Item(const std::string&);
|
||||
explicit Text2Item(std::string);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -38,12 +38,11 @@ TYPESYSTEM_SOURCE(Base::Exception, Base::BaseClass)
|
||||
|
||||
|
||||
Exception::Exception()
|
||||
: _line(0)
|
||||
: _sErrMsg("FreeCAD Exception")
|
||||
, _line(0)
|
||||
, _isTranslatable(false)
|
||||
, _isReported(false)
|
||||
{
|
||||
_sErrMsg = "FreeCAD Exception";
|
||||
}
|
||||
{}
|
||||
|
||||
Exception::Exception(const Exception& inst) = default;
|
||||
|
||||
@@ -56,8 +55,8 @@ Exception::Exception(const char* sMessage)
|
||||
, _isReported(false)
|
||||
{}
|
||||
|
||||
Exception::Exception(const std::string& sMessage)
|
||||
: _sErrMsg(sMessage)
|
||||
Exception::Exception(std::string sMessage)
|
||||
: _sErrMsg(std::move(sMessage))
|
||||
, _line(0)
|
||||
, _isTranslatable(false)
|
||||
, _isReported(false)
|
||||
@@ -283,9 +282,8 @@ FileException::FileException(const char* sMessage, const FileInfo& File)
|
||||
|
||||
FileException::FileException()
|
||||
: Exception("Unknown file exception happened")
|
||||
{
|
||||
_sErrMsgAndFileName = _sErrMsg;
|
||||
}
|
||||
, _sErrMsgAndFileName(_sErrMsg)
|
||||
{}
|
||||
|
||||
void FileException::setFileName(const char* sFileName)
|
||||
{
|
||||
|
||||
@@ -248,7 +248,7 @@ protected:
|
||||
* The preferred way of throwing an exception is using the macros above.
|
||||
* This way, the file, line, and function are automatically inserted. */
|
||||
explicit Exception(const char* sMessage);
|
||||
explicit Exception(const std::string& sMessage);
|
||||
explicit Exception(std::string sMessage);
|
||||
Exception();
|
||||
Exception(const Exception& inst);
|
||||
Exception(Exception&& inst) noexcept;
|
||||
|
||||
@@ -30,7 +30,6 @@ using namespace Base;
|
||||
FutureWatcherProgress::FutureWatcherProgress(const char* text, unsigned int steps)
|
||||
: seq(text, 100)
|
||||
, steps(steps)
|
||||
, current(0)
|
||||
{}
|
||||
|
||||
FutureWatcherProgress::~FutureWatcherProgress() = default;
|
||||
|
||||
@@ -49,7 +49,7 @@ public Q_SLOTS:
|
||||
|
||||
private:
|
||||
Base::SequencerLauncher seq;
|
||||
unsigned int steps, current;
|
||||
unsigned int steps, current {0};
|
||||
};
|
||||
} // namespace Base
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ struct StdInputStream::TextCodec
|
||||
{
|
||||
QTextCodec* textCodec = QTextCodec::codecForName("UTF-8");
|
||||
if (textCodec) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
const QString text = textCodec->toUnicode(reinterpret_cast<char*>(toFill),
|
||||
static_cast<int>(len),
|
||||
&state);
|
||||
@@ -85,6 +86,7 @@ struct StdInputStream::TextCodec
|
||||
{
|
||||
void validateBytes(XMLByte* const toFill, std::streamsize len)
|
||||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
QByteArray encodedString(reinterpret_cast<char*>(toFill), static_cast<int>(len));
|
||||
auto toUtf16 = QStringDecoder(QStringDecoder::Utf8);
|
||||
QString text = toUtf16(encodedString);
|
||||
@@ -133,7 +135,7 @@ XMLSize_t StdInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxTo
|
||||
// Read up to the maximum bytes requested. We return the number
|
||||
// actually read.
|
||||
//
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
stream.read(reinterpret_cast<char*>(toFill), static_cast<std::streamsize>(maxToRead));
|
||||
std::streamsize len = stream.gcount();
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
return _exitCode;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
long _exitCode;
|
||||
};
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ struct string_comp
|
||||
class unique_name
|
||||
{
|
||||
public:
|
||||
unique_name(const std::string& name, const std::vector<std::string>& names, int padding)
|
||||
: base_name {name}
|
||||
unique_name(std::string name, const std::vector<std::string>& names, int padding)
|
||||
: base_name {std::move(name)}
|
||||
, padding {padding}
|
||||
{
|
||||
removeDigitsFromEnd();
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
using namespace Base;
|
||||
XERCES_CPP_NAMESPACE_USE
|
||||
|
||||
std::unique_ptr<XMLTranscoder> XMLTools::transcoder;
|
||||
std::unique_ptr<XMLTranscoder> XMLTools::transcoder; // NOLINT
|
||||
|
||||
void XMLTools::initialize()
|
||||
{
|
||||
@@ -40,7 +40,7 @@ void XMLTools::initialize()
|
||||
4096,
|
||||
XMLPlatformUtils::fgMemoryManager));
|
||||
if (res != XMLTransService::Ok) {
|
||||
throw Base::UnicodeError("Can\'t create transcoder");
|
||||
throw Base::UnicodeError("Can't create transcoder");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,7 @@ std::string XMLTools::toStdString(const XMLCh* const toTranscode)
|
||||
128,
|
||||
eaten,
|
||||
XMLTranscoder::UnRep_RepChar);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
str.append(reinterpret_cast<const char*>(outBuff), outputLength);
|
||||
offset += eaten;
|
||||
inputLength -= eaten;
|
||||
@@ -88,6 +89,7 @@ std::basic_string<XMLCh> XMLTools::toXMLString(const char* const fromTranscode)
|
||||
initialize();
|
||||
|
||||
static XMLCh outBuff[128];
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
const XMLByte* xmlBytes = reinterpret_cast<const XMLByte*>(fromTranscode);
|
||||
XMLSize_t outputLength = 0;
|
||||
XMLSize_t eaten = 0;
|
||||
|
||||
@@ -78,10 +78,8 @@ inline std::ostream& operator<<(std::ostream& target, const StrX& toDump)
|
||||
}
|
||||
|
||||
inline StrX::StrX(const XMLCh* const toTranscode)
|
||||
{
|
||||
// Call the private transcoding method
|
||||
fLocalForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode);
|
||||
}
|
||||
: fLocalForm(XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode))
|
||||
{}
|
||||
|
||||
inline StrX::~StrX()
|
||||
{
|
||||
@@ -158,9 +156,8 @@ private:
|
||||
|
||||
|
||||
inline XStr::XStr(const char* const toTranscode)
|
||||
{
|
||||
fUnicodeForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode);
|
||||
}
|
||||
: fUnicodeForm(XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode))
|
||||
{}
|
||||
|
||||
inline XStr::~XStr()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user