本文整理汇总了C++中CDatum::GetBasicType方法的典型用法代码示例。如果您正苦于以下问题:C++ CDatum::GetBasicType方法的具体用法?C++ CDatum::GetBasicType怎么用?C++ CDatum::GetBasicType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatum
的用法示例。
在下文中一共展示了CDatum::GetBasicType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CComplexArray::CComplexArray (CDatum dSrc)
// ComplexArray constructor
{
int i;
if (dSrc.GetBasicType() == CDatum::typeStruct)
{
InsertEmpty(1);
SetElement(0, dSrc);
}
else
{
int iCount = dSrc.GetCount();
// Clone from another complex array
if (iCount > 0)
{
InsertEmpty(iCount);
for (i = 0; i < iCount; i++)
SetElement(i, dSrc.GetElement(i));
}
}
}
示例2: IsEqual
bool CDatum::IsEqual (CDatum dValue) const
// IsEqual
//
// Returns TRUE if the values are equal
{
switch (GetBasicType())
{
case typeNil:
return dValue.IsNil();
case typeTrue:
return !dValue.IsNil();
case typeInteger32:
case typeInteger64:
case typeIntegerIP:
case typeDouble:
return (dValue.IsNumber() && CNumberValue(*this).Compare(dValue) == 0);
case typeString:
return (dValue.GetBasicType() == typeString && strEquals(*this, dValue));
case typeDateTime:
return (dValue.GetBasicType() == typeDateTime && ((const CDateTime &)*this == (const CDateTime &)dValue));
// LATER
case typeArray:
case typeBinary:
case typeStruct:
case typeSymbol:
return false;
default:
ASSERT(false);
return false;
}
}
示例3: AppendStruct
void CComplexStruct::AppendStruct (CDatum dDatum)
// AppendStruct
//
// Appends the element of the given structure
{
int i;
if (dDatum.GetBasicType() == CDatum::typeStruct)
{
for (i = 0; i < dDatum.GetCount(); i++)
SetElement(dDatum.GetKey(i), dDatum.GetElement(i));
}
}
示例4: OnStartSession
bool CRunSession::OnStartSession (const SArchonMessage &Msg, DWORD dwTicket)
// OnStartSession
//
// Start the session
{
CDatum dCode = Msg.dPayload.GetElement(0);
// Initialize the process
m_Process.LoadLibrary(LIBRARY_CORE);
// Parse into an expression (depending on the type of input)
CDatum dExpression;
if (dCode.GetBasicType() == CDatum::typeString)
{
CString sError;
if (!CHexeDocument::ParseLispExpression(dCode, &dExpression, &sError))
{
SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, strPattern(ERR_COMPILER, sError));
return false;
}
}
// Otherwise we don't know how to parse the input
else
{
SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, ERR_UNABLE_TO_PARSE_CODE);
return false;
}
// Run the code
CDatum dResult;
CHexeProcess::ERunCodes iRun = m_Process.Run(dExpression, &dResult);
// Deal with the result
return HandleResult(iRun, dResult);
}
示例5: OutputDatum
void CHexeMarkupEvaluator::OutputDatum (CDatum dValue)
// OutputDatum
//
// Outputs a datum to the resulting HTML page. NOTE: We expect the values to be
// HTML compatible (i.e., caller is responsible for escaping).
{
int i;
if (dValue.GetBasicType() == CDatum::typeArray)
{
for (i = 0; i < dValue.GetCount(); i++)
OutputDatum(dValue.GetElement(i));
}
else
{
m_Output.Write(dValue.AsString());
}
}
示例6: AddHeader
void CHexeMarkupEvaluator::AddHeader (const CString &sField, CDatum dValue)
// AddHeader
//
// Adds the header
{
CHTTPMessage::SHeader *pNewHeader;
switch (dValue.GetBasicType())
{
case CDatum::typeString:
pNewHeader = m_Headers.Insert();
pNewHeader->sField = sField;
pNewHeader->sValue = dValue;
break;
default:
pNewHeader = m_Headers.Insert();
pNewHeader->sField = sField;
pNewHeader->sValue = dValue.AsString();
}
}
示例7: ProcessHeader
bool CHexeMarkupEvaluator::ProcessHeader (SHTTPRequestCtx &Ctx, CDatum dResult)
// ProcessHeader
//
// Outputs the given header
{
// Check for error
if (dResult.IsError())
{
m_Output.Write(strPattern(ERR_PROCESSING_HEADER, dResult.AsString()));
return true;
}
// Processing depends on result type
switch (dResult.GetBasicType())
{
case CDatum::typeNil:
return true;
// If this is a string or anything else, we expect both field and value
// are in the same string and we need to parse it.
default:
{
CString sData = dResult.AsString();
// Parse into field and value
char *pPos = sData.GetParsePointer();
while (strIsWhitespace(pPos))
pPos++;
// Look for the field name
char *pStart = pPos;
while (*pPos != ':' && *pPos != '\0')
pPos++;
CString sField(pStart, pPos - pStart);
if (sField.IsEmpty())
{
m_Output.Write(strPattern(ERR_NO_HEADER_FIELD, sData));
return true;
}
// Look for the value
CString sValue;
if (*pPos == ':')
{
pPos++;
while (strIsWhitespace(pPos))
pPos++;
sValue = CString(pPos);
}
// Done
CHTTPMessage::SHeader *pNewHeader = m_Headers.Insert();
pNewHeader->sField = sField;
pNewHeader->sValue = sValue;
}
}
return true;
}
示例8: DefaultCompare
int CDatum::DefaultCompare (void *pCtx, const CDatum &dKey1, const CDatum &dKey2)
// DefaultCompare
//
// Default comparison routine used for sorting. Returns:
//
// -1: If dKey1 < dKey2
// 0: If dKey1 == dKey2
// 1: If dKey1 > dKey2
//
// NOTES:
//
// Nil == ""
// Nil == {}
// Nil == ()
// "abc" != "ABC"
{
int i;
// If both are the same datatype, then compare
CDatum::Types iType1 = dKey1.GetBasicType();
CDatum::Types iType2 = dKey2.GetBasicType();
// If both types are equal, then compare
if (iType1 == iType2)
{
switch (iType1)
{
case CDatum::typeNil:
case CDatum::typeTrue:
return 0;
case CDatum::typeInteger32:
if ((int)dKey1 > (int)dKey2)
return 1;
else if ((int)dKey1 < (int)dKey2)
return -1;
else
return 0;
case CDatum::typeInteger64:
if ((DWORDLONG)dKey1 > (DWORDLONG)dKey2)
return 1;
else if ((DWORDLONG)dKey1 < (DWORDLONG)dKey2)
return -1;
else
return 0;
case CDatum::typeDouble:
if ((double)dKey1 > (double)dKey2)
return 1;
else if ((double)dKey1 < (double)dKey2)
return -1;
else
return 0;
case CDatum::typeIntegerIP:
return KeyCompare((const CIPInteger &)dKey1, (const CIPInteger &)dKey2);
case CDatum::typeString:
return KeyCompare((const CString &)dKey1, (const CString &)dKey2);
case CDatum::typeDateTime:
return ((const CDateTime &)dKey1).Compare((const CDateTime &)dKey2);
case CDatum::typeArray:
if (dKey1.GetCount() > dKey2.GetCount())
return 1;
else if (dKey1.GetCount() < dKey2.GetCount())
return -1;
else
{
for (i = 0; i < dKey1.GetCount(); i++)
{
CDatum dItem1 = dKey1.GetElement(i);
CDatum dItem2 = dKey2.GetElement(i);
int iItemCompare = CDatum::DefaultCompare(pCtx, dItem1, dItem2);
if (iItemCompare != 0)
return iItemCompare;
}
return 0;
}
case CDatum::typeStruct:
if (dKey1.GetCount() > dKey2.GetCount())
return 1;
else if (dKey1.GetCount() < dKey2.GetCount())
return -1;
else
{
for (i = 0; i < dKey1.GetCount(); i++)
{
CString sItemKey1 = dKey1.GetKey(i);
CString sItemKey2 = dKey2.GetKey(i);
int iKeyCompare = KeyCompare(sItemKey1, sItemKey2);
if (iKeyCompare != 0)
//.........这里部分代码省略.........