mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
Resync more code with upstream
This commit is contained in:
parent
507ba861ea
commit
f723657204
58
external/libdxfrw/intern/dwgbuffer.cpp
vendored
58
external/libdxfrw/intern/dwgbuffer.cpp
vendored
@ -151,34 +151,29 @@ bool dwgCharStream::read( duint8 *s, duint64 n )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwgBuffer::dwgBuffer( duint8 *buf, int size, DRW_TextCodec *dc )
|
dwgBuffer::dwgBuffer(duint8 *buf, duint64 size, DRW_TextCodec *dc)
|
||||||
{
|
:decoder{dc}
|
||||||
filestr = new dwgCharStream( buf, size );
|
,filestr{new dwgCharStream(buf, size)}
|
||||||
decoder = dc;
|
,maxSize{size}
|
||||||
maxSize = size;
|
{}
|
||||||
bitPos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwgBuffer::dwgBuffer( std::ifstream *stream, DRW_TextCodec *dc )
|
dwgBuffer::dwgBuffer(std::ifstream *stream, DRW_TextCodec *dc)
|
||||||
{
|
:decoder{dc}
|
||||||
filestr = new dwgFileStream( stream );
|
,filestr{new dwgFileStream(stream)}
|
||||||
decoder = dc;
|
,maxSize{filestr->size()}
|
||||||
maxSize = filestr->size();
|
{}
|
||||||
bitPos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwgBuffer::dwgBuffer( const dwgBuffer &org )
|
dwgBuffer::dwgBuffer( const dwgBuffer& org )
|
||||||
{
|
:decoder{org.decoder}
|
||||||
filestr = org.filestr->clone();
|
,filestr{org.filestr->clone()}
|
||||||
decoder = org.decoder;
|
,maxSize{filestr->size()}
|
||||||
maxSize = filestr->size();
|
,currByte{org.currByte}
|
||||||
currByte = org.currByte;
|
,bitPos{org.bitPos}
|
||||||
bitPos = org.bitPos;
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
dwgBuffer &dwgBuffer::operator=( const dwgBuffer &org )
|
dwgBuffer &dwgBuffer::operator=( const dwgBuffer &org )
|
||||||
{
|
{
|
||||||
filestr = org.filestr->clone();
|
filestr.reset(org.filestr->clone());
|
||||||
decoder = org.decoder;
|
decoder = org.decoder;
|
||||||
maxSize = filestr->size();
|
maxSize = filestr->size();
|
||||||
currByte = org.currByte;
|
currByte = org.currByte;
|
||||||
@ -186,10 +181,7 @@ dwgBuffer &dwgBuffer::operator=( const dwgBuffer &org )
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwgBuffer::~dwgBuffer()
|
dwgBuffer::~dwgBuffer() = default;
|
||||||
{
|
|
||||||
delete filestr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Gets the current byte position in buffer
|
//! Gets the current byte position in buffer
|
||||||
duint64 dwgBuffer::getPosition()
|
duint64 dwgBuffer::getPosition()
|
||||||
@ -349,9 +341,9 @@ dint16 dwgBuffer::getSBitShort()
|
|||||||
{
|
{
|
||||||
duint8 b = get2Bits();
|
duint8 b = get2Bits();
|
||||||
if ( b == 0 )
|
if ( b == 0 )
|
||||||
return ( dint16 )getRawShort16();
|
return static_cast<dint16>(getRawShort16());
|
||||||
else if ( b == 1 )
|
else if ( b == 1 )
|
||||||
return ( dint16 )getRawChar8();
|
return static_cast<dint16>(getRawChar8());
|
||||||
else if ( b == 2 )
|
else if ( b == 2 )
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
@ -880,16 +872,12 @@ duint32 dwgBuffer::getCmColor( DRW::Version v )
|
|||||||
{
|
{
|
||||||
case 0xC0:
|
case 0xC0:
|
||||||
return 256;//ByLayer
|
return 256;//ByLayer
|
||||||
break;
|
|
||||||
case 0xC1:
|
case 0xC1:
|
||||||
return 0;//ByBlock
|
return 0;//ByBlock
|
||||||
break;
|
|
||||||
case 0xC2:
|
case 0xC2:
|
||||||
return 256;//RGB RLZ TODO
|
return 256;//RGB RLZ TODO
|
||||||
break;
|
|
||||||
case 0xC3:
|
case 0xC3:
|
||||||
return rgb & 0xFF; //ACIS
|
return rgb & 0xFF; //ACIS
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -978,7 +966,7 @@ bool dwgBuffer::getBytes( unsigned char *buf, int size )
|
|||||||
|
|
||||||
duint16 dwgBuffer::crc8( duint16 dx, dint32 start, dint32 end )
|
duint16 dwgBuffer::crc8( duint16 dx, dint32 start, dint32 end )
|
||||||
{
|
{
|
||||||
int pos = filestr->getPos();
|
duint64 pos = filestr->getPos();
|
||||||
filestr->setPos( start );
|
filestr->setPos( start );
|
||||||
int n = end - start;
|
int n = end - start;
|
||||||
duint8 *tmpBuf = new duint8[n];
|
duint8 *tmpBuf = new duint8[n];
|
||||||
@ -1003,7 +991,7 @@ duint16 dwgBuffer::crc8( duint16 dx, dint32 start, dint32 end )
|
|||||||
|
|
||||||
duint32 dwgBuffer::crc32( duint32 seed, dint32 start, dint32 end )
|
duint32 dwgBuffer::crc32( duint32 seed, dint32 start, dint32 end )
|
||||||
{
|
{
|
||||||
int pos = filestr->getPos();
|
duint64 pos = filestr->getPos();
|
||||||
filestr->setPos( start );
|
filestr->setPos( start );
|
||||||
int n = end - start;
|
int n = end - start;
|
||||||
duint8 *tmpBuf = new duint8[n];
|
duint8 *tmpBuf = new duint8[n];
|
||||||
|
36
external/libdxfrw/intern/dwgbuffer.h
vendored
36
external/libdxfrw/intern/dwgbuffer.h
vendored
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <memory>
|
||||||
#include "../drw_base.h"
|
#include "../drw_base.h"
|
||||||
|
|
||||||
class DRW_Coord;
|
class DRW_Coord;
|
||||||
@ -51,20 +52,17 @@ class dwgFileStream: public dwgBasicStream
|
|||||||
virtual bool good() {return stream->good();}
|
virtual bool good() {return stream->good();}
|
||||||
virtual dwgBasicStream *clone() {return new dwgFileStream( stream );}
|
virtual dwgBasicStream *clone() {return new dwgFileStream( stream );}
|
||||||
private:
|
private:
|
||||||
std::ifstream *stream = nullptr;
|
std::ifstream *stream{nullptr};
|
||||||
duint64 sz;
|
duint64 sz{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
class dwgCharStream: public dwgBasicStream
|
class dwgCharStream: public dwgBasicStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dwgCharStream( duint8 *buf, int s )
|
dwgCharStream( duint8 *buf, duint64 s )
|
||||||
{
|
:stream{buf}
|
||||||
stream = buf;
|
,sz{s}
|
||||||
sz = s;
|
{}
|
||||||
pos = 0;
|
|
||||||
isOk = true;
|
|
||||||
}
|
|
||||||
virtual bool read( duint8 *s, duint64 n );
|
virtual bool read( duint8 *s, duint64 n );
|
||||||
virtual duint64 size() {return sz;}
|
virtual duint64 size() {return sz;}
|
||||||
virtual duint64 getPos() {return pos;}
|
virtual duint64 getPos() {return pos;}
|
||||||
@ -72,17 +70,17 @@ class dwgCharStream: public dwgBasicStream
|
|||||||
virtual bool good() {return isOk;}
|
virtual bool good() {return isOk;}
|
||||||
virtual dwgBasicStream *clone() {return new dwgCharStream( stream, sz );}
|
virtual dwgBasicStream *clone() {return new dwgCharStream( stream, sz );}
|
||||||
private:
|
private:
|
||||||
duint8 *stream = nullptr;
|
duint8 *stream{nullptr};
|
||||||
duint64 sz;
|
duint64 sz{0};
|
||||||
duint64 pos;
|
duint64 pos{0};
|
||||||
bool isOk;
|
bool isOk{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
class dwgBuffer
|
class dwgBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dwgBuffer( std::ifstream *stream, DRW_TextCodec *decoder = nullptr );
|
dwgBuffer( std::ifstream *stream, DRW_TextCodec *decoder = nullptr );
|
||||||
dwgBuffer( duint8 *buf, int size, DRW_TextCodec *decoder = nullptr );
|
dwgBuffer( duint8 *buf, duint64 size, DRW_TextCodec *decoder = nullptr );
|
||||||
dwgBuffer( const dwgBuffer &org );
|
dwgBuffer( const dwgBuffer &org );
|
||||||
dwgBuffer &operator=( const dwgBuffer &org );
|
dwgBuffer &operator=( const dwgBuffer &org );
|
||||||
~dwgBuffer();
|
~dwgBuffer();
|
||||||
@ -144,13 +142,13 @@ class dwgBuffer
|
|||||||
duint32 crc32( duint32 seed, dint32 start, dint32 end );
|
duint32 crc32( duint32 seed, dint32 start, dint32 end );
|
||||||
|
|
||||||
// duint8 getCurrByte(){return currByte;}
|
// duint8 getCurrByte(){return currByte;}
|
||||||
DRW_TextCodec *decoder = nullptr;
|
DRW_TextCodec *decoder{nullptr};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
dwgBasicStream *filestr = nullptr;
|
std::unique_ptr<dwgBasicStream> filestr;
|
||||||
int maxSize;
|
duint64 maxSize{0};
|
||||||
duint8 currByte;
|
duint8 currByte{0};
|
||||||
duint8 bitPos;
|
duint8 bitPos{0};
|
||||||
|
|
||||||
UTF8STRING get8bitStr();
|
UTF8STRING get8bitStr();
|
||||||
UTF8STRING get16bitStr( duint16 textSize, bool nullTerm = true );
|
UTF8STRING get16bitStr( duint16 textSize, bool nullTerm = true );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user