summaryrefslogtreecommitdiffstats
path: root/lib/antlr/antlr/RefCount.hpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-12-17 20:50:19 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-12-17 23:51:16 +0900
commit4ae7b32dc09eb7acd9411a8af63a767660aa64ec (patch)
tree3d150131675502f5d5a3ff054ec6fc3dbe4e78fd /lib/antlr/antlr/RefCount.hpp
parent25071ecede33675972c3163f4b46df964a06dadf (diff)
downloadtdevelop-4ae7b32dc09eb7acd9411a8af63a767660aa64ec.tar.gz
tdevelop-4ae7b32dc09eb7acd9411a8af63a767660aa64ec.zip
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 3e3d9eda9d1dd8c67c1c27c6a9bdc68bdecfcc30)
Diffstat (limited to 'lib/antlr/antlr/RefCount.hpp')
-rw-r--r--lib/antlr/antlr/RefCount.hpp80
1 files changed, 0 insertions, 80 deletions
diff --git a/lib/antlr/antlr/RefCount.hpp b/lib/antlr/antlr/RefCount.hpp
deleted file mode 100644
index 8546a049..00000000
--- a/lib/antlr/antlr/RefCount.hpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef INC_RefCount_hpp__
-#define INC_RefCount_hpp__
-/* ANTLR Translator Generator
- * Project led by Terence Parr at http://www.jGuru.com
- * Software rights: http://www.antlr.org/license.html
- *
- * $Id$
- */
-
-#include <antlr/config.hpp>
-
-#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
-namespace antlr {
-#endif
-
-template<class T>
-class ANTLR_API RefCount {
-private:
- struct Ref {
- T* const ptr;
- unsigned int count;
-
- Ref(T* p) : ptr(p), count(1) {}
- ~Ref() {delete ptr;}
- Ref* increment() {++count;return this;}
- bool decrement() {return (--count==0);}
- private:
- Ref(const Ref&);
- Ref& operator=(const Ref&);
- }* ref;
-
-public:
- explicit RefCount(T* p = 0)
- : ref(p ? new Ref(p) : 0)
- {
- }
- RefCount(const RefCount<T>& other)
- : ref(other.ref ? other.ref->increment() : 0)
- {
- }
- ~RefCount()
- {
- if (ref && ref->decrement())
- delete ref;
- }
- RefCount<T>& operator=(const RefCount<T>& other)
- {
- Ref* tmp = other.ref ? other.ref->increment() : 0;
- if (ref && ref->decrement())
- delete ref;
- ref = tmp;
- return *this;
- }
-
- operator T* () const
- {
- return ref ? ref->ptr : 0;
- }
-
- T* operator->() const
- {
- return ref ? ref->ptr : 0;
- }
-
- T* get() const
- {
- return ref ? ref->ptr : 0;
- }
-
- template<class newType> operator RefCount<newType>()
- {
- return RefCount<newType>(ref);
- }
-};
-
-#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
-}
-#endif
-
-#endif //INC_RefCount_hpp__