Cppcheck warnings.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-07-06 12:58:26 +03:00
parent 189f091bb4
commit e6eb9c756b
41 changed files with 255 additions and 253 deletions

View File

@ -6,11 +6,12 @@
CPPCHECK="../../../../cppcheck/cppcheck"
$CPPCHECK \
-j4 -f -q \
-UDRW_DBG \
-U__INTEL_COMPILER_UPDATE \
-UqApp \
--template '{file}:{line}:{message}:{id}' \
--inline-suppr \
--platform=unix32 \
--platform=unix64 \
--std=c++11 \
--std=posix \
--enable=all \

View File

@ -1923,9 +1923,10 @@ void TMainWindow::SetupMenu()
{
QAction *action = new QAction(this);
recentFileActs[i] = action;
connect(action, &QAction::triggered, this, [action, this]()
connect(action, &QAction::triggered, this, [this]()
{
if (action != nullptr)
QAction *action = qobject_cast<QAction *>(sender());
if (action)
{
const QString filePath = action->data().toString();
if (not filePath.isEmpty())

View File

@ -311,7 +311,7 @@ UTF8STRING dx_iface::AddFont(const QFont &f)
return ts.name;
}
std::string dx_iface::LocaleToISO() const
std::string dx_iface::LocaleToISO()
{
QMap <std::string, std::string> locMap;
locMap["croatian"] = "ISO8859-2";

View File

@ -26,7 +26,7 @@ public:
: path()
{}
dx_ifaceImg(const DRW_Image& p)
explicit dx_ifaceImg(const DRW_Image& p)
: DRW_Image(p),
path()
{}
@ -42,7 +42,7 @@ public:
: ent()
{}
dx_ifaceBlock(const DRW_Block& p)
explicit dx_ifaceBlock(const DRW_Block& p)
: DRW_Block(p),
ent()
{}
@ -132,7 +132,7 @@ private:
void InitTextstyles();
void InitAppId();
std::string LocaleToISO() const;
static std::string LocaleToISO();
};
#endif // DX_IFACE_H

View File

@ -194,6 +194,12 @@ public:
z(iz)
{}
DRW_Coord(const DRW_Coord &data)
: x(data.x),
y(data.y),
z(data.z)
{}
DRW_Coord &operator = (const DRW_Coord& data)
{
if ( &data == this )
@ -310,7 +316,7 @@ public:
addDouble(d);
}
DRW_Variant(int c, UTF8STRING s)
DRW_Variant(int c, const UTF8STRING &s)
: content(),
type(),
code(c),
@ -320,7 +326,7 @@ public:
addString(s);
}
DRW_Variant(int c, DRW_Coord crd)
DRW_Variant(int c, const DRW_Coord &crd)
: content(),
type(),
code(c),
@ -352,11 +358,11 @@ public:
~DRW_Variant() = default;
void addString(UTF8STRING s) {setType(STRING); sdata = s; content.s = &sdata;}
void addString(const UTF8STRING &s) {setType(STRING); sdata = s; content.s = &sdata;}
void addInt(int i) {setType(INTEGER); content.i = i;}
void addDouble(double d) {setType(DOUBLE); content.d = d;}
void addCoord() {setType(COORD); vdata.x=0.0; vdata.y=0.0; vdata.z=0.0; content.v = &vdata;}
void addCoord(DRW_Coord v) {setType(COORD); vdata = v; content.v = &vdata;}
void addCoord(const DRW_Coord &v) {setType(COORD); vdata = v; content.v = &vdata;}
void setType(enum TYPE t) { type = t;}
void setCoordX(double d) { if (type == COORD) vdata.x = d;}
void setCoordY(double d) { if (type == COORD) vdata.y = d;}
@ -376,6 +382,7 @@ public:
int code; /*!< dxf code of this value*/
private:
DRW_Variant &operator=(const DRW_Variant &) Q_DECL_EQ_DELETE;
std::string sdata;
DRW_Coord vdata;
};

View File

@ -55,7 +55,7 @@ void DRW_Entity::calculateAxis(DRW_Coord extPoint){
* apply extrusion in a point using arbitary axis (previous calculated)
* @author Rallaz
*/
void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point){
void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const{
double px, py, pz;
px = (extAxisX.x*point->x)+(extAxisY.x*point->y)+(extPoint.x*point->z);
py = (extAxisX.y*point->x)+(extAxisY.y*point->y)+(extPoint.y*point->z);
@ -782,7 +782,6 @@ bool DRW_Ellipse::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
//parts are the number of vertex to split polyline, default 128
void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
double radMajor, radMinor, cosRot, sinRot, incAngle, curAngle;
double cosCurr, sinCurr;
radMajor = sqrt(secPoint.x*secPoint.x + secPoint.y*secPoint.y);
radMinor = radMajor*ratio;
//calculate sin & cos of included angle
@ -797,8 +796,8 @@ void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
curAngle = endparam;
i = parts+2;
}
cosCurr = cos(curAngle);
sinCurr = sin(curAngle);
double cosCurr = cos(curAngle);
double sinCurr = sin(curAngle);
double x = basePoint.x + (cosCurr*cosRot*radMajor) - (sinCurr*sinRot*radMinor);
double y = basePoint.y + (cosCurr*sinRot*radMajor) + (sinCurr*cosRot*radMinor);
pol->addVertex( DRW_Vertex(x, y, 0.0, 0.0));

View File

@ -216,7 +216,7 @@ protected:
//calculates extrusion axis (normal vector)
void calculateAxis(DRW_Coord extPoint);
//apply extrusion to @extPoint and return data in @point
void extrudePoint(DRW_Coord extPoint, DRW_Coord *point);
void extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const;
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0)=0;
//parses dwg common start part to read entity
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBuf, duint32 bs=0);
@ -398,23 +398,23 @@ public:
virtual void applyExtrusion();
//! center point in OCS
const DRW_Coord & center() { return basePoint; }
const DRW_Coord & center() const { return basePoint; }
//! the radius of the circle
double radius() { return radious; }
double radius() const { return radious; }
//! start angle in radians
double startAngle() { return staangle; }
double startAngle() const { return staangle; }
//! end angle in radians
double endAngle() { return endangle; }
double endAngle() const { return endangle; }
//! thickness
double thick() { return thickness; }
double thick() const { return thickness; }
//! extrusion
const DRW_Coord & extrusion() { return extPoint; }
const DRW_Coord & extrusion() const { return extPoint; }
protected:
//! interpret code in dxf reading process or dispatch to inherited class
void parseCode(int code, dxfReader *reader);
//! interpret dwg data (was already determined to be part of this object)
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
double staangle; /*!< start angle, code 50 in radians*/
@ -448,7 +448,7 @@ protected:
//! interpret code in dxf reading process or dispatch to inherited class
void parseCode(int code, dxfReader *reader);
//! interpret dwg data (was already determined to be part of this object)
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
private:
void correctAxis();
@ -479,7 +479,7 @@ public:
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
DRW_Coord thirdPoint; /*!< third point, code 12, 22 & 32 */
@ -506,19 +506,19 @@ protected:
public:
//! first corner (2D)
const DRW_Coord & firstCorner() { return basePoint; }
const DRW_Coord & firstCorner() const { return basePoint; }
//! second corner (2D)
const DRW_Coord & secondCorner() { return secPoint; }
const DRW_Coord & secondCorner() const { return secPoint; }
//! third corner (2D)
const DRW_Coord & thirdCorner() { return thirdPoint; }
const DRW_Coord & thirdCorner() const { return thirdPoint; }
//! fourth corner (2D)
const DRW_Coord & fourthCorner() { return thirdPoint; }
const DRW_Coord & fourthCorner() const { return thirdPoint; }
//! thickness
double thick() { return thickness; }
double thick() const { return thickness; }
//! elevation
double elevation() { return basePoint.z; }
double elevation() const { return basePoint.z; }
//! extrusion
const DRW_Coord & extrusion() { return extPoint; }
const DRW_Coord & extrusion() const { return extPoint; }
};
@ -545,18 +545,18 @@ public:
eType = DRW::E3DFACE;
}
virtual void applyExtrusion(){}
virtual void applyExtrusion() {}
//! first corner in WCS
const DRW_Coord & firstCorner() { return basePoint; }
const DRW_Coord & firstCorner() const { return basePoint; }
//! second corner in WCS
const DRW_Coord & secondCorner() { return secPoint; }
const DRW_Coord & secondCorner() const { return secPoint; }
//! third corner in WCS
const DRW_Coord & thirdCorner() { return thirdPoint; }
const DRW_Coord & thirdCorner() const { return thirdPoint; }
//! fourth corner in WCS
const DRW_Coord & fourthCorner() { return fourPoint; }
const DRW_Coord & fourthCorner() const { return fourPoint; }
//! edge visibility flags
InvisibleEdgeFlags edgeFlags() { return static_cast<InvisibleEdgeFlags>(invisibleflag); }
InvisibleEdgeFlags edgeFlags() const { return static_cast<InvisibleEdgeFlags>(invisibleflag); }
protected:
//! interpret code in dxf reading process or dispatch to inherited class
@ -590,7 +590,7 @@ public:
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
UTF8STRING name; /*!< block name, code 2 */
@ -628,7 +628,7 @@ public:
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
UTF8STRING name; /*!< block name, code 2 */
@ -706,7 +706,7 @@ public:
protected:
void parseCode(int code, dxfReader *reader);
bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
int vertexnum; /*!< number of vertex, code 90 */
@ -963,6 +963,7 @@ public:
std::vector<DRW_Vertex *> vertlist; /*!< vertex list */
private:
DRW_Polyline &operator=(const DRW_Polyline &) Q_DECL_EQ_DELETE;
std::list<duint32>hadlesList; //list of handles, only in 2004+
duint32 firstEH; //handle of first entity, only in pre-2004
duint32 lastEH; //handle of last entity, only in pre-2004
@ -1078,7 +1079,7 @@ private:
*/
class DRW_HatchLoop {
public:
DRW_HatchLoop(int t)
explicit DRW_HatchLoop(int t)
: type(t),
numedges(0),
objlist()
@ -1342,26 +1343,26 @@ protected:
public:
DRW_Coord getDefPoint() const {return defPoint;} /*!< Definition point, code 10, 20 & 30 */
void setDefPoint(const DRW_Coord p) {defPoint =p;}
void setDefPoint(const DRW_Coord &p) {defPoint =p;}
DRW_Coord getTextPoint() const {return textPoint;} /*!< Middle point of text, code 11, 21 & 31 */
void setTextPoint(const DRW_Coord p) {textPoint =p;}
void setTextPoint(const DRW_Coord &p) {textPoint =p;}
std::string getStyle() const {return style;} /*!< Dimension style, code 3 */
void setStyle(const std::string s) {style = s;}
void setStyle(const std::string &s) {style = s;}
int getAlign() const { return align;} /*!< attachment point, code 71 */
void setAlign(const int a) { align = a;}
int getTextLineStyle() const { return linesty;} /*!< Dimension text line spacing style, code 72, default 1 */
void setTextLineStyle(const int l) { linesty = l;}
std::string getText() const {return text;} /*!< Dimension text explicitly entered by the user, code 1 */
void setText(const std::string t) {text = t;}
void setText(const std::string &t) {text = t;}
double getTextLineFactor() const { return linefactor;} /*!< Dimension text line spacing factor, code 41, default 1? */
void setTextLineFactor(const double l) { linefactor = l;}
double getDir() const { return rot;} /*!< rotation angle of the dimension text, code 53 (optional) default 0 */
void setDir(const double d) { rot = d;}
DRW_Coord getExtrusion(){return extPoint;} /*!< extrusion, code 210, 220 & 230 */
void setExtrusion(const DRW_Coord p) {extPoint =p;}
std::string getName(){return name;} /*!< Name of the block that contains the entities, code 2 */
void setName(const std::string s) {name = s;}
DRW_Coord getExtrusion() const {return extPoint;} /*!< extrusion, code 210, 220 & 230 */
void setExtrusion(const DRW_Coord &p) {extPoint = p;}
std::string getName() const {return name;} /*!< Name of the block that contains the entities, code 2 */
void setName(const std::string &s) {name = s;}
// int getType(){ return type;} /*!< Dimension type, code 70 */
bool hasActualMeasurement() const { return hasActual; }
void setActualMeasurement(double value) { hasActual = true; actual = value; }
@ -1369,15 +1370,15 @@ public:
protected:
DRW_Coord getPt2() const {return clonePoint;}
void setPt2(const DRW_Coord p) {clonePoint= p;}
void setPt2(const DRW_Coord &p) {clonePoint= p;}
DRW_Coord getPt3() const {return def1;}
void setPt3(const DRW_Coord p) {def1= p;}
void setPt3(const DRW_Coord &p) {def1= p;}
DRW_Coord getPt4() const {return def2;}
void setPt4(const DRW_Coord p) {def2= p;}
void setPt4(const DRW_Coord &p) {def2= p;}
DRW_Coord getPt5() const {return circlePoint;}
void setPt5(const DRW_Coord p) {circlePoint= p;}
void setPt5(const DRW_Coord &p) {circlePoint= p;}
DRW_Coord getPt6() const {return arcPoint;}
void setPt6(const DRW_Coord p) {arcPoint= p;}
void setPt6(const DRW_Coord &p) {arcPoint= p;}
double getAn50() const {return angle;} /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
void setAn50(const double d) {angle = d;}
double getOb52() const {return oblique;} /*!< oblique angle, code 52 */
@ -1387,6 +1388,7 @@ protected:
public:
int type; /*!< Dimension type, code 70 */
private:
DRW_Dimension &operator=(const DRW_Dimension &) Q_DECL_EQ_DELETE;
std::string name; /*!< Name of the block that contains the entities, code 2 */
DRW_Coord defPoint; /*!< definition point, code 10, 20 & 30 (WCS) */
DRW_Coord textPoint; /*!< Middle point of text, code 11, 21 & 31 (OCS) */
@ -1429,19 +1431,21 @@ public:
eType = DRW::DIMALIGNED;
type = 1;
}
DRW_DimAligned(const DRW_Dimension& d): DRW_Dimension(d) {
explicit DRW_DimAligned(const DRW_Dimension& d)
: DRW_Dimension(d)
{
eType = DRW::DIMALIGNED;
}
DRW_Coord getClonepoint() const {return getPt2();} /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */
void setClonePoint(DRW_Coord c){setPt2(c);}
void setClonePoint(DRW_Coord &c){setPt2(c);}
DRW_Coord getDimPoint() const {return getDefPoint();} /*!< dim line location point, code 10, 20 & 30 */
void setDimPoint(const DRW_Coord p){setDefPoint(p);}
void setDimPoint(const DRW_Coord &p){setDefPoint(p);}
DRW_Coord getDef1Point() const {return getPt3();} /*!< Definition point 1, code 13, 23 & 33 */
void setDef1Point(const DRW_Coord p) {setPt3(p);}
void setDef1Point(const DRW_Coord &p) {setPt3(p);}
DRW_Coord getDef2Point() const {return getPt4();} /*!< Definition point 2, code 14, 24 & 34 */
void setDef2Point(const DRW_Coord p) {setPt4(p);}
void setDef2Point(const DRW_Coord &p) {setPt4(p);}
protected:
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
@ -1458,7 +1462,9 @@ public:
eType = DRW::DIMLINEAR;
type = 0;
}
DRW_DimLinear(const DRW_Dimension& d): DRW_DimAligned(d) {
explicit DRW_DimLinear(const DRW_Dimension& d)
: DRW_DimAligned(d)
{
eType = DRW::DIMLINEAR;
}
@ -1480,14 +1486,16 @@ public:
eType = DRW::DIMRADIAL;
type = 4;
}
DRW_DimRadial(const DRW_Dimension& d): DRW_Dimension(d) {
explicit DRW_DimRadial(const DRW_Dimension& d)
: DRW_Dimension(d)
{
eType = DRW::DIMRADIAL;
}
DRW_Coord getCenterPoint() const {return getDefPoint();} /*!< center point, code 10, 20 & 30 */
void setCenterPoint(const DRW_Coord p){setDefPoint(p);}
void setCenterPoint(const DRW_Coord &p){setDefPoint(p);}
DRW_Coord getDiameterPoint() const {return getPt5();} /*!< Definition point for radius, code 15, 25 & 35 */
void setDiameterPoint(const DRW_Coord p){setPt5(p);}
void setDiameterPoint(const DRW_Coord &p){setPt5(p);}
double getLeaderLength() const {return getRa40();} /*!< Leader length, code 40 */
void setLeaderLength(const double d) {setRa40(d);}
@ -1507,14 +1515,16 @@ public:
eType = DRW::DIMDIAMETRIC;
type = 3;
}
DRW_DimDiametric(const DRW_Dimension& d): DRW_Dimension(d) {
explicit DRW_DimDiametric(const DRW_Dimension& d)
: DRW_Dimension(d)
{
eType = DRW::DIMDIAMETRIC;
}
DRW_Coord getDiameter1Point() const {return getPt5();} /*!< First definition point for diameter, code 15, 25 & 35 */
void setDiameter1Point(const DRW_Coord p){setPt5(p);}
void setDiameter1Point(const DRW_Coord &p){setPt5(p);}
DRW_Coord getDiameter2Point() const {return getDefPoint();} /*!< Oposite point for diameter, code 10, 20 & 30 */
void setDiameter2Point(const DRW_Coord p){setDefPoint(p);}
void setDiameter2Point(const DRW_Coord &p){setDefPoint(p);}
double getLeaderLength() const {return getRa40();} /*!< Leader length, code 40 */
void setLeaderLength(const double d) {setRa40(d);}
@ -1534,20 +1544,21 @@ public:
eType = DRW::DIMANGULAR;
type = 2;
}
DRW_DimAngular(const DRW_Dimension& d): DRW_Dimension(d) {
explicit DRW_DimAngular(const DRW_Dimension& d): DRW_Dimension(d)
{
eType = DRW::DIMANGULAR;
}
DRW_Coord getFirstLine1() const {return getPt3();} /*!< Definition point line 1-1, code 13, 23 & 33 */
void setFirstLine1(const DRW_Coord p) {setPt3(p);}
void setFirstLine1(const DRW_Coord &p) {setPt3(p);}
DRW_Coord getFirstLine2() const {return getPt4();} /*!< Definition point line 1-2, code 14, 24 & 34 */
void setFirstLine2(const DRW_Coord p) {setPt4(p);}
void setFirstLine2(const DRW_Coord &p) {setPt4(p);}
DRW_Coord getSecondLine1() const {return getPt5();} /*!< Definition point line 2-1, code 15, 25 & 35 */
void setSecondLine1(const DRW_Coord p) {setPt5(p);}
void setSecondLine1(const DRW_Coord &p) {setPt5(p);}
DRW_Coord getSecondLine2() const {return getDefPoint();} /*!< Definition point line 2-2, code 10, 20 & 30 */
void setSecondLine2(const DRW_Coord p){setDefPoint(p);}
void setSecondLine2(const DRW_Coord &p){setDefPoint(p);}
DRW_Coord getDimPoint() const {return getPt6();} /*!< Dimension definition point, code 16, 26 & 36 */
void setDimPoint(const DRW_Coord p) {setPt6(p);}
void setDimPoint(const DRW_Coord &p) {setPt6(p);}
protected:
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
@ -1566,18 +1577,19 @@ public:
eType = DRW::DIMANGULAR3P;
type = 5;
}
DRW_DimAngular3p(const DRW_Dimension& d): DRW_Dimension(d) {
explicit DRW_DimAngular3p(const DRW_Dimension& d): DRW_Dimension(d)
{
eType = DRW::DIMANGULAR3P;
}
DRW_Coord getFirstLine() const {return getPt3();} /*!< Definition point line 1, code 13, 23 & 33 */
void setFirstLine(const DRW_Coord p) {setPt3(p);}
void setFirstLine(const DRW_Coord &p) {setPt3(p);}
DRW_Coord getSecondLine() const {return getPt4();} /*!< Definition point line 2, code 14, 24 & 34 */
void setSecondLine(const DRW_Coord p) {setPt4(p);}
void setSecondLine(const DRW_Coord &p) {setPt4(p);}
DRW_Coord getVertexPoint() const {return getPt5();} /*!< Vertex point, code 15, 25 & 35 */
void SetVertexPoint(const DRW_Coord p) {setPt5(p);}
void SetVertexPoint(const DRW_Coord &p) {setPt5(p);}
DRW_Coord getDimPoint() const {return getDefPoint();} /*!< Dimension definition point, code 10, 20 & 30 */
void setDimPoint(const DRW_Coord p) {setDefPoint(p);}
void setDimPoint(const DRW_Coord &p) {setDefPoint(p);}
protected:
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
@ -1595,16 +1607,18 @@ public:
eType = DRW::DIMORDINATE;
type = 6;
}
DRW_DimOrdinate(const DRW_Dimension& d): DRW_Dimension(d) {
explicit DRW_DimOrdinate(const DRW_Dimension& d)
: DRW_Dimension(d)
{
eType = DRW::DIMORDINATE;
}
DRW_Coord getOriginPoint() const {return getDefPoint();} /*!< Origin definition point, code 10, 20 & 30 */
void setOriginPoint(const DRW_Coord p) {setDefPoint(p);}
void setOriginPoint(const DRW_Coord &p) {setDefPoint(p);}
DRW_Coord getFirstLine() const {return getPt3();} /*!< Feature location point, code 13, 23 & 33 */
void setFirstLine(const DRW_Coord p) {setPt3(p);}
void setFirstLine(const DRW_Coord &p) {setPt3(p);}
DRW_Coord getSecondLine() const {return getPt4();} /*!< Leader end point, code 14, 24 & 34 */
void setSecondLine(const DRW_Coord p) {setPt4(p);}
void setSecondLine(const DRW_Coord &p) {setPt4(p);}
protected:
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);

View File

@ -34,7 +34,7 @@ DRW_Header::DRW_Header()
vpEntHeaderCtrl(0)
{}
void DRW_Header::addComment(std::string c){
void DRW_Header::addComment(const std::string &c){
if (!comments.empty())
comments += '\n';
comments += c;
@ -1703,6 +1703,7 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){
}
void DRW_Header::addDouble(std::string key, double value, int code){
// cppcheck-suppress publicAllocationError
curr = new DRW_Variant();
curr->addDouble( value );
curr->code = code;
@ -1710,6 +1711,7 @@ void DRW_Header::addDouble(std::string key, double value, int code){
}
void DRW_Header::addInt(std::string key, int value, int code){
// cppcheck-suppress publicAllocationError
curr = new DRW_Variant();
curr->addInt( value );
curr->code = code;
@ -1717,6 +1719,7 @@ void DRW_Header::addInt(std::string key, int value, int code){
}
void DRW_Header::addStr(std::string key, std::string value, int code){
// cppcheck-suppress publicAllocationError
curr = new DRW_Variant();
curr->addString( value );
curr->code = code;
@ -1724,6 +1727,7 @@ void DRW_Header::addStr(std::string key, std::string value, int code){
}
void DRW_Header::addCoord(std::string key, DRW_Coord value, int code){
// cppcheck-suppress publicAllocationError
curr = new DRW_Variant();
curr->addCoord( value );
curr->code = code;
@ -1797,7 +1801,6 @@ bool DRW_Header::getCoord(std::string key, DRW_Coord *varCoord){
bool DRW_Header::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf, duint8 mv){
bool result = true;
duint32 size = buf->getRawLong32();
duint32 bitSize = 0;
duint32 endBitPos = 160; //start bit: 16 sentinel + 4 size
DRW_DBG("\nbyte size of data: "); DRW_DBG(size);
if (version > DRW::AC1021 && mv > 3) { //2010+
@ -1812,7 +1815,7 @@ bool DRW_Header::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf
//and mark the start of handle stream
//header is one object reads data and continue read strings ???
if (version > DRW::AC1018) {//2007+
bitSize = buf->getRawLong32();
duint32 bitSize = buf->getRawLong32();
DRW_DBG("\nsize in bits: "); DRW_DBG(bitSize);
endBitPos += bitSize;
hBbuf->setPosition(endBitPos >>3);

View File

@ -83,7 +83,7 @@ public:
void addCoord(std::string key, DRW_Coord value, int code);
std::string getComments() const {return comments;}
void write(dxfWriter *writer, DRW::Version ver);
void addComment(std::string c);
void addComment(const std::string &c);
protected:
void parseCode(int code, dxfReader *reader);
@ -92,7 +92,7 @@ private:
bool getDouble(std::string key, double *varDouble);
bool getInt(std::string key, int *varInt);
bool getStr(std::string key, std::string *varStr);
bool getCoord(std::string key, DRW_Coord *varStr);
bool getCoord(std::string key, DRW_Coord *varCoord);
void clearVars()
{
for (std::map<std::string,DRW_Variant*>::iterator it=vars.begin(); it!=vars.end(); ++it)

View File

@ -1128,7 +1128,7 @@ bool DRW_Vport::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
void DRW_ImageDef::parseCode(int code, dxfReader *reader){
switch (code) {
case 1:
name = reader->getUtf8String();
fileName = reader->getUtf8String();
break;
case 5:
handle = reader->getHandleString();
@ -1173,8 +1173,8 @@ bool DRW_ImageDef::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
DRW_DBG("class Version: "); DRW_DBG(imgVersion);
DRW_Coord size = buf->get2RawDouble();
(void)size;
name = sBuf->getVariableText(version, false);
DRW_DBG("appId name: "); DRW_DBG(name.c_str()); DRW_DBG("\n");
fileName = sBuf->getVariableText(version, false);
DRW_DBG("appId name: "); DRW_DBG(fileName.c_str()); DRW_DBG("\n");
loaded = buf->getBit();
resolution = buf->getRawChar8();
up = buf->getRawDouble();

View File

@ -592,7 +592,7 @@ class DRW_ImageDef : public DRW_TableEntry {//
SETOBJFRIENDS
public:
DRW_ImageDef()
: name(),
: fileName(),
imgVersion(),
u(),
v(),
@ -617,7 +617,7 @@ protected:
public:
// std::string handle; /*!< entity identifier, code 5 */
UTF8STRING name; /*!< File name of image, code 1 */
UTF8STRING fileName; /*!< File name of image, code 1 */
int imgVersion; /*!< class version, code 90, 0=R14 version */
double u; /*!< image size in pixels U value, code 10 */
double v; /*!< image size in pixels V value, code 20 */

View File

@ -61,6 +61,11 @@ DRW_dbg::DRW_dbg()
prClass(new print_none)
{}
DRW_dbg::~DRW_dbg()
{
delete prClass;
}
void DRW_dbg::setLevel(LEVEL lvl){
level = lvl;
delete prClass;
@ -73,7 +78,7 @@ void DRW_dbg::setLevel(LEVEL lvl){
}
}
DRW_dbg::LEVEL DRW_dbg::getLevel(){
DRW_dbg::LEVEL DRW_dbg::getLevel() const{
return level;
}

View File

@ -15,6 +15,7 @@
#include <string>
#include <iostream>
#include <QtGlobal>
//#include <iomanip>
#define DRW_DBGSL(a) DRW_dbg::getInstance()->setLevel(a)
@ -35,7 +36,7 @@ public:
DEBUG
};
void setLevel(LEVEL lvl);
LEVEL getLevel();
LEVEL getLevel() const;
static DRW_dbg *getInstance();
void print(std::string s);
void print(int i);
@ -50,7 +51,9 @@ public:
void printPT(double x, double y, double z);
private:
Q_DISABLE_COPY(DRW_dbg)
DRW_dbg();
~DRW_dbg();
static DRW_dbg *instance;
LEVEL level;
std::ios_base::fmtflags flags;

View File

@ -48,7 +48,7 @@ void DRW_TextCodec::setVersion(std::string *v, bool dxfFormat){
}
}
void DRW_TextCodec::setCodePage(std::string *c, bool dxfFormat){
void DRW_TextCodec::setCodePage(const std::string *c, bool dxfFormat){
cp = correctCodePage(*c);
if (version < DRW::AC1021)
{
@ -71,7 +71,7 @@ void DRW_TextCodec::setCodePage(std::string *c, bool dxfFormat){
}
}
std::string DRW_TextCodec::toUtf8(std::string s) {
std::string DRW_TextCodec::toUtf8(const std::string &s) {
if (conv == nullptr)
{
return s;
@ -81,7 +81,7 @@ std::string DRW_TextCodec::toUtf8(std::string s) {
return encodedString.toStdString();
}
std::string DRW_TextCodec::fromUtf8(std::string s) {
std::string DRW_TextCodec::fromUtf8(const std::__cxx11::string &s) {
if (conv == nullptr)
{
return s;

View File

@ -10,14 +10,14 @@ class DRW_TextCodec
{
public:
DRW_TextCodec();
std::string fromUtf8(std::string s);
std::string toUtf8(std::string s);
int getVersion(){return version;}
std::string fromUtf8(const std::string &s);
std::string toUtf8(const std::string &s);
int getVersion() const {return version;}
void setVersion(std::string *v, bool dxfFormat);
void setVersion(int v, bool dxfFormat);
void setCodePage(std::string *c, bool dxfFormat);
void setCodePage(std::string c, bool dxfFormat){setCodePage(&c, dxfFormat);}
std::string getCodePage(){return cp;}
void setCodePage(const std::string *c, bool dxfFormat);
void setCodePage(const std::string &c, bool dxfFormat){setCodePage(&c, dxfFormat);}
std::string getCodePage() const {return cp;}
private:
std::string correctCodePage(const std::string& s);

View File

@ -102,14 +102,6 @@ static unsigned int crc32Table[256] ={
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
union typeCast {
char buf[8];
duint16 i16;
duint32 i32;
duint64 i64;
ddouble64 d64;
};
bool dwgFileStream::setPos(duint64 p){
if (p >= sz)
return false;
@ -368,6 +360,7 @@ double dwgBuffer::getBitDouble(){
} else {
filestr->read (buffer,8);
}
// cppcheck-suppress invalidPointerCast
double* ret = reinterpret_cast<double*>( buffer );
return *ret;
}
@ -429,6 +422,7 @@ double dwgBuffer::getRawDouble(){
for (int i = 0; i < 8; i++)
buffer[i] = getRawChar8();
}
// cppcheck-suppress invalidPointerCast
double* nOffset = reinterpret_cast<double*>( buffer );
return *nOffset;
}
@ -713,9 +707,11 @@ double dwgBuffer::getDefaultDouble(double d){
} else {
filestr->read (buffer,4);
}
// cppcheck-suppress invalidPointerCast
tmp = reinterpret_cast<char*>(&d);
for (int i = 0; i < 4; i++)
tmp[i] = buffer[i];
// cppcheck-suppress invalidPointerCast
double ret = *reinterpret_cast<double*>( tmp );
return ret;
} else if (b == 2){
@ -727,11 +723,13 @@ double dwgBuffer::getDefaultDouble(double d){
} else {
filestr->read (buffer,6);
}
// cppcheck-suppress invalidPointerCast
tmp = reinterpret_cast<char*>(&d);
for (int i = 2; i < 6; i++)
tmp[i-2] = buffer[i];
tmp[4] = buffer[0];
tmp[5] = buffer[1];
// cppcheck-suppress invalidPointerCast
double ret = *reinterpret_cast<double*>( tmp );
return ret;
}
@ -807,7 +805,6 @@ duint32 dwgBuffer::getEnColor(DRW::Version v) {
if (v < DRW::AC1018) //2000-
return getSBitShort();
duint32 rgb = 0;
duint32 cb = 0;
duint16 idx = getBitShort();
DRW_DBG("idx reads COLOR: "); DRW_DBGH(idx);
duint16 flags = static_cast<duint16>(idx>>8);
@ -819,7 +816,7 @@ duint32 dwgBuffer::getEnColor(DRW::Version v) {
// DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb);
// }
if (flags & 0x20) {
cb = getBitLong();
duint32 cb = getBitLong();
DRW_DBG("\nTransparency COLOR: "); DRW_DBGH(cb);
}
if (flags & 0x40)
@ -849,14 +846,13 @@ duint16 dwgBuffer::getBERawShort16(){
/* reads "size" bytes and stores in "buf" return false if fail */
bool dwgBuffer::getBytes(unsigned char *buf, int size){
duint8 tmp;
filestr->read (buf,size);
if (!filestr->good())
return false;
if (bitPos != 0){
for (int i=0; i<size;i++){
tmp = buf[i];
duint8 tmp = buf[i];
buf[i] = static_cast<unsigned char>((currByte << bitPos) | (tmp >> (8 - bitPos)));
currByte = tmp;
}
@ -875,10 +871,8 @@ duint16 dwgBuffer::crc8(duint16 dx, dint32 start, dint32 end){
if (!filestr->good())
return 0;
duint8 al;
while (n-- > 0) {
al = static_cast<duint8>((*p) ^ (static_cast<duint8>(dx & 0xFF)));
duint8 al = static_cast<duint8>((*p) ^ (static_cast<duint8>(dx & 0xFF)));
dx = (dx>>8) & 0xFF;
dx = static_cast<duint16>(dx ^ crctable[al & 0xFF]);
p++;

View File

@ -25,7 +25,7 @@ class dwgBasicStream{
protected:
dwgBasicStream(){}
public:
virtual ~dwgBasicStream(){}
virtual ~dwgBasicStream() = default;
virtual bool read(duint8* s, duint64 n) = 0;
virtual duint64 size() = 0;
virtual duint64 getPos() = 0;
@ -36,7 +36,7 @@ public:
class dwgFileStream: public dwgBasicStream{
public:
dwgFileStream(std::istream *s)
explicit dwgFileStream(std::istream *s)
: stream(nullptr),
sz(0)
{
@ -84,8 +84,8 @@ private:
class dwgBuffer {
public:
dwgBuffer(std::istream *stream, DRW_TextCodec *decoder = NULL);
dwgBuffer(duint8 *buf, int size, DRW_TextCodec *decoder= NULL);
dwgBuffer(std::istream *stream, DRW_TextCodec *dc = nullptr);
dwgBuffer(duint8 *buf, int size, DRW_TextCodec *dc = nullptr);
dwgBuffer( const dwgBuffer& org );
dwgBuffer& operator=( const dwgBuffer& org );
~dwgBuffer();
@ -94,7 +94,7 @@ public:
duint64 getPosition();
void resetPosition(){setPosition(0); setBitPos(0);}
void setBitPos(duint8 pos);
duint8 getBitPos(){return bitPos;}
duint8 getBitPos() const {return bitPos;}
bool moveBitPos(dint32 size);
duint8 getBit(); //B

View File

@ -694,13 +694,13 @@ bool dwgReader::readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf) {
oc = mit->second;
ObjectMap.erase(mit);
DRW_DBG("vpEntHeader Control Obj Handle= "); DRW_DBGH(oc.handle); DRW_DBG(" "); DRW_DBG(oc.loc); DRW_DBG("\n");
DRW_ObjControl vpEntHeaderCtrl;
// DRW_ObjControl vpEntHeaderCtrl;
dbuf->setPosition(oc.loc);
int size = dbuf->getModularShort();
if (version > DRW::AC1021) //2010+
bs = dbuf->getUModularChar();
else
bs = 0;
// if (version > DRW::AC1021) //2010+
// bs = dbuf->getUModularChar();
// else
// bs = 0;
tmpByteStr = new duint8[size];
dbuf->getBytes(tmpByteStr, size);
dwgBuffer buff(tmpByteStr, size, &decoder);
@ -934,13 +934,12 @@ bool dwgReader::readPlineVertex(DRW_Polyline& pline, dwgBuffer *dbuf){
bool dwgReader::readDwgEntities(DRW_Interface& intfa, dwgBuffer *dbuf){
bool ret = true;
bool ret2 = true;
DRW_DBG("\nobject map total size= "); DRW_DBG(ObjectMap.size());
std::map<duint32, objHandle>::iterator itB=ObjectMap.begin();
std::map<duint32, objHandle>::iterator itE=ObjectMap.end();
while (itB != itE){
ret2 = readDwgEntity(dbuf, itB->second, intfa);
bool ret2 = readDwgEntity(dbuf, itB->second, intfa);
ObjectMap.erase(itB);
itB=ObjectMap.begin();
if (ret)
@ -1170,21 +1169,20 @@ bool dwgReader::readDwgEntity(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& in
bool dwgReader::readDwgObjects(DRW_Interface& intfa, dwgBuffer *dbuf){
bool ret = true;
bool ret2 = true;
duint32 i=0;
DRW_DBG("\nentities map total size= "); DRW_DBG(ObjectMap.size());
DRW_DBG("\nobjects map total size= "); DRW_DBG(objObjectMap.size());
std::map<duint32, objHandle>::iterator itB=objObjectMap.begin();
std::map<duint32, objHandle>::iterator itE=objObjectMap.end();
while (itB != itE){
ret2 = readDwgObject(dbuf, itB->second, intfa);
bool ret2 = readDwgObject(dbuf, itB->second, intfa);
objObjectMap.erase(itB);
itB=objObjectMap.begin();
if (ret)
ret = ret2;
}
if (DRW_DBGGL == DRW_dbg::DEBUG) {
duint32 i=0;
for (std::map<duint32, objHandle>::iterator it=remainingMap.begin(); it != remainingMap.end(); ++it){
DRW_DBG("\nnum.# "); DRW_DBG(i++); DRW_DBG(" Remaining object Handle, loc, type= "); DRW_DBG(it->first);
DRW_DBG(" "); DRW_DBG(it->second.loc); DRW_DBG(" "); DRW_DBG(it->second.type);

View File

@ -140,6 +140,7 @@ public:
: hadlesList()
{ reset();}
// cppcheck-suppress functionStatic
void reset(){}
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
std::list<duint32>hadlesList;
@ -195,11 +196,11 @@ protected:
std::string findTableName(DRW::TTYPE table, dint32 handle);
void setCodePage(std::string *c){decoder.setCodePage(c, false);}
std::string getCodePage(){ return decoder.getCodePage();}
std::string getCodePage() const { return decoder.getCodePage();}
bool readDwgHeader(DRW_Header& hdr, dwgBuffer *buf, dwgBuffer *hBuf);
bool readDwgHandles(dwgBuffer *dbuf, duint32 offset, duint32 size);
bool readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf);
bool checkSentinel(dwgBuffer *buf, enum secEnum::DWGSection, bool start);
static bool checkSentinel(dwgBuffer *buf, enum secEnum::DWGSection, bool start);
bool readDwgBlocks(DRW_Interface& intfa, dwgBuffer *dbuf);
bool readDwgEntities(DRW_Interface& intfa, dwgBuffer *dbuf);

View File

@ -179,8 +179,7 @@ bool dwgReader15::readDwgHandles() {
if (si.Id<0)//not found, ends
return false;
bool ret = dwgReader::readDwgHandles(fileBuf, static_cast<duint32>(si.address), static_cast<duint32>(si.size));
return ret;
return dwgReader::readDwgHandles(fileBuf, static_cast<duint32>(si.address), static_cast<duint32>(si.size));
}
/*********** objects ************************/
@ -189,9 +188,7 @@ bool dwgReader15::readDwgHandles() {
* (using their object file offsets)
*/
bool dwgReader15::readDwgTables(DRW_Header& hdr) {
bool ret = dwgReader::readDwgTables(hdr, fileBuf);
return ret;
return dwgReader::readDwgTables(hdr, fileBuf);
}
/**
@ -199,7 +196,5 @@ bool dwgReader15::readDwgTables(DRW_Header& hdr) {
* (using their object file offsets)
*/
bool dwgReader15::readDwgBlocks(DRW_Interface& intfa) {
bool ret = true;
ret = dwgReader::readDwgBlocks(intfa, fileBuf);
return ret;
return dwgReader::readDwgBlocks(intfa, fileBuf);
}

View File

@ -31,14 +31,10 @@ public:
bool readDwgTables(DRW_Header& hdr);
bool readDwgBlocks(DRW_Interface& intfa);
bool readDwgEntities(DRW_Interface& intfa){
bool ret = true;
ret = dwgReader::readDwgEntities(intfa, fileBuf);
return ret;
return dwgReader::readDwgEntities(intfa, fileBuf);
}
bool readDwgObjects(DRW_Interface& intfa){
bool ret = true;
ret = dwgReader::readDwgObjects(intfa, fileBuf);
return ret;
return dwgReader::readDwgObjects(intfa, fileBuf);
}
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa);
};

View File

@ -149,7 +149,10 @@ bool dwgReader18::parseDataPage(dwgSectionInfo si/*, duint8 *dData*/){
//get compresed data
duint8 *cData = new duint8[pi.cSize];
if (!fileBuf->setPosition(pi.address+32))
{
delete[]cData;
return false;
}
fileBuf->getBytes(cData, static_cast<int>(pi.cSize));
//calculate checksum
@ -269,8 +272,8 @@ bool dwgReader18::readFileHeader() {
DRW_DBG("\nGap array size= "); DRW_DBGH(buff.getRawLong32());
//TODO: verify CRC
DRW_DBG("\nCRC32= "); DRW_DBGH(buff.getRawLong32());
for (duint8 i = 0x68; i < 0x6c; ++i)
byteStr[i] = '\0';
// for (duint8 i = 0x68; i < 0x6c; ++i)
// byteStr[i] = '\0';
// byteStr[i] = '\0';
duint32 crcCalc = buff.crc32(0x00,0,0x6C);
DRW_DBG("\nCRC32 calculated= "); DRW_DBGH(crcCalc);

View File

@ -61,23 +61,17 @@ public:
bool readDwgHandles();
bool readDwgTables(DRW_Header& hdr);
bool readDwgBlocks(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgBlocks(intfa, &dataBuf);
return ret;
return dwgReader::readDwgBlocks(intfa, &dataBuf);
}
virtual bool readDwgEntities(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgEntities(intfa, &dataBuf);
return ret;
return dwgReader::readDwgEntities(intfa, &dataBuf);
}
virtual bool readDwgObjects(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgObjects(intfa, &dataBuf);
return ret;
return dwgReader::readDwgObjects(intfa, &dataBuf);
}
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
@ -91,11 +85,12 @@ protected:
private:
Q_DISABLE_COPY(dwgReader18)
void genMagicNumber();
// cppcheck-suppress unusedPrivateFunction
static void genMagicNumber();
// dwgBuffer* bufObj;
void parseSysPage(duint8 *decompSec, duint32 decompSize); //called: Section page map: 0x41630e3b
bool parseDataPage(dwgSectionInfo si/*, duint8 *dData*/); //called ???: Section map: 0x4163003b
duint32 checksum(duint32 seed, duint8* data, duint32 sz);
static duint32 checksum(duint32 seed, duint8* data, duint32 sz);
private:
duint32 securityFlags;

View File

@ -481,10 +481,6 @@ bool dwgReader21::readDwgTables(DRW_Header& hdr) {
bool dwgReader21::readDwgBlocks(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(dataSize), &decoder);
ret = dwgReader::readDwgBlocks(intfa, &dataBuf);
return ret;
return false;
return dwgReader::readDwgBlocks(intfa, &dataBuf);
}

View File

@ -40,16 +40,12 @@ public:
bool readDwgTables(DRW_Header& hdr);
bool readDwgBlocks(DRW_Interface& intfa);
virtual bool readDwgEntities(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(dataSize), &decoder);
ret = dwgReader::readDwgEntities(intfa, &dataBuf);
return ret;
return dwgReader::readDwgEntities(intfa, &dataBuf);
}
virtual bool readDwgObjects(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(dataSize), &decoder);
ret = dwgReader::readDwgObjects(intfa, &dataBuf);
return ret;
return dwgReader::readDwgObjects(intfa, &dataBuf);
}
//bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
// return false;

View File

@ -29,22 +29,16 @@ public:
// bool readDwgHandles(){return false;}
// bool readDwgTables(){return false;}
bool readDwgBlocks(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgBlocks(intfa, &dataBuf);
return ret;
return dwgReader::readDwgBlocks(intfa, &dataBuf);
}
virtual bool readDwgEntities(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgEntities(intfa, &dataBuf);
return ret;
return dwgReader::readDwgEntities(intfa, &dataBuf);
}
virtual bool readDwgObjects(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgObjects(intfa, &dataBuf);
return ret;
return dwgReader::readDwgObjects(intfa, &dataBuf);
}
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){

View File

@ -29,22 +29,16 @@ public:
// bool readDwgHandles(){return false;}
// bool readDwgTables(){return false;}
bool readDwgBlocks(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgBlocks(intfa, &dataBuf);
return ret;
return dwgReader::readDwgBlocks(intfa, &dataBuf);
}
virtual bool readDwgEntities(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgEntities(intfa, &dataBuf);
return ret;
return dwgReader::readDwgEntities(intfa, &dataBuf);
}
virtual bool readDwgObjects(DRW_Interface& intfa){
bool ret = true;
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
ret = dwgReader::readDwgObjects(intfa, &dataBuf);
return ret;
return dwgReader::readDwgObjects(intfa, &dataBuf);
}
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
// DRW_UNUSED(obj);

View File

@ -40,11 +40,10 @@ std::string toHexStr(int n){
* @param blk number of codewords ( 1 cw == 255 bytes)
*/
void dwgRSCodec::decode239I(unsigned char *in, unsigned char *out, duint32 blk){
int k=0;
unsigned char data[255];
RScodec rsc(0x96, 8, 8); //(255, 239)
for (duint32 i=0; i<blk; i++){
k = i;
int k = i;
for (int j=0; j<255; j++) {
data[j] = in[k];
k +=blk;
@ -66,11 +65,10 @@ void dwgRSCodec::decode239I(unsigned char *in, unsigned char *out, duint32 blk){
* @param blk number of codewords ( 1 cw == 255 bytes)
*/
void dwgRSCodec::decode251I(unsigned char *in, unsigned char *out, duint32 blk){
int k=0;
unsigned char data[255];
RScodec rsc(0xB8, 8, 2); //(255, 251)
for (duint32 i=0; i<blk; i++){
k = i;
int k = i;
for (int j=0; j<255; j++) {
data[j] = in[k];
k +=blk;
@ -649,7 +647,7 @@ void dwgCompressor::copyCompBytes21(duint8 *cbuf, duint8 *dbuf, duint32 l, duint
}
secEnum::DWGSection secEnum::getEnum(std::string nameSec){
secEnum::DWGSection secEnum::getEnum(const std::string &nameSec){
//TODO: complete it
if (nameSec=="AcDb:Header"){
return HEADER;

View File

@ -93,7 +93,7 @@ public:
secEnum(){}
~secEnum(){}
static DWGSection getEnum(std::string nameSec);
static DWGSection getEnum(const std::__cxx11::string &nameSec);
};
#endif // DWGUTIL_H

View File

@ -90,6 +90,7 @@ bool dxfReader::readRec(int *codeData) {
int dxfReader::getHandleString(){
int res;
#if defined(__APPLE__)
// cppcheck-suppress invalidScanfArgType_int
int Succeeded = sscanf ( strData.c_str(), "%x", &res );
if ( !Succeeded || Succeeded == EOF )
res = 0;
@ -169,6 +170,7 @@ bool dxfReaderBinary::readDouble() {
double *result;
char buffer[8];
filestr->read(buffer,8);
// cppcheck-suppress invalidPointerCast
result = reinterpret_cast<double *>(buffer);
doubleData = *result;
DRW_DBG(doubleData); DRW_DBG("\n");

View File

@ -27,7 +27,7 @@ public:
};
enum TYPE type;
public:
dxfReader(std::istream *stream)
explicit dxfReader(std::istream *stream)
: type(INVALID),
filestr(stream),
strData(),
@ -39,20 +39,20 @@ public:
{}
virtual ~dxfReader() = default;
bool readRec(int *code);
bool readRec(int *codeData);
std::string getString() {return strData;}
std::string getString() const {return strData;}
int getHandleString();//Convert hex string to int
std::string toUtf8String(std::string t) {return decoder.toUtf8(t);}
std::string getUtf8String() {return decoder.toUtf8(strData);}
double getDouble() {return doubleData;}
int getInt32() {return intData;}
unsigned long long int getInt64() {return int64;}
bool getBool() { return (intData==0) ? false : true;}
int getVersion(){return decoder.getVersion();}
double getDouble() const {return doubleData;}
int getInt32() const {return intData;}
unsigned long long int getInt64() const {return int64;}
bool getBool() const { return (intData==0) ? false : true;}
int getVersion() const {return decoder.getVersion();}
void setVersion(std::string *v, bool dxfFormat){decoder.setVersion(v, dxfFormat);}
void setCodePage(std::string *c){decoder.setCodePage(c, true);}
std::string getCodePage(){ return decoder.getCodePage();}
std::string getCodePage() const { return decoder.getCodePage();}
protected:
virtual bool readCode(int *code) = 0; //return true if sucesful (not EOF)
@ -78,8 +78,11 @@ private:
class dxfReaderBinary : public dxfReader {
public:
dxfReaderBinary(std::istream *stream):dxfReader(stream){skip = false; }
virtual ~dxfReaderBinary() {}
explicit dxfReaderBinary(std::istream *stream)
: dxfReader(stream)
{skip = false; }
virtual ~dxfReaderBinary() = default;
virtual bool readCode(int *code);
virtual bool readString(std::string *text);
virtual bool readString();
@ -92,8 +95,11 @@ public:
class dxfReaderAscii : public dxfReader {
public:
dxfReaderAscii(std::istream *stream):dxfReader(stream){skip = true; }
virtual ~dxfReaderAscii(){}
explicit dxfReaderAscii(std::istream *stream)
: dxfReader(stream)
{skip = true; }
virtual ~dxfReaderAscii() = default;
virtual bool readCode(int *code);
virtual bool readString(std::string *text);
virtual bool readString();

View File

@ -91,12 +91,12 @@
return (filestr->good());
}*/
bool dxfWriter::writeUtf8String(int code, std::string text) {
bool dxfWriter::writeUtf8String(int code, const std::string &text) {
std::string t = encoder.fromUtf8(text);
return writeString(code, t);
}
bool dxfWriter::writeUtf8Caps(int code, std::string text) {
bool dxfWriter::writeUtf8Caps(int code, const std::string &text) {
std::string strname = text;
std::transform(strname.begin(), strname.end(), strname.begin(),::toupper);
std::string t = encoder.fromUtf8(strname);
@ -194,6 +194,7 @@ bool dxfWriterBinary::writeDouble(int code, double data) {
filestr->write(bufcode, 2);
unsigned char *val;
// cppcheck-suppress invalidPointerCast
val = reinterpret_cast<unsigned char *>(&data);
for (int i=0; i<8; i++) {
buffer[i] =val[i];

View File

@ -17,15 +17,15 @@
class dxfWriter {
public:
dxfWriter(std::ofstream *stream)
explicit dxfWriter(std::ofstream *stream)
: filestr(stream),
encoder()
{}
virtual ~dxfWriter() = default;
virtual bool writeString(int code, std::string text) = 0;
bool writeUtf8String(int code, std::string text);
bool writeUtf8Caps(int code, std::string text);
bool writeUtf8String(int code, const std::__cxx11::string &text);
bool writeUtf8Caps(int code, const std::__cxx11::string &text);
std::string fromUtf8String(std::string t) {return encoder.fromUtf8(t);}
virtual bool writeInt16(int code, int data) = 0;
virtual bool writeInt32(int code, int data) = 0;
@ -34,7 +34,7 @@ public:
virtual bool writeBool(int code, bool data) = 0;
void setVersion(std::string *v, bool dxfFormat){encoder.setVersion(v, dxfFormat);}
void setCodePage(std::string *c){encoder.setCodePage(c, true);}
std::string getCodePage(){return encoder.getCodePage();}
std::string getCodePage() const {return encoder.getCodePage();}
protected:
std::ofstream *filestr;
private:
@ -44,8 +44,10 @@ private:
class dxfWriterBinary : public dxfWriter {
public:
dxfWriterBinary(std::ofstream *stream):dxfWriter(stream){}
virtual ~dxfWriterBinary() {}
explicit dxfWriterBinary(std::ofstream *stream)
: dxfWriter(stream)
{}
virtual ~dxfWriterBinary() = default;
virtual bool writeString(int code, std::string text);
virtual bool writeInt16(int code, int data);
virtual bool writeInt32(int code, int data);
@ -56,8 +58,8 @@ public:
class dxfWriterAscii : public dxfWriter {
public:
dxfWriterAscii(std::ofstream *stream);
virtual ~dxfWriterAscii(){}
explicit dxfWriterAscii(std::ofstream *stream);
virtual ~dxfWriterAscii() = default;
virtual bool writeString(int code, std::string text);
virtual bool writeInt16(int code, int data);
virtual bool writeInt32(int code, int data);

View File

@ -58,14 +58,13 @@ RScodec::~RScodec() {
*/
void RScodec::RSgenerate_gf(unsigned int pp) {
int i, mask ;
int pb;
mask = 1 ;
alpha_to[mm] = 0 ;
for (i=0; i<mm; i++) {
alpha_to[i] = mask ;
index_of[alpha_to[i]] = i ;
pb = (pp >>(mm-1-i)) & 1;
int pb = (pp >>(mm-1-i)) & 1;
if (pb!=0) {
alpha_to[mm] ^= mask;
}
@ -110,7 +109,8 @@ void RScodec::RSgen_poly() {
for (i=0; i<=bb; i++) gg[i] = index_of[gg[i]] ;
}
int RScodec::calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root, int* loc, int* z, int* err, int* reg, int bb)
int RScodec::calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root,
int* loc, int* z, int* err, int* reg, int bb) const
{
if (!isOk) return -1;
int count = 0;
@ -315,17 +315,16 @@ int RScodec::calcDecode(unsigned char* data, int* recd, int** elp, int* d, int*
Encoding is done by using a feedback shift register with appropriate
connections specified by the elements of gg[], which was generated above.
Codeword is c(X) = data(X)*X**(nn-kk)+ b(X) */
bool RScodec::encode(unsigned char *data, unsigned char *parity) {
bool RScodec::encode(unsigned char *data, unsigned char *parity) const {
if (!isOk) return false;
int i,j ;
int feedback ;
unsigned char *idata = data;
unsigned char *bd = parity;
int bb = nn-kk;; //nn-kk length of parity data
for (i=0; i<bb; i++) bd[i] = 0 ;
for (i=kk-1; i>=0; i--) {
feedback = index_of[idata[i]^bd[bb-1]] ;
int feedback = index_of[idata[i]^bd[bb-1]] ;
if (feedback != -1) {
for (j=bb-1; j>0; j--)
if (gg[j] != -1)
@ -362,7 +361,7 @@ bool RScodec::encode(unsigned char *data, unsigned char *parity) {
parity part of the transmitted codeword). Of course, these insoluble cases
can be returned as error flags to the calling routine if desired. */
/** return value: number of corrected errors or -1 if can't correct it */
int RScodec::decode(unsigned char *data) {
int RScodec::decode(unsigned char *data) const {
if (!isOk) return -1;
int bb = nn-kk;; //nn-kk length of parity data

View File

@ -45,16 +45,17 @@ public:
~RScodec();
// bool encode(int *data, int *parity);
// int decode(int *recd);
bool encode(unsigned char *data, unsigned char *parity);
int decode(unsigned char *data);
bool isOkey(){return isOk;}
const unsigned int* indexOf() {return index_of;}
const int* alphaTo() {return alpha_to;}
bool encode(unsigned char *data, unsigned char *parity) const;
int decode(unsigned char *data) const;
bool isOkey() const {return isOk;}
const unsigned int* indexOf() const {return index_of;}
const int* alphaTo() const {return alpha_to;}
private:
void RSgenerate_gf(unsigned int pp);
void RSgen_poly();
int calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root, int* loc, int* z, int* err, int* reg, int bb);
int calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root, int* loc,
int* z, int* err, int* reg, int bb) const;
private:

View File

@ -65,9 +65,7 @@ void dwgR::setDebug(DRW::DBG_LEVEL lvl){
/*reads metadata and loads image preview*/
bool dwgR::getPreview(std::istream &stream){
bool isOk = false;
isOk = open(&stream);
bool isOk = open(&stream);
if (!isOk)
return false;
@ -88,9 +86,7 @@ bool dwgR::read(std::istream &stream, DRW_Interface *interface_, bool ext){
applyExt = ext;
iface = interface_;
bool isOk = false;
isOk = open(&stream);
bool isOk = open(&stream);
if (!isOk)
return false;

View File

@ -29,9 +29,9 @@ public:
//read: return true if all ok
bool read(std::istream &stream, DRW_Interface *interface_, bool ext);
bool getPreview(std::istream &stream);
DRW::Version getVersion(){return version;}
DRW::error getError(){return error;}
void setDebug(DRW::DBG_LEVEL lvl);
DRW::Version getVersion() const {return version;}
DRW::error getError() const {return error;}
static void setDebug(DRW::DBG_LEVEL lvl);
private:
bool open(std::istream *stream);

View File

@ -1264,7 +1264,7 @@ bool dxfRW::writeViewport(DRW_Viewport *ent) {
return true;
}
DRW_ImageDef* dxfRW::writeImage(DRW_Image *ent, std::string name){
DRW_ImageDef* dxfRW::writeImage(DRW_Image *ent, const std::string &name){
if (version > DRW::AC1009) {
//search if exist imagedef with this mane (image inserted more than 1 time)
//RLZ: imagedef_reactor seem needed to read in acad
@ -1280,7 +1280,7 @@ DRW_ImageDef* dxfRW::writeImage(DRW_Image *ent, std::string name){
imageDef.push_back(id);
id->handle = ++entCount;
}
id->name = name;
id->fileName = name;
std::string idReactor = toHexStr(++entCount);
writer->writeString(0, "IMAGE");
@ -1775,7 +1775,7 @@ bool dxfRW::writeObjects() {
writer->writeString(102, "}");
writer->writeString(100, "AcDbRasterImageDef");
writer->writeInt16(90, 0); //version 0=R14 to v2010
writer->writeUtf8String(1, id->name);
writer->writeUtf8String(1, id->fileName);
writer->writeDouble(10, id->u);
writer->writeDouble(20, id->v);
writer->writeDouble(11, id->up);

View File

@ -25,9 +25,9 @@ class dxfWriter;
class dxfRW {
public:
dxfRW(const char* name);
explicit dxfRW(const char* name);
~dxfRW();
void setDebug(DRW::DBG_LEVEL lvl);
static void setDebug(DRW::DBG_LEVEL lvl);
/// reads the file specified in constructor
/*!
* An interface must be provided. It is used by the class to signal various
@ -60,13 +60,13 @@ public:
bool writePolyline(DRW_Polyline *ent);
bool writeSpline(DRW_Spline *ent);
bool writeBlockRecord(std::string name);
bool writeBlock(DRW_Block *ent);
bool writeBlock(DRW_Block *bk);
bool writeInsert(DRW_Insert *ent);
bool writeMText(DRW_MText *ent);
bool writeText(DRW_Text *ent);
bool writeHatch(DRW_Hatch *ent);
bool writeViewport(DRW_Viewport *ent);
DRW_ImageDef *writeImage(DRW_Image *ent, std::string name);
DRW_ImageDef *writeImage(DRW_Image *ent, const std::__cxx11::string &name);
bool writeLeader(DRW_Leader *ent);
bool writeDimension(DRW_Dimension *ent);
void setEllipseParts(int parts){elParts = parts;} /*!< set parts munber when convert ellipse to polyline */
@ -120,7 +120,7 @@ private:
bool writeObjects();
bool writeExtData(const std::vector<DRW_Variant*> &ed);
/*use version from dwgutil.h*/
std::string toHexStr(int n);//RLZ removeme
static std::string toHexStr(int n);//RLZ removeme
private:
DRW::Version version;

View File

@ -81,6 +81,7 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
#endif //defined(V_NO_ASSERT)
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 4, 1)
// cppcheck-suppress reademptycontainer
if (not rules.isEmpty())
{
QLoggingCategory::setFilterRules(rules);

View File

@ -153,10 +153,10 @@ void VPE::VPropertySet::clear(bool delete_properties)
QString VPE::VPropertySet::getPropertyID(const VProperty *prop, bool look_for_parent_id) const
{
QString tmpResult;
// QString tmpResult;
const VProperty* tmpCurrentProp = prop;
while (tmpCurrentProp && (look_for_parent_id || prop == tmpCurrentProp) && tmpResult.isEmpty())
while (tmpCurrentProp && (look_for_parent_id || prop == tmpCurrentProp) /*&& tmpResult.isEmpty()*/)
{
// todo: The following code doesn't work, because .key() doesn't accept a const VProperty* pointer ...
@ -175,7 +175,8 @@ QString VPE::VPropertySet::getPropertyID(const VProperty *prop, bool look_for_pa
tmpCurrentProp = tmpCurrentProp->getParent();
}
return tmpResult;
// return tmpResult;
return QString();
}
// cppcheck-suppress unusedFunction