You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

884 lines
25 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: mfcstl/shims/access/string/cwnd.hpp
  3. *
  4. * Purpose: Contains classes and functions for dealing with MFC strings.
  5. *
  6. * Created: 24th May 2002
  7. * Updated: 22nd November 2011
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2002-2011, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file mfcstl/shims/access/string/cwnd.hpp
  40. *
  41. * \brief [C++] Definition of the string access shims for
  42. * <code>CWnd</code>
  43. * (\ref group__concept__shim__string_access "String Access Shims" Concept).
  44. */
  45. #ifndef MFCSTL_INCL_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND
  46. #define MFCSTL_INCL_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND
  47. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  48. # define MFCSTL_VER_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND_MAJOR 4
  49. # define MFCSTL_VER_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND_MINOR 0
  50. # define MFCSTL_VER_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND_REVISION 6
  51. # define MFCSTL_VER_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND_EDIT 94
  52. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Includes
  55. */
  56. #ifndef MFCSTL_INCL_MFCSTL_HPP_MFCSTL
  57. # include <mfcstl/mfcstl.hpp>
  58. #endif /* !MFCSTL_INCL_MFCSTL_HPP_MFCSTL */
  59. #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
  60. # include <stlsoft/shims/access/string.hpp>
  61. #endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING */
  62. #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_CONSTRAINTS
  63. # include <stlsoft/util/constraints.hpp>
  64. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_HPP_CONSTRAINTS */
  65. #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_CSTRING_MAKER
  66. # include <stlsoft/string/cstring_maker.hpp>
  67. #endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_CSTRING_MAKER */
  68. #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_LIBRARY_DISCRIMINATOR
  69. # include <stlsoft/util/std/library_discriminator.hpp>
  70. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_STD_LIBRARY_DISCRIMINATOR */
  71. #if defined(STLSOFT_COMPILER_IS_BORLAND)
  72. # pragma warn -8022 /* Suppresses "'f()' hides virtual function 'g()'" */
  73. # pragma warn -8084 /* Suppresses "Suggest parentheses to clarify precedence in function 'f()'" */
  74. #endif /* compiler */
  75. #ifndef STLSOFT_INCL_H_AFXWIN
  76. # define STLSOFT_INCL_H_AFXWIN
  77. # include <afxwin.h> // for CWnd, CListBox
  78. #endif /* !STLSOFT_INCL_H_AFXWIN */
  79. #if !defined(__AFXCMN_H__) && \
  80. !defined(MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCMN)
  81. # ifndef STLSOFT_INCL_H_AFXCMN
  82. # define STLSOFT_INCL_H_AFXCMN
  83. # include <afxcmn.h> // for CListCtrl
  84. # endif /* !STLSOFT_INCL_H_AFXCMN */
  85. #endif /* !__AFXCMN_H__ && !MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCMN */
  86. #if !defined(__AFXCVIEW_H__) && \
  87. !defined(MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCVIEW)
  88. # ifndef STLSOFT_INCL_H_AFXCVIEW
  89. # define STLSOFT_INCL_H_AFXCVIEW
  90. # include <afxcview.h> // for CListView
  91. # endif /* !STLSOFT_INCL_H_AFXCVIEW */
  92. #endif /* !__AFXCVIEW_H__ && !MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCMN */
  93. #if defined(STLSOFT_COMPILER_IS_BORLAND)
  94. # pragma warn .8022 /* Suppresses "'f()' hides virtual function 'g()'" */
  95. # pragma warn .8084 /* Suppresses "Suggest parentheses to clarify precedence in function 'f()'" */
  96. #endif /* compiler */
  97. /* /////////////////////////////////////////////////////////////////////////
  98. * Namespace
  99. */
  100. #ifndef _MFCSTL_NO_NAMESPACE
  101. # if defined(_STLSOFT_NO_NAMESPACE) || \
  102. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  103. /* There is no stlsoft namespace, so must define ::mfcstl */
  104. namespace mfcstl
  105. {
  106. # else
  107. /* Define stlsoft::mfcstl_project */
  108. namespace stlsoft
  109. {
  110. namespace mfcstl_project
  111. {
  112. # endif /* _STLSOFT_NO_NAMESPACE */
  113. #endif /* !_MFCSTL_NO_NAMESPACE */
  114. /* /////////////////////////////////////////////////////////////////////////
  115. * Functions
  116. */
  117. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  118. namespace impl
  119. {
  120. inline ms_size_t GetWindowTextLength_T_(CWnd const& w)
  121. {
  122. return (NULL != w.m_hWnd) ? static_cast<ms_size_t>(w.GetWindowTextLength()) : 0;
  123. }
  124. inline ms_size_t GetWindowText_T_(CWnd const& w, LPTSTR buffer, ms_size_t cchBuffer)
  125. {
  126. MFCSTL_ASSERT(NULL != w.m_hWnd);
  127. return static_cast<ms_size_t>(w.GetWindowText(buffer, cchBuffer));
  128. }
  129. inline ms_size_t GetWindowTextLength_T_(CListBox const& w)
  130. {
  131. int sel;
  132. if( 0 == (w.GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) &&
  133. LB_ERR != (sel = w.GetCurSel()))
  134. {
  135. return static_cast<ms_size_t>(w.GetTextLen(sel));
  136. }
  137. else
  138. {
  139. return static_cast<ms_size_t>(w.GetWindowTextLength());
  140. }
  141. }
  142. inline ms_size_t GetWindowText_T_(CListBox const& w, LPTSTR buffer, ms_size_t cchBuffer)
  143. {
  144. int sel = -1;
  145. if( 0 == (w.GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) &&
  146. LB_ERR != (sel = w.GetCurSel()))
  147. {
  148. ms_size_t cch = static_cast<ms_size_t>(w.GetText(sel, buffer));
  149. MFCSTL_MESSAGE_ASSERT("Invalid item", LB_ERR != cch);
  150. MFCSTL_MESSAGE_ASSERT("Buffer overwrite", !(cchBuffer < cch));
  151. return static_cast<ms_size_t>(cch);
  152. }
  153. else
  154. {
  155. return w.GetWindowText(buffer, cchBuffer);
  156. }
  157. }
  158. #ifdef __AFXCMN_H__
  159. # if _MFC_VER >= 0x0600
  160. inline ms_size_t GetWindowTextLength_T_(CListCtrl const& w)
  161. {
  162. if(1 == w.GetSelectedCount())
  163. {
  164. POSITION pos = w.GetFirstSelectedItemPosition();
  165. int sel = w.GetNextSelectedItem(pos);
  166. return static_cast<ms_size_t>(w.GetItemText(sel, 0).GetLength());
  167. }
  168. else
  169. {
  170. return static_cast<ms_size_t>(w.GetWindowTextLength());
  171. }
  172. }
  173. inline ms_size_t GetWindowText_T_(CListCtrl const& w, LPTSTR buffer, ms_size_t cchBuffer)
  174. {
  175. if(1 == w.GetSelectedCount())
  176. {
  177. POSITION pos = w.GetFirstSelectedItemPosition();
  178. int sel = w.GetNextSelectedItem(pos);
  179. return static_cast<ms_size_t>(w.GetItemText(sel, 0, buffer, cchBuffer));
  180. }
  181. else
  182. {
  183. return w.GetWindowText(buffer, cchBuffer);
  184. }
  185. }
  186. # ifdef __AFXCVIEW_H__
  187. inline ms_size_t GetWindowTextLength_T_(CListView const& w)
  188. {
  189. return GetWindowTextLength_T_(w.GetListCtrl());
  190. }
  191. inline ms_size_t GetWindowText_T_(CListView const& w, LPTSTR buffer, ms_size_t cchBuffer)
  192. {
  193. return GetWindowText_T_(w.GetListCtrl(), buffer, cchBuffer);
  194. }
  195. # endif /* __AFXCVIEW_H__ */
  196. # endif /* _MFC_VER >= 0x0600 */
  197. #endif /* __AFXCMN_H__ */
  198. } /* namespace impl */
  199. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  200. /* /////////////////////////////////////////////////////////////////////////
  201. * Classes
  202. */
  203. /* CWnd */
  204. /** \brief This class provides an intermediary object that may be returned by the
  205. * c_str_ptr_null() function, such that the window text of a given window
  206. * may be accessed as a null-terminated string.
  207. *
  208. * \ingroup group__concept__shim__string_access
  209. *
  210. */
  211. class c_str_ptr_null_CWnd_proxy
  212. {
  213. typedef TCHAR char_type;
  214. typedef cstring_maker<TCHAR> string_maker_type;
  215. public:
  216. typedef c_str_ptr_null_CWnd_proxy class_type;
  217. // Construction
  218. public:
  219. /// Constructs an instance of the proxy from the given CWnd instance
  220. ///
  221. /// \param w The CWnd instance from which the text will be retrieved
  222. template<ss_typename_param_k W>
  223. c_str_ptr_null_CWnd_proxy(W const& w)
  224. {
  225. stlsoft_constraint_must_have_base(W, CWnd);
  226. ms_size_t length = impl::GetWindowTextLength_T_(w);
  227. if(length == 0)
  228. {
  229. m_buffer = NULL;
  230. }
  231. else
  232. {
  233. m_buffer = string_maker_type::alloc(length);
  234. if(NULL != m_buffer)
  235. {
  236. impl::GetWindowText_T_(w, m_buffer, length + 1);
  237. }
  238. }
  239. }
  240. #ifdef STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT
  241. /// Move constructor
  242. ///
  243. /// This <a href = "http://synesis.com.au/resources/articles/cpp/movectors.pdf">move constructor</a>
  244. /// is for circumstances when the compiler does not, or cannot, apply the
  245. /// return value optimisation. It causes the contents of \c rhs to be
  246. /// transferred into the constructing instance. This is completely safe
  247. /// because the \c rhs instance will never be accessed in its own right, so
  248. /// does not need to maintain ownership of its contents.
  249. c_str_ptr_null_CWnd_proxy(class_type& rhs)
  250. : m_buffer(rhs.m_buffer)
  251. {
  252. rhs.m_buffer = NULL;
  253. }
  254. #else /* ? STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */
  255. // Copy constructor
  256. c_str_ptr_null_CWnd_proxy(class_type const& rhs)
  257. : m_buffer(string_maker_type::dup_null(rhs.m_buffer))
  258. {}
  259. #endif /* STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */
  260. /// Releases any storage aquired by the proxy
  261. ~c_str_ptr_null_CWnd_proxy() stlsoft_throw_0()
  262. {
  263. string_maker_type::free(m_buffer);
  264. }
  265. // Accessors
  266. public:
  267. /// Returns a null-terminated string representing the window contents, or
  268. /// NULL if the window contains no text.
  269. operator LPCTSTR () const
  270. {
  271. return m_buffer;
  272. }
  273. // Members
  274. private:
  275. LPTSTR m_buffer;
  276. // Not to be implemented
  277. private:
  278. void operator =(class_type const& rhs);
  279. };
  280. /** \brief This class provides an intermediary object that may be returned by the
  281. * c_str_ptr() function, such that the window text of a given window may be
  282. * accessed as a null-terminated string.
  283. *
  284. * \ingroup group__concept__shim__string_access
  285. *
  286. */
  287. class c_str_ptr_CWnd_proxy
  288. {
  289. typedef TCHAR char_type;
  290. typedef cstring_maker<TCHAR> string_maker_type;
  291. private:
  292. typedef c_str_ptr_CWnd_proxy class_type;
  293. // Construction
  294. public:
  295. /// Constructs an instance of the proxy from the given CWnd instance
  296. ///
  297. /// \param w The CWnd instance from which the text will be retrieved
  298. template<ss_typename_param_k W>
  299. c_str_ptr_CWnd_proxy(W const& w)
  300. {
  301. stlsoft_constraint_must_have_base(W, CWnd);
  302. ms_size_t length = impl::GetWindowTextLength_T_(w);
  303. if(length == 0)
  304. {
  305. m_buffer = string_maker_type::dup(_T(""));
  306. }
  307. else
  308. {
  309. m_buffer = string_maker_type::alloc(length);
  310. if(NULL != m_buffer)
  311. {
  312. impl::GetWindowText_T_(w, m_buffer, length + 1);
  313. }
  314. }
  315. }
  316. #ifdef STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT
  317. /// Move constructor
  318. ///
  319. /// This <a href = "http://synesis.com.au/resources/articles/cpp/movectors.pdf">move constructor</a>
  320. /// is for circumstances when the compiler does not, or cannot, apply the
  321. /// return value optimisation. It causes the contents of \c rhs to be
  322. /// transferred into the constructing instance. This is completely safe
  323. /// because the \c rhs instance will never be accessed in its own right, so
  324. /// does not need to maintain ownership of its contents.
  325. c_str_ptr_CWnd_proxy(class_type& rhs)
  326. : m_buffer(rhs.m_buffer)
  327. {
  328. rhs.m_buffer = NULL;
  329. }
  330. #else /* ? STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */
  331. // Copy constructor
  332. c_str_ptr_CWnd_proxy(class_type const& rhs)
  333. : m_buffer(string_maker_type::dup_null(rhs.m_buffer))
  334. {}
  335. #endif /* STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */
  336. /// Releases any storage aquired by the proxy
  337. ~c_str_ptr_CWnd_proxy() stlsoft_throw_0()
  338. {
  339. string_maker_type::free(m_buffer);
  340. }
  341. // Accessors
  342. public:
  343. /// Returns a null-terminated string representing the window contents, or
  344. /// the empty string "" if the window contains no text.
  345. operator LPCTSTR () const
  346. {
  347. static char_type s_ch[1] = { '\0' };
  348. return (NULL == m_buffer) ? s_ch : m_buffer;
  349. }
  350. // Members
  351. private:
  352. LPTSTR m_buffer;
  353. // Not to be implemented
  354. private:
  355. void operator =(class_type const& rhs);
  356. };
  357. /* /////////////////////////////////////////////////////////////////////////
  358. * Equivalence testing
  359. */
  360. inline ms_bool_t operator ==(LPCTSTR lhs, c_str_ptr_null_CWnd_proxy const& rhs)
  361. {
  362. return lhs == static_cast<LPCTSTR>(rhs);
  363. }
  364. inline ms_bool_t operator ==(c_str_ptr_null_CWnd_proxy const& lhs, LPCTSTR rhs)
  365. {
  366. return static_cast<LPCTSTR>(lhs) == rhs;
  367. }
  368. inline ms_bool_t operator !=(LPCTSTR lhs, c_str_ptr_null_CWnd_proxy const& rhs)
  369. {
  370. return lhs != static_cast<LPCTSTR>(rhs);
  371. }
  372. inline ms_bool_t operator !=(c_str_ptr_null_CWnd_proxy const& lhs, LPCTSTR rhs)
  373. {
  374. return static_cast<LPCTSTR>(lhs) != rhs;
  375. }
  376. /* /////////////////////////////////////////////////////////////////////////
  377. * IOStream compatibility
  378. */
  379. template<ss_typename_param_k S>
  380. inline S& operator <<(S& s, c_str_ptr_null_CWnd_proxy const& shim)
  381. {
  382. s << static_cast<LPCTSTR>(shim);
  383. return s;
  384. }
  385. template <ss_typename_param_k S>
  386. inline S& operator <<(S& s, c_str_ptr_CWnd_proxy const& shim)
  387. {
  388. s << static_cast<LPCTSTR>(shim);
  389. return s;
  390. }
  391. /* /////////////////////////////////////////////////////////////////////////
  392. * c_str_ptr_null
  393. *
  394. * This can be applied to an expression, and the return value is either a
  395. * pointer to the character string or NULL.
  396. */
  397. /* CWnd */
  398. /** \brief \ref group__concept__shim__string_access__c_str_ptr_null for CWnd
  399. *
  400. * \ingroup group__concept__shim__string_access
  401. *
  402. */
  403. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(CWnd const& w)
  404. {
  405. return c_str_ptr_null_CWnd_proxy(w);
  406. }
  407. #if defined(UNICODE)
  408. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_w(CWnd const& w)
  409. #else /* ? UNICODE */
  410. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_a(CWnd const& w)
  411. #endif /* UNICODE */
  412. {
  413. return c_str_ptr_null(w);
  414. }
  415. /** \brief \ref group__concept__shim__string_access__c_str_ptr_null for CListBox
  416. *
  417. * \ingroup group__concept__shim__string_access
  418. *
  419. */
  420. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(CListBox const& w)
  421. {
  422. return c_str_ptr_null_CWnd_proxy(w);
  423. }
  424. #if defined(UNICODE)
  425. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_w(CListBox const& w)
  426. #else /* ? UNICODE */
  427. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_a(CListBox const& w)
  428. #endif /* UNICODE */
  429. {
  430. return c_str_ptr_null(w);
  431. }
  432. #ifdef __AFXCMN_H__
  433. /** \brief \ref group__concept__shim__string_access__c_str_ptr_null for CListCtrl
  434. *
  435. * \ingroup group__concept__shim__string_access
  436. *
  437. */
  438. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(CListCtrl const& w)
  439. {
  440. return c_str_ptr_null_CWnd_proxy(w);
  441. }
  442. #if defined(UNICODE)
  443. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_w(CListCtrl const& w)
  444. #else /* ? UNICODE */
  445. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_a(CListCtrl const& w)
  446. #endif /* UNICODE */
  447. {
  448. return c_str_ptr_null(w);
  449. }
  450. # ifdef __AFXCVIEW_H__
  451. /** \brief \ref group__concept__shim__string_access__c_str_ptr_null for CListView
  452. *
  453. * \ingroup group__concept__shim__string_access
  454. *
  455. */
  456. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(CListView const& w)
  457. {
  458. return c_str_ptr_null(w.GetListCtrl());
  459. }
  460. #if defined(UNICODE)
  461. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_w(CListView const& w)
  462. #else /* ? UNICODE */
  463. inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_a(CListView const& w)
  464. #endif /* UNICODE */
  465. {
  466. return c_str_ptr_null(w);
  467. }
  468. # endif /* __AFXCVIEW_H__ */
  469. #endif /* __AFXCMN_H__ */
  470. /* /////////////////////////////////////////////////////////////////////////
  471. * c_str_ptr
  472. *
  473. * This can be applied to an expression, and the return value is either a
  474. * pointer to the character string or to an empty string.
  475. */
  476. /* CWnd */
  477. /** \brief \ref group__concept__shim__string_access__c_str_ptr for CWnd
  478. *
  479. * \ingroup group__concept__shim__string_access
  480. *
  481. */
  482. inline c_str_ptr_CWnd_proxy c_str_ptr(CWnd const& w)
  483. {
  484. return c_str_ptr_CWnd_proxy(w);
  485. }
  486. #if defined(UNICODE)
  487. inline c_str_ptr_CWnd_proxy c_str_ptr_w(CWnd const& w)
  488. #else /* ? UNICODE */
  489. inline c_str_ptr_CWnd_proxy c_str_ptr_a(CWnd const& w)
  490. #endif /* UNICODE */
  491. {
  492. return c_str_ptr(w);
  493. }
  494. /** \brief \ref group__concept__shim__string_access__c_str_ptr for CListBox
  495. *
  496. * \ingroup group__concept__shim__string_access
  497. *
  498. */
  499. inline c_str_ptr_CWnd_proxy c_str_ptr(CListBox const& w)
  500. {
  501. return c_str_ptr_CWnd_proxy(w);
  502. }
  503. #if defined(UNICODE)
  504. inline c_str_ptr_CWnd_proxy c_str_ptr_w(CListBox const& w)
  505. #else /* ? UNICODE */
  506. inline c_str_ptr_CWnd_proxy c_str_ptr_a(CListBox const& w)
  507. #endif /* UNICODE */
  508. {
  509. return c_str_ptr(w);
  510. }
  511. #ifdef __AFXCMN_H__
  512. /** \brief \ref group__concept__shim__string_access__c_str_ptr for CListCtrl
  513. *
  514. * \ingroup group__concept__shim__string_access
  515. *
  516. */
  517. inline c_str_ptr_CWnd_proxy c_str_ptr(CListCtrl const& w)
  518. {
  519. return c_str_ptr_CWnd_proxy(w);
  520. }
  521. #if defined(UNICODE)
  522. inline c_str_ptr_CWnd_proxy c_str_ptr_w(CListCtrl const& w)
  523. #else /* ? UNICODE */
  524. inline c_str_ptr_CWnd_proxy c_str_ptr_a(CListCtrl const& w)
  525. #endif /* UNICODE */
  526. {
  527. return c_str_ptr(w);
  528. }
  529. # ifdef __AFXCVIEW_H__
  530. /** \brief \ref group__concept__shim__string_access__c_str_ptr for CListView
  531. *
  532. * \ingroup group__concept__shim__string_access
  533. *
  534. */
  535. inline c_str_ptr_CWnd_proxy c_str_ptr(CListView const& w)
  536. {
  537. return c_str_ptr(w.GetListCtrl());
  538. }
  539. #if defined(UNICODE)
  540. inline c_str_ptr_CWnd_proxy c_str_ptr_w(CListView const& w)
  541. #else /* ? UNICODE */
  542. inline c_str_ptr_CWnd_proxy c_str_ptr_a(CListView const& w)
  543. #endif /* UNICODE */
  544. {
  545. return c_str_ptr(w);
  546. }
  547. # endif /* __AFXCVIEW_H__ */
  548. #endif /* __AFXCMN_H__ */
  549. /* /////////////////////////////////////////////////////////////////////////
  550. * c_str_data
  551. *
  552. * This can be applied to an expression, and the return value is either a
  553. * pointer to the character string or to an empty string.
  554. */
  555. /* CWnd */
  556. /** \brief \ref group__concept__shim__string_access__c_str_data for CWnd
  557. *
  558. * \ingroup group__concept__shim__string_access
  559. *
  560. */
  561. inline c_str_ptr_CWnd_proxy c_str_data(CWnd const& w)
  562. {
  563. return c_str_ptr_CWnd_proxy(w);
  564. }
  565. #if defined(UNICODE)
  566. inline c_str_ptr_CWnd_proxy c_str_data_w(CWnd const& w)
  567. #else /* ? UNICODE */
  568. inline c_str_ptr_CWnd_proxy c_str_data_a(CWnd const& w)
  569. #endif /* UNICODE */
  570. {
  571. return c_str_data(w);
  572. }
  573. /** \brief \ref group__concept__shim__string_access__c_str_data for CListBox
  574. *
  575. * \ingroup group__concept__shim__string_access
  576. *
  577. */
  578. inline c_str_ptr_CWnd_proxy c_str_data(CListBox const& w)
  579. {
  580. return c_str_ptr_CWnd_proxy(w);
  581. }
  582. #if defined(UNICODE)
  583. inline c_str_ptr_CWnd_proxy c_str_data_w(CListBox const& w)
  584. #else /* ? UNICODE */
  585. inline c_str_ptr_CWnd_proxy c_str_data_a(CListBox const& w)
  586. #endif /* UNICODE */
  587. {
  588. return c_str_data(w);
  589. }
  590. #ifdef __AFXCMN_H__
  591. /** \brief \ref group__concept__shim__string_access__c_str_data for CListCtrl
  592. *
  593. * \ingroup group__concept__shim__string_access
  594. *
  595. */
  596. inline c_str_ptr_CWnd_proxy c_str_data(CListCtrl const& w)
  597. {
  598. return c_str_ptr_CWnd_proxy(w);
  599. }
  600. #if defined(UNICODE)
  601. inline c_str_ptr_CWnd_proxy c_str_data_w(CListCtrl const& w)
  602. #else /* ? UNICODE */
  603. inline c_str_ptr_CWnd_proxy c_str_data_a(CListCtrl const& w)
  604. #endif /* UNICODE */
  605. {
  606. return c_str_data(w);
  607. }
  608. # ifdef __AFXCVIEW_H__
  609. /** \brief \ref group__concept__shim__string_access__c_str_data for CListView
  610. *
  611. * \ingroup group__concept__shim__string_access
  612. *
  613. */
  614. inline c_str_ptr_CWnd_proxy c_str_data(CListView const& w)
  615. {
  616. return c_str_data(w.GetListCtrl());
  617. }
  618. #if defined(UNICODE)
  619. inline c_str_ptr_CWnd_proxy c_str_data_w(CListView const& w)
  620. #else /* ? UNICODE */
  621. inline c_str_ptr_CWnd_proxy c_str_data_a(CListView const& w)
  622. #endif /* UNICODE */
  623. {
  624. return c_str_data(w);
  625. }
  626. # endif /* __AFXCVIEW_H__ */
  627. #endif /* __AFXCMN_H__ */
  628. /* /////////////////////////////////////////////////////////////////////////
  629. * c_str_len
  630. *
  631. * This can be applied to an expression, and the return value is the number of
  632. * characters in the character string in the expression.
  633. */
  634. /* CWnd */
  635. /** \brief \ref group__concept__shim__string_access__c_str_len for CWnd
  636. *
  637. * \ingroup group__concept__shim__string_access
  638. *
  639. */
  640. inline ms_size_t c_str_len(CWnd const& w)
  641. {
  642. return impl::GetWindowTextLength_T_(w);
  643. }
  644. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  645. # ifdef UNICODE
  646. inline ms_size_t c_str_len_w(CWnd const& w)
  647. # else /* ? UNICODE */
  648. inline ms_size_t c_str_len_a(CWnd const& w)
  649. # endif /* UNICODE */
  650. {
  651. return c_str_len(w);
  652. }
  653. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  654. /** \brief \ref group__concept__shim__string_access__c_str_len for CListBox
  655. *
  656. * \ingroup group__concept__shim__string_access
  657. *
  658. */
  659. inline ms_size_t c_str_len(CListBox const& w)
  660. {
  661. return impl::GetWindowTextLength_T_(w);
  662. }
  663. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  664. # ifdef UNICODE
  665. inline ms_size_t c_str_len_w(CListBox const& w)
  666. # else /* ? UNICODE */
  667. inline ms_size_t c_str_len_a(CListBox const& w)
  668. # endif /* UNICODE */
  669. {
  670. return c_str_len(w);
  671. }
  672. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  673. #ifdef __AFXCMN_H__
  674. /** \brief \ref group__concept__shim__string_access__c_str_len for CListCtrl
  675. *
  676. * \ingroup group__concept__shim__string_access
  677. *
  678. */
  679. inline ms_size_t c_str_len(CListCtrl const& w)
  680. {
  681. return impl::GetWindowTextLength_T_(w);
  682. }
  683. # ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  684. # ifdef UNICODE
  685. inline ms_size_t c_str_len_w(CListCtrl const& w)
  686. # else /* ? UNICODE */
  687. inline ms_size_t c_str_len_a(CListCtrl const& w)
  688. # endif /* UNICODE */
  689. {
  690. return c_str_len(w);
  691. }
  692. # endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  693. # ifdef __AFXCVIEW_H__
  694. /** \brief \ref group__concept__shim__string_access__c_str_len for CListView
  695. *
  696. * \ingroup group__concept__shim__string_access
  697. *
  698. */
  699. inline ms_size_t c_str_len(CListView const& w)
  700. {
  701. return c_str_len(w.GetListCtrl());
  702. }
  703. # ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  704. # ifdef UNICODE
  705. inline ms_size_t c_str_len_w(CListView const& w)
  706. # else /* ? UNICODE */
  707. inline ms_size_t c_str_len_a(CListView const& w)
  708. # endif /* UNICODE */
  709. {
  710. return c_str_len(w);
  711. }
  712. # endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  713. # endif /* __AFXCVIEW_H__ */
  714. #endif /* __AFXCMN_H__ */
  715. ////////////////////////////////////////////////////////////////////////////
  716. // Unit-testing
  717. #ifdef STLSOFT_UNITTEST
  718. # include "./unittest/cwnd_unittest_.h"
  719. #endif /* STLSOFT_UNITTEST */
  720. /* ////////////////////////////////////////////////////////////////////// */
  721. #ifndef _MFCSTL_NO_NAMESPACE
  722. # if defined(_STLSOFT_NO_NAMESPACE) || \
  723. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  724. } // namespace mfcstl
  725. # else
  726. } // namespace stlsoft::mfcstl_project
  727. } // namespace stlsoft
  728. # endif /* _STLSOFT_NO_NAMESPACE */
  729. #endif /* !_MFCSTL_NO_NAMESPACE */
  730. /* /////////////////////////////////////////////////////////////////////////
  731. * Namespace
  732. *
  733. * The string access shims exist either in the stlsoft namespace, or in the
  734. * global namespace. This is required by the lookup rules.
  735. *
  736. */
  737. #ifndef _MFCSTL_NO_NAMESPACE
  738. # if !defined(_STLSOFT_NO_NAMESPACE) && \
  739. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  740. namespace stlsoft
  741. {
  742. # else /* ? _STLSOFT_NO_NAMESPACE */
  743. /* There is no stlsoft namespace, so must define in the global namespace */
  744. # endif /* !_STLSOFT_NO_NAMESPACE */
  745. using ::mfcstl::c_str_data;
  746. #if defined(UNICODE)
  747. using ::mfcstl::c_str_data_w;
  748. #else /* ? UNICODE */
  749. using ::mfcstl::c_str_data_a;
  750. #endif /* UNICODE */
  751. using ::mfcstl::c_str_len;
  752. #if defined(UNICODE)
  753. using ::mfcstl::c_str_len_w;
  754. #else /* ? UNICODE */
  755. using ::mfcstl::c_str_len_a;
  756. #endif /* UNICODE */
  757. using ::mfcstl::c_str_ptr;
  758. #if defined(UNICODE)
  759. using ::mfcstl::c_str_ptr_w;
  760. #else /* ? UNICODE */
  761. using ::mfcstl::c_str_ptr_a;
  762. #endif /* UNICODE */
  763. using ::mfcstl::c_str_ptr_null;
  764. #if defined(UNICODE)
  765. using ::mfcstl::c_str_ptr_null_w;
  766. #else /* ? UNICODE */
  767. using ::mfcstl::c_str_ptr_null_a;
  768. #endif /* UNICODE */
  769. # if !defined(_STLSOFT_NO_NAMESPACE) && \
  770. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  771. } // namespace stlsoft
  772. # else /* ? _STLSOFT_NO_NAMESPACE */
  773. /* There is no stlsoft namespace, so must define in the global namespace */
  774. # endif /* !_STLSOFT_NO_NAMESPACE */
  775. #endif /* !_MFCSTL_NO_NAMESPACE */
  776. /* ////////////////////////////////////////////////////////////////////// */
  777. #endif /* !MFCSTL_INCL_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND */
  778. /* ///////////////////////////// end of file //////////////////////////// */