/src/aspell/common/generic_copy_ptr.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2001 |
2 | | // Kevin Atkinson |
3 | | // |
4 | | // Permission to use, copy, modify, distribute and sell this software |
5 | | // and its documentation for any purpose is hereby granted without |
6 | | // fee, provided that the above copyright notice appear in all copies |
7 | | // and that both that copyright notice and this permission notice |
8 | | // appear in supporting documentation. Kevin Atkinson makes no |
9 | | // representations about the suitability of this software for any |
10 | | // purpose. It is provided "as is" without express or implied |
11 | | // warranty. |
12 | | |
13 | | #ifndef autil__generic_copy_ptr |
14 | | #define autil__generic_copy_ptr |
15 | | |
16 | | namespace acommon { |
17 | | |
18 | | // Parms is expected to have the following members |
19 | | // T * Parms::clone(const T *); |
20 | | // void Parms::assign(T * &, const T *); |
21 | | // void Parms::del(T *); |
22 | | // All members can assume that all pointers are not null |
23 | | |
24 | | template <typename T, typename Parms> |
25 | | class GenericCopyPtr { |
26 | | |
27 | | T * ptr_; |
28 | | Parms parms_; |
29 | | |
30 | | public: |
31 | | |
32 | | explicit GenericCopyPtr(T * p = 0, const Parms & parms = Parms()) |
33 | 23.8k | : ptr_(p), parms_(parms) {} acommon::GenericCopyPtr<acommon::Error, acommon::CopyPtr<acommon::Error>::Parms>::GenericCopyPtr(acommon::Error*, acommon::CopyPtr<acommon::Error>::Parms const&) Line | Count | Source | 33 | 13.0k | : ptr_(p), parms_(parms) {} |
acommon::GenericCopyPtr<acommon::Filter, acommon::CopyPtr<acommon::Filter>::Parms>::GenericCopyPtr(acommon::Filter*, acommon::CopyPtr<acommon::Filter>::Parms const&) Line | Count | Source | 33 | 696 | : ptr_(p), parms_(parms) {} |
acommon::GenericCopyPtr<acommon::Tokenizer, acommon::CopyPtr<acommon::Tokenizer>::Parms>::GenericCopyPtr(acommon::Tokenizer*, acommon::CopyPtr<acommon::Tokenizer>::Parms const&) Line | Count | Source | 33 | 696 | : ptr_(p), parms_(parms) {} |
acommon::GenericCopyPtr<aspeller::SensitiveCompare, acommon::CopyPtr<aspeller::SensitiveCompare>::Parms>::GenericCopyPtr(aspeller::SensitiveCompare*, acommon::CopyPtr<aspeller::SensitiveCompare>::Parms const&) Line | Count | Source | 33 | 739 | : ptr_(p), parms_(parms) {} |
acommon::GenericCopyPtr<aspeller::Suggest, acommon::ClonePtr<aspeller::Suggest>::Parms>::GenericCopyPtr(aspeller::Suggest*, acommon::ClonePtr<aspeller::Suggest>::Parms const&) Line | Count | Source | 33 | 1.47k | : ptr_(p), parms_(parms) {} |
acommon::GenericCopyPtr<acommon::Convert, acommon::ClonePtr<acommon::Convert>::Parms>::GenericCopyPtr(acommon::Convert*, acommon::ClonePtr<acommon::Convert>::Parms const&) Line | Count | Source | 33 | 1.47k | : ptr_(p), parms_(parms) {} |
acommon::GenericCopyPtr<acommon::Config, acommon::CopyPtr<acommon::Config>::Parms>::GenericCopyPtr(acommon::Config*, acommon::CopyPtr<acommon::Config>::Parms const&) Line | Count | Source | 33 | 739 | : ptr_(p), parms_(parms) {} |
Unexecuted instantiation: acommon::GenericCopyPtr<acommon::Enumeration<aspeller::WordEntry*>, acommon::ClonePtr<acommon::Enumeration<aspeller::WordEntry*> >::Parms>::GenericCopyPtr(acommon::Enumeration<aspeller::WordEntry*>*, acommon::ClonePtr<acommon::Enumeration<aspeller::WordEntry*> >::Parms const&) acommon::GenericCopyPtr<aspeller::Dictionary::Id, acommon::CopyPtr<aspeller::Dictionary::Id>::Parms>::GenericCopyPtr(aspeller::Dictionary::Id*, acommon::CopyPtr<aspeller::Dictionary::Id>::Parms const&) Line | Count | Source | 33 | 4.97k | : ptr_(p), parms_(parms) {} |
|
34 | | |
35 | | GenericCopyPtr(const GenericCopyPtr & other); |
36 | 0 | GenericCopyPtr & operator= (const GenericCopyPtr & other) { |
37 | 0 | assign(other.ptr_, parms_); |
38 | 0 | return *this; |
39 | 0 | } Unexecuted instantiation: acommon::GenericCopyPtr<acommon::Error, acommon::CopyPtr<acommon::Error>::Parms>::operator=(acommon::GenericCopyPtr<acommon::Error, acommon::CopyPtr<acommon::Error>::Parms> const&) Unexecuted instantiation: acommon::GenericCopyPtr<acommon::Enumeration<aspeller::WordEntry*>, acommon::ClonePtr<acommon::Enumeration<aspeller::WordEntry*> >::Parms>::operator=(acommon::GenericCopyPtr<acommon::Enumeration<aspeller::WordEntry*>, acommon::ClonePtr<acommon::Enumeration<aspeller::WordEntry*> >::Parms> const&) |
40 | | |
41 | | // assign makes a copy of other |
42 | | void assign(const T * other, const Parms & parms = Parms()); |
43 | | |
44 | | // reset takes ownership of other |
45 | | void reset(T * other = 0, const Parms & parms = Parms()); |
46 | | |
47 | 40.3k | T & operator* () const {return *ptr_;} acommon::GenericCopyPtr<aspeller::Dictionary::Id, acommon::CopyPtr<aspeller::Dictionary::Id>::Parms>::operator*() const Line | Count | Source | 47 | 31.8k | T & operator* () const {return *ptr_;} |
acommon::GenericCopyPtr<acommon::Config, acommon::CopyPtr<acommon::Config>::Parms>::operator*() const Line | Count | Source | 47 | 8.57k | T & operator* () const {return *ptr_;} |
Unexecuted instantiation: acommon::GenericCopyPtr<aspeller::SensitiveCompare, acommon::CopyPtr<aspeller::SensitiveCompare>::Parms>::operator*() const |
48 | | T * operator-> () const {return ptr_;} |
49 | | T * get() const {return ptr_;} |
50 | 267k | operator T * () const {return ptr_;} acommon::GenericCopyPtr<acommon::Filter, acommon::CopyPtr<acommon::Filter>::Parms>::operator acommon::Filter*() const Line | Count | Source | 50 | 1.38k | operator T * () const {return ptr_;} |
acommon::GenericCopyPtr<acommon::Error, acommon::CopyPtr<acommon::Error>::Parms>::operator acommon::Error*() const Line | Count | Source | 50 | 32.8k | operator T * () const {return ptr_;} |
acommon::GenericCopyPtr<acommon::Config, acommon::CopyPtr<acommon::Config>::Parms>::operator acommon::Config*() const Line | Count | Source | 50 | 19.1k | operator T * () const {return ptr_;} |
acommon::GenericCopyPtr<acommon::Convert, acommon::ClonePtr<acommon::Convert>::Parms>::operator acommon::Convert*() const Line | Count | Source | 50 | 35.8k | operator T * () const {return ptr_;} |
acommon::GenericCopyPtr<acommon::Tokenizer, acommon::CopyPtr<acommon::Tokenizer>::Parms>::operator acommon::Tokenizer*() const Line | Count | Source | 50 | 167k | operator T * () const {return ptr_;} |
acommon::GenericCopyPtr<aspeller::Suggest, acommon::ClonePtr<aspeller::Suggest>::Parms>::operator aspeller::Suggest*() const Line | Count | Source | 50 | 10.5k | operator T * () const {return ptr_;} |
Unexecuted instantiation: acommon::GenericCopyPtr<acommon::Enumeration<aspeller::WordEntry*>, acommon::ClonePtr<acommon::Enumeration<aspeller::WordEntry*> >::Parms>::operator acommon::Enumeration<aspeller::WordEntry*>*() const Unexecuted instantiation: acommon::GenericCopyPtr<aspeller::Dictionary::Id, acommon::CopyPtr<aspeller::Dictionary::Id>::Parms>::operator aspeller::Dictionary::Id*() const |
51 | | |
52 | | T * release() {T * tmp = ptr_; ptr_ = 0; return tmp;} |
53 | | |
54 | | const Parms & parms() {return parms_;} |
55 | | const Parms & parms() const {return parms_;} |
56 | | |
57 | | ~GenericCopyPtr(); |
58 | | }; |
59 | | |
60 | | } |
61 | | |
62 | | #endif |
63 | | |