TAO_PSDL_String Class Reference

Wrapper for the ACE_CString to facilitate saving the string persistently. More...

#include <PSDL_String.h>

Collaboration diagram for TAO_PSDL_String:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_PSDL_String (void)
 Constructor.

 TAO_PSDL_String (ACE_Allocator *persistent_allocator)
 Constructor.

 TAO_PSDL_String (const TAO_PSDL_String &rhs)
 Copy constructor.

 ~TAO_PSDL_String (void)
 Destructor.

void operator= (const TAO_PSDL_String &rhs)
 Assignment operator.

void operator= (const ACE_CString &rhs)
bool operator== (const TAO_PSDL_String &rhs) const
 Equality comparison operator.

bool operator!= (const TAO_PSDL_String &rhs) const
 Inequality comparison operator.

u_long hash (void) const
 Returns a hash value for this string.

 operator ACE_CString * () const
 operator ACE_CString * ()

Public Attributes

ACE_Allocatorallocator_
const char * buffer_
CORBA::ULong length_

Detailed Description

Wrapper for the ACE_CString to facilitate saving the string persistently.

Definition at line 36 of file PSDL_String.h.


Constructor & Destructor Documentation

TAO_PSDL_String::TAO_PSDL_String void   ) 
 

Constructor.

Definition at line 11 of file PSDL_String.cpp.

00012   : allocator_ (0),
00013     buffer_ (0),
00014     length_ (0)
00015 {
00016 }

TAO_PSDL_String::TAO_PSDL_String ACE_Allocator persistent_allocator  ) 
 

Constructor.

Definition at line 19 of file PSDL_String.cpp.

00020   : allocator_ (persistent_allocator),
00021     buffer_ (0),
00022     length_ (0)
00023 {
00024 }

TAO_PSDL_String::TAO_PSDL_String const TAO_PSDL_String rhs  ) 
 

Copy constructor.

Definition at line 34 of file PSDL_String.cpp.

00035 {
00036   *this = rhs;
00037 }

TAO_PSDL_String::~TAO_PSDL_String void   ) 
 

Destructor.

Definition at line 27 of file PSDL_String.cpp.

References ACE_Allocator::free().

00028 {
00029   if (this->buffer_ != 0)
00030     this->allocator_->free ((void *) this->buffer_);
00031 }


Member Function Documentation

u_long TAO_PSDL_String::hash void   )  const
 

Returns a hash value for this string.

Definition at line 110 of file PSDL_String.cpp.

References ACE::hash_pjw().

00111 {
00112   return ACE::hash_pjw (this->buffer_);
00113 }

TAO_PSDL_String::operator ACE_CString *  ) 
 

Definition at line 129 of file PSDL_String.cpp.

References ACE_CString, and ACE_OS::memcpy().

00130 {
00131   ACE_CString *str = 0;
00132 
00133   char * dest = str->rep ();
00134   const char * src = this->buffer_;
00135   ACE_OS::memcpy (dest, src, this->length_);
00136 
00137   return str;
00138 }

TAO_PSDL_String::operator ACE_CString *  )  const
 

Definition at line 117 of file PSDL_String.cpp.

References ACE_CString, and ACE_OS::memcpy().

00118 {
00119   ACE_CString *str = 0;
00120 
00121   char * dest = str->rep ();
00122   const char * src = this->buffer_;
00123 
00124   ACE_OS::memcpy (dest, src, this->length_);
00125 
00126   return str;
00127 }

bool TAO_PSDL_String::operator!= const TAO_PSDL_String rhs  )  const
 

Inequality comparison operator.

Definition at line 104 of file PSDL_String.cpp.

References buffer_, and ACE_OS::strcmp().

00105 {
00106   return (ACE_OS::strcmp (buffer_, rhs.buffer_) != 0);
00107 }

void TAO_PSDL_String::operator= const ACE_CString rhs  ) 
 

Definition at line 68 of file PSDL_String.cpp.

References ACE_Allocator::free(), ACE_Allocator::malloc(), and ACE_OS::memcpy().

00069 {
00070   // Free the existing buffer before assigning octet
00071   // sequence.
00072   if (this->buffer_ != 0)
00073     this->allocator_->free ((void *) this->buffer_);
00074 
00075   const CORBA::ULong len = rhs.length ();
00076 
00077   void * buf = this->allocator_->malloc (len);
00078 
00079   this->buffer_ = (const char *) buf;
00080 
00081   if (this->buffer_)
00082     {
00083       const char * dest = this->buffer_;
00084       const char * src = rhs.rep ();
00085 
00086       // Deep copy the buffer.
00087       ACE_OS::memcpy ((void *)dest,
00088                       src,
00089                       len);
00090 
00091       this->length_ = len;
00092     }
00093   else
00094     this->length_ = 0;
00095 }

void TAO_PSDL_String::operator= const TAO_PSDL_String rhs  ) 
 

Assignment operator.

Definition at line 41 of file PSDL_String.cpp.

References allocator_, buffer_, ACE_Allocator::free(), length_, ACE_Allocator::malloc(), and ACE_OS::memcpy().

00042 {
00043   if (this == &rhs)  // Prevent self assignment
00044     return;
00045 
00046   // Free the existing buffer before assigning a new
00047   // allocator and buffer.
00048   if (this->buffer_ != 0)
00049     this->allocator_->free ((void *) this->buffer_);
00050 
00051   this->allocator_ = rhs.allocator_;
00052   void * buf = this->allocator_->malloc (rhs.length_);
00053   this->buffer_ = (const char *) buf;
00054   if (this->buffer_)
00055     {
00056       // Deep copy the buffer.
00057       ACE_OS::memcpy ( (void *) this->buffer_,
00058                        rhs.buffer_,
00059                        rhs.length_);
00060 
00061       this->length_ = rhs.length_;
00062     }
00063   else
00064     this->length_ = 0;
00065 }

bool TAO_PSDL_String::operator== const TAO_PSDL_String rhs  )  const
 

Equality comparison operator.

Definition at line 98 of file PSDL_String.cpp.

References buffer_, and ACE_OS::strcmp().

00099 {
00100   return (ACE_OS::strcmp (buffer_, rhs.buffer_) == 0);
00101 }


Member Data Documentation

ACE_Allocator* TAO_PSDL_String::allocator_
 

Definition at line 74 of file PSDL_String.h.

Referenced by operator=(), and TAO_PSDL_Datastore::unbind().

const char* TAO_PSDL_String::buffer_
 

Definition at line 77 of file PSDL_String.h.

Referenced by operator!=(), operator=(), and operator==().

CORBA::ULong TAO_PSDL_String::length_
 

Definition at line 80 of file PSDL_String.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:10:29 2006 for TAO_PSS by doxygen 1.3.6