本文整理汇总了C++中COpcString::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ COpcString::IsEmpty方法的具体用法?C++ COpcString::IsEmpty怎么用?C++ COpcString::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COpcString
的用法示例。
在下文中一共展示了COpcString::IsEmpty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
// Save
bool COpcXmlDocument::Save(const COpcString& cFilePath)
{
HRESULT hResult = S_OK;
VARIANT varFile;
varFile.vt = VT_BSTR;
varFile.bstrVal = SysAllocString((LPCWSTR)((cFilePath.IsEmpty())?m_cFilePath:cFilePath));
TRY
{
// save the file.
hResult = m_ipDocument->save(varFile);
if (FAILED(hResult))
{
THROW();
}
}
CATCH_FINALLY
{
OpcVariantClear(&varFile);
}
return SUCCEEDED(hResult);
}
示例2: AddNamespace
// AddNamespace
bool COpcXmlDocument::AddNamespace(const COpcString& cPrefix, const COpcString& cNamespace)
{
// check for a valid root element.
COpcXmlElement cElement(GetRoot());
if (cElement == NULL)
{
return false;
}
// check for an invalid prefix
if (cPrefix.IsEmpty())
{
return false;
}
// construct the new namespace attribute name.
COpcString cAttributeName;
cAttributeName += OPCXML_NAMESPACE_ATTRIBUTE;
cAttributeName += ":";
cAttributeName += cPrefix;
// add or update the namespace string.
cElement.SetAttribute(cAttributeName, cNamespace);
return true;
}
示例3: GetNamespaces
// GetNamespaces
void COpcXmlDocument::GetNamespaces(COpcStringMap& cNamespaces)
{
// clear the current set.
cNamespaces.RemoveAll();
// check for a valid root element.
COpcXmlElement cElement(GetRoot());
if (cElement == NULL)
{
return;
}
// add the namespace for the root element.
COpcString cPrefix = cElement.GetPrefix();
if (!cPrefix.IsEmpty())
{
cNamespaces[cPrefix] = cElement.GetNamespace();
}
// fetch the attributes from the root element.
COpcXmlAttributeList cAttributes;
if (cElement.GetAttributes(cAttributes) > 0)
{
for (UINT ii = 0; ii < cAttributes.GetSize(); ii++)
{
if (cAttributes[ii].GetPrefix() == OPCXML_NAMESPACE_ATTRIBUTE)
{
COpcString cName = cAttributes[ii].GetQualifiedName().GetName();
// don't add the default namespace.
if (!cName.IsEmpty())
{
cNamespaces[cName] = cAttributes[ii].GetValue();
}
}
}
}
}
示例4: wcsncpy
COpcTextReader::COpcTextReader(const COpcString& cBuffer)
:
m_szBuf(NULL),
m_uLength(0),
m_uEndOfData(0)
{
if (!cBuffer.IsEmpty())
{
LPCWSTR szBuf = (COpcString&)cBuffer;
m_uLength = (szBuf != NULL)?wcslen(szBuf):0;
m_szBuf = (WCHAR*)OpcAlloc((m_uLength+1)*sizeof(WCHAR));
wcsncpy(m_szBuf, szBuf, m_uLength);
m_uEndOfData = m_uLength;
m_szBuf[m_uEndOfData] = L'\0';
}
}
示例5: GetItemID
// GetItemID
COpcString COpcBrowseElement::GetItemID() const
{
if (m_cItemID.IsEmpty())
{
COpcString cItemID;
if (m_pParent != NULL)
{
cItemID += m_pParent->GetItemID();
if (!cItemID.IsEmpty())
{
cItemID += m_pParent->GetSeparator();
}
}
cItemID += m_cName;
return cItemID;
}
return m_cItemID;
}
示例6: cReader
// Read
template<> bool OpcXml::Read(const COpcString& cString, DateTime& cValue)
{
bool bResult = true;
FILETIME cFileTime;
// check for invalid date.
if (cString.IsEmpty())
{
cValue = OpcMinDate();
return true;
}
TRY
{
SYSTEMTIME cSystemTime; ZeroMemory(&cSystemTime, sizeof(cSystemTime));
COpcText cText;
COpcTextReader cReader(cString);
// parse date fields.
cText.SetType(COpcText::Delimited);
cText.SetDelims(L"T");
if (!cReader.GetNext(cText)) THROW_(bResult, false);
if (!ToDate(cText, cSystemTime.wYear, cSystemTime.wMonth, cSystemTime.wDay))
{
THROW_(bResult, false);
}
// parse time fields.
cText.SetType(COpcText::Delimited);
cText.SetDelims(L"Z-+");
cText.SetEofDelim();
if (!cReader.GetNext(cText)) THROW_(bResult, false);
bResult = ToTime(
cText,
cSystemTime.wHour,
cSystemTime.wMinute,
cSystemTime.wSecond,
cSystemTime.wMilliseconds);
if (!bResult)
{
THROW_(bResult, false);
}
// convert to a UTC file time.
if (!SystemTimeToFileTime(&cSystemTime, &cFileTime))
{
THROW_(bResult, false);
}
if (cText.GetDelimChar() != _T('Z'))
{
// convert local system time to UTC file time.
if (cText.GetEof())
{
FILETIME ftUtcTime;
if (!OpcLocalTimeToUtcTime(cFileTime, ftUtcTime))
{
THROW_(bResult, false);
}
cFileTime = ftUtcTime;
}
// apply offset specified in the datetime string.
else
{
bool bNegative = (cText.GetDelimChar() == _T('-'));
// parse time fields.
cText.SetType(COpcText::Delimited);
cText.SetEofDelim();
if (!cReader.GetNext(cText)) THROW_(bResult, false);
SHORT sMinutes = 0;
bResult = ToOffset(
cText,
bNegative,
sMinutes);
if (!bResult)
{
THROW_(bResult, false);
}
// apply timezone offset.
LONGLONG llTime = OpcToInt64(cFileTime);
llTime -= ((LONGLONG)sMinutes)*60*10000000;
//.........这里部分代码省略.........
示例7: Load
// Load
bool COpcXmlDocument::Load(const COpcString& cFilePath)
{
HRESULT hResult = S_OK;
VARIANT varFile;
varFile.vt = VT_BSTR;
varFile.bstrVal = SysAllocString((LPCWSTR)cFilePath);
TRY
{
// create new document instance.
if (!Init())
{
THROW_(hResult, E_FAIL);
}
// load the file.
VARIANT_BOOL bResult = VARIANT_FALSE;
hResult = m_ipDocument->load(varFile, &bResult);
if (FAILED(hResult))
{
THROW();
}
if (!bResult)
{
IXMLDOMParseError* ipError = NULL;
hResult = m_ipDocument->get_parseError(&ipError);
if (FAILED(hResult))
{
THROW_(hResult, E_FAIL);
}
BSTR bstrReason = NULL;
hResult = ipError->get_reason(&bstrReason);
if (SUCCEEDED(hResult))
{
SysFreeString(bstrReason);
}
ipError->Release();
}
// update default path.
if (!cFilePath.IsEmpty()) m_cFilePath = cFilePath;
}
CATCH
{
Clear();
}
FINALLY
{
OpcVariantClear(&varFile);
}
return SUCCEEDED(hResult);
}
示例8: Insert
// Insert
COpcBrowseElement* COpcBrowseElement::Insert(const COpcString& cPath)
{
COpcString cName = cPath;
COpcString cSubPath = OPC_EMPTY_STRING;
// check if multiple levels have been specified.
do
{
UINT uIndex = cName.Find(GetSeparator());
if (uIndex == -1)
{
break;
}
cSubPath = cName.SubStr(uIndex + GetSeparator().GetLength());
cName = cName.SubStr(0, uIndex);
if (!cName.IsEmpty())
{
break;
}
cName = cSubPath;
}
while (!cSubPath.IsEmpty());
// invalid path specified.
if (cName.IsEmpty())
{
return NULL;
}
// find out if node already exists.
COpcBrowseElement* pNode = NULL;
OPC_POS pos = m_cChildren.GetHeadPosition();
while (pos != NULL)
{
pNode = m_cChildren.GetNext(pos);
if (pNode->m_cName == cName)
{
// return existing node.
if (cSubPath.IsEmpty())
{
return pNode;
}
// insert sub-path into existing node.
return pNode->Insert(cSubPath);
}
}
// create new node.
pNode = CreateInstance();
pNode->m_cName = cName;
OPC_ASSERT(!pNode->m_cName.IsEmpty());
COpcBrowseElement* pChild = pNode;
if (!cSubPath.IsEmpty())
{
pChild = pNode->Insert(cSubPath);
if (pChild == NULL)
{
delete pNode;
return NULL;
}
}
m_cChildren.AddTail(pNode);
return pChild;
}