STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

mfcstl_string_access.h

Go to the documentation of this file.
00001 /* 
00002  * File:        mfcstl_string_access.h
00003  *
00004  * Purpose:     Contains classes and functions for dealing with MFC strings.
00005  *
00006  * Created:
00007  * Updated:     11th September 2004
00008  *
00009  * Home:        http://stlsoft.org/
00010  *
00011  * Copyright (c) 2002-2004, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * 
00039 
00040 
00044 
00045 #ifndef MFCSTL_INCL_H_MFCSTL_STRING_ACCESS
00046 #define MFCSTL_INCL_H_MFCSTL_STRING_ACCESS
00047 
00048 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00049 # define MFCSTL_VER_H_MFCSTL_STRING_ACCESS_MAJOR     2
00050 # define MFCSTL_VER_H_MFCSTL_STRING_ACCESS_MINOR     0
00051 # define MFCSTL_VER_H_MFCSTL_STRING_ACCESS_REVISION  1
00052 # define MFCSTL_VER_H_MFCSTL_STRING_ACCESS_EDIT      50
00053 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00054 
00055 /* 
00056  * Includes
00057  */
00058 
00059 #ifndef MFCSTL_INCL_H_MFCSTL
00060 # include "mfcstl.h"    // Include the MFCSTL root header
00061 #endif /* !MFCSTL_INCL_H_MFCSTL */
00062 #ifndef STLSOFT_INCL_H_STLSOFT_STRING_ACCESS
00063 # include "stlsoft_string_access.h"
00064 #endif /* !STLSOFT_INCL_H_STLSOFT_STRING_ACCESS */
00065 #ifndef STLSOFT_INCL_H_STLSOFT_CONSTRAINTS
00066 # include "stlsoft_constraints.h"
00067 #endif /* !STLSOFT_INCL_H_STLSOFT_CONSTRAINTS */
00068 #ifndef STLSOFT_INCL_H_STLSOFT_CSTRING_MAKER
00069 # include "stlsoft_cstring_maker.h"         //
00070 #endif /* !STLSOFT_INCL_H_STLSOFT_CSTRING_MAKER */
00071 
00072 #if defined(__STLSOFT_COMPILER_IS_BORLAND)
00073 # pragma warn -8022 /* Suppresses "'f()' hides virtual function 'g()'" */
00074 # pragma warn -8084 /* Suppresses "Suggest parentheses to clarify precedence in function 'f()'" */
00075 #endif /* compiler */
00076 
00077 #include <afxwin.h>     // CWnd, CListBox
00078 #if !defined(__AFXCMN_H__) && \
00079     !defined(MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCMN)
00080 # include <afxcmn.h>    // CListCtrl
00081 #endif /* !__AFXCMN_H__ && !MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCMN */
00082 #if !defined(__AFXCVIEW_H__) && \
00083     !defined(MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCVIEW)
00084 # include <afxcview.h> // CListView
00085 #endif /* !__AFXCVIEW_H__ && !MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCMN */
00086 
00087 #if defined(__STLSOFT_COMPILER_IS_BORLAND)
00088 # pragma warn .8022 /* Suppresses "'f()' hides virtual function 'g()'" */
00089 # pragma warn .8084 /* Suppresses "Suggest parentheses to clarify precedence in function 'f()'" */
00090 #endif /* compiler */
00091 
00092 /* 
00093  * Namespace
00094  *
00095  * The MFCSTL components are contained within the mfcstl namespace. This is
00096  * actually an alias for stlsoft::mfcstl_project,
00097  *
00098  * The definition matrix is as follows:
00099  *
00100  * _STLSOFT_NO_NAMESPACE    _MFCSTL_NO_NAMESPACE    mfcstl definition
00101  * ---------------------    --------------------    -----------------
00102  *  not defined              not defined             = stlsoft::mfcstl_project
00103  *  not defined              defined                 not defined
00104  *  defined                  not defined             mfcstl
00105  *  defined                  defined                 not defined
00106  *
00107  */
00108 
00109 #ifndef _MFCSTL_NO_NAMESPACE
00110 # if defined(_STLSOFT_NO_NAMESPACE) || \
00111      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00112 /* There is no stlsoft namespace, so must define ::mfcstl */
00113 namespace mfcstl
00114 {
00115 # else
00116 /* Define stlsoft::mfcstl_project */
00117 
00118 namespace stlsoft
00119 {
00120 
00121 namespace mfcstl_project
00122 {
00123 
00124 # endif /* _STLSOFT_NO_NAMESPACE */
00125 #endif /* !_MFCSTL_NO_NAMESPACE */
00126 
00127 /* 
00128 
00130 
00133 
00137 
00142 
00143 /* 
00144  * Functions
00145  */
00146 
00147 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00148 
00149 inline ms_size_t GetWindowTextLength__(CWnd const &w)
00150 {
00151     return (NULL != w.m_hWnd) ? static_cast<ms_size_t>(w.GetWindowTextLength()) : 0;
00152 }
00153 
00154 inline ms_size_t GetWindowText__(CWnd const &w, LPTSTR buffer, ms_size_t cchBuffer)
00155 {
00156     mfcstl_assert(NULL != w.m_hWnd);
00157 
00158     return static_cast<ms_size_t>(w.GetWindowText(buffer, cchBuffer));
00159 }
00160 
00161 
00162 inline ms_size_t GetWindowTextLength__(CListBox const &w)
00163 {
00164     int sel;
00165 
00166     if( 0 == (w.GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) &&
00167         LB_ERR != (sel = w.GetCurSel()))
00168     {
00169         return static_cast<ms_size_t>(w.GetTextLen(sel));
00170     }
00171     else
00172     {
00173         return static_cast<ms_size_t>(w.GetWindowTextLength());
00174     }
00175 }
00176 
00177 inline ms_size_t GetWindowText__(CListBox const &w, LPTSTR buffer, ms_size_t cchBuffer)
00178 {
00179     int sel = -1;
00180 
00181     if( 0 == (w.GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) &&
00182         LB_ERR != (sel = w.GetCurSel()))
00183     {
00184         ms_size_t cch = static_cast<ms_size_t>(w.GetText(sel, buffer));
00185 
00186         mfcstl_message_assert("Invalid item", LB_ERR != cch);
00187         mfcstl_message_assert("Buffer overwrite", !(cchBuffer < cch));
00188 
00189         return static_cast<ms_size_t>(cch);
00190     }
00191     else
00192     {
00193         return w.GetWindowText(buffer, cchBuffer);
00194     }
00195 }
00196 
00197 #ifdef __AFXCMN_H__
00198 # if _MFC_VER >= 0x0600
00199 inline ms_size_t GetWindowTextLength__(CListCtrl const &w)
00200 {
00201     if(1 == w.GetSelectedCount())
00202     {
00203         POSITION    pos =   w.GetFirstSelectedItemPosition();
00204         int         sel =   w.GetNextSelectedItem(pos);
00205 
00206         return static_cast<ms_size_t>(w.GetItemText(sel, 0).GetLength());
00207     }
00208     else
00209     {
00210         return static_cast<ms_size_t>(w.GetWindowTextLength());
00211     }
00212 }
00213 
00214 inline ms_size_t GetWindowText__(CListCtrl const &w, LPTSTR buffer, ms_size_t cchBuffer)
00215 {
00216     if(1 == w.GetSelectedCount())
00217     {
00218         POSITION    pos =   w.GetFirstSelectedItemPosition();
00219         int         sel =   w.GetNextSelectedItem(pos);
00220 
00221         return static_cast<ms_size_t>(w.GetItemText(sel, 0, buffer, cchBuffer));
00222     }
00223     else
00224     {
00225         return w.GetWindowText(buffer, cchBuffer);
00226     }
00227 }
00228 
00229 #  ifdef __AFXCVIEW_H__
00230 inline ms_size_t GetWindowTextLength__(CListView const &w)
00231 {
00232     return GetWindowTextLength__(w.GetListCtrl());
00233 }
00234 
00235 inline ms_size_t GetWindowText__(CListView const &w, LPTSTR buffer, ms_size_t cchBuffer)
00236 {
00237     return GetWindowText__(w.GetListCtrl(), buffer, cchBuffer);
00238 }
00239 #  endif /* __AFXCVIEW_H__ */
00240 # endif /* _MFC_VER >= 0x0600 */
00241 #endif /* __AFXCMN_H__ */
00242 
00243 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00244 
00245 
00246 /* 
00247  * Classes
00248  */
00249 
00250 /* CWnd */
00251 
00255 class c_str_ptr_null_CWnd_proxy
00256 {
00257     typedef TCHAR                       char_type;
00258     typedef cstring_maker<TCHAR>        string_maker_type;
00259 public:
00260     typedef c_str_ptr_null_CWnd_proxy   class_type;
00261 
00262 // Construction
00263 public:
00267     template<ss_typename_param_k W>
00268     c_str_ptr_null_CWnd_proxy(const W &w)
00269     {
00270         stlsoft_constraint_must_have_base(W, CWnd);
00271 
00272         ms_size_t length = GetWindowTextLength__(w);
00273 
00274         if(length == 0)
00275         {
00276             m_buffer = NULL;
00277         }
00278         else
00279         {
00280             m_buffer = string_maker_type::alloc(length);
00281 
00282             if(NULL != m_buffer)
00283             {
00284                 GetWindowText__(w, m_buffer, length + 1);
00285             }
00286         }
00287     }
00288 
00289 #ifdef __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT
00298     c_str_ptr_null_CWnd_proxy(class_type &rhs)
00299         : m_buffer(rhs.m_buffer)
00300     {
00301         rhs.m_buffer = NULL;
00302     }
00303 #else /* ? __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */
00304     // Copy constructor
00305     c_str_ptr_null_CWnd_proxy(class_type const &rhs)
00306         : m_buffer(string_maker_type::dup_null(rhs.m_buffer))
00307     {}
00308 #endif /* __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */
00309 
00311     ~c_str_ptr_null_CWnd_proxy()
00312     {
00313         string_maker_type::free(m_buffer);
00314     }
00315 
00316 // Accessors
00317 public:
00320     operator LPCTSTR () const
00321     {
00322         return m_buffer;
00323     }
00324 
00325 // Members
00326 private:
00327     LPTSTR  m_buffer;
00328 
00329 // Not to be implemented
00330 private:
00331     void operator =(class_type const &rhs);
00332 };
00333 
00337 class c_str_ptr_CWnd_proxy
00338 {
00339     typedef TCHAR                   char_type;
00340     typedef cstring_maker<TCHAR>    string_maker_type;
00341 private:
00342     typedef c_str_ptr_CWnd_proxy    class_type;
00343 
00344 // Construction
00345 public:
00349     template<ss_typename_param_k W>
00350     c_str_ptr_CWnd_proxy(const W &w)
00351     {
00352         stlsoft_constraint_must_have_base(W, CWnd);
00353 
00354         ms_size_t length = GetWindowTextLength__(w);
00355 
00356         if(length == 0)
00357         {
00358             m_buffer = string_maker_type::dup(_T(""));
00359         }
00360         else
00361         {
00362             m_buffer = string_maker_type::alloc(length);
00363 
00364             if(NULL != m_buffer)
00365             {
00366                 GetWindowText__(w, m_buffer, length + 1);
00367             }
00368         }
00369     }
00370 
00371 #ifdef __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT
00380     c_str_ptr_CWnd_proxy(class_type &rhs)
00381         : m_buffer(rhs.m_buffer)
00382     {
00383         rhs.m_buffer = NULL;
00384     }
00385 #else /* ? __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */
00386     // Copy constructor
00387     c_str_ptr_CWnd_proxy(class_type const &rhs)
00388         : m_buffer(string_maker_type::dup_null(rhs.m_buffer))
00389     {}
00390 #endif /* __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */
00391 
00393     ~c_str_ptr_CWnd_proxy()
00394     {
00395         string_maker_type::free(m_buffer);
00396     }
00397 
00398 // Accessors
00399 public:
00402     operator LPCTSTR () const
00403     {
00404         static char_type    s_ch[1] = { '\0' };
00405 
00406         return (NULL == m_buffer) ? s_ch : m_buffer;
00407     }
00408 
00409 // Implementation
00410 private:
00411     // \note Does not need to worry about operator new() returning NULL
00412     static LPTSTR dup_(LPCTSTR s)
00413     {
00414         return lstrcpy(new TCHAR[1 + lstrlen(s)], s);
00415     }
00416 
00417 // Members
00418 private:
00419     LPTSTR  m_buffer;
00420 
00421 // Not to be implemented
00422 private:
00423     void operator =(class_type const &rhs);
00424 };
00425 
00426 /* 
00427  * Equivalence testing
00428  */
00429 
00430 inline ms_bool_t operator ==(LPCTSTR lhs, c_str_ptr_null_CWnd_proxy const &rhs)
00431 {
00432     return lhs == static_cast<LPCTSTR>(rhs);
00433 }
00434 
00435 inline ms_bool_t operator ==(c_str_ptr_null_CWnd_proxy const &lhs, LPCTSTR rhs)
00436 {
00437     return static_cast<LPCTSTR>(lhs) == rhs;
00438 }
00439 
00440 inline ms_bool_t operator !=(LPCTSTR lhs, c_str_ptr_null_CWnd_proxy const &rhs)
00441 {
00442     return lhs != static_cast<LPCTSTR>(rhs);
00443 }
00444 
00445 inline ms_bool_t operator !=(c_str_ptr_null_CWnd_proxy const &lhs, LPCTSTR rhs)
00446 {
00447     return static_cast<LPCTSTR>(lhs) != rhs;
00448 }
00449 
00450 /* 
00451  * IOStream compatibility
00452  */
00453 
00454 template<ss_typename_param_k S>
00455 inline S &operator <<(S & s, c_str_ptr_null_CWnd_proxy const &shim)
00456 {
00457     s << static_cast<LPCTSTR>(shim);
00458 
00459     return s;
00460 }
00461 
00462 template <ss_typename_param_k S>
00463 inline S &operator <<(S & s, c_str_ptr_CWnd_proxy const &shim)
00464 {
00465     s << static_cast<LPCTSTR>(shim);
00466 
00467     return s;
00468 }
00469 
00470 /* 
00471  * c_str_ptr_null
00472  *
00473  * This can be applied to an expression, and the return value is either a
00474  * pointer to the character string or NULL.
00475  */
00476 
00477 /* CWnd */
00479 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(const CWnd &w)
00480 {
00481     return c_str_ptr_null_CWnd_proxy(w);
00482 }
00483 
00484 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(const CListBox &w)
00485 {
00486     return c_str_ptr_null_CWnd_proxy(w);
00487 }
00488 
00489 #ifdef __AFXCMN_H__
00490 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(const CListCtrl &w)
00491 {
00492     return c_str_ptr_null_CWnd_proxy(w);
00493 }
00494 
00495 # ifdef __AFXCVIEW_H__
00496 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(const CListView &w)
00497 {
00498     return c_str_ptr_null(w.GetListCtrl());
00499 }
00500 # endif /* __AFXCVIEW_H__ */
00501 #endif /* __AFXCMN_H__ */
00502 
00503 /* CString */
00505 inline LPCTSTR c_str_ptr_null(const CString &s)
00506 {
00507     /* CString always points to valid memory, whether its own
00508      * CStringData or afxEmptyString.m_pchData
00509      */
00510     return s.IsEmpty() ? NULL : (LPCTSTR)s;
00511 }
00512 
00513 /* 
00514  * c_str_ptr
00515  *
00516  * This can be applied to an expression, and the return value is either a
00517  * pointer to the character string or to an empty string.
00518  */
00519 
00520 /* CWnd */
00522 inline c_str_ptr_CWnd_proxy c_str_ptr(const CWnd &w)
00523 {
00524     return c_str_ptr_CWnd_proxy(w);
00525 }
00526 
00527 inline c_str_ptr_CWnd_proxy c_str_ptr(const CListBox &w)
00528 {
00529     return c_str_ptr_CWnd_proxy(w);
00530 }
00531 
00532 #ifdef __AFXCMN_H__
00533 inline c_str_ptr_CWnd_proxy c_str_ptr(const CListCtrl &w)
00534 {
00535     return c_str_ptr_CWnd_proxy(w);
00536 }
00537 
00538 # ifdef __AFXCVIEW_H__
00539 inline c_str_ptr_CWnd_proxy c_str_ptr(const CListView &w)
00540 {
00541     return c_str_ptr(w.GetListCtrl());
00542 }
00543 # endif /* __AFXCVIEW_H__ */
00544 #endif /* __AFXCMN_H__ */
00545 
00546 /* CString */
00548 inline LPCTSTR c_str_ptr(const CString &s)
00549 {
00550     /* CString always points to valid memory, whether its own
00551      * CStringData or afxEmptyString.m_pchData
00552      */
00553     return s;
00554 }
00555 
00556 /* 
00557  * c_str_len
00558  *
00559  * This can be applied to an expression, and the return value is the number of
00560  * characters in the character string in the expression.
00561  */
00562 
00563 /* CWnd */
00565 inline ms_size_t c_str_len(const CWnd &w)
00566 {
00567     return GetWindowTextLength__(w);
00568 }
00569 
00570 inline ms_size_t c_str_len(const CListBox &w)
00571 {
00572     return GetWindowTextLength__(w);
00573 }
00574 
00575 #ifdef __AFXCMN_H__
00576 inline ms_size_t c_str_len(const CListCtrl &w)
00577 {
00578     return GetWindowTextLength__(w);
00579 }
00580 
00581 # ifdef __AFXCVIEW_H__
00582 inline ms_size_t c_str_len(const CListView &w)
00583 {
00584     return c_str_len(w.GetListCtrl());
00585 }
00586 # endif /* __AFXCVIEW_H__ */
00587 #endif /* __AFXCMN_H__ */
00588 
00589 /* CString */
00591 inline ms_size_t c_str_len(const CString &s)
00592 {
00593     return s.GetLength();
00594 }
00595 
00596 /* 
00597  * c_str_size
00598  *
00599  * This can be applied to an expression, and the return value is the number of
00600  * bytes required to store the character string in the expression, NOT including
00601  * the null-terminating character.
00602  */
00603 
00604 /* CWnd */
00606 inline ms_size_t c_str_size(const CWnd &w)
00607 {
00608     return c_str_len(w) * sizeof(TCHAR);
00609 }
00610 
00611 inline ms_size_t c_str_size(const CListBox &w)
00612 {
00613     return c_str_len(w) * sizeof(TCHAR);
00614 }
00615 
00616 #ifdef __AFXCMN_H__
00617 inline ms_size_t c_str_size(const CListCtrl &w)
00618 {
00619     return c_str_len(w) * sizeof(TCHAR);
00620 }
00621 
00622 # ifdef __AFXCVIEW_H__
00623 inline ms_size_t c_str_size(const CListView &w)
00624 {
00625     return c_str_size(w.GetListCtrl());
00626 }
00627 # endif /* __AFXCVIEW_H__ */
00628 #endif /* __AFXCMN_H__ */
00629 
00630 /* CString */
00632 inline ms_size_t c_str_size(const CString &s)
00633 {
00634     return c_str_len(s) * sizeof(TCHAR);
00635 }
00636 
00638 // Unit-testing
00639 
00640 #ifdef STLSOFT_UNITTEST
00641 
00642 namespace unittest
00643 {
00644     namespace
00645     {
00646         ss_bool_t test_mfcstl_string_access_CString(unittest_reporter *r)
00647         {
00648             ss_bool_t   bSuccess = true;
00649 
00650             CString     str1("String #1");
00651 
00652             if(0 != _tcscmp(_T("String #1"), c_str_ptr(str1)))
00653             {
00654                 r->report("c_str_ptr(CString) failed ", __LINE__);
00655                 bSuccess = false;
00656             }
00657 
00658             if(0 != _tcscmp(_T("String #1"), c_str_ptr_null(str1)))
00659             {
00660                 r->report("c_str_ptr_null(CString) failed ", __LINE__);
00661                 bSuccess = false;
00662             }
00663 
00664             CString     str2;
00665 
00666             if(NULL != c_str_ptr_null(str2))
00667             {
00668                 r->report("c_str_ptr_null(CString) failed ", __LINE__);
00669                 bSuccess = false;
00670             }
00671 
00672             return bSuccess;
00673         }
00674 
00675         ss_bool_t test_mfcstl_string_access_CWnd(unittest_reporter *r)
00676         {
00677             ss_bool_t   bSuccess = true;
00678 
00679             CWnd    wnd1;
00680             CWnd    *pwndDesktopWindow  =   CWnd::GetDesktopWindow();
00681             RECT    rc                  =   { 0, 0, 10, 10 };
00682 
00683             if( wnd1.Create("BUTTON", "Window #1", NULL, rc, pwndDesktopWindow, 0) &&
00684                 0 != strcmp("Window #1", c_str_ptr(wnd1)))
00685             {
00686                 r->report("c_str_ptr(CWnd) failed ", __LINE__);
00687                 bSuccess = false;
00688             }
00689 
00690             wnd1.DestroyWindow();
00691 
00692             CWnd    wnd2;
00693 
00694             if(0 != strcmp("", c_str_ptr(wnd2)))
00695             {
00696                 r->report("c_str_ptr(CWnd) failed ", __LINE__);
00697                 bSuccess = false;
00698             }
00699 
00700             if(NULL != c_str_ptr_null(wnd2))
00701             {
00702                 r->report("c_str_ptr_null(CWnd) failed ", __LINE__);
00703                 bSuccess = false;
00704             }
00705 
00706             return bSuccess;
00707         }
00708 
00709     } // anonymous namespace
00710 
00711     ss_bool_t test_mfcstl_string_access(unittest_reporter *r)
00712     {
00713         using stlsoft::unittest::unittest_initialiser;
00714 
00715         ss_bool_t               bSuccess    =   true;
00716 
00717         unittest_initialiser    init(r, "MFCSTL", "string_access", __FILE__);
00718 
00719         // 1. Test CString
00720         if(bSuccess)
00721         {
00722             bSuccess = test_mfcstl_string_access_CString(r);
00723         }
00724 
00725         // 1. Test CWnd
00726         if(bSuccess)
00727         {
00728             bSuccess = test_mfcstl_string_access_CWnd(r);
00729         }
00730 
00731         return bSuccess;
00732     }
00733 
00734     unittest_registrar    unittest_mfcstl_string_access(test_mfcstl_string_access);
00735 
00736 } // namespace unittest
00737 
00738 #endif /* STLSOFT_UNITTEST */
00739 
00740 /* 
00741 
00743 
00744 /* 
00745 
00746 #ifndef _MFCSTL_NO_NAMESPACE
00747 # if defined(_STLSOFT_NO_NAMESPACE) || \
00748      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00749 } // namespace mfcstl
00750 # else
00751 } // namespace stlsoft::mfcstl_project
00752 } // namespace stlsoft
00753 # endif /* _STLSOFT_NO_NAMESPACE */
00754 #endif /* !_MFCSTL_NO_NAMESPACE */
00755 
00756 /* 
00757  * Namespace
00758  *
00759  * The string access shims exist either in the stlsoft namespace, or in the
00760  * global namespace. This is required by the lookup rules.
00761  *
00762  */
00763 
00764 #ifndef _MFCSTL_NO_NAMESPACE
00765 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00766      !defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00767 namespace stlsoft
00768 {
00769 # else /* ? _STLSOFT_NO_NAMESPACE */
00770 /* There is no stlsoft namespace, so must define in the global namespace */
00771 # endif /* !_STLSOFT_NO_NAMESPACE */
00772 
00773 using ::mfcstl::c_str_ptr_null;
00774 
00775 using ::mfcstl::c_str_ptr;
00776 
00777 using ::mfcstl::c_str_len;
00778 
00779 using ::mfcstl::c_str_size;
00780 
00781 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00782      !defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00783 } // namespace stlsoft
00784 # else /* ? _STLSOFT_NO_NAMESPACE */
00785 /* There is no stlsoft namespace, so must define in the global namespace */
00786 # endif /* !_STLSOFT_NO_NAMESPACE */
00787 #endif /* !_MFCSTL_NO_NAMESPACE */
00788 
00789 /* 
00790 
00791 #endif /* !MFCSTL_INCL_H_MFCSTL_STRING_ACCESS */
00792 
00793 /* 

STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004