From 3e05d92dcb5f6c2017bc462554901ba27816bdb4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 17 Apr 2018 15:56:52 +0300 Subject: MNonCopyable - the common class to avoid declaring fake private constructors --- plugins/UserInfoEx/src/classMAnnivDate.h | 4 ++-- plugins/UserInfoEx/src/classMTime.h | 10 +++++----- .../src/ex_import/classExImContactBase.h | 2 +- .../UserInfoEx/src/ex_import/classExImContactXML.h | 2 +- plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp | 2 +- plugins/UserInfoEx/src/ex_import/svc_ExImVCF.h | 2 +- plugins/UserInfoEx/src/ex_import/tinystr.h | 10 +++++----- plugins/UserInfoEx/src/ex_import/tinyxml.h | 23 ++++------------------ 8 files changed, 20 insertions(+), 35 deletions(-) (limited to 'plugins/UserInfoEx') diff --git a/plugins/UserInfoEx/src/classMAnnivDate.h b/plugins/UserInfoEx/src/classMAnnivDate.h index 987408cb63..1dcfda6124 100644 --- a/plugins/UserInfoEx/src/classMAnnivDate.h +++ b/plugins/UserInfoEx/src/classMAnnivDate.h @@ -118,6 +118,6 @@ public: BYTE operator == (const SYSTEMTIME &st) { return IsEqual(st); }; BYTE operator == (const MAnnivDate &mda) { return IsEqual(mda); }; - void operator = (SYSTEMTIME &st) { SetDate(st); }; - void operator = (MAnnivDate &mda) { SetDate(mda); }; + void operator=(SYSTEMTIME &st) { SetDate(st); }; + void operator=(MAnnivDate &mda) { SetDate(mda); }; }; diff --git a/plugins/UserInfoEx/src/classMTime.h b/plugins/UserInfoEx/src/classMTime.h index 3388611c2f..eff510421a 100644 --- a/plugins/UserInfoEx/src/classMTime.h +++ b/plugins/UserInfoEx/src/classMTime.h @@ -105,11 +105,11 @@ public: int DBWriteStamp(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting); // operatoren - void operator = (DWORD& dwTimeStamp) { FromStampAsUTC(dwTimeStamp); }; - void operator = (FILETIME &ftFileTime) { Set(ftFileTime, FALSE); }; - void operator = (LARGE_INTEGER &liFileTime) { Set(liFileTime, FALSE); }; - void operator = (SYSTEMTIME &st) { Set(st, FALSE); }; - void operator = (const MTime &mt) { Set(mt); }; + void operator=(DWORD& dwTimeStamp) { FromStampAsUTC(dwTimeStamp); }; + void operator=(FILETIME &ftFileTime) { Set(ftFileTime, FALSE); }; + void operator=(LARGE_INTEGER &liFileTime) { Set(liFileTime, FALSE); }; + void operator=(SYSTEMTIME &st) { Set(st, FALSE); }; + void operator=(const MTime &mt) { Set(mt); }; }; /** diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.h b/plugins/UserInfoEx/src/ex_import/classExImContactBase.h index ad89480259..e34d77d338 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.h +++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.h @@ -83,5 +83,5 @@ public: MCONTACT toDB(); void toIni(FILE* file, int modCount); - BYTE operator = (MCONTACT hContact) { return fromDB(hContact); } + BYTE operator=(MCONTACT hContact) { return fromDB(hContact); } }; diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.h b/plugins/UserInfoEx/src/ex_import/classExImContactXML.h index 759f8d756a..7b2a255929 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.h +++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.h @@ -81,7 +81,7 @@ public: int LoadXmlElemnt(TiXmlElement *xContact); int Import(BYTE keepMetaSubContact = FALSE); - BYTE operator = (TiXmlElement* xmlContact) { + BYTE operator=(TiXmlElement* xmlContact) { return LoadXmlElemnt(xmlContact) == ERROR_OK; } }; diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp index eab2949fe4..eda76bb29d 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp @@ -113,7 +113,7 @@ BYTE CLineBuffer::_resizeBuf(const size_t cbReq) * * return: length of the string, added **/ -size_t CLineBuffer::operator = (const CHAR *szVal) +size_t CLineBuffer::operator=(const CHAR *szVal) { if (szVal) { size_t cbLength = mir_strlen(szVal); diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.h b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.h index 0636d37dd4..7ea59290ce 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.h +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.h @@ -35,7 +35,7 @@ public: CLineBuffer(); ~CLineBuffer(); - size_t operator = (const CHAR *szVal); + size_t operator=(const CHAR *szVal); size_t operator + (const CHAR *szVal); size_t operator + (const WCHAR *wszVal); diff --git a/plugins/UserInfoEx/src/ex_import/tinystr.h b/plugins/UserInfoEx/src/ex_import/tinystr.h index a5d85d11dc..3f5dbf9308 100644 --- a/plugins/UserInfoEx/src/ex_import/tinystr.h +++ b/plugins/UserInfoEx/src/ex_import/tinystr.h @@ -100,32 +100,32 @@ class TiXmlString } // = operator - TiXmlString& operator = (const char * copy) + TiXmlString& operator=(const char * copy) { return assign(copy, (size_type)mir_strlen(copy)); } // = operator - TiXmlString& operator = (const TiXmlString & copy) + TiXmlString& operator=(const TiXmlString & copy) { return assign(copy.start(), copy.length()); } // += operator. Maps to append - TiXmlString& operator += (const char * suffix) + TiXmlString& operator+=(const char * suffix) { return append(suffix, static_cast(mir_strlen(suffix))); } // += operator. Maps to append - TiXmlString& operator += (char single) + TiXmlString& operator+=(char single) { return append(&single, 1); } // += operator. Maps to append - TiXmlString& operator += (const TiXmlString & suffix) + TiXmlString& operator+=(const TiXmlString & suffix) { return append(suffix.data(), suffix.length()); } diff --git a/plugins/UserInfoEx/src/ex_import/tinyxml.h b/plugins/UserInfoEx/src/ex_import/tinyxml.h index ac98ee8d74..dc9087cc8c 100644 --- a/plugins/UserInfoEx/src/ex_import/tinyxml.h +++ b/plugins/UserInfoEx/src/ex_import/tinyxml.h @@ -151,7 +151,7 @@ const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; #include "ticpprc.h" class TiXmlBase : public TiCppRC #else -class TiXmlBase +class TiXmlBase : private MNonCopyable #endif { friend class TiXmlNode; @@ -366,9 +366,6 @@ protected: static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length); private: - TiXmlBase(const TiXmlBase&); // not implemented. - void operator=(const TiXmlBase& base); // not allowed. - struct Entity { const char* str; @@ -392,7 +389,7 @@ private: in a document, or stand on its own. The type of a TiXmlNode can be queried, and it can be cast to its more defined type. */ -class TiXmlNode : public TiXmlBase +class TiXmlNode : public TiXmlBase, private MNonCopyable { friend class TiXmlDocument; friend class TiXmlElement; @@ -686,10 +683,6 @@ protected: TiXmlNode* prev; TiXmlNode* next; - -private: - TiXmlNode(const TiXmlNode&); // not implemented. - void operator=(const TiXmlNode& base); // not allowed. }; /** An attribute is a name-value pair. Elements have an arbitrary @@ -699,7 +692,7 @@ private: part of the tinyXML document object model. There are other suggested ways to look at this problem. */ -class TiXmlAttribute : public TiXmlBase +class TiXmlAttribute : public TiXmlBase, private MNonCopyable { friend class TiXmlAttributeSet; @@ -795,9 +788,6 @@ public: void SetDocument(TiXmlDocument* doc) { document = doc; } private: - TiXmlAttribute(const TiXmlAttribute&); // not implemented. - void operator=(const TiXmlAttribute& base); // not allowed. - TiXmlDocument* document; // A pointer back to a document, for error reporting. TIXML_STRING name; TIXML_STRING value; @@ -818,7 +808,7 @@ private: - I like circular lists - it demonstrates some independence from the (typical) doubly linked list. */ -class TiXmlAttributeSet +class TiXmlAttributeSet : private MNonCopyable { public: TiXmlAttributeSet(); @@ -836,11 +826,6 @@ public: TiXmlAttribute* Find(const TIXML_STRING& name); private: - //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), - //*ME: this class must be also use a hidden/disabled copy-constructor !!! - TiXmlAttributeSet(const TiXmlAttributeSet&); // not allowed - void operator=(const TiXmlAttributeSet&); // not allowed (as TiXmlAttribute) - TiXmlAttribute sentinel; }; -- cgit v1.2.3