⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmautopointer.hpp

📁 可以播放MP3,wma等文件格式的播放器
💻 HPP
字号:
/* ;-*-c++-*- * qmautopointer.hpp * * $Id: qmautopointer.hpp,v 1.2 2002/03/05 13:09:13 amos Exp $ * * Apollo sound player: http://www.apolloplayer.org * Copyright(C) 2000-2001 Apollo Team.  See CREDITS file. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * The GNU General Public License is also available online at: * * http://www.gnu.org/copyleft/gpl.html */#ifndef QMAUTOPOINTER_H_INCLUDED#define QMAUTOPOINTER_H_INCLUDED/*! \file qmautopointer.h  Declaration of QmAutoPointer template class.*/template<class T>class QmAutoPointer{public:    QmAutoPointer( T *ptr = 0 ) throw();    QmAutoPointer( QmAutoPointer<T> &a ) throw();    ~QmAutoPointer()  throw();    void reset( T *ptr ) throw();    T *get() const throw();    T *release() throw();    bool isNull() const throw();    T *operator->() const throw();    T &operator *() const throw();    operator T *() const throw();    QmAutoPointer &operator =( QmAutoPointer &ptr ) throw();    QmAutoPointer &operator=( T * ) throw();private:    T *Pointer;};/*!  Creates the object and takes ownership of the object.  \param ptr Pointer to the object which this class should manage.*/template<class T>inline QmAutoPointer<T>::QmAutoPointer( T *ptr ) throw()    : Pointer( ptr ){}/*!  Takes the ownership from another auto pointer.*/template<class T>inline QmAutoPointer<T>::QmAutoPointer( QmAutoPointer<T> &a ) throw()    : Pointer( a.Pointer ){    a.Pointer = 0;}/*!  Destroys this object and the managed object.*/template<class T>inline QmAutoPointer<T>::~QmAutoPointer() throw(){    delete Pointer;}/*!  Returns true if the pointer is zero.*/template<class T>inline bool QmAutoPointer<T>::isNull() const throw(){    return Pointer == 0;}/*!  Makes it possible to access the dynamic object without having the pointer to it.  \return The pointer the dynamic object.*/template<class T>inline T *QmAutoPointer<T>::operator->() const throw(){    return Pointer;}/*!  \return The current pointer in use.*/template<class T>inline T &QmAutoPointer<T>::operator *() const throw(){    return *Pointer;}/*!  \return The current pointer in use.*/template<class T>inline QmAutoPointer<T>::operator T *() const throw(){    return Pointer;}/*!  Assignment from another auto pointer.*/template<class T>inline QmAutoPointer<T> &QmAutoPointer<T>::operator =( QmAutoPointer &ptr ) throw(){    delete Pointer;    Pointer = ptr.Pointer;    ptr.Pointer = 0;    return *this;}/*!  Changes the pointer, thus deleting the old one.  \param ptr Pointer to the object which this class should manage.*/template<class T>inline QmAutoPointer<T> &QmAutoPointer<T>::operator=( T *ptr ) throw(){    reset( ptr );    return *this;}/*!  Changes the pointer, thus deleting the old one.  \param ptr Pointer to the object which this class should manage.*/template<class T>inline void QmAutoPointer<T>::reset( T *ptr ) throw(){    if ( ptr != Pointer )    {        delete Pointer;        Pointer = ptr;    }}/*!  Returns the pointer in use.*/template<class T>inline T *QmAutoPointer<T>::get() const throw(){    return Pointer;}/*!  Relinquish ownership, pointer is no longer maintained.*/template<class T>inline T *QmAutoPointer<T>::release() throw(){    T *ptr = Pointer;    Pointer = 0;    return ptr;}#endif // QMAUTOPOINTER_H_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -