Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/shared/Utils.cpp

Issue 29332484: Noissue - Add conversion function from 'BSTR' to 'std::wstring' (Closed)
Patch Set: Created Dec. 9, 2015, 1:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/shared/Utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/shared/Utils.cpp
===================================================================
--- a/src/shared/Utils.cpp
+++ b/src/shared/Utils.cpp
@@ -53,6 +53,16 @@
return (osvi->dwMajorVersion == 6 && osvi->dwMinorVersion >= 2) || osvi->dwMajorVersion > 6;
}
+std::wstring ToWstring(const BSTR b)
+{
+ if (!b)
+ {
+ // A null BSTR pointer is considered semantically equal to the zero-length string.
+ return std::wstring();
+ }
+ return std::wstring(b, ::SysStringLen(b));
+}
+
std::string ToUtf8String(const std::wstring& str)
{
int length = static_cast<int>(str.size());
« no previous file with comments | « src/shared/Utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld