00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef MFCSTL_INCL_MFCSTL_STRING_HPP_RESOURCE_STRING
00048 #define MFCSTL_INCL_MFCSTL_STRING_HPP_RESOURCE_STRING
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define MFCSTL_VER_MFCSTL_STRING_HPP_RESOURCE_STRING_MAJOR 4
00052 # define MFCSTL_VER_MFCSTL_STRING_HPP_RESOURCE_STRING_MINOR 0
00053 # define MFCSTL_VER_MFCSTL_STRING_HPP_RESOURCE_STRING_REVISION 3
00054 # define MFCSTL_VER_MFCSTL_STRING_HPP_RESOURCE_STRING_EDIT 80
00055 #endif
00056
00057
00058
00059
00060
00061 #ifndef MFCSTL_INCL_MFCSTL_HPP_MFCSTL
00062 # include <mfcstl/mfcstl.hpp>
00063 #endif
00064
00065 #if defined(STLSOFT_COMPILER_IS_BORLAND)
00066 # pragma warn -8022
00067 # pragma warn -8084
00068 #endif
00069
00070 #ifndef STLSOFT_INCL_H_AFXWIN
00071 # define STLSOFT_INCL_H_AFXWIN
00072 # include <afxwin.h>
00073 #endif
00074
00075 #if defined(STLSOFT_COMPILER_IS_BORLAND)
00076 # pragma warn .8022
00077 # pragma warn .8084
00078 #endif
00079
00080 #ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
00081 # include <stlsoft/collections/util/collections.hpp>
00082 #endif
00083
00084
00085
00086
00087
00088 #ifndef _MFCSTL_NO_NAMESPACE
00089 # if defined(_STLSOFT_NO_NAMESPACE) || \
00090 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00091
00092 namespace mfcstl
00093 {
00094 # else
00095
00096
00097 namespace stlsoft
00098 {
00099
00100 namespace mfcstl_project
00101 {
00102
00103 # endif
00104 #endif
00105
00106
00107
00108
00114 class resource_string
00115 : public CString
00116 , public stlsoft_ns_qual(stl_collection_tag)
00117 {
00118 private:
00119 typedef CString parent_class_type;
00120 typedef resource_string class_type;
00121 public:
00123 typedef LPCTSTR const_iterator;
00125 typedef UINT size_type;
00126
00127
00128 public:
00132 ss_explicit_k resource_string(ms_uint_t id) stlsoft_throw_2(CMemoryException*, CResourceException*);
00137 resource_string(HINSTANCE hinst, ms_uint_t id) stlsoft_throw_2(CMemoryException*, CResourceException*);
00141 resource_string(resource_string const& rhs);
00145 resource_string(CString const& rhs);
00146
00150 resource_string const& operator =(resource_string const& rhs);
00154 resource_string const& operator =(CString const& rhs);
00155
00156
00157 public:
00161 const_iterator begin() const;
00165 const_iterator end() const;
00166
00167
00168 public:
00170 size_type size() const;
00172 size_type length() const;
00174 ms_bool_t empty() const;
00176 LPCTSTR c_str() const;
00178 LPCTSTR data() const;
00179 };
00180
00181
00182
00183
00184
00185 inline LPCTSTR c_str_ptr_null(resource_string const& s)
00186 {
00187 return s.empty() ? NULL : s.c_str();
00188 }
00189 #ifdef UNICODE
00190 inline LPCTSTR c_str_ptr_null_w(resource_string const& s)
00191 #else
00192 inline LPCTSTR c_str_ptr_null_a(resource_string const& s)
00193 #endif
00194 {
00195 return c_str_ptr_null(s);
00196 }
00197
00198 inline LPCTSTR c_str_ptr(resource_string const& s)
00199 {
00200 return s.c_str();
00201 }
00202 #ifdef UNICODE
00203 inline LPCTSTR c_str_ptr_w(resource_string const& s)
00204 #else
00205 inline LPCTSTR c_str_ptr_a(resource_string const& s)
00206 #endif
00207 {
00208 return c_str_ptr(s);
00209 }
00210
00211 inline LPCTSTR c_str_data(resource_string const& s)
00212 {
00213 return s.data();
00214 }
00215 #ifdef UNICODE
00216 inline LPCTSTR c_str_data_w(resource_string const& s)
00217 #else
00218 inline LPCTSTR c_str_data_a(resource_string const& s)
00219 #endif
00220 {
00221 return c_str_data(s);
00222 }
00223
00224 inline ms_size_t c_str_len(resource_string const& s)
00225 {
00226 return s.length();
00227 }
00228
00229
00230
00231 template<ss_typename_param_k S>
00232 inline S& operator <<(S& s, resource_string const& str)
00233 {
00234 s << str.c_str();
00235
00236 return s;
00237 }
00238
00240
00241
00242 #ifdef STLSOFT_UNITTEST
00243 # include "./unittest/resource_string_unittest_.h"
00244 #endif
00245
00247
00248
00249 inline resource_string::resource_string(ms_uint_t id) stlsoft_throw_2(CMemoryException*, CResourceException*)
00250 {
00251 if(!parent_class_type::LoadString(id))
00252 {
00253 AfxThrowResourceException();
00254 }
00255 }
00256
00257 inline resource_string::resource_string(HINSTANCE hinst, ms_uint_t id) stlsoft_throw_2(CMemoryException*, CResourceException*)
00258 {
00259 TCHAR sz[1024];
00260
00261 if(0 == ::LoadString(hinst, id, sz, STLSOFT_NUM_ELEMENTS(sz)))
00262 {
00263 AfxThrowResourceException();
00264 }
00265 else
00266 {
00267 parent_class_type *pThis = this;
00268
00269 pThis->operator =(sz);
00270 }
00271 }
00272
00273 inline resource_string::resource_string(resource_string const& rhs)
00274 : parent_class_type(rhs)
00275 {}
00276
00277 inline resource_string::resource_string(CString const& rhs)
00278 : parent_class_type(rhs)
00279 {}
00280
00281 inline resource_string const& resource_string::operator =(resource_string const& rhs)
00282 {
00283 parent_class_type *pThis = this;
00284
00285 pThis->operator =(rhs);
00286
00287 return *this;
00288 }
00289
00290 inline resource_string const& resource_string::operator =(CString const& rhs)
00291 {
00292 parent_class_type *pThis = this;
00293
00294 pThis->operator =(rhs);
00295
00296 return *this;
00297 }
00298
00299 inline resource_string::const_iterator resource_string::begin() const
00300 {
00301 return *this;
00302 }
00303
00304 inline resource_string::const_iterator resource_string::end() const
00305 {
00306 return begin() + length();
00307 }
00308
00309 inline resource_string::size_type resource_string::size() const
00310 {
00311 return GetLength();
00312 }
00313
00314 inline resource_string::size_type resource_string::length() const
00315 {
00316 return GetLength();
00317 }
00318
00319 inline ms_bool_t resource_string::empty() const
00320 {
00321 return 0 == length();
00322 }
00323
00324 inline LPCTSTR resource_string::c_str() const
00325 {
00326 return *this;
00327 }
00328
00329 inline LPCTSTR resource_string::data() const
00330 {
00331 return c_str();
00332 }
00333
00334
00335
00336 #ifndef _MFCSTL_NO_NAMESPACE
00337 # if defined(_STLSOFT_NO_NAMESPACE) || \
00338 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00339 }
00340 # else
00341 }
00342 }
00343 # endif
00344 #endif
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 #ifndef _MFCSTL_NO_NAMESPACE
00355 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00356 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00357 namespace stlsoft
00358 {
00359 # else
00360
00361 # endif
00362
00363 using ::mfcstl::c_str_ptr_null;
00364 #if defined(UNICODE)
00365 using ::mfcstl::c_str_ptr_null_w;
00366 #else
00367 using ::mfcstl::c_str_ptr_null_a;
00368 #endif
00369
00370 using ::mfcstl::c_str_ptr;
00371 #if defined(UNICODE)
00372 using ::mfcstl::c_str_ptr_w;
00373 #else
00374 using ::mfcstl::c_str_ptr_a;
00375 #endif
00376
00377 using ::mfcstl::c_str_data;
00378 #if defined(UNICODE)
00379 using ::mfcstl::c_str_data_w;
00380 #else
00381 using ::mfcstl::c_str_data_a;
00382 #endif
00383
00384 using ::mfcstl::c_str_len;
00385
00386 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00387 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00388 }
00389 # else
00390
00391 # endif
00392 #endif
00393
00394
00395
00396 #endif
00397
00398