1 // RegistryValueImpl.cpp: Implementierung der Klasse RegistryValueImpl.
3 //////////////////////////////////////////////////////////////////////
5 #include "registryvalueimpl.hxx"
8 #pragma warning(push, 1) /* disable warnings within system headers */
18 #include "stringconverter.hxx"
20 //#################################
21 // Creation/Destruction
22 //#################################
24 //--------------------------------------------
27 RegistryValueImpl::RegistryValueImpl(const std::wstring
& Name
, int Value
) :
34 //--------------------------------------------
37 RegistryValueImpl::RegistryValueImpl(const std::wstring
& Name
, const std::wstring
& Value
) :
45 //--------------------------------------------
48 RegistryValueImpl::RegistryValueImpl(const std::wstring
& Name
, const std::string
& Value
) :
53 m_StringData
= AnsiToUnicodeString(Value
);
56 #if (_MSC_VER >= 1300)
57 RegistryValueImpl::RegistryValueImpl(const RegistryValueImpl
& s
) :
60 m_StringData(s
.m_StringData
),
61 m_IntData(s
.m_IntData
)
65 //--------------------------------------------
68 RegistryValueImpl::~RegistryValueImpl()
72 //#################################
74 //#################################
76 //--------------------------------------------
77 /** Returns the name of the value
79 std::wstring
RegistryValueImpl::GetName() const
84 //--------------------------------------------
85 /** Return the size of data held
87 size_t RegistryValueImpl::GetDataSize() const
91 if (REG_DWORD
== m_Type
)
92 size
= sizeof(m_IntData
);
93 else if (REG_SZ
== m_Type
)
94 size
= m_StringData
.length() ? ((m_StringData
.length() + 1) * sizeof(wchar_t)) : 0;
99 //--------------------------------------------
100 /** Get a pointer to the data buffer
101 in order to copy the data
103 const void* RegistryValueImpl::GetDataBuffer() const
105 const void* pData
= 0;
107 if (REG_DWORD
== m_Type
)
108 pData
= reinterpret_cast<const void*>(&m_IntData
);
109 else if (REG_SZ
== m_Type
)
110 pData
= reinterpret_cast<const void*>(m_StringData
.c_str());
115 //--------------------------------------------
116 /** Returns the data as string
118 std::wstring
RegistryValueImpl::GetDataAsUniString() const
120 assert(REG_SZ
== m_Type
);
124 //--------------------------------------------
125 /** Returns the data as string
127 std::string
RegistryValueImpl::GetDataAsAnsiString() const
129 assert(REG_SZ
== m_Type
);
130 return UnicodeToAnsiString(m_StringData
);
133 //--------------------------------------------
134 /** Returns the data as number
136 int RegistryValueImpl::GetDataAsInt() const
138 assert(REG_DWORD
== m_Type
);
142 //--------------------------------------------
143 /** Returns the type of the data
145 int RegistryValueImpl::GetType() const
151 //#################################
153 //#################################
156 //--------------------------------------------
159 void RegistryValueImpl::SetName(const std::wstring
& NewName
)
164 //--------------------------------------------
167 void RegistryValueImpl::SetValue(const std::wstring
& NewValue
)
170 m_StringData
= NewValue
;
173 //--------------------------------------------
176 void RegistryValueImpl::SetValue(const std::string
& NewValue
)
179 m_StringData
= AnsiToUnicodeString(NewValue
);
182 //--------------------------------------------
185 void RegistryValueImpl::SetValue(int NewValue
)
188 m_IntData
= NewValue
;