Public Member Functions | Static Public Member Functions | Protected Attributes | Friends

OCIPL::SqlString Struct Reference

string buffer bind variable structure More...

#include <ocipl.h>

Inheritance diagram for OCIPL::SqlString:
Inheritance graph
[legend]
Collaboration diagram for OCIPL::SqlString:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SqlString (int blen=OCIPL_DEFAULT_STRING_BUFFER)
 SqlString (const TCHAR *s)
 SqlString (const TCHAR *s, int blen)
 SqlString (const SqlString &other)
 ~SqlString ()
size_t len () const
size_t blen () const
size_t alen () const
void resize (size_t l)
void clear ()
TCHAR * str ()
TCHAR * str (int l)
const TCHAR * c_str () const
 operator const TCHAR * () const
SqlStringoperator= (const TCHAR *s)
SqlStringoperator= (const tstring &s)
bool operator== (const TCHAR *s) const
bool operator!= (const TCHAR *s) const
bool operator< (const TCHAR *s) const
bool is_null () const
bool is_not_null () const
const SqlIndind () const
SqlIndind ()

Static Public Member Functions

static TCHAR * ocipl_tcscpyn (TCHAR *dest, const TCHAR *source, size_t count)

Protected Attributes

size_t _blen
TCHAR * _str
SqlInd _ind

Friends

tostreamoperator<< (tostream &os, const SqlString &str)

Detailed Description

string buffer bind variable structure

Definition at line 1408 of file ocipl.h.


Constructor & Destructor Documentation

OCIPL::SqlString::SqlString ( int  blen = OCIPL_DEFAULT_STRING_BUFFER ) [inline]

Definition at line 1410 of file ocipl.h.

     :  _blen(blen),
        _str(static_cast<TCHAR*>(ocipl_alloc((blen+1)*sizeof(TCHAR))))
    {
        *_str = '\0';
    }
OCIPL::SqlString::SqlString ( const TCHAR *  s ) [inline]

Definition at line 1417 of file ocipl.h.

     :  _blen(_tcslen(s)),
        _str(_tcsdup(s))
    {
        if (*s)
            _ind.set();
    }
OCIPL::SqlString::SqlString ( const TCHAR *  s,
int  blen 
) [inline]

Definition at line 1425 of file ocipl.h.

     :  _blen(blen),
        _str(static_cast<TCHAR*>(ocipl_alloc((blen+1)*sizeof(TCHAR))))
    {
        ocipl_tcscpyn(_str, s, blen+1);

        if (*s)
            _ind.set();
    }
OCIPL::SqlString::SqlString ( const SqlString other ) [inline]

Definition at line 1435 of file ocipl.h.

     :  SqlValue(other),
        _blen(_tcslen(other._str)),
        _str(_tcsdup(other._str))
    {
    }
OCIPL::SqlString::~SqlString (  ) [inline]

Definition at line 1442 of file ocipl.h.

References ocipl_free.


Member Function Documentation

size_t OCIPL::SqlString::alen (  ) const [inline]

Definition at line 1449 of file ocipl.h.

Referenced by OCIPL::BindInput::BindInput(), OCIPL::BindOutput::BindOutput(), and OCIPL::DefinePar::DefinePar().

{return _blen + 1;}

Here is the caller graph for this function:

size_t OCIPL::SqlString::blen (  ) const [inline]

Definition at line 1448 of file ocipl.h.

{return _blen;}
const TCHAR* OCIPL::SqlString::c_str (  ) const [inline]

Definition at line 1457 of file ocipl.h.

References TEXT.

Referenced by OCIPL::BindInput::BindInput(), and OCIPL::TrimBindPar::TrimBindPar().

{return is_null()? TEXT(""): _str;}

Here is the caller graph for this function:

void OCIPL::SqlString::clear (  ) [inline]

Definition at line 1452 of file ocipl.h.

{*_str = '\0'; _ind.clear();}
const SqlInd& OCIPL::SqlValue::ind (  ) const [inline, inherited]
SqlInd& OCIPL::SqlValue::ind (  ) [inline, inherited]

Definition at line 1245 of file ocipl.h.

{return _ind;}
bool OCIPL::SqlValue::is_not_null (  ) const [inline, inherited]

Definition at line 1242 of file ocipl.h.

Referenced by OCIPL::SqlInt::operator int().

{return _ind.is_not_null();}

Here is the caller graph for this function:

bool OCIPL::SqlValue::is_null (  ) const [inline, inherited]

Definition at line 1241 of file ocipl.h.

{return _ind.is_null();}
size_t OCIPL::SqlString::len (  ) const [inline]

Definition at line 1447 of file ocipl.h.

References _tcslen.

Referenced by OCIPL::TrimBindPar::TrimBindPar().

{return is_null()? 0: _tcslen(_str);}

Here is the caller graph for this function:

static TCHAR* OCIPL::SqlString::ocipl_tcscpyn ( TCHAR *  dest,
const TCHAR *  source,
size_t  count 
) [inline, static]

Definition at line 1470 of file ocipl.h.

References TCHAR.

    {
        TCHAR* d = dest;

        for(const TCHAR* s=source; count&&(*d++=*s++); )
            count--;

        return dest;
    }
OCIPL::SqlString::operator const TCHAR * (  ) const [inline]

Definition at line 1458 of file ocipl.h.

References TEXT.

{return is_null()? TEXT(""): _str;}
bool OCIPL::SqlString::operator!= ( const TCHAR *  s ) const [inline]

Definition at line 1464 of file ocipl.h.

References _tcscmp.

{return _tcscmp(c_str(), s) != 0;}
bool OCIPL::SqlString::operator< ( const TCHAR *  s ) const [inline]

Definition at line 1465 of file ocipl.h.

References _tcscmp.

{return _tcscmp(c_str(), s) < 0;}
SqlString & OCIPL::SqlString::operator= ( const TCHAR *  s )

Definition at line 394 of file ocipl.cpp.

References _blen, OCIPL::SqlValue::_ind, _str, _tcscpy_s, _tcslen, resize(), and TEXT.

{
    size_t l = s? _tcslen(s): 0;
    if (l > _blen)
        resize(l);  // resize for longer new strings

    _tcscpy_s(_str, _blen+1, s?s:TEXT(""));
    _ind = l>0? 0: -1;
    return *this;
}

Here is the call graph for this function:

SqlString & OCIPL::SqlString::operator= ( const tstring s )

Definition at line 405 of file ocipl.cpp.

References _blen, OCIPL::SqlValue::_ind, _str, and resize().

{
    if (!s.empty()) {
        size_t l = s.length();
        if (_blen < l)
            resize(l);  // resize for longer new strings

        memcpy(_str, s.c_str(), (l+1)*sizeof(char));
        _ind = 0;
    } else {
        *_str = '\0';
        _ind = -1;
    }

    return *this;
}

Here is the call graph for this function:

bool OCIPL::SqlString::operator== ( const TCHAR *  s ) const [inline]

Definition at line 1463 of file ocipl.h.

References _tcscmp.

{return !_tcscmp(c_str(), s);}
void OCIPL::SqlString::resize ( size_t  l ) [inline]

Definition at line 1451 of file ocipl.h.

References ocipl_realloc, and TCHAR.

Referenced by operator=().

{void* new_ptr = ocipl_realloc(_str,(l+1)*sizeof(TCHAR)); if (new_ptr) {_str=(TCHAR*)new_ptr; _str[l]='\0'; _blen=l;}}

Here is the caller graph for this function:

TCHAR* OCIPL::SqlString::str (  ) [inline]

Definition at line 1454 of file ocipl.h.

Referenced by OCIPL::BindOutput::BindOutput(), and OCIPL::DefinePar::DefinePar().

{return _str;}  // Note: _ind is not checked by this function.

Here is the caller graph for this function:

TCHAR* OCIPL::SqlString::str ( int  l ) [inline]

Definition at line 1455 of file ocipl.h.

{resize(l); return _str;}   // Note: _ind is not changed by this function.

Friends And Related Function Documentation

tostream& operator<< ( tostream os,
const SqlString str 
) [friend]

Definition at line 1467 of file ocipl.h.

        {if (str.is_not_null()) os << str._str; return os;}

Member Data Documentation

size_t OCIPL::SqlString::_blen [protected]

Definition at line 1481 of file ocipl.h.

Referenced by operator=().

SqlInd OCIPL::SqlValue::_ind [protected, inherited]

Definition at line 1248 of file ocipl.h.

Referenced by OCIPL::OciDate::OciDate(), operator=(), and OCIPL::SqlNumber::SqlNumber().

TCHAR* OCIPL::SqlString::_str [protected]

Definition at line 1482 of file ocipl.h.

Referenced by operator=().


The documentation for this struct was generated from the following files: