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 8 of 20)
Listing 4: Generalization via the preprocessor. Not very maintainable...

Listing 4: Generalization via the preprocessor. Not very maintainable...

#if defined(PPHACK_USE_STD_STRING)
  typedef std::string               string_t;
#elif defined(PPHACK_USE_CSTRING)
  typedef CString                   string_t;
#elif defined(PPHACK_USE_CUSTOM_TYPE)
 #if !defined(PPHACK_CUSTOM_TYPE)
  #error Must defined PPHACK_CUSTOM_TYPE with custom type
 #endif /* !PPHACK_CUSTOM_TYPE */
  typedef PPHACK_CUSTOM_TYPE        string_t;
#else
 #error Must specify recognised PPHACK_USE_*** selector
#endif /* type */

  ...

  for(; begin != end; ++begin)
  {
    // Add the item to the result ...
    string_t const  &s(*begin);

#if defined(PPHACK_USE_STD_STRING)
    ListBox_AddString(hwndList, s.c_str());
#elif defined(PPHACK_USE_CSTRING)
    ListBox_AddString(hwndList, static_cast<char const *>(s));
#elif defined(PPHACK_USE_CUSTOM_TYPE)
 #if !defined(PPHACK_ACCESS_CUSTOM_TYPE)
  #error Must defined PPHACK_ACCESS_CUSTOM_TYPE with custom type
 #endif /* !PPHACK_ACCESS_CUSTOM_TYPE */
    ListBox_AddString(hwndList, PPHACK_ACCESS_CUSTOM_TYPE(s));
#else
 #error Must specify recognised PPHACK_USE_*** selector
#endif /* type */
  }

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