comet::bstr_t Class Reference
[Com type wrappers.Com type wrappers.]

#include <comet/bstr.h>

List of all members.

Public Types

typedef wchar_t value_type
typedef std::wstring::iterator iterator
typedef std::wstring::const_iterator const_iterator
typedef std::wstring::reverse_iterator reverse_iterator
typedef std::wstring::const_reverse_iterator const_reverse_iterator
typedef std::wstring::size_type size_type
typedef std::wstring::difference_type difference_type
typedef wchar_t & reference
typedef const wchar_t const_reference

Public Member Functions

 bstr_t () throw ()
 bstr_t (const bstr_t &s) throw (std::bad_alloc)
 Copy constructor.
 bstr_t (const wchar_t *s) throw (std::bad_alloc)
 Construct string from const wchar_t*.
 bstr_t (const wchar_t *s, size_t len) throw (std::bad_alloc)
 bstr_t (const char *s) throw (std::runtime_error)
 Construct string from const char*.
 bstr_t (const char *s, size_t len) throw (std::bad_alloc)
 bstr_t (const std::string &s) throw (std::runtime_error)
 Construct string from const std::string&.
 bstr_t (const impl::auto_attach_t< BSTR > &s) throw ()
 Construct string from BSTR.
 bstr_t (const std::wstring &s) throw (std::bad_alloc)
 Construct string from const std::wstring&.
 bstr_t (size_type sz, wchar_t c) throw (std::bad_alloc)
 bstr_t (size_type sz) throw (std::bad_alloc)
template<typename IT>  bstr_t (IT first, IT last)
 bstr_t (const uuid_t &u, bool braces=false)
 ~bstr_t () throw ()
 Destructor.
void swap (bstr_t &x) throw ()
 Swap.
const wchar_t * c_str () const throw ()
 Explicit conversion to const wchar_t*.
std::wstring w_str () const throw ()
 Explicit conversion to std::wstring.
std::string s_str () const
 Explicit conversion to std::string.
std::string t_str () const
 Explicit conversion to "tstring".
 operator std::wstring () const
 Implicit conversion to std::wstring.
 operator std::string () const
 Implicit conversion to std::string.
bool is_null () const throw ()
 Returns true if and only if wrapped str is null.
bool is_empty () const throw ()
bool empty () const throw ()
 Returns true if and only if wrapped str has zero length.
size_t length () const throw ()
 Returns length of wrapped string.
size_t size () const throw ()
BSTR get_raw () const
int cmp (const bstr_t &s, compare_flags_t flags=compare_flags_t(0)) const
 String comparsion function.
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
reverse_iterator rbegin ()
reverse_iterator rend ()
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const
reference at (size_type i)
const_reference at (size_type i) const
const_reference operator[] (size_type idx) const
reference operator[] (size_type idx)
void assign (size_type sz, wchar_t c) throw (std::bad_alloc)
 Assign string to be sz of charater c .
template<typename IT> void assign (IT first, IT last)
 Assign string from two iterators.
template<typename T> bstr_toperator= (const T &x)
 Assignment operator from any (non integer) constructable.
bstr_toperator= (const bstr_t &x) throw (std::bad_alloc)
 Default assignment.
bstr_t operator+ (const bstr_t &s) const throw (std::bad_alloc)
 Concat operation.
bstr_t operator+ (const wchar_t *s) const throw (std::bad_alloc)
 Concat with const wchar_t*.
bstr_t operator+ (const std::wstring &s) const throw (std::bad_alloc)
 Concat with std::wstring.
bstr_toperator+= (const bstr_t &s) throw (std::bad_alloc)
 Concat assignment.
bstr_toperator+= (const wchar_t *s) throw (std::bad_alloc)
 Concat assigment with const wchar_t*.
bstr_toperator+= (const std::wstring &s) throw (std::bad_alloc)
 Concat assignment with std::wstring.
BSTR * get_ptr_to_raw () const
BSTR in () const throw ()
 [in] adapter.
BSTR * in_ptr () const throw ()
 [in] adapter.
BSTR * out () throw ()
 [out] adapter.
BSTR * inout () throw (std::bad_alloc)
 [in, out] adapter.
Boolean operators
bool operator== (const wchar_t *s) const
bool operator!= (const wchar_t *s) const
bool operator< (const wchar_t *s) const
bool operator> (const wchar_t *s) const
bool operator>= (const wchar_t *s) const
bool operator<= (const wchar_t *s) const
bool operator== (const std::wstring &s) const
bool operator!= (const std::wstring &s) const
bool operator< (const std::wstring &s) const
bool operator> (const std::wstring &s) const
bool operator>= (const std::wstring &s) const
bool operator<= (const std::wstring &s) const
bool operator== (const bstr_t &s) const
bool operator!= (const bstr_t &s) const
bool operator< (const bstr_t &s) const
bool operator> (const bstr_t &s) const
bool operator>= (const bstr_t &s) const
bool operator<= (const bstr_t &s) const

Static Public Member Functions

BSTR detach (bstr_t &s)
 Detaches specified bstr.
template<typename T> BSTR detach (const T &s)
Create a reference to a BSTR
const bstr_tcreate_const_reference (const BSTR &s) throw ()
bstr_tcreate_reference (BSTR &s) throw ()

Friends

std::basic_ostream< char > & operator<< (std::basic_ostream< char > &os, const bstr_t &val)
std::basic_ostream< wchar_t > & operator<< (std::basic_ostream< wchar_t > &os, const bstr_t &val)
bstr_t operator+ (const std::wstring &s, const bstr_t &t) throw (std::bad_alloc)
 Concat operation.
bstr_t operator+ (const wchar_t *s, const bstr_t &t) throw (std::bad_alloc)
 Concat operation.

Related Functions

(Note that these are not member functions.)

Boolean Operators on String
bool operator== (const wchar_t *s1, const bstr_t &s2) throw()
bool operator!= (const wchar_t *s1, const bstr_t &s2) throw()
bool operator< (const wchar_t *s1, const bstr_t &s2) throw()
bool operator> (const wchar_t *s1, const bstr_t &s2) throw()
bool operator<= (const wchar_t *s1, const bstr_t &s2) throw()
bool operator>= (const wchar_t *s1, const bstr_t &s2) throw()
bool operator== (const std::wstring &s1, const bstr_t &s2) throw()
bool operator!= (const std::wstring &s1, const bstr_t &s2) throw()
bool operator< (const std::wstring &s1, const bstr_t &s2) throw()
bool operator> (const std::wstring &s1, const bstr_t &s2) throw()
bool operator<= (const std::wstring &s1, const bstr_t &s2) throw()
bool operator>= (const std::wstring &s1, const bstr_t &s2) throw()


Detailed Description

BSTR Wrapper.
See also:
bstr_t


Constructor & Destructor Documentation

comet::bstr_t::bstr_t  )  throw () [inline]
 

Default constructor Constructs a null string.

comet::bstr_t::bstr_t const bstr_t s  )  throw (std::bad_alloc) [inline]
 

Copy constructor.

Parameters:
s String initialise bstr_t from.
Exceptions:
std::bad_alloc On memory exhaustion std::bad_alloc is thrown.

comet::bstr_t::bstr_t const wchar_t *  s  )  throw (std::bad_alloc) [inline]
 

Construct string from const wchar_t*.

Parameters:
s String to initialise bstr_t from.
Exceptions:
std::bad_alloc On memory exhaustion std::bad_alloc is thrown.

comet::bstr_t::bstr_t const char *  s  )  throw (std::runtime_error) [inline]
 

Construct string from const char*.

Parameters:
s String to initialise bstr_t from.
Exceptions:
std::bad_alloc On memory exhaustion std::bad_alloc is thrown.
std::runtime_error Should string conversion fail, std::runtime_error will be thrown.

comet::bstr_t::bstr_t const std::string &  s  )  throw (std::runtime_error) [inline]
 

Construct string from const std::string&.

Parameters:
s String to initialise bstr_t from.
Exceptions:
std::bad_alloc On memory exhaustion std::bad_alloc is thrown.
std::runtime_error Should string conversion fail, std::runtime_error will be thrown.

comet::bstr_t::bstr_t const impl::auto_attach_t< BSTR > &  s  )  throw () [inline]
 

Construct string from BSTR.

Takes ownership of specified BSTR. To prevent misuse the BSTR must be wrapped using auto_attach.

                                bstr_t bs( auto_attach( myBSTR ) );

Parameters:
s String to initialise bstr_t from.

comet::bstr_t::bstr_t const std::wstring &  s  )  throw (std::bad_alloc) [inline]
 

Construct string from const std::wstring&.

Parameters:
s String to initialise bstr_t from.
Exceptions:
std::bad_alloc On memory exhaustion std::bad_alloc is thrown.

comet::bstr_t::~bstr_t  )  throw () [inline]
 

Destructor.

Deletes the wrapped BSTR.


Member Function Documentation

int comet::bstr_t::cmp const bstr_t s,
compare_flags_t  flags = compare_flags_t(0)
const [inline]
 

String comparsion function.

Parameters:
s String to compare
flags Comparison Flags
Return values:
&lt;0 if less
0 if Equal
&gt;0 if greater

const bstr_t& comet::bstr_t::create_const_reference const BSTR &  s  )  throw () [inline, static]
 

Creates a bstr_t that is a reference to the BSTR. It will not be reference counted and will not be deleted when the bstr_t goes out of scope.

This is used by the interface wrappers for [in] BSTR's. Typically clients do not need create_reference.

BSTR comet::bstr_t::in  )  const throw () [inline]
 

[in] adapter.

Used when calling raw interfaces that require an [in] BSTR argument.

                                bstr_t bs;
                                HRESULT hr = pRawInterface->raw_Method(bs.in());

Only use this wrapper when forced to deal with raw interface.

BSTR* comet::bstr_t::in_ptr  )  const throw () [inline]
 

[in] adapter.

Used when calling raw interfaces that require an [in] BSTR* argument.

                                bstr_t bs;
                                HRESULT hr = pRawInterface->raw_Method(bs.in_ptr());

Only use this wrapper when forced to deal with raw interface.

BSTR* comet::bstr_t::inout  )  throw (std::bad_alloc) [inline]
 

[in, out] adapter.

Used when calling raw interfaces that require an [in, out] BSTR * argument.

                                bstr_t bs;
                                HRESULT hr = pRawInterface->raw_MethodThatChangesBSTR(bs.inout());

Only use this wrapper when forced to deal with raw interface.

Note:
If the wrapped BSTR is shared. The bstr_t is copied so that only this version is modified.
Exceptions:
std::bad_alloc Throws std::bad_alloc if the bstr_t is being copied and memory is exhausted.

bool comet::bstr_t::is_empty  )  const throw () [inline]
 

Returns true if and only if wrapped str has zero length.

BSTR* comet::bstr_t::out  )  throw () [inline]
 

[out] adapter.

Used when calling raw interfaces that require an [out] BSTR * argument.

                                bstr_t bs;
                                HRESULT hr = pRawInterface->raw_MethodThatReturnsBSTR(bs.out());

Only use this wrapper when forced to deal with raw interface.


The documentation for this class was generated from the following file: