Skip to content

Commit

Permalink
修正几个bug
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Dec 23, 2013
1 parent 749ec94 commit e399a2c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
37 changes: 33 additions & 4 deletions Development/Editor/Core/YDWEBase/base/win/registry/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@ inline bool basic_read_key<C, T, V>::has_sub_key(const string_type& subKeyName)

template <typename C, typename T = reg_traits<C>, typename V = basic_write_value<C, T>>
class basic_write_key
: public basic_read_key<C, T, V>
: public basic_base_key<C, T, V>
{
public:
typedef C char_type;
typedef T traits_type;
typedef V value_type;
typedef basic_read_key<C, T, V> base_type;
typedef basic_base_key<C, T, V> base_type;
typedef basic_write_key<C, T, V> class_type;
typedef typename traits_type::size_type size_type;
typedef typename traits_type::string_type string_type;
Expand All @@ -331,14 +331,26 @@ class basic_write_key

basic_write_key (class_type const& rhs);

public:
string_type reg_class () const;
size_type num_sub_keys () const;
size_type num_values () const;

public:
template <typename KeyType>
KeyType create_sub_key(const string_type& subKeyName)
{
return KeyType(m_hkey, subKeyName, KeyType::default_access_mask(), open_option::create_if_not_exists);
}

template <typename KeyType>
KeyType open_sub_key(const string_type& subKeyName) const
{
return KeyType(m_hkey, subKeyName, KeyType::default_access_mask(), open_option::fail_if_not_exists);
}

bool delete_sub_key (const string_type& subKeyName, bool deleteTree = false);
bool has_sub_key (const string_type& subKeyName);

public:
static REGSAM default_access_mask() { return KEY_WRITE | KEY_READ; }
Expand Down Expand Up @@ -382,16 +394,33 @@ inline bool basic_write_key<C, T, V>::delete_sub_key(const string_type& subKeyNa
}
}

template <typename C, typename T, typename V>
inline bool basic_write_key<C, T, V>::has_sub_key(const string_type& subKeyName)
{
hkey_type hkey;
result_type res = traits_type::open_key(m_hkey, subKeyName.c_str(), &hkey, KEY_READ);

switch (res)
{
case ERROR_SUCCESS:
::RegCloseKey(hkey);
case ERROR_ACCESS_DENIED:
return true;
default:
return false;
}
}

template <typename C, typename T, typename V>
inline basic_read_key<C, T, V> operator/(const basic_read_key<C, T, V>& lhs, const typename basic_read_key<C, T, V>::string_type& rhs)
{
return lhs.open_sub_key<basic_read_key<C, T, V>>(rhs);
}

template <typename C, typename T, typename V>
inline basic_write_key<C, T, V> operator/(const basic_write_key<C, T, V>& lhs, const typename basic_write_key<C, T, V>::string_type& rhs)
inline basic_write_key<C, T, V> operator/(basic_write_key<C, T, V>& lhs, const typename basic_write_key<C, T, V>::string_type& rhs)
{
return lhs.open_sub_key<basic_write_key<C, T, V>>(rhs);
return lhs.create_sub_key<basic_write_key<C, T, V>>(rhs);
}

typedef basic_read_key <char, reg_traits<char>> read_key_a;
Expand Down
3 changes: 2 additions & 1 deletion Development/Editor/Core/YDWEBase/base/win/registry/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ namespace base { namespace registry {
{
string_type ret;
size_type data_size = 0;
result_type res = traits_type::query_info(m_hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &data_size, NULL, NULL);
uint32_t dw;
result_type res = traits_type::query_value(m_hkey, m_name.c_str(), dw, NULL, data_size);
check_and_throw_exception("could not determine the data size", res);

if (data_size > 0)
Expand Down
4 changes: 2 additions & 2 deletions Development/Editor/Core/YDWEConfig/Regedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ bool FileAssociation::Ext::remove(base::registry::write_key_w& root)
return false;
}

bool FileAssociation::Ext::set(base::registry::write_key_w const& root, Classes const& c)
bool FileAssociation::Ext::set(base::registry::write_key_w& root, Classes const& c)
{
try {
(root /ext_)[L""] = c.name();
(root / ext_)[L""] = c.name();
} catch (base::registry::registry_exception const& ) { }

return false;
Expand Down
2 changes: 1 addition & 1 deletion Development/Editor/Core/YDWEConfig/Regedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FileAssociation
Ext(std::wstring const& ext);
bool has(base::registry::write_key_w& root, Classes const& c) const;
bool remove(base::registry::write_key_w& root);
bool set(base::registry::write_key_w const& root, Classes const& c);
bool set(base::registry::write_key_w& root, Classes const& c);

bool has_owl(base::registry::write_key_w& root) const;
bool set_owl(base::registry::write_key_w& root);
Expand Down

0 comments on commit e399a2c

Please sign in to comment.