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 COMSTL_INCL_COMSTL_UTIL_HPP_COMSTL_GUID
00048 #define COMSTL_INCL_COMSTL_UTIL_HPP_COMSTL_GUID
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define _COMSTL_VER_COMSTL_UTIL_HPP_COMSTL_GUID_MAJOR 4
00052 # define _COMSTL_VER_COMSTL_UTIL_HPP_COMSTL_GUID_MINOR 3
00053 # define _COMSTL_VER_COMSTL_UTIL_HPP_COMSTL_GUID_REVISION 2
00054 # define _COMSTL_VER_COMSTL_UTIL_HPP_COMSTL_GUID_EDIT 46
00055 #endif
00056
00057
00058
00059
00060
00061 #ifndef COMSTL_INCL_COMSTL_H_COMSTL
00062 # include <comstl/comstl.h>
00063 #endif
00064 #ifndef COMSTL_INCL_COMSTL_SHIMS_ACCESS_HPP_STRING
00065 # include <comstl/shims/access/string.hpp>
00066 #endif
00067 #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
00068 # ifndef COMSTL_INCL_COMSTL_ERROR_HPP_EXCEPTIONS
00069 # include <comstl/error/exceptions.hpp>
00070 # endif
00071 #endif
00072 #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_STD_SWAP
00073 # include <stlsoft/util/std_swap.hpp>
00074 #endif
00075
00076
00077
00078
00079
00080 #ifndef _COMSTL_NO_NAMESPACE
00081 # if defined(_STLSOFT_NO_NAMESPACE) || \
00082 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00083
00084 namespace comstl
00085 {
00086 # else
00087
00088
00089 namespace stlsoft
00090 {
00091
00092 namespace comstl_project
00093 {
00094
00095 # endif
00096 #endif
00097
00098
00099
00100
00101
00106 class guid
00107 {
00110 public:
00111 typedef guid class_type;
00112
00113 typedef GUID const& resource_type;
00115
00118 public:
00125 guid();
00138 ss_explicit_k guid(cs_char_a_t const* s);
00151 ss_explicit_k guid(cs_char_w_t const* s);
00153 ss_explicit_k guid(GUID const& g);
00155 guid(class_type const& rhs);
00156
00158 guid& operator =(class_type const& rhs);
00173 guid& operator =(cs_char_a_t const* s);
00188 guid& operator =(cs_char_w_t const* s);
00190 guid& operator =(GUID const& g);
00192
00195 public:
00196 GUID const& get() const;
00198
00201 public:
00203 cs_bool_t equal(class_type const& rhs) const;
00205 cs_bool_t equal(GUID const& rhs) const;
00207
00210 public:
00212 void swap(class_type& rhs) stlsoft_throw_0();
00214
00217 private:
00218 GUID m_guid;
00220 };
00221
00222
00223
00224
00225
00230 inline c_str_ptr_GUID_proxy<TCHAR> c_str_data(comstl_ns_qual(guid) const& g)
00231 {
00232 return stlsoft_ns_qual(c_str_data)(g.get());
00233 }
00234
00235 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00236
00237 inline c_str_ptr_GUID_proxy<cs_char_a_t> c_str_data_a(comstl_ns_qual(guid) const& g)
00238 {
00239 return stlsoft_ns_qual(c_str_data_a)(g.get());
00240 }
00241
00242 inline c_str_ptr_GUID_proxy<cs_char_w_t> c_str_data_w(comstl_ns_qual(guid) const& g)
00243 {
00244 return stlsoft_ns_qual(c_str_data_w)(g.get());
00245 }
00246
00247 inline c_str_ptr_GUID_proxy<cs_char_o_t> c_str_data_o(comstl_ns_qual(guid) const& g)
00248 {
00249 return stlsoft_ns_qual(c_str_data_o)(g.get());
00250 }
00251
00252 #endif
00253
00258 inline cs_size_t c_str_len(comstl_ns_qual(guid) const& g)
00259 {
00260 return stlsoft_ns_qual(c_str_len)(g.get());
00261 }
00262
00263 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00264
00265 inline cs_size_t c_str_len_a(comstl_ns_qual(guid) const& g)
00266 {
00267 return stlsoft_ns_qual(c_str_len_a)(g.get());
00268 }
00269
00270 inline cs_size_t c_str_len_w(comstl_ns_qual(guid) const& g)
00271 {
00272 return stlsoft_ns_qual(c_str_len_w)(g.get());
00273 }
00274
00275 inline cs_size_t c_str_len_o(comstl_ns_qual(guid) const& g)
00276 {
00277 return stlsoft_ns_qual(c_str_len_o)(g.get());
00278 }
00279
00280 #endif
00281
00286 inline c_str_ptr_GUID_proxy<TCHAR> c_str_ptr(comstl_ns_qual(guid) const& g)
00287 {
00288 return stlsoft_ns_qual(c_str_ptr)(g.get());
00289 }
00290
00291 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00292
00293 inline c_str_ptr_GUID_proxy<cs_char_a_t> c_str_ptr_a(comstl_ns_qual(guid) const& g)
00294 {
00295 return stlsoft_ns_qual(c_str_ptr_a)(g.get());
00296 }
00297
00298 inline c_str_ptr_GUID_proxy<cs_char_w_t> c_str_ptr_w(comstl_ns_qual(guid) const& g)
00299 {
00300 return stlsoft_ns_qual(c_str_ptr_w)(g.get());
00301 }
00302
00303 inline c_str_ptr_GUID_proxy<cs_char_o_t> c_str_ptr_o(comstl_ns_qual(guid) const& g)
00304 {
00305 return stlsoft_ns_qual(c_str_ptr_o)(g.get());
00306 }
00307
00308 #endif
00309
00314 inline c_str_ptr_GUID_proxy<TCHAR> c_str_ptr_null(comstl_ns_qual(guid) const& g)
00315 {
00316 return stlsoft_ns_qual(c_str_ptr_null)(g.get());
00317 }
00318
00319 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00320
00321 inline c_str_ptr_GUID_proxy<cs_char_a_t> c_str_ptr_null_a(comstl_ns_qual(guid) const& g)
00322 {
00323 return stlsoft_ns_qual(c_str_ptr_null_a)(g.get());
00324 }
00325
00326 inline c_str_ptr_GUID_proxy<cs_char_w_t> c_str_ptr_null_w(comstl_ns_qual(guid) const& g)
00327 {
00328 return stlsoft_ns_qual(c_str_ptr_null_w)(g.get());
00329 }
00330
00331 inline c_str_ptr_GUID_proxy<cs_char_o_t> c_str_ptr_null_o(comstl_ns_qual(guid) const& g)
00332 {
00333 return stlsoft_ns_qual(c_str_ptr_null_o)(g.get());
00334 }
00335
00336 #endif
00337
00338
00339
00340
00341
00342 inline cs_bool_t operator ==(guid const& lhs, guid const& rhs)
00343 {
00344 return lhs.equal(rhs);
00345 }
00346
00347 inline cs_bool_t operator !=(guid const& lhs, guid const& rhs)
00348 {
00349 return !operator ==(lhs, rhs);
00350 }
00351
00352 inline cs_bool_t operator ==(guid const& lhs, GUID const& rhs)
00353 {
00354 return lhs.equal(rhs);
00355 }
00356
00357 inline cs_bool_t operator !=(guid const& lhs, GUID const& rhs)
00358 {
00359 return !operator ==(lhs, rhs);
00360 }
00361
00362 inline cs_bool_t operator ==(GUID const& lhs, guid const& rhs)
00363 {
00364 return rhs.equal(lhs);
00365 }
00366
00367 inline cs_bool_t operator !=(GUID const& lhs, guid const& rhs)
00368 {
00369 return !operator ==(lhs, rhs);
00370 }
00371
00373
00374
00375 #ifdef STLSOFT_UNITTEST
00376 # include "./unittest/guid_unittest_.h"
00377 #endif
00378
00379
00380
00381
00382
00383 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00384
00385 inline guid::guid()
00386 {
00387 HRESULT hr = ::CoCreateGuid(&m_guid);
00388
00389 if(FAILED(hr))
00390 {
00391 #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
00392 STLSOFT_THROW_X(com_exception("Could not allocate GUID", hr));
00393 #else
00394 m_guid = GUID_NULL;
00395 #endif
00396 }
00397 }
00398
00399 inline guid::guid(cs_char_a_t const* s)
00400 {
00401 OLECHAR osz[1 + COMSTL_CCH_GUID];
00402 HRESULT hr = S_OK;
00403
00404 switch(::MultiByteToWideChar(0, 0, s, -1, &osz[0], 1 + COMSTL_CCH_GUID))
00405 {
00406 case 1 + COMSTL_CCH_GUID:
00407 osz[COMSTL_CCH_GUID] = L'\0';
00408 hr = ::CLSIDFromString(osz, &m_guid);
00409 break;
00410 default:
00411 if(S_OK == (hr = HRESULT_FROM_WIN32(::GetLastError())))
00412 {
00413 hr = E_INVALIDARG;
00414 }
00415 break;
00416 }
00417
00418 if(FAILED(hr))
00419 {
00420 #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
00421 STLSOFT_THROW_X(com_exception("Could not convert string to valid GUID", hr));
00422 #else
00423 m_guid = GUID_NULL;
00424 #endif
00425 }
00426 }
00427
00428 inline guid::guid(cs_char_w_t const* s)
00429 {
00430 HRESULT hr = ::CLSIDFromString(const_cast<LPOLESTR>(s), &m_guid);
00431
00432 if(FAILED(hr))
00433 {
00434 #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
00435 STLSOFT_THROW_X(com_exception("Could not convert string to valid GUID", hr));
00436 #else
00437 m_guid = GUID_NULL;
00438 #endif
00439 }
00440 }
00441
00442 inline guid::guid(GUID const& g)
00443 : m_guid(g)
00444 {}
00445
00446 inline guid::guid(guid const& rhs)
00447 : m_guid(rhs.m_guid)
00448 {}
00449
00450 inline guid &guid::operator =(guid const& rhs)
00451 {
00452 m_guid = rhs.m_guid;
00453
00454 return *this;
00455 }
00456
00457 inline guid &guid::operator =(cs_char_a_t const* s)
00458 {
00459 guid t(s);
00460
00461 t.swap(*this);
00462
00463 return *this;
00464 }
00465
00466 inline guid &guid::operator =(cs_char_w_t const* s)
00467 {
00468 guid t(s);
00469
00470 t.swap(*this);
00471
00472 return *this;
00473 }
00474
00475 inline guid &guid::operator =(GUID const& g)
00476 {
00477 guid t(g);
00478
00479 t.swap(*this);
00480
00481 return *this;
00482 }
00483
00484 inline GUID const& guid::get() const
00485 {
00486 return m_guid;
00487 }
00488
00489 inline cs_bool_t guid::equal(class_type const& rhs) const
00490 {
00491 return 0 != IsEqualGUID(m_guid, rhs.m_guid);
00492 }
00493
00494 inline cs_bool_t guid::equal(GUID const& rhs) const
00495 {
00496 return 0 != IsEqualGUID(m_guid, rhs);
00497 }
00498
00499 inline void guid::swap(guid::class_type& rhs) stlsoft_throw_0()
00500 {
00501 stlsoft_ns_qual(std_swap)(m_guid, rhs.m_guid);
00502 }
00503
00504 #endif
00505
00506
00507
00508 #ifndef _COMSTL_NO_NAMESPACE
00509 # if defined(_STLSOFT_NO_NAMESPACE) || \
00510 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00511 }
00512 # else
00513 }
00514 }
00515 # endif
00516 #endif
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526 #ifndef _COMSTL_NO_NAMESPACE
00527 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00528 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00529 namespace stlsoft
00530 {
00531 # else
00532
00533 # endif
00534
00535 using ::comstl::c_str_data;
00536 using ::comstl::c_str_data_a;
00537 using ::comstl::c_str_data_w;
00538 using ::comstl::c_str_data_o;
00539
00540 using ::comstl::c_str_len;
00541 using ::comstl::c_str_len_a;
00542 using ::comstl::c_str_len_w;
00543 using ::comstl::c_str_len_o;
00544
00545 using ::comstl::c_str_ptr;
00546 using ::comstl::c_str_ptr_a;
00547 using ::comstl::c_str_ptr_w;
00548 using ::comstl::c_str_ptr_o;
00549
00550 using ::comstl::c_str_ptr_null;
00551 using ::comstl::c_str_ptr_null_a;
00552 using ::comstl::c_str_ptr_null_w;
00553 using ::comstl::c_str_ptr_null_o;
00554
00555 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00556 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00557 }
00558 # else
00559
00560 # endif
00561 #endif
00562
00563
00564
00565 #endif
00566
00567