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.

1619 lines
50 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: mfcstl/collections/cstring_adaptors.hpp
  3. *
  4. * Purpose: Contains the definition of the CString_cadaptor and CString_iadaptor
  5. * class templates.
  6. *
  7. * Created: 1st October 2002
  8. * Updated: 10th August 2009
  9. *
  10. * Home: http://stlsoft.org/
  11. *
  12. * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software
  13. * All rights reserved.
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice, this
  19. * list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright notice,
  21. * this list of conditions and the following disclaimer in the documentation
  22. * and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  24. * any contributors may be used to endorse or promote products derived from
  25. * this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  31. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  32. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  35. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  36. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /** \file mfcstl/collections/cstring_adaptors.hpp
  41. *
  42. * \brief [C++ only] Definition of the mfcstl::CString_cadaptor and
  43. * mfcstl::CString_iadaptor class templates
  44. * (\ref group__library__collections "Collections" Library).
  45. */
  46. #ifndef MFCSTL_INCL_MFCSTL_COLLECTIONS_HPP_CSTRING_ADAPTORS
  47. #define MFCSTL_INCL_MFCSTL_COLLECTIONS_HPP_CSTRING_ADAPTORS
  48. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  49. # define MFCSTL_VER_MFCSTL_COLLECTIONS_HPP_CSTRING_ADAPTORS_MAJOR 4
  50. # define MFCSTL_VER_MFCSTL_COLLECTIONS_HPP_CSTRING_ADAPTORS_MINOR 1
  51. # define MFCSTL_VER_MFCSTL_COLLECTIONS_HPP_CSTRING_ADAPTORS_REVISION 1
  52. # define MFCSTL_VER_MFCSTL_COLLECTIONS_HPP_CSTRING_ADAPTORS_EDIT 89
  53. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  54. /* /////////////////////////////////////////////////////////////////////////
  55. * Compatibility
  56. */
  57. /*
  58. [Incompatibilies-start]
  59. STLSOFT_COMPILER_IS_MSVC: _MSC_VER<1100
  60. [Incompatibilies-end]
  61. */
  62. /* /////////////////////////////////////////////////////////////////////////
  63. * Includes
  64. */
  65. #ifndef MFCSTL_INCL_MFCSTL_HPP_MFCSTL
  66. # include <mfcstl/mfcstl.hpp>
  67. #endif /* !MFCSTL_INCL_MFCSTL_HPP_MFCSTL */
  68. #if defined(STLSOFT_COMPILER_IS_MSVC) && \
  69. _MSC_VER < 1100
  70. # error mfcstl_cstring_veneer.h is not compatible with Visual C++ 4.2 or earlier
  71. #endif /* compiler */
  72. #ifndef MFCSTL_INCL_MFCSTL_MEMORY_HPP_AFX_ALLOCATOR
  73. # include <mfcstl/memory/afx_allocator.hpp>
  74. #endif /* !MFCSTL_INCL_MFCSTL_MEMORY_HPP_AFX_ALLOCATOR */
  75. #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
  76. # include <stlsoft/util/std/iterator_helper.hpp>
  77. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER */
  78. #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_CONSTRAINTS
  79. # include <stlsoft/util/constraints.hpp>
  80. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_HPP_CONSTRAINTS */
  81. #ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
  82. # include <stlsoft/collections/util/collections.hpp>
  83. #endif /* !STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS */
  84. #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_LIBRARY_DISCRIMINATOR
  85. # include <stlsoft/util/std/library_discriminator.hpp>
  86. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_STD_LIBRARY_DISCRIMINATOR */
  87. #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_STRING_TRAITS_FWD
  88. # include <stlsoft/string/string_traits_fwd.hpp>
  89. #endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_STRING_TRAITS_FWD */
  90. /* /////////////////////////////////////////////////////////////////////////
  91. * Namespace
  92. */
  93. #ifndef _MFCSTL_NO_NAMESPACE
  94. # if defined(_STLSOFT_NO_NAMESPACE) || \
  95. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  96. /* There is no stlsoft namespace, so must define ::mfcstl */
  97. namespace mfcstl
  98. {
  99. # else
  100. /* Define stlsoft::mfcstl_project */
  101. namespace stlsoft
  102. {
  103. namespace mfcstl_project
  104. {
  105. # endif /* _STLSOFT_NO_NAMESPACE */
  106. #endif /* !_MFCSTL_NO_NAMESPACE */
  107. /* /////////////////////////////////////////////////////////////////////////
  108. * Classes
  109. */
  110. /** \brief Applies standard string (std::basic_string) interface to the CString class
  111. *
  112. * \ingroup group__library__collections
  113. *
  114. * This class adapts the MFC CString type to express a standard String-like interface
  115. *
  116. * \ingroup concepts_veneer
  117. */
  118. template<ss_typename_param_k I>
  119. class CString_adaptor_base
  120. : public stlsoft_ns_qual(stl_collection_tag)
  121. {
  122. /// \name Member Types
  123. /// @{
  124. private:
  125. typedef I interface_type;
  126. typedef CString_adaptor_base<I> class_type;
  127. public:
  128. /// The value type
  129. typedef TCHAR value_type;
  130. /// The allocator type
  131. typedef afx_allocator<value_type> allocator_type;
  132. /// The pointer type
  133. typedef LPTSTR pointer;
  134. /// The pointer-to-const type
  135. typedef LPCTSTR const_pointer;
  136. /// The reference type
  137. typedef TCHAR& reference;
  138. /// The reference-to-const type
  139. typedef TCHAR const& const_reference;
  140. /// The size type
  141. typedef ms_size_t size_type;
  142. /// The difference type
  143. typedef ms_ptrdiff_t difference_type;
  144. #if !defined(STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT)
  145. /// The mutating iterator type
  146. typedef LPTSTR iterator;
  147. /// The non-mutating (const) iterator type
  148. typedef LPCTSTR const_iterator;
  149. #else /* ? !STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT */
  150. /// The iterator type
  151. typedef
  152. # if !defined(STLSOFT_COMPILER_IS_BORLAND)
  153. ss_typename_type_k
  154. # endif /* compiler */
  155. pointer_iterator < value_type
  156. , pointer
  157. , reference
  158. >::type iterator;
  159. /// The non-mutating (const) iterator type
  160. typedef
  161. # if !defined(STLSOFT_COMPILER_IS_BORLAND)
  162. ss_typename_type_k
  163. # endif /* compiler */
  164. pointer_iterator < value_type const
  165. , const_pointer
  166. , const_reference
  167. >::type const_iterator;
  168. /// The mutating (non-const) reverse iterator type
  169. typedef reverse_iterator_base < iterator
  170. , value_type
  171. , reference
  172. , pointer
  173. , difference_type
  174. > reverse_iterator;
  175. /// The non-mutating (const) reverse iterator type
  176. typedef const_reverse_iterator_base < const_iterator
  177. , value_type const
  178. , const_reference
  179. , const_pointer
  180. , difference_type
  181. > const_reverse_iterator;
  182. #endif /* !STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT */
  183. /// The Boolean type
  184. typedef ms_bool_t bool_type;
  185. /// @}
  186. /// \name Construction
  187. /// @{
  188. public:
  189. allocator_type get_allocator() const;
  190. /// @}
  191. /// \name Underlying container
  192. /// @{
  193. public:
  194. /// \brief Returns a mutating (non-const) reference to the underlying CString
  195. CString &get_CString()
  196. {
  197. return static_cast<interface_type*>(this)->get_actual_string();
  198. }
  199. /// \brief Returns a non-mutating (const) reference to the underlying CString
  200. CString const &get_CString() const
  201. {
  202. return static_cast<interface_type const*>(this)->get_actual_string();
  203. }
  204. /// @}
  205. /// \name Assignment
  206. /// @{
  207. public:
  208. /// \brief Replaces the string contents with \c s
  209. class_type &assign(LPCSTR s);
  210. /// \brief Replaces the string contents with \c s
  211. class_type &assign(LPCWSTR s);
  212. /// \brief Replaces the string contents with \c s
  213. class_type &assign(unsigned char const* s);
  214. /// \brief Replaces the string contents with the first \c n characters from \c s
  215. class_type &assign(LPCSTR s, size_type n);
  216. /// \brief Replaces the string contents with the first \c n characters from \c s
  217. class_type &assign(LPCWSTR s, size_type n);
  218. /// \brief Replaces the string contents with the first \c n characters from \c s
  219. class_type &assign(unsigned char const* s, size_type n);
  220. /// \brief Replaces the string contents with \c s
  221. class_type &assign(class_type const& s);
  222. /// \brief Replaces the string contents with \c n characters of \c s, starting from offset \c pos
  223. class_type &assign(class_type const& str, size_type pos, size_type n);
  224. /// \brief Replaces the string contents with \c n elements of \c ch
  225. class_type &assign(size_type n, value_type ch);
  226. /// \brief Replaces the string contents with the contents of the range [first, last)
  227. #if defined(STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION) && \
  228. STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_7_0
  229. # pragma message("TODO: Fix this up before 1.9.1 proper")
  230. class_type &assign(LPCTSTR first, LPCTSTR last);
  231. #else /* ? library */
  232. class_type &assign(const_iterator first, const_iterator last);
  233. #endif /* library */
  234. /// @}
  235. /// \name Iteration
  236. /// @{
  237. public:
  238. /// Begins the iteration
  239. ///
  240. /// \return A mutating (non-const) iterator representing the start of the sequence
  241. iterator begin();
  242. /// Ends the iteration
  243. ///
  244. /// \return A mutating (non-const) iterator representing the end of the sequence
  245. iterator end();
  246. /// Begins the iteration
  247. ///
  248. /// \return A non-mutating (const) iterator representing the start of the sequence
  249. const_iterator begin() const;
  250. /// Ends the iteration
  251. ///
  252. /// \return A non-mutating (const) iterator representing the end of the sequence
  253. const_iterator end() const;
  254. #ifdef STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT
  255. /// Begins the iteration
  256. ///
  257. /// \return A mutating (non-const) reverse iterator representing the start of the sequence
  258. reverse_iterator rbegin();
  259. /// Ends the iteration
  260. ///
  261. /// \return A mutating (non-const) reverse iterator representing the end of the sequence
  262. reverse_iterator rend();
  263. /// Begins the iteration
  264. ///
  265. /// \return A non-mutating (const) reverse iterator representing the start of the sequence
  266. const_reverse_iterator rbegin() const;
  267. /// Ends the iteration
  268. ///
  269. /// \return A non-mutating (const) reverse iterator representing the end of the sequence
  270. const_reverse_iterator rend() const;
  271. #endif /* STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT */
  272. /// @}
  273. /// \name Element Access
  274. /// @{
  275. protected:
  276. reference subscript_(size_type index);
  277. const_reference subscript_(size_type index) const;
  278. public:
  279. /// Returns a mutable (non-const) reference to the element at \c index
  280. ///
  281. /// \note Throws an instance of std::out_of_range if index >= size()
  282. reference at(size_type index);
  283. /// Returns a non-mutable (const) reference to the element at \c index
  284. ///
  285. /// \note Throws an instance of std::out_of_range if index >= size()
  286. const_reference at(size_type index) const;
  287. /// @}
  288. /// \name Attributes
  289. /// @{
  290. public:
  291. /// Returns the number of elements in the sequence
  292. size_type length() const;
  293. /// Returns the number of elements in the sequence
  294. size_type size() const;
  295. /// \brief Indicates whether the sequence is empty
  296. bool_type empty() const;
  297. /// Returns a pointer to constant data representing the managed string
  298. const_pointer c_str() const;
  299. /// Returns a possibly unterminated pointer to constant data representing the managed string
  300. const_pointer data() const;
  301. /// @}
  302. };
  303. /** \brief Adaptor class, representing a Class Adaptor over the MFC CString type
  304. *
  305. * \ingroup group__library__collections
  306. *
  307. * It can be used wherever a CString is, or it can be used via the std::basic_string-like interface
  308. */
  309. class CString_cadaptor
  310. : public CString
  311. , public CString_adaptor_base<CString_cadaptor>
  312. {
  313. /// \name Member Types
  314. /// @{
  315. private:
  316. typedef CString_adaptor_base<CString_cadaptor> parent_class_type;
  317. public:
  318. /// The class type
  319. typedef CString_cadaptor class_type;
  320. /// @}
  321. public:
  322. /// Default constructor
  323. CString_cadaptor();
  324. /// Copy constructor
  325. CString_cadaptor(class_type const& rhs);
  326. /// Copy constructor
  327. ss_explicit_k CString_cadaptor(CString const& rhs);
  328. /// Construct from an ANSI string
  329. ss_explicit_k CString_cadaptor(LPCSTR s);
  330. /// Construct from a Unicode string
  331. ss_explicit_k CString_cadaptor(LPCWSTR s);
  332. /// Construct from an MBCS string
  333. ss_explicit_k CString_cadaptor(unsigned char const* s);
  334. /// Construct from a range
  335. CString_cadaptor(LPCTSTR from, LPCTSTR to);
  336. /// Construct from a range
  337. CString_cadaptor(LPCTSTR from, size_type length);
  338. /// \brief Constructs from str the range identified by [pos, pos + n)
  339. CString_cadaptor(class_type const& str, size_type pos, size_type n);
  340. ///
  341. CString_cadaptor(ms_size_t cch, TCHAR ch);
  342. /// Copy assignment operator
  343. class_type const& operator =(class_type const& rhs);
  344. /// Copy assignment operator
  345. class_type const& operator =(CString const& rhs);
  346. /// Assignment operator
  347. class_type const& operator =(LPCSTR s);
  348. /// Assignment operator
  349. class_type const& operator =(LPCWSTR s);
  350. /// Assignment operator
  351. class_type const& operator =(unsigned char const* s);
  352. private:
  353. friend class CString_adaptor_base<CString_cadaptor>;
  354. CString &get_actual_string()
  355. {
  356. return *this;
  357. }
  358. CString const &get_actual_string() const
  359. {
  360. return *this;
  361. }
  362. };
  363. /** \brief Adaptor class, representing an Instance Adaptor over the MFC CString type
  364. *
  365. * \ingroup group__library__collections
  366. *
  367. * It can be used via the std::basic_string-like interface
  368. */
  369. class CString_iadaptor
  370. : public CString_adaptor_base<CString_iadaptor>
  371. {
  372. /// \name Member Types
  373. /// @{
  374. private:
  375. typedef CString_adaptor_base<CString_iadaptor> parent_class_type;
  376. public:
  377. /// The class type
  378. typedef CString_iadaptor class_type;
  379. /// @}
  380. /// \name Construction
  381. /// @{
  382. public:
  383. CString_iadaptor(CString &str);
  384. CString_iadaptor(CString *str);
  385. /// @}
  386. /// Copy assignment operator
  387. class_type const& operator =(class_type const& rhs);
  388. /// Copy assignment operator
  389. class_type const& operator =(CString const& rhs);
  390. /// Assignment operator
  391. class_type const& operator =(LPCSTR s);
  392. /// Assignment operator
  393. class_type const& operator =(LPCWSTR s);
  394. /// Assignment operator
  395. class_type const& operator =(unsigned char const* s);
  396. /// \name Element Access
  397. /// @{
  398. public:
  399. /// Returns a mutable (non-const) reference to the element at \c index
  400. ///
  401. /// \note The behaviour is undefined if index >= size()
  402. reference operator [](size_type index);
  403. /// Returns a non-mutable (const) reference to the element at \c index
  404. ///
  405. /// \note The behaviour is undefined if index >= size()
  406. const_reference operator [](size_type index) const;
  407. /// @}
  408. /// \name Implementation
  409. /// @{
  410. private:
  411. friend class CString_adaptor_base<CString_iadaptor>;
  412. CString &get_actual_string()
  413. {
  414. return *m_str;
  415. }
  416. CString const &get_actual_string() const
  417. {
  418. return *m_str;
  419. }
  420. /// @}
  421. /// \name Members
  422. /// @{
  423. private:
  424. CString *m_str;
  425. /// @}
  426. };
  427. /** \brief Non-mutable Adaptor class, representing an Instance Adaptor over the MFC CString type
  428. *
  429. * \ingroup group__library__collections
  430. *
  431. * It can be used via the std::basic_string-like interface
  432. */
  433. class const_CString_iadaptor
  434. : public CString_adaptor_base<const_CString_iadaptor>
  435. {
  436. /// \name Member Types
  437. /// @{
  438. private:
  439. typedef CString_adaptor_base<const_CString_iadaptor> parent_class_type;
  440. public:
  441. /// The class type
  442. typedef CString_iadaptor class_type;
  443. /// @}
  444. /// \name Construction
  445. /// @{
  446. public:
  447. const_CString_iadaptor(CString const& str);
  448. const_CString_iadaptor(CString const* str);
  449. /// @}
  450. /// \name Element Access
  451. /// @{
  452. public:
  453. /// Returns a non-mutable (const) reference to the element at \c index
  454. ///
  455. /// \note The behaviour is undefined if index >= size()
  456. const_reference operator [](size_type index) const;
  457. /// @}
  458. /// \name Implementation
  459. /// @{
  460. private:
  461. friend class CString_adaptor_base<const_CString_iadaptor>;
  462. CString const &get_actual_string() const
  463. {
  464. return *m_str;
  465. }
  466. /// @}
  467. /// \name Members
  468. /// @{
  469. private:
  470. CString const *m_str;
  471. /// @}
  472. };
  473. /* /////////////////////////////////////////////////////////////////////////
  474. * Operators
  475. */
  476. // operator ==
  477. inline ms_bool_t operator ==(CString_cadaptor const& lhs, CString_cadaptor const& rhs)
  478. {
  479. return lhs.get_CString() == rhs.get_CString();
  480. }
  481. inline ms_bool_t operator ==(CString_cadaptor const& lhs, CString const& rhs)
  482. {
  483. return lhs.get_CString() == rhs;
  484. }
  485. inline ms_bool_t operator ==(CString const& lhs, CString_cadaptor const& rhs)
  486. {
  487. return lhs == rhs.get_CString();
  488. }
  489. inline ms_bool_t operator ==(CString_cadaptor const& lhs, LPCSTR rhs)
  490. {
  491. return lhs.get_CString() == rhs;
  492. }
  493. inline ms_bool_t operator ==(LPCSTR lhs, CString_cadaptor const& rhs)
  494. {
  495. return lhs == rhs.get_CString();
  496. }
  497. inline ms_bool_t operator ==(CString_cadaptor const& lhs, LPCWSTR rhs)
  498. {
  499. return lhs.get_CString() == CString(rhs);
  500. }
  501. inline ms_bool_t operator ==(LPCWSTR lhs, CString_cadaptor const& rhs)
  502. {
  503. return CString(lhs) == rhs.get_CString();
  504. }
  505. inline ms_bool_t operator ==(CString_cadaptor const& lhs, unsigned char const* rhs)
  506. {
  507. return lhs.get_CString() == CString(rhs);
  508. }
  509. inline ms_bool_t operator ==(unsigned char const* lhs, CString_cadaptor const& rhs)
  510. {
  511. return CString(lhs) == rhs.get_CString();
  512. }
  513. inline ms_bool_t operator ==(CString_iadaptor const& lhs, CString_iadaptor const& rhs)
  514. {
  515. return lhs.get_CString() == rhs.get_CString();
  516. }
  517. inline ms_bool_t operator ==(CString_iadaptor const& lhs, CString const& rhs)
  518. {
  519. return lhs.get_CString() == rhs;
  520. }
  521. inline ms_bool_t operator ==(CString const& lhs, CString_iadaptor const& rhs)
  522. {
  523. return lhs == rhs.get_CString();
  524. }
  525. inline ms_bool_t operator ==(CString_iadaptor const& lhs, LPCSTR rhs)
  526. {
  527. return lhs.get_CString() == rhs;
  528. }
  529. inline ms_bool_t operator ==(LPCSTR lhs, CString_iadaptor const& rhs)
  530. {
  531. return lhs == rhs.get_CString();
  532. }
  533. inline ms_bool_t operator ==(CString_iadaptor const& lhs, LPCWSTR rhs)
  534. {
  535. return lhs.get_CString() == CString(rhs);
  536. }
  537. inline ms_bool_t operator ==(LPCWSTR lhs, CString_iadaptor const& rhs)
  538. {
  539. return CString(lhs) == rhs.get_CString();
  540. }
  541. inline ms_bool_t operator ==(CString_iadaptor const& lhs, unsigned char const* rhs)
  542. {
  543. return lhs.get_CString() == CString(rhs);
  544. }
  545. inline ms_bool_t operator ==(unsigned char const* lhs, CString_iadaptor const& rhs)
  546. {
  547. return CString(lhs) == rhs.get_CString();
  548. }
  549. inline ms_bool_t operator ==(const_CString_iadaptor const& lhs, const_CString_iadaptor const& rhs)
  550. {
  551. return lhs.get_CString() == rhs.get_CString();
  552. }
  553. inline ms_bool_t operator ==(const_CString_iadaptor const& lhs, CString const& rhs)
  554. {
  555. return lhs.get_CString() == rhs;
  556. }
  557. inline ms_bool_t operator ==(CString const& lhs, const_CString_iadaptor const& rhs)
  558. {
  559. return lhs == rhs.get_CString();
  560. }
  561. inline ms_bool_t operator ==(const_CString_iadaptor const& lhs, LPCSTR rhs)
  562. {
  563. return lhs.get_CString() == rhs;
  564. }
  565. inline ms_bool_t operator ==(LPCSTR lhs, const_CString_iadaptor const& rhs)
  566. {
  567. return lhs == rhs.get_CString();
  568. }
  569. inline ms_bool_t operator ==(const_CString_iadaptor const& lhs, LPCWSTR rhs)
  570. {
  571. return lhs.get_CString() == CString(rhs);
  572. }
  573. inline ms_bool_t operator ==(LPCWSTR lhs, const_CString_iadaptor const& rhs)
  574. {
  575. return CString(lhs) == rhs.get_CString();
  576. }
  577. inline ms_bool_t operator ==(const_CString_iadaptor const& lhs, unsigned char const* rhs)
  578. {
  579. return lhs.get_CString() == CString(rhs);
  580. }
  581. inline ms_bool_t operator ==(unsigned char const* lhs, const_CString_iadaptor const& rhs)
  582. {
  583. return CString(lhs) == rhs.get_CString();
  584. }
  585. // operator !=
  586. inline ms_bool_t operator !=(CString_cadaptor const& lhs, CString_cadaptor const& rhs)
  587. {
  588. return lhs.get_CString() != rhs.get_CString();
  589. }
  590. inline ms_bool_t operator !=(CString_cadaptor const& lhs, CString const& rhs)
  591. {
  592. return lhs.get_CString() != rhs;
  593. }
  594. inline ms_bool_t operator !=(CString const& lhs, CString_cadaptor const& rhs)
  595. {
  596. return lhs != rhs.get_CString();
  597. }
  598. inline ms_bool_t operator !=(CString_cadaptor const& lhs, LPCSTR rhs)
  599. {
  600. return lhs.get_CString() != rhs;
  601. }
  602. inline ms_bool_t operator !=(LPCSTR lhs, CString_cadaptor const& rhs)
  603. {
  604. return lhs != rhs.get_CString();
  605. }
  606. inline ms_bool_t operator !=(CString_cadaptor const& lhs, LPCWSTR rhs)
  607. {
  608. return lhs.get_CString() != CString(rhs);
  609. }
  610. inline ms_bool_t operator !=(LPCWSTR lhs, CString_cadaptor const& rhs)
  611. {
  612. return CString(lhs) != rhs.get_CString();
  613. }
  614. inline ms_bool_t operator !=(CString_cadaptor const& lhs, unsigned char const* rhs)
  615. {
  616. return lhs.get_CString() != CString(rhs);
  617. }
  618. inline ms_bool_t operator !=(unsigned char const* lhs, CString_cadaptor const& rhs)
  619. {
  620. return CString(lhs) != rhs.get_CString();
  621. }
  622. inline ms_bool_t operator !=(CString_iadaptor const& lhs, CString_iadaptor const& rhs)
  623. {
  624. return lhs.get_CString() != rhs.get_CString();
  625. }
  626. inline ms_bool_t operator !=(CString_iadaptor const& lhs, CString const& rhs)
  627. {
  628. return lhs.get_CString() != rhs;
  629. }
  630. inline ms_bool_t operator !=(CString const& lhs, CString_iadaptor const& rhs)
  631. {
  632. return lhs != rhs.get_CString();
  633. }
  634. inline ms_bool_t operator !=(CString_iadaptor const& lhs, LPCSTR rhs)
  635. {
  636. return lhs.get_CString() != rhs;
  637. }
  638. inline ms_bool_t operator !=(LPCSTR lhs, CString_iadaptor const& rhs)
  639. {
  640. return lhs != rhs.get_CString();
  641. }
  642. inline ms_bool_t operator !=(CString_iadaptor const& lhs, LPCWSTR rhs)
  643. {
  644. return lhs.get_CString() != CString(rhs);
  645. }
  646. inline ms_bool_t operator !=(LPCWSTR lhs, CString_iadaptor const& rhs)
  647. {
  648. return CString(lhs) != rhs.get_CString();
  649. }
  650. inline ms_bool_t operator !=(CString_iadaptor const& lhs, unsigned char const* rhs)
  651. {
  652. return lhs.get_CString() != CString(rhs);
  653. }
  654. inline ms_bool_t operator !=(unsigned char const* lhs, CString_iadaptor const& rhs)
  655. {
  656. return CString(lhs) != rhs.get_CString();
  657. }
  658. inline ms_bool_t operator !=(const_CString_iadaptor const& lhs, const_CString_iadaptor const& rhs)
  659. {
  660. return lhs.get_CString() != rhs.get_CString();
  661. }
  662. inline ms_bool_t operator !=(const_CString_iadaptor const& lhs, CString const& rhs)
  663. {
  664. return lhs.get_CString() != rhs;
  665. }
  666. inline ms_bool_t operator !=(CString const& lhs, const_CString_iadaptor const& rhs)
  667. {
  668. return lhs != rhs.get_CString();
  669. }
  670. inline ms_bool_t operator !=(const_CString_iadaptor const& lhs, LPCSTR rhs)
  671. {
  672. return lhs.get_CString() != rhs;
  673. }
  674. inline ms_bool_t operator !=(LPCSTR lhs, const_CString_iadaptor const& rhs)
  675. {
  676. return lhs != rhs.get_CString();
  677. }
  678. inline ms_bool_t operator !=(const_CString_iadaptor const& lhs, LPCWSTR rhs)
  679. {
  680. return lhs.get_CString() != CString(rhs);
  681. }
  682. inline ms_bool_t operator !=(LPCWSTR lhs, const_CString_iadaptor const& rhs)
  683. {
  684. return CString(lhs) != rhs.get_CString();
  685. }
  686. inline ms_bool_t operator !=(const_CString_iadaptor const& lhs, unsigned char const* rhs)
  687. {
  688. return lhs.get_CString() != CString(rhs);
  689. }
  690. inline ms_bool_t operator !=(unsigned char const* lhs, const_CString_iadaptor const& rhs)
  691. {
  692. return CString(lhs) != rhs.get_CString();
  693. }
  694. // operator <
  695. inline ms_bool_t operator <(CString_cadaptor const& lhs, CString_cadaptor const& rhs)
  696. {
  697. return lhs.get_CString() < rhs.get_CString();
  698. }
  699. inline ms_bool_t operator <(CString_cadaptor const& lhs, CString const& rhs)
  700. {
  701. return lhs.get_CString() < rhs;
  702. }
  703. inline ms_bool_t operator <(CString const& lhs, CString_cadaptor const& rhs)
  704. {
  705. return lhs < rhs.get_CString();
  706. }
  707. inline ms_bool_t operator <(CString_cadaptor const& lhs, LPCSTR rhs)
  708. {
  709. return lhs.get_CString() < rhs;
  710. }
  711. inline ms_bool_t operator <(LPCSTR lhs, CString_cadaptor const& rhs)
  712. {
  713. return lhs < rhs.get_CString();
  714. }
  715. inline ms_bool_t operator <(CString_cadaptor const& lhs, LPCWSTR rhs)
  716. {
  717. return lhs.get_CString() < CString(rhs);
  718. }
  719. inline ms_bool_t operator <(LPCWSTR lhs, CString_cadaptor const& rhs)
  720. {
  721. return CString(lhs) < rhs.get_CString();
  722. }
  723. inline ms_bool_t operator <(CString_cadaptor const& lhs, unsigned char const* rhs)
  724. {
  725. return lhs.get_CString() < CString(rhs);
  726. }
  727. inline ms_bool_t operator <(unsigned char const* lhs, CString_cadaptor const& rhs)
  728. {
  729. return CString(lhs) < rhs.get_CString();
  730. }
  731. inline ms_bool_t operator <(CString_iadaptor const& lhs, CString_iadaptor const& rhs)
  732. {
  733. return lhs.get_CString() < rhs.get_CString();
  734. }
  735. inline ms_bool_t operator <(CString_iadaptor const& lhs, CString const& rhs)
  736. {
  737. return lhs.get_CString() < rhs;
  738. }
  739. inline ms_bool_t operator <(CString const& lhs, CString_iadaptor const& rhs)
  740. {
  741. return lhs < rhs.get_CString();
  742. }
  743. inline ms_bool_t operator <(CString_iadaptor const& lhs, LPCSTR rhs)
  744. {
  745. return lhs.get_CString() < rhs;
  746. }
  747. inline ms_bool_t operator <(LPCSTR lhs, CString_iadaptor const& rhs)
  748. {
  749. return lhs < rhs.get_CString();
  750. }
  751. inline ms_bool_t operator <(CString_iadaptor const& lhs, LPCWSTR rhs)
  752. {
  753. return lhs.get_CString() < CString(rhs);
  754. }
  755. inline ms_bool_t operator <(LPCWSTR lhs, CString_iadaptor const& rhs)
  756. {
  757. return CString(lhs) < rhs.get_CString();
  758. }
  759. inline ms_bool_t operator <(CString_iadaptor const& lhs, unsigned char const* rhs)
  760. {
  761. return lhs.get_CString() < CString(rhs);
  762. }
  763. inline ms_bool_t operator <(unsigned char const* lhs, CString_iadaptor const& rhs)
  764. {
  765. return CString(lhs) < rhs.get_CString();
  766. }
  767. inline ms_bool_t operator <(const_CString_iadaptor const& lhs, const_CString_iadaptor const& rhs)
  768. {
  769. return lhs.get_CString() < rhs.get_CString();
  770. }
  771. inline ms_bool_t operator <(const_CString_iadaptor const& lhs, CString const& rhs)
  772. {
  773. return lhs.get_CString() < rhs;
  774. }
  775. inline ms_bool_t operator <(CString const& lhs, const_CString_iadaptor const& rhs)
  776. {
  777. return lhs < rhs.get_CString();
  778. }
  779. inline ms_bool_t operator <(const_CString_iadaptor const& lhs, LPCSTR rhs)
  780. {
  781. return lhs.get_CString() < rhs;
  782. }
  783. inline ms_bool_t operator <(LPCSTR lhs, const_CString_iadaptor const& rhs)
  784. {
  785. return lhs < rhs.get_CString();
  786. }
  787. inline ms_bool_t operator <(const_CString_iadaptor const& lhs, LPCWSTR rhs)
  788. {
  789. return lhs.get_CString() < CString(rhs);
  790. }
  791. inline ms_bool_t operator <(LPCWSTR lhs, const_CString_iadaptor const& rhs)
  792. {
  793. return CString(lhs) < rhs.get_CString();
  794. }
  795. inline ms_bool_t operator <(const_CString_iadaptor const& lhs, unsigned char const* rhs)
  796. {
  797. return lhs.get_CString() < CString(rhs);
  798. }
  799. inline ms_bool_t operator <(unsigned char const* lhs, const_CString_iadaptor const& rhs)
  800. {
  801. return CString(lhs) < rhs.get_CString();
  802. }
  803. // operator >
  804. inline ms_bool_t operator >(CString_cadaptor const& lhs, CString_cadaptor const& rhs)
  805. {
  806. return lhs.get_CString() > rhs.get_CString();
  807. }
  808. inline ms_bool_t operator >(CString_cadaptor const& lhs, CString const& rhs)
  809. {
  810. return lhs.get_CString() > rhs;
  811. }
  812. inline ms_bool_t operator >(CString const& lhs, CString_cadaptor const& rhs)
  813. {
  814. return lhs > rhs.get_CString();
  815. }
  816. inline ms_bool_t operator >(CString_cadaptor const& lhs, LPCSTR rhs)
  817. {
  818. return lhs.get_CString() > rhs;
  819. }
  820. inline ms_bool_t operator >(LPCSTR lhs, CString_cadaptor const& rhs)
  821. {
  822. return lhs > rhs.get_CString();
  823. }
  824. inline ms_bool_t operator >(CString_cadaptor const& lhs, LPCWSTR rhs)
  825. {
  826. return lhs.get_CString() > CString(rhs);
  827. }
  828. inline ms_bool_t operator >(LPCWSTR lhs, CString_cadaptor const& rhs)
  829. {
  830. return CString(lhs) > rhs.get_CString();
  831. }
  832. inline ms_bool_t operator >(CString_cadaptor const& lhs, unsigned char const* rhs)
  833. {
  834. return lhs.get_CString() > CString(rhs);
  835. }
  836. inline ms_bool_t operator >(unsigned char const* lhs, CString_cadaptor const& rhs)
  837. {
  838. return CString(lhs) > rhs.get_CString();
  839. }
  840. inline ms_bool_t operator >(CString_iadaptor const& lhs, CString_iadaptor const& rhs)
  841. {
  842. return lhs.get_CString() > rhs.get_CString();
  843. }
  844. inline ms_bool_t operator >(CString_iadaptor const& lhs, CString const& rhs)
  845. {
  846. return lhs.get_CString() > rhs;
  847. }
  848. inline ms_bool_t operator >(CString const& lhs, CString_iadaptor const& rhs)
  849. {
  850. return lhs > rhs.get_CString();
  851. }
  852. inline ms_bool_t operator >(CString_iadaptor const& lhs, LPCSTR rhs)
  853. {
  854. return lhs.get_CString() > rhs;
  855. }
  856. inline ms_bool_t operator >(LPCSTR lhs, CString_iadaptor const& rhs)
  857. {
  858. return lhs > rhs.get_CString();
  859. }
  860. inline ms_bool_t operator >(CString_iadaptor const& lhs, LPCWSTR rhs)
  861. {
  862. return lhs.get_CString() > CString(rhs);
  863. }
  864. inline ms_bool_t operator >(LPCWSTR lhs, CString_iadaptor const& rhs)
  865. {
  866. return CString(lhs) > rhs.get_CString();
  867. }
  868. inline ms_bool_t operator >(CString_iadaptor const& lhs, unsigned char const* rhs)
  869. {
  870. return lhs.get_CString() > CString(rhs);
  871. }
  872. inline ms_bool_t operator >(unsigned char const* lhs, CString_iadaptor const& rhs)
  873. {
  874. return CString(lhs) > rhs.get_CString();
  875. }
  876. inline ms_bool_t operator >(const_CString_iadaptor const& lhs, const_CString_iadaptor const& rhs)
  877. {
  878. return lhs.get_CString() > rhs.get_CString();
  879. }
  880. inline ms_bool_t operator >(const_CString_iadaptor const& lhs, CString const& rhs)
  881. {
  882. return lhs.get_CString() > rhs;
  883. }
  884. inline ms_bool_t operator >(CString const& lhs, const_CString_iadaptor const& rhs)
  885. {
  886. return lhs > rhs.get_CString();
  887. }
  888. inline ms_bool_t operator >(const_CString_iadaptor const& lhs, LPCSTR rhs)
  889. {
  890. return lhs.get_CString() > rhs;
  891. }
  892. inline ms_bool_t operator >(LPCSTR lhs, const_CString_iadaptor const& rhs)
  893. {
  894. return lhs > rhs.get_CString();
  895. }
  896. inline ms_bool_t operator >(const_CString_iadaptor const& lhs, LPCWSTR rhs)
  897. {
  898. return lhs.get_CString() > CString(rhs);
  899. }
  900. inline ms_bool_t operator >(LPCWSTR lhs, const_CString_iadaptor const& rhs)
  901. {
  902. return CString(lhs) > rhs.get_CString();
  903. }
  904. inline ms_bool_t operator >(const_CString_iadaptor const& lhs, unsigned char const* rhs)
  905. {
  906. return lhs.get_CString() > CString(rhs);
  907. }
  908. inline ms_bool_t operator >(unsigned char const* lhs, const_CString_iadaptor const& rhs)
  909. {
  910. return CString(lhs) > rhs.get_CString();
  911. }
  912. // operator <=
  913. inline ms_bool_t operator <=(CString_cadaptor const& lhs, CString_cadaptor const& rhs)
  914. {
  915. return lhs.get_CString() <= rhs.get_CString();
  916. }
  917. inline ms_bool_t operator <=(CString_cadaptor const& lhs, CString const& rhs)
  918. {
  919. return lhs.get_CString() <= rhs;
  920. }
  921. inline ms_bool_t operator <=(CString const& lhs, CString_cadaptor const& rhs)
  922. {
  923. return lhs <= rhs.get_CString();
  924. }
  925. inline ms_bool_t operator <=(CString_cadaptor const& lhs, LPCSTR rhs)
  926. {
  927. return lhs.get_CString() <= rhs;
  928. }
  929. inline ms_bool_t operator <=(LPCSTR lhs, CString_cadaptor const& rhs)
  930. {
  931. return lhs <= rhs.get_CString();
  932. }
  933. inline ms_bool_t operator <=(CString_cadaptor const& lhs, LPCWSTR rhs)
  934. {
  935. return lhs.get_CString() <= CString(rhs);
  936. }
  937. inline ms_bool_t operator <=(LPCWSTR lhs, CString_cadaptor const& rhs)
  938. {
  939. return CString(lhs) <= rhs.get_CString();
  940. }
  941. inline ms_bool_t operator <=(CString_cadaptor const& lhs, unsigned char const* rhs)
  942. {
  943. return lhs.get_CString() <= CString(rhs);
  944. }
  945. inline ms_bool_t operator <=(unsigned char const* lhs, CString_cadaptor const& rhs)
  946. {
  947. return CString(lhs) <= rhs.get_CString();
  948. }
  949. inline ms_bool_t operator <=(CString_iadaptor const& lhs, CString_iadaptor const& rhs)
  950. {
  951. return lhs.get_CString() <= rhs.get_CString();
  952. }
  953. inline ms_bool_t operator <=(CString_iadaptor const& lhs, CString const& rhs)
  954. {
  955. return lhs.get_CString() <= rhs;
  956. }
  957. inline ms_bool_t operator <=(CString const& lhs, CString_iadaptor const& rhs)
  958. {
  959. return lhs <= rhs.get_CString();
  960. }
  961. inline ms_bool_t operator <=(CString_iadaptor const& lhs, LPCSTR rhs)
  962. {
  963. return lhs.get_CString() <= rhs;
  964. }
  965. inline ms_bool_t operator <=(LPCSTR lhs, CString_iadaptor const& rhs)
  966. {
  967. return lhs <= rhs.get_CString();
  968. }
  969. inline ms_bool_t operator <=(CString_iadaptor const& lhs, LPCWSTR rhs)
  970. {
  971. return lhs.get_CString() <= CString(rhs);
  972. }
  973. inline ms_bool_t operator <=(LPCWSTR lhs, CString_iadaptor const& rhs)
  974. {
  975. return CString(lhs) <= rhs.get_CString();
  976. }
  977. inline ms_bool_t operator <=(CString_iadaptor const& lhs, unsigned char const* rhs)
  978. {
  979. return lhs.get_CString() <= CString(rhs);
  980. }
  981. inline ms_bool_t operator <=(unsigned char const* lhs, CString_iadaptor const& rhs)
  982. {
  983. return CString(lhs) <= rhs.get_CString();
  984. }
  985. inline ms_bool_t operator <=(const_CString_iadaptor const& lhs, const_CString_iadaptor const& rhs)
  986. {
  987. return lhs.get_CString() <= rhs.get_CString();
  988. }
  989. inline ms_bool_t operator <=(const_CString_iadaptor const& lhs, CString const& rhs)
  990. {
  991. return lhs.get_CString() <= rhs;
  992. }
  993. inline ms_bool_t operator <=(CString const& lhs, const_CString_iadaptor const& rhs)
  994. {
  995. return lhs <= rhs.get_CString();
  996. }
  997. inline ms_bool_t operator <=(const_CString_iadaptor const& lhs, LPCSTR rhs)
  998. {
  999. return lhs.get_CString() <= rhs;
  1000. }
  1001. inline ms_bool_t operator <=(LPCSTR lhs, const_CString_iadaptor const& rhs)
  1002. {
  1003. return lhs <= rhs.get_CString();
  1004. }
  1005. inline ms_bool_t operator <=(const_CString_iadaptor const& lhs, LPCWSTR rhs)
  1006. {
  1007. return lhs.get_CString() <= CString(rhs);
  1008. }
  1009. inline ms_bool_t operator <=(LPCWSTR lhs, const_CString_iadaptor const& rhs)
  1010. {
  1011. return CString(lhs) <= rhs.get_CString();
  1012. }
  1013. inline ms_bool_t operator <=(const_CString_iadaptor const& lhs, unsigned char const* rhs)
  1014. {
  1015. return lhs.get_CString() <= CString(rhs);
  1016. }
  1017. inline ms_bool_t operator <=(unsigned char const* lhs, const_CString_iadaptor const& rhs)
  1018. {
  1019. return CString(lhs) <= rhs.get_CString();
  1020. }
  1021. // operator >=
  1022. inline ms_bool_t operator >=(CString_cadaptor const& lhs, CString_cadaptor const& rhs)
  1023. {
  1024. return lhs.get_CString() >= rhs.get_CString();
  1025. }
  1026. inline ms_bool_t operator >=(CString_cadaptor const& lhs, CString const& rhs)
  1027. {
  1028. return lhs.get_CString() >= rhs;
  1029. }
  1030. inline ms_bool_t operator >=(CString const& lhs, CString_cadaptor const& rhs)
  1031. {
  1032. return lhs >= rhs.get_CString();
  1033. }
  1034. inline ms_bool_t operator >=(CString_cadaptor const& lhs, LPCSTR rhs)
  1035. {
  1036. return lhs.get_CString() >= rhs;
  1037. }
  1038. inline ms_bool_t operator >=(LPCSTR lhs, CString_cadaptor const& rhs)
  1039. {
  1040. return lhs >= rhs.get_CString();
  1041. }
  1042. inline ms_bool_t operator >=(CString_cadaptor const& lhs, LPCWSTR rhs)
  1043. {
  1044. return lhs.get_CString() >= CString(rhs);
  1045. }
  1046. inline ms_bool_t operator >=(LPCWSTR lhs, CString_cadaptor const& rhs)
  1047. {
  1048. return CString(lhs) >= rhs.get_CString();
  1049. }
  1050. inline ms_bool_t operator >=(CString_cadaptor const& lhs, unsigned char const* rhs)
  1051. {
  1052. return lhs.get_CString() >= CString(rhs);
  1053. }
  1054. inline ms_bool_t operator >=(unsigned char const* lhs, CString_cadaptor const& rhs)
  1055. {
  1056. return CString(lhs) >= rhs.get_CString();
  1057. }
  1058. inline ms_bool_t operator >=(CString_iadaptor const& lhs, CString_iadaptor const& rhs)
  1059. {
  1060. return lhs.get_CString() >= rhs.get_CString();
  1061. }
  1062. inline ms_bool_t operator >=(CString_iadaptor const& lhs, CString const& rhs)
  1063. {
  1064. return lhs.get_CString() >= rhs;
  1065. }
  1066. inline ms_bool_t operator >=(CString const& lhs, CString_iadaptor const& rhs)
  1067. {
  1068. return lhs >= rhs.get_CString();
  1069. }
  1070. inline ms_bool_t operator >=(CString_iadaptor const& lhs, LPCSTR rhs)
  1071. {
  1072. return lhs.get_CString() >= rhs;
  1073. }
  1074. inline ms_bool_t operator >=(LPCSTR lhs, CString_iadaptor const& rhs)
  1075. {
  1076. return lhs >= rhs.get_CString();
  1077. }
  1078. inline ms_bool_t operator >=(CString_iadaptor const& lhs, LPCWSTR rhs)
  1079. {
  1080. return lhs.get_CString() >= CString(rhs);
  1081. }
  1082. inline ms_bool_t operator >=(LPCWSTR lhs, CString_iadaptor const& rhs)
  1083. {
  1084. return CString(lhs) >= rhs.get_CString();
  1085. }
  1086. inline ms_bool_t operator >=(CString_iadaptor const& lhs, unsigned char const* rhs)
  1087. {
  1088. return lhs.get_CString() >= CString(rhs);
  1089. }
  1090. inline ms_bool_t operator >=(unsigned char const* lhs, CString_iadaptor const& rhs)
  1091. {
  1092. return CString(lhs) >= rhs.get_CString();
  1093. }
  1094. inline ms_bool_t operator >=(const_CString_iadaptor const& lhs, const_CString_iadaptor const& rhs)
  1095. {
  1096. return lhs.get_CString() >= rhs.get_CString();
  1097. }
  1098. inline ms_bool_t operator >=(const_CString_iadaptor const& lhs, CString const& rhs)
  1099. {
  1100. return lhs.get_CString() >= rhs;
  1101. }
  1102. inline ms_bool_t operator >=(CString const& lhs, const_CString_iadaptor const& rhs)
  1103. {
  1104. return lhs >= rhs.get_CString();
  1105. }
  1106. inline ms_bool_t operator >=(const_CString_iadaptor const& lhs, LPCSTR rhs)
  1107. {
  1108. return lhs.get_CString() >= rhs;
  1109. }
  1110. inline ms_bool_t operator >=(LPCSTR lhs, const_CString_iadaptor const& rhs)
  1111. {
  1112. return lhs >= rhs.get_CString();
  1113. }
  1114. inline ms_bool_t operator >=(const_CString_iadaptor const& lhs, LPCWSTR rhs)
  1115. {
  1116. return lhs.get_CString() >= CString(rhs);
  1117. }
  1118. inline ms_bool_t operator >=(LPCWSTR lhs, const_CString_iadaptor const& rhs)
  1119. {
  1120. return CString(lhs) >= rhs.get_CString();
  1121. }
  1122. inline ms_bool_t operator >=(const_CString_iadaptor const& lhs, unsigned char const* rhs)
  1123. {
  1124. return lhs.get_CString() >= CString(rhs);
  1125. }
  1126. inline ms_bool_t operator >=(unsigned char const* lhs, const_CString_iadaptor const& rhs)
  1127. {
  1128. return CString(lhs) >= rhs.get_CString();
  1129. }
  1130. ////////////////////////////////////////////////////////////////////////////
  1131. // string traits
  1132. #ifndef _MFCSTL_NO_NAMESPACE
  1133. # if defined(_STLSOFT_NO_NAMESPACE) || \
  1134. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  1135. } // namespace mfcstl
  1136. # else
  1137. } // namespace mfcstl_project
  1138. # endif /* _STLSOFT_NO_NAMESPACE */
  1139. #endif /* !_MFCSTL_NO_NAMESPACE */
  1140. /** Specialisation for mfcstl::CString_cadaptor
  1141. */
  1142. STLSOFT_TEMPLATE_SPECIALISATION
  1143. struct string_traits<mfcstl_ns_qual(CString_cadaptor)>
  1144. {
  1145. typedef mfcstl_ns_qual(CString_cadaptor) value_type;
  1146. typedef TCHAR char_type;
  1147. typedef ss_size_t size_type;
  1148. typedef char_type const const_char_type;
  1149. typedef value_type string_type;
  1150. typedef LPCSTR pointer;
  1151. typedef LPCTSTR const_pointer;
  1152. typedef LPCSTR iterator;
  1153. typedef LPCTSTR const_iterator;
  1154. typedef value_type::reverse_iterator reverse_iterator;
  1155. typedef value_type::const_reverse_iterator const_reverse_iterator;
  1156. enum
  1157. {
  1158. is_pointer = false
  1159. , is_pointer_to_const = false
  1160. , char_type_size = sizeof(char_type)
  1161. };
  1162. static string_type empty_string()
  1163. {
  1164. return string_type();
  1165. }
  1166. static string_type construct(string_type const& src, size_type pos, size_type len)
  1167. {
  1168. return string_type(src, pos, len);
  1169. }
  1170. static string_type &assign_inplace(string_type &str, const_iterator first, const_iterator last)
  1171. {
  1172. return (str = string_type(first, last), str);
  1173. }
  1174. };
  1175. #ifndef _MFCSTL_NO_NAMESPACE
  1176. # if defined(_STLSOFT_NO_NAMESPACE) || \
  1177. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  1178. /* There is no stlsoft namespace, so must define ::mfcstl */
  1179. namespace mfcstl
  1180. {
  1181. # else
  1182. namespace mfcstl_project
  1183. {
  1184. # endif /* _STLSOFT_NO_NAMESPACE */
  1185. #endif /* !_MFCSTL_NO_NAMESPACE */
  1186. ////////////////////////////////////////////////////////////////////////////
  1187. // Unit-testing
  1188. #ifdef STLSOFT_UNITTEST
  1189. # include "./unittest/cstring_adaptors_unittest_.h"
  1190. #endif /* STLSOFT_UNITTEST */
  1191. /* /////////////////////////////////////////////////////////////////////////
  1192. * Implementation
  1193. */
  1194. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  1195. // CString_adaptor_base
  1196. template<ss_typename_param_k I>
  1197. inline ss_typename_type_ret_k CString_adaptor_base<I>::allocator_type CString_adaptor_base<I>::get_allocator() const
  1198. {
  1199. return allocator_type();
  1200. }
  1201. template<ss_typename_param_k I>
  1202. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(LPCSTR s)
  1203. {
  1204. get_CString() = s;
  1205. return *this;
  1206. }
  1207. template<ss_typename_param_k I>
  1208. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(LPCWSTR s)
  1209. {
  1210. get_CString() = s;
  1211. return *this;
  1212. }
  1213. template<ss_typename_param_k I>
  1214. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(unsigned char const* s)
  1215. {
  1216. get_CString() = s;
  1217. return *this;
  1218. }
  1219. template<ss_typename_param_k I>
  1220. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(LPCSTR s, size_type n)
  1221. {
  1222. #ifdef UNICODE
  1223. get_CString() = CString(s).Left(n);
  1224. #else /* ? UNICODE */
  1225. get_CString() = CString(s, n);
  1226. #endif /* UNICODE */
  1227. return *this;
  1228. }
  1229. template<ss_typename_param_k I>
  1230. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(LPCWSTR s, size_type n)
  1231. {
  1232. #ifdef UNICODE
  1233. get_CString() = CString(s, n);
  1234. #else /* ? UNICODE */
  1235. get_CString() = CString(s).Left(n);
  1236. #endif /* UNICODE */
  1237. return *this;
  1238. }
  1239. template<ss_typename_param_k I>
  1240. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(unsigned char const* s, size_type n)
  1241. {
  1242. get_CString() = CString(s).Left(n);
  1243. return *this;
  1244. }
  1245. template<ss_typename_param_k I>
  1246. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(class_type const& s)
  1247. {
  1248. get_CString() = s.get_CString();
  1249. return *this;
  1250. }
  1251. template<ss_typename_param_k I>
  1252. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(class_type const& s, size_type pos, size_type index)
  1253. {
  1254. MFCSTL_MESSAGE_ASSERT("invalid index", index + pos <= s.size());
  1255. get_CString() = CString(s.c_str() + pos, index);
  1256. return *this;
  1257. }
  1258. template<ss_typename_param_k I>
  1259. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(size_type n, value_type ch)
  1260. {
  1261. get_CString() = CString(ch, static_cast<int>(n));
  1262. return *this;
  1263. }
  1264. template<ss_typename_param_k I>
  1265. #if defined(STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION) && \
  1266. STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_7_0
  1267. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(LPCTSTR first, LPCTSTR last)
  1268. #else /* ? library */
  1269. inline ss_typename_type_ret_k CString_adaptor_base<I>::class_type& CString_adaptor_base<I>::assign(const_iterator first, const_iterator last)
  1270. #endif /* library */
  1271. {
  1272. get_CString() = CString(first, static_cast<int>(last - first));
  1273. return *this;
  1274. }
  1275. template<ss_typename_param_k I>
  1276. inline ss_typename_type_ret_k CString_adaptor_base<I>::iterator CString_adaptor_base<I>::begin()
  1277. {
  1278. return const_cast<pointer>(this->c_str());
  1279. }
  1280. template<ss_typename_param_k I>
  1281. inline ss_typename_type_ret_k CString_adaptor_base<I>::iterator CString_adaptor_base<I>::end()
  1282. {
  1283. return this->begin() + this->size();
  1284. }
  1285. template<ss_typename_param_k I>
  1286. inline ss_typename_type_ret_k CString_adaptor_base<I>::const_iterator CString_adaptor_base<I>::begin() const
  1287. {
  1288. return this->c_str();
  1289. }
  1290. template<ss_typename_param_k I>
  1291. inline ss_typename_type_ret_k CString_adaptor_base<I>::const_iterator CString_adaptor_base<I>::end() const
  1292. {
  1293. return this->begin() + this->size();
  1294. }
  1295. #ifdef STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT
  1296. template<ss_typename_param_k I>
  1297. inline ss_typename_type_ret_k CString_adaptor_base<I>::reverse_iterator CString_adaptor_base<I>::rbegin()
  1298. {
  1299. return reverse_iterator(end());
  1300. }
  1301. template<ss_typename_param_k I>
  1302. inline ss_typename_type_ret_k CString_adaptor_base<I>::reverse_iterator CString_adaptor_base<I>::rend()
  1303. {
  1304. return reverse_iterator(begin());
  1305. }
  1306. template<ss_typename_param_k I>
  1307. inline ss_typename_type_ret_k CString_adaptor_base<I>::const_reverse_iterator CString_adaptor_base<I>::rbegin() const
  1308. {
  1309. return const_reverse_iterator(end());
  1310. }
  1311. template<ss_typename_param_k I>
  1312. inline ss_typename_type_ret_k CString_adaptor_base<I>::const_reverse_iterator CString_adaptor_base<I>::rend() const
  1313. {
  1314. return const_reverse_iterator(begin());
  1315. }
  1316. #endif /* STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT */
  1317. template<ss_typename_param_k I>
  1318. inline ss_typename_type_ret_k CString_adaptor_base<I>::reference CString_adaptor_base<I>::subscript_(size_type index)
  1319. {
  1320. MFCSTL_MESSAGE_ASSERT("invalid index", index < size());
  1321. return const_cast<pointer>(this->data())[index];
  1322. }
  1323. template<ss_typename_param_k I>
  1324. inline ss_typename_type_ret_k CString_adaptor_base<I>::const_reference CString_adaptor_base<I>::subscript_(size_type index) const
  1325. {
  1326. MFCSTL_MESSAGE_ASSERT("invalid index", index < size());
  1327. return this->data()[index];
  1328. }
  1329. template<ss_typename_param_k I>
  1330. inline ss_typename_type_ret_k CString_adaptor_base<I>::reference CString_adaptor_base<I>::at(size_type index)
  1331. {
  1332. if(index >= size())
  1333. {
  1334. STLSOFT_THROW_X(mfcstl_ns_qual_std(out_of_range)("invalid index"));
  1335. }
  1336. return subscript_(index);
  1337. }
  1338. template<ss_typename_param_k I>
  1339. inline ss_typename_type_ret_k CString_adaptor_base<I>::const_reference CString_adaptor_base<I>::at(size_type index) const
  1340. {
  1341. if(index >= size())
  1342. {
  1343. STLSOFT_THROW_X(mfcstl_ns_qual_std(out_of_range)("invalid index"));
  1344. }
  1345. return subscript_(index);
  1346. }
  1347. template<ss_typename_param_k I>
  1348. inline ss_typename_type_ret_k CString_adaptor_base<I>::size_type CString_adaptor_base<I>::length() const
  1349. {
  1350. return get_CString().GetLength();
  1351. }
  1352. template<ss_typename_param_k I>
  1353. inline ss_typename_type_ret_k CString_adaptor_base<I>::size_type CString_adaptor_base<I>::size() const
  1354. {
  1355. return this->length();
  1356. }
  1357. template<ss_typename_param_k I>
  1358. inline ss_typename_type_ret_k CString_adaptor_base<I>::bool_type CString_adaptor_base<I>::empty() const
  1359. {
  1360. return 0 == this->length();
  1361. }
  1362. template<ss_typename_param_k I>
  1363. inline ss_typename_type_ret_k CString_adaptor_base<I>::const_pointer CString_adaptor_base<I>::c_str() const
  1364. {
  1365. // return empty() ? _T("") : static_cast<const_pointer>(get_CString());
  1366. return get_CString();
  1367. }
  1368. template<ss_typename_param_k I>
  1369. inline ss_typename_type_ret_k CString_adaptor_base<I>::const_pointer CString_adaptor_base<I>::data() const
  1370. {
  1371. return this->c_str();
  1372. }
  1373. // CString_cadaptor
  1374. inline CString_cadaptor::CString_cadaptor()
  1375. {}
  1376. inline CString_cadaptor::CString_cadaptor(class_type const& rhs)
  1377. : CString(rhs)
  1378. {}
  1379. inline /* ss_explicit_k */ CString_cadaptor::CString_cadaptor(CString const& rhs)
  1380. : CString(rhs)
  1381. {}
  1382. inline /* ss_explicit_k */ CString_cadaptor::CString_cadaptor(LPCSTR s)
  1383. : CString(s)
  1384. {}
  1385. inline /* ss_explicit_k */ CString_cadaptor::CString_cadaptor(LPCWSTR s)
  1386. : CString(s)
  1387. {}
  1388. inline /* ss_explicit_k */ CString_cadaptor::CString_cadaptor(unsigned char const* s)
  1389. : CString(s)
  1390. {}
  1391. inline CString_cadaptor::CString_cadaptor(LPCTSTR from, LPCTSTR to)
  1392. : CString(from, static_cast<int>(to - from))
  1393. {}
  1394. inline CString_cadaptor::CString_cadaptor(LPCTSTR from, size_type length)
  1395. : CString(from, length)
  1396. {}
  1397. inline CString_cadaptor::CString_cadaptor(class_type const& str, size_type pos, size_type n)
  1398. : CString(static_cast<LPCTSTR>(str) + pos, n)
  1399. {}
  1400. inline CString_cadaptor::CString_cadaptor(ms_size_t cch, TCHAR ch)
  1401. : CString(ch, static_cast<int>(cch))
  1402. {}
  1403. inline CString_cadaptor::class_type const& CString_cadaptor::operator =(CString_cadaptor::class_type const& rhs)
  1404. {
  1405. assign(rhs);
  1406. return *this;
  1407. }
  1408. inline CString_cadaptor::class_type const& CString_cadaptor::operator =(CString const& rhs)
  1409. {
  1410. assign(rhs);
  1411. return *this;
  1412. }
  1413. inline CString_cadaptor::class_type const& CString_cadaptor::operator =(LPCSTR rhs)
  1414. {
  1415. assign(rhs);
  1416. return *this;
  1417. }
  1418. inline CString_cadaptor::class_type const& CString_cadaptor::operator =(LPCWSTR rhs)
  1419. {
  1420. assign(rhs);
  1421. return *this;
  1422. }
  1423. inline CString_cadaptor::class_type const& CString_cadaptor::operator =(unsigned char const* rhs)
  1424. {
  1425. assign(rhs);
  1426. return *this;
  1427. }
  1428. // CString_iadaptor
  1429. inline CString_iadaptor::CString_iadaptor(CString &str)
  1430. : m_str(&str)
  1431. {}
  1432. inline CString_iadaptor::CString_iadaptor(CString *str)
  1433. : m_str(str)
  1434. {}
  1435. inline CString_iadaptor::class_type const& CString_iadaptor::operator =(CString_iadaptor::class_type const& rhs)
  1436. {
  1437. assign(rhs);
  1438. return *this;
  1439. }
  1440. inline CString_iadaptor::class_type const& CString_iadaptor::operator =(CString const& rhs)
  1441. {
  1442. assign(rhs);
  1443. return *this;
  1444. }
  1445. inline CString_iadaptor::class_type const& CString_iadaptor::operator =(LPCSTR rhs)
  1446. {
  1447. assign(rhs);
  1448. return *this;
  1449. }
  1450. inline CString_iadaptor::class_type const& CString_iadaptor::operator =(LPCWSTR rhs)
  1451. {
  1452. assign(rhs);
  1453. return *this;
  1454. }
  1455. inline CString_iadaptor::class_type const& CString_iadaptor::operator =(unsigned char const* rhs)
  1456. {
  1457. assign(rhs);
  1458. return *this;
  1459. }
  1460. inline CString_iadaptor::reference CString_iadaptor::operator [](CString_iadaptor::size_type index)
  1461. {
  1462. return this->subscript_(index);
  1463. }
  1464. inline CString_iadaptor::const_reference CString_iadaptor::operator [](CString_iadaptor::size_type index) const
  1465. {
  1466. return this->subscript_(index);
  1467. }
  1468. // const_CString_iadaptor
  1469. inline const_CString_iadaptor::const_CString_iadaptor(CString const& str)
  1470. : m_str(&str)
  1471. {}
  1472. inline const_CString_iadaptor::const_CString_iadaptor(CString const* str)
  1473. : m_str(str)
  1474. {}
  1475. inline const_CString_iadaptor::const_reference const_CString_iadaptor::operator [](const_CString_iadaptor::size_type index) const
  1476. {
  1477. return this->subscript_(index);
  1478. }
  1479. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  1480. /* ////////////////////////////////////////////////////////////////////// */
  1481. #ifndef _MFCSTL_NO_NAMESPACE
  1482. # if defined(_STLSOFT_NO_NAMESPACE) || \
  1483. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  1484. } // namespace mfcstl
  1485. # else
  1486. } // namespace mfcstl_project
  1487. } // namespace stlsoft
  1488. # endif /* _STLSOFT_NO_NAMESPACE */
  1489. #endif /* !_MFCSTL_NO_NAMESPACE */
  1490. /* ////////////////////////////////////////////////////////////////////// */
  1491. #endif /* !MFCSTL_INCL_MFCSTL_COLLECTIONS_HPP_CSTRING_ADAPTORS */
  1492. /* ///////////////////////////// end of file //////////////////////////// */