Browse Source

Improve singleton

Close #6036
pull/6046/head
Rajendra Singh 5 years ago committed by Don HO
parent
commit
938dae9b2a
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
  1. 21
      PowerEditor/src/EncodingMapper.h
  2. 8
      PowerEditor/src/MISC/Common/Common.h
  3. 8
      PowerEditor/src/Parameters.h
  4. 11
      PowerEditor/src/ScitillaComponent/Buffer.h

21
PowerEditor/src/EncodingMapper.h

@ -35,17 +35,24 @@ struct EncodingUnit {
class EncodingMapper {
public:
static EncodingMapper * getInstance() {
static EncodingMapper instance;
return &instance;
};
static EncodingMapper* getInstance() {
static EncodingMapper instance;
return &instance;
}
int getEncodingFromIndex(int index) const;
int getIndexFromEncoding(int encoding) const;
int getEncodingFromString(const char * encodingAlias) const;
private:
EncodingMapper(){};
~EncodingMapper(){};
EncodingUnit* _encodings = nullptr;
EncodingMapper() = default;
~EncodingMapper() = default;
// No copy ctor and assignment
EncodingMapper(const EncodingMapper&) = delete;
EncodingMapper& operator=(const EncodingMapper&) = delete;
// No move ctor and assignment
EncodingMapper(EncodingMapper&&) = delete;
EncodingMapper& operator=(EncodingMapper&&) = delete;
};

8
PowerEditor/src/MISC/Common/Common.h

@ -114,14 +114,18 @@ public:
}
protected:
WcharMbcsConvertor() {}
~WcharMbcsConvertor() {}
WcharMbcsConvertor() = default;
~WcharMbcsConvertor() = default;
// Since there's no public ctor, we need to void the default assignment operator and copy ctor.
// Since these are marked as deleted does not matter under which access specifier are kept
WcharMbcsConvertor(const WcharMbcsConvertor&) = delete;
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&) = delete;
// No move ctor and assignment
WcharMbcsConvertor(WcharMbcsConvertor&&) = delete;
WcharMbcsConvertor& operator= (WcharMbcsConvertor&&) = delete;
template <class T>
class StringBuffer final
{

8
PowerEditor/src/Parameters.h

@ -1648,6 +1648,14 @@ private:
NppParameters();
~NppParameters();
// No copy ctor and assignment
NppParameters(const NppParameters&) = delete;
NppParameters& operator=(const NppParameters&) = delete;
// No move ctor and assignment
NppParameters(NppParameters&&) = delete;
NppParameters& operator=(NppParameters&&) = delete;
TiXmlDocument *_pXmlDoc = nullptr;
TiXmlDocument *_pXmlUserDoc = nullptr;
TiXmlDocument *_pXmlUserStylerDoc = nullptr;

11
PowerEditor/src/ScitillaComponent/Buffer.h

@ -122,7 +122,18 @@ private:
int _encoding;
EolType _eolFormat;
};
FileManager() = default;
~FileManager();
// No copy ctor and assignment
FileManager(const FileManager&) = delete;
FileManager& operator=(const FileManager&) = delete;
// No move ctor and assignment
FileManager(FileManager&&) = delete;
FileManager& operator=(FileManager&&) = delete;
int detectCodepage(char* buf, size_t len);
bool loadFileData(Document doc, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LoadedFileFormat& fileFormat);
LangType detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen);

Loading…
Cancel
Save