FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
August 01, 2003

Generalized String Manipulation: Access Shims and Type Tunneling

(Page 4 of 20)
Listing 11: Shims returning NULL strings

Listing 11: Shims returning NULL strings

/* /////////////////////////////////////////////////////////////
 * Extract from stlsoft_string_access.h, atlstl_string_access.h,
 *              mfcstl_string_access.h
 *
 * www:    http://stlsoft.org/, http://atlstl.org/
 *         http://mfcstl.org/
 *
 * Copyright (C) 2002, Synesis Software Pty Ltd.
 * (Licensed under the Synesis Software Standard Source License:
 *  http://www.synesis.com.au/licenses/ssssl.html)
 * ////////////////////////////////////////////////////////// */

namespace stlsoft
{
  /* C-style ANSI string */
  inline char const *c_str_ptr_null(char const *s)
  {
    return s;
  }
  /* std::basic_string */
  template <class C>
  inline C const *c_str_ptr_null(std::basic_string<C> const &s)
  {
    return (s.length() == 0) ? 0 : s.c_str();
  }
} // namespace stlsoft

namespace atlstl
{
  /* CComBSTR */
  inline LPCOLESTR c_str_ptr_null(CComBSTR const &s)
  {
    /* NULL is a valid BSTR value, so may return that */
    return s.m_str;
  }

} // namespace atlstl

namespace mfcstl
{
  /* CString */
  inline LPCTSTR c_str_ptr_null(CString const &s)
  {
    /* CString always points to valid memory, whether its own 
     * CStringData or afxEmptyString.m_pchData
     */
    return s.IsEmpty() ? NULL : (LPCTSTR)s;
  }

} // namespace mfcstl

Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK