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

📄 support.hxx

📁 一个SIP协议栈
💻 HXX
字号:
#ifndef SUPPORT_HXX_#define SUPPORT_HXX_// $Id: support.hxx,v 1.1 1999/08/31 01:53:27 cullen Exp $/*This library is free software; you can redistribute it and/or modifyit under the terms of the GNU Lesser General Public License aspublished by the Free Software Foundation; either version 2 of theLicense, or (at your option) any later version.This library is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not; write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA.*/// $Log: support.hxx,v $// Revision 1.1  1999/08/31 01:53:27  cullen// Cullen check in some code from Luan that has things needed to compile//// Revision 1.8  1999/07/23 23:57:25  bogawa//// the mgcp/examples/gateway Makefile was changed to use the new make file system.//// improve the global makefiles.  Now, most targets use these makefiles// which should simplify the lives of the users, we hope.//// Key features include support for nested object directories as well as// a more coherent install strategy (so that installs are less likely to// produce error messages)//// in addition, the code was cleaned up to add a few new features and to// remove some warnings.//// Revision 1.7  1999/06/30 06:09:08  bogawa//// update copyright and license//// Revision 1.6  1999/06/29 23:42:03  bogawa//// Updated copyright notice.//// Revision 1.5  1999/06/28 21:30:37  bogawa//// Update to the latest version of the MGCP stack.//// Revision 1.4  1999/06/09 08:16:44  bogawa//// Add copyright notices.//// Revision 1.3  1999/06/09 04:09:46  bogawa//// This makefile now correctly does diving makes.//// In addition, the code has been cleaned up and adds some comments for doc++.//// doc++ can be invoked by using make doc -- the current version will be shipped// with  appropriate html documentation.//// Revision 1.2  1999/06/09 01:04:59  bogawa//// Changes to make the new structure compile correctly, and to allow the// code to use the new hardware structure.  gateway1 is now using the// new structure fully, while gateway2 is using it partially (actually// not very much).//// A future version should be much cleaner.//#include "global.h"#include <vector>#include <string>/***********************************************************************  Utility and support functions for the stack. **********************************************************************//**   splits a string into a vector of substrings.    This is inefficient because copying is generally involved here.  A   more efficient implementation which uses pointers into the original   string (and length counts) may replace this in a future version.    Clearly, this was influenced by perl.*/vector<string>& split(const string& inputText, const string& characters);/**   removes the trailing character from a string.    Clearly, this was influenced by perl.*/void chop(string* input);/**     removes the trailing character from a string if it is \r or \n.    Clearly, this was influenced by perl.*/void chomp(string* input);string itos(int i);/** Template simulates a pointer with a "smart" reference that deletes    the item when no more references exist*/template<class T> class Sptr{private:    template<class U>    class Sptr_impl_    {    public://	Sptr_impl_() : ptr(NULL), refcount(0) {};	Sptr_impl_(U* p) : ptr(p), refcount(1) {};//	Sptr_impl_(const Sptr_impl_& ref) ://	    ptr(ref.ptr), refcount(ref.refcount) {};	~Sptr_impl_() {	    delete ptr; 	    ptr = NULL;	}	void incr() { refcount++; }	bool decr() { 	    refcount--; 	    if(refcount == 0) { 		return true;	    }	    return false;	}	U* get() { return ptr; }    private:	U* ptr;	int refcount;    };public:    Sptr() : ptr(NULL) {};    Sptr(T* original)	{	    ptr = new Sptr_impl_<T>(original);	};    Sptr(const Sptr& x)	: ptr(x.ptr)	{	    ptr->incr();	};    ~Sptr() {	{	    if(ptr->decr())	    {		delete ptr;		ptr = NULL;	    }	}    }    operator!() const {	if(ptr)	{	    return (ptr->get() == NULL);	}	else	    return true;    }    operator T* () const {	return ptr->get();    }    T& operator()() const {	return *(ptr->get());    }    T* operator->() const {	return ptr->get();    }    operator=(T* original)	{	    ptr = new Sptr_impl_<T>(original);	};    operator=(const Sptr& x)	{	    if(ptr)	    {		if(ptr->decr())		{		    delete ptr;		    ptr = NULL;		}	    }	    ptr = x.ptr;	    ptr->incr();	}    operator==(const Sptr& x)	{	    if(x.ptr == ptr)		return true;	    else		return false;	}private:    Sptr_impl_<T>* ptr;};#endif

⌨️ 快捷键说明

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