本文整理汇总了C++中CDatum::Serialize方法的典型用法代码示例。如果您正苦于以下问题:C++ CDatum::Serialize方法的具体用法?C++ CDatum::Serialize怎么用?C++ CDatum::Serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatum
的用法示例。
在下文中一共展示了CDatum::Serialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetValue
void CAeonRowValue::SetValue (CDatum dValue)
// SetValue
//
// Sets the value of a 0D row
{
CMemoryBuffer Buffer(4096);
dValue.Serialize(CDatum::formatAEONScript, Buffer);
// Allocate a new block
DWORD dwSizeUp = AlignUp(Buffer.GetLength(), (int)sizeof(DWORD));
DWORD dwNewFixedBlockAlloc = sizeof(SItemHeader) + sizeof(SItemHeader) + dwSizeUp;
void *pNewFixedBlock = new char [dwNewFixedBlockAlloc];
// Init
SItemHeader *pHeader = (SItemHeader *)pNewFixedBlock;
pHeader->dwSize = sizeof(SItemHeader) + dwSizeUp;
SItemHeader *pItem = (SItemHeader *)&pHeader[1];
pItem->dwSize = Buffer.GetLength();
utlMemCopy(Buffer.GetPointer(), &pItem[1], Buffer.GetLength());
// Replace
if (m_pFixedBlock && m_dwFixedBlockAlloc)
delete m_pFixedBlock;
m_pFixedBlock = pNewFixedBlock;
m_dwFixedBlockAlloc = dwNewFixedBlockAlloc;
}
示例2: ExecuteScript
int ExecuteScript (const SOptions &Options)
{
int i, j;
// Load the script file
CDatum dScript;
CString sError;
if (!CDatum::CreateFromFile(Options.sScriptFile, CDatum::formatAEONScript, &dScript, &sError))
{
printf("ERROR: %s\n", (LPSTR)sError);
return 1;
}
// Get the server to connect to
CString sServer = dScript.GetElement(FIELD_SERVER);
if (sServer.IsEmpty())
sServer = Options.sServer;
// Connect
CSocket theSocket;
if (!ConnectToArcology(STR_ARC_CONSOLE, sServer, Options, &theSocket))
return 1;
// Run the script
CDatum dCommands = dScript.GetElement(FIELD_COMMANDS);
for (i = 0; i < dCommands.GetCount(); i++)
{
CDatum dCommand = dCommands.GetElement(i);
// Generate a command-line from the command
CStringBuffer Buffer;
for (j = 0; j < dCommand.GetCount(); j++)
{
if (j != 0)
Buffer.Write(" ", 1);
dCommand.Serialize(CDatum::formatAEONScript, Buffer);
}
// Run
printf("%s\n", (LPSTR)(const CString &)Buffer);
CString sResult = ExecuteArcologyCommand(theSocket, Buffer);
PrintUTF8(sResult);
printf("\n");
}
// Done
return 0;
}