Files
Slnkdwf/ATL90/source/SProxy/Util.h
Jos Groot Lipman 0e37d774d2 Merge SLNKDWF64 branch
svn path=/Slnkdwf/trunk/; revision=23911
2015-01-21 12:09:31 +00:00

78 lines
1.2 KiB
C

//
// Util.h
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#pragma once
#include "stdafx.h"
HRESULT GetAttribute(
ISAXAttributes *pAttributes,
const wchar_t *wszAttrName, int cchName,
const wchar_t **pwszValue, int *pcchValue,
wchar_t *wszNamespace = NULL, int cchNamespace = 0);
HRESULT GetAttribute(
ISAXAttributes *pAttributes,
const wchar_t *wszAttrName, int cchName,
CStringW &strValue,
wchar_t *wszNamespace = NULL, int cchNamespace = 0);
inline HRESULT GetBooleanValue(bool *pbOut, const wchar_t *wsz, int cch)
{
if (pbOut == NULL)
{
return E_POINTER;
}
if (wsz == NULL)
{
return E_INVALIDARG;
}
HRESULT hr = E_FAIL;
switch (wsz[0])
{
case L'1':
{
if (cch == 1)
{
*pbOut = true;
hr = S_OK;
}
break;
}
case L'0':
{
if (cch == 1)
{
*pbOut = false;
hr = S_OK;
}
break;
}
case L't':
{
if ((cch==sizeof("true")-1) && (!wcsncmp(wsz, L"true", cch)))
{
*pbOut = true;
hr = S_OK;
}
break;
}
case L'f':
{
if ((cch==sizeof("false")-1) && (!wcsncmp(wsz, L"false", cch)))
{
*pbOut = false;
hr = S_OK;
}
break;
}
}
return hr;
}