mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-24 00:47:57 -05:00
Syncs some files with their counterparts from https://github.com/LibreCAD/libdxfrw Basically this undoes the QGIS specific styling applied to these files and excludes them from the astyle script. Apart from the whitespace changes there's only very minor code modernization changes. But the goal here is to reduce the diffs between us and upstream so that we can more easily push fixes upstream and pull them downstream.
97 lines
2.4 KiB
C++
97 lines
2.4 KiB
C++
#ifndef DRW_TEXTCODEC_H
|
|
#define DRW_TEXTCODEC_H
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
|
|
class DRW_Converter;
|
|
|
|
class DRW_TextCodec
|
|
{
|
|
public:
|
|
DRW_TextCodec();
|
|
~DRW_TextCodec();
|
|
std::string fromUtf8(std::string s);
|
|
std::string toUtf8(std::string s);
|
|
int getVersion(){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;}
|
|
|
|
private:
|
|
std::string correctCodePage(const std::string& s);
|
|
|
|
private:
|
|
int version;
|
|
std::string cp;
|
|
std::unique_ptr< DRW_Converter> conv;
|
|
};
|
|
|
|
class DRW_Converter
|
|
{
|
|
public:
|
|
DRW_Converter(const int *t, int l)
|
|
:table{t }
|
|
,cpLength{l}
|
|
{}
|
|
virtual ~DRW_Converter(){}
|
|
virtual std::string fromUtf8(std::string *s) {return *s;}
|
|
virtual std::string toUtf8(std::string *s);
|
|
std::string encodeText(std::string stmp);
|
|
std::string decodeText(int c);
|
|
std::string encodeNum(int c);
|
|
int decodeNum(std::string s, int *b);
|
|
const int *table = nullptr;
|
|
int cpLength;
|
|
};
|
|
|
|
class DRW_ConvUTF16 : public DRW_Converter {
|
|
public:
|
|
DRW_ConvUTF16():DRW_Converter(nullptr, 0) {}
|
|
virtual std::string fromUtf8(std::string *s);
|
|
virtual std::string toUtf8(std::string *s);
|
|
};
|
|
|
|
class DRW_ConvTable : public DRW_Converter {
|
|
public:
|
|
DRW_ConvTable(const int *t, int l):DRW_Converter(t, l) {}
|
|
virtual std::string fromUtf8(std::string *s);
|
|
virtual std::string toUtf8(std::string *s);
|
|
};
|
|
|
|
class DRW_ConvDBCSTable : public DRW_Converter {
|
|
public:
|
|
DRW_ConvDBCSTable(const int *t, const int *lt, const int dt[][2], int l)
|
|
:DRW_Converter(t, l)
|
|
,leadTable{lt}
|
|
,doubleTable{dt}
|
|
{}
|
|
|
|
virtual std::string fromUtf8(std::string *s);
|
|
virtual std::string toUtf8(std::string *s);
|
|
private:
|
|
const int *leadTable;
|
|
const int (*doubleTable)[2];
|
|
|
|
};
|
|
|
|
class DRW_Conv932Table : public DRW_Converter {
|
|
public:
|
|
DRW_Conv932Table(const int *t, const int *lt, const int dt[][2], int l)
|
|
:DRW_Converter(t, l)
|
|
,leadTable{lt}
|
|
,doubleTable{dt}
|
|
{}
|
|
|
|
virtual std::string fromUtf8(std::string *s);
|
|
virtual std::string toUtf8(std::string *s);
|
|
private:
|
|
const int *leadTable;
|
|
const int (*doubleTable)[2];
|
|
|
|
};
|
|
|
|
#endif // DRW_TEXTCODEC_H
|