?????????????????????????????????const char* _buffer?????????????????????????ü????????????????????????String???????????ü?????????????getName()?????????????????ж??????copy????????????????????е?????????????κ?copy??????????????????????????????????????????????????κ???????????????????????????????String???????????????????????????????·?????棬???????????????????·??????????У?????????μ????????????????????????????????????????????String??????????????

??????????????????????????????У????????????String???????????ж???????????????£????ü???????????????????????????????????????????????????????????????Java?У?????????????????????????????????????????????????????????????ü????????????????????????????????????????????????????????????????

class RefCountedBase
 {
 public:
     void addRef() {
         //????????ü?????????????????????????????????
 //?????????????????????
         ATOMIC_INC(_refCount);
     }
     void release() {
         //????????ü?????????????????????????????????
 //????????????????????
         if (0 == ATOMIC_DEC_AND_RETURN(_refCount))
             delete this;
     }
     uint64 getRefCount() const {
         return _refCount;
     }
   
 protected:
     RefCountedBase():_refCount(0) {
     }
     virtual ~RefCountedBase() {
     }
 
 private:
     uint64     _refCount;        //???????????ü??????
 };
 
 template<typename _TRefCountedObject>
 class RefCountedPtr
 {
 public:
     RefCountedPtr():_refObject(0) {
     }
     RefCountedPtr(const RefCountedPtr<_TRefCountedObject>& otherPtr)
         :_refObject(otherPtr._refObject) {
         if (NULL != _refObject)
             _refObject->addRef();
     }
     RefCountedPtr(_TRefCountedObject* const otherObjectPtr)
         :_refObject(otherObjectPtr) {
         if (NULL != _refObject)
             _refObject->addRef();
     }
     ~RefCountedPtr() {
         if (NULL != _refObject)
             _refObject->release();
     }
     const RefCountedPtr<_TRefCountedObject>& operator=
         (const RefCountedPtr<_TRefCountedObject>& otherPtr) {
         if (_refObject != otherPtr._refObject) {
             _TRefCountedObject* oldPtr = _refObject;
             _refObject = otherPtr._refObject;
             //???μ???????????
             if (NULL != _refObject)
                 _refObject->addRef();
             //????е????????
             if (NULL != oldPtr)
                 oldPtr->release();
         }
         return *this;
       
     }
     const RefCountedPtr<_TRefCountedObject>& operator=
         (_TRefCountedObject* const otherObjectPtr) {
         if (_refObject != otherObjectPtr) {
             _TRefCountedObject* oldPtr = _refObject;
             _refObject = otherObjectPtr;
             //???μ???????????
             if (NULL != _refObject)
                 _refObject->addRef();
             //????е????????
             if (NULL != oldPtr)
                 oldPtr->release();
         }
         return *this;
     }
     operator _TRefCountedObject* () const {
         return _refObject;
     }
     bool operator== (_TRefCountedObject* const otherObjectPtr) const {
         return _refObject == otherObjectPtr;
     }
     bool operator!= (_TRefCountedObject* const otherObjectPtr) const {
         return !operator==(otherObjectPtr);
     }
     _TRefCountedObject* operator-> () const {
         return _refObject;
     }
 
 private:
     _TRefCountedObject* _refObject;        //????й????
 };