Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

O3DBIClob.cpp

Go to the documentation of this file.
00001 
00011 #include "O3DBIClob.h"
00012 
00013 // ----------------------------------------------------------------------------
00014 // O3DBIClob construction/destruction
00015 
00016 O3DBIClob::O3DBIClob() : _lpszBuffer(NULL)
00017 {
00018 
00019 }
00020 
00021 O3DBIClob::O3DBIClob(const O3DBIClob& other) : _lpszBuffer(NULL)
00022 {
00023     AllocateAndSetBuffer(other.GetRaw());
00024 }
00025 
00026 O3DBIClob::O3DBIClob(PC_TCHAR lpszClob) : _lpszBuffer(NULL)
00027 {
00028     AllocateAndSetBuffer(lpszClob);
00029 }
00030 
00031 O3DBIClob::~O3DBIClob()
00032 {
00033     AllocateAndSetBuffer(NULL);
00034 }
00035 
00036 // ----------------------------------------------------------------------------
00037 // O3DBIClob operations
00038 
00039 O3DBIClob& O3DBIClob::operator=(const O3DBIClob& other)
00040 {
00041     SetRaw(other.GetRaw());
00042     return (*this);
00043 }
00044 
00045 O3DBIClob& O3DBIClob::operator=(PC_TCHAR lpszClob)
00046 {
00047     SetRaw(lpszClob);
00048     return (*this);
00049 }
00050 
00051 bool O3DBIClob::operator==(const O3DBIClob& other) const
00052 {
00053     return (::_tcscmp(_lpszBuffer, other._lpszBuffer) == 0);
00054 }
00055 
00056 bool O3DBIClob::SetRaw(PC_TCHAR lpszClob)
00057 {
00058     return AllocateAndSetBuffer(lpszClob);
00059 }
00060 
00061 PC_TCHAR O3DBIClob::GetRaw() const
00062 {
00063     return _lpszBuffer;
00064 }
00065 
00066 TO3DBIString O3DBIClob::ToString() const
00067 {
00068     return TO3DBIString();
00069 }
00070 
00071 // ----------------------------------------------------------------------------
00072 // O3DBIClob internal implementation
00073 
00074 bool O3DBIClob::AllocateAndSetBuffer(PC_TCHAR lpszClob)
00075 {
00076     if (_lpszBuffer != NULL)
00077     {
00078         // Delete previous buffer content first
00079         delete [] _lpszBuffer;
00080         _lpszBuffer = NULL;
00081     }
00082 
00083     // We are ready, if parameter is NULL pointer
00084     if (lpszClob == NULL)
00085         return true;
00086 
00087     // Determine character count
00088     size_t nCount = ::_tcslen(lpszClob);
00089     // Allocate memory for new string on the heap
00090     _lpszBuffer = new TCHAR[nCount + sizeof(TCHAR)];
00091     // Copy string into buffer
00092     ::_tcsncpy(_lpszBuffer, lpszClob, nCount + sizeof(TCHAR));
00093 
00094     return (_lpszBuffer != NULL);
00095 }
00096 



SourceForge.net Logo Generated on Sun Jan 23 11:36:34 2005 for Oracle Object Oriented Database Interface (O3DBI) by  doxygen 1.3.9.1