当前位置: 首页>>代码示例>>C++>>正文


C++ CDatum类代码示例

本文整理汇总了C++中CDatum的典型用法代码示例。如果您正苦于以下问题:C++ CDatum类的具体用法?C++ CDatum怎么用?C++ CDatum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CDatum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleResult

bool CRunSession::HandleResult (CHexeProcess::ERunCodes iRun, CDatum dResult)

//	HandleResult
//
//	Handles the result from a run

	{
	switch (iRun)
		{
		case CHexeProcess::runOK:
		case CHexeProcess::runError:
			SendMessageReply(MSG_REPLY_DATA, dResult);
			//	FALSE means we're done with the session
			return false;

		case CHexeProcess::runAsyncRequest:
			{
			SendMessageCommand(dResult.GetElement(0), 
					dResult.GetElement(1), 
					GenerateAddress(PORT_HEXE_COMMAND),
					dResult.GetElement(2),
					MESSAGE_TIMEOUT);

			m_iState = stateWaitingForHexarcReply;

			return true;
			}

		default:
			//	LATER:
			SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, CString("LATER"));
			return false;
		}
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:34,代码来源:ExecSession.cpp

示例2:

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));
			}
		}
	}
开发者ID:kronosaur,项目名称:Hexarc,代码行数:27,代码来源:IComplexDatum.cpp

示例3: ValidateAuthDescCreate

bool CCryptosaurEngine::ValidateAuthDescCreate (const SArchonMessage &Msg, const CHexeSecurityCtx *pSecurityCtx, CDatum dAuthDesc)

//	ValidateAuthDescCreate
//
//	Make sure that the authDesc structure has the proper fields for creating
//	a new user (either admin or not).

	{
	if (!strEquals(dAuthDesc.GetElement(FIELD_TYPE), AUTH_TYPE_SHA1))
		{
		SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, strPattern(ERR_INVALID_AUTHDESC_TYPE, dAuthDesc.GetElement(FIELD_TYPE).AsString()), Msg);
		return false;
		}

	if (dAuthDesc.GetElement(FIELD_CREDENTIALS).IsNil())
		{
		SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, ERR_AUTHDESC_CREDENTIALS_REQUIRED, Msg);
		return false;
		}

	if (dAuthDesc.GetElement(FIELD_ACTUAL).IsNil())
		{
		SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, ERR_AUTHDESC_ACTUAL_REQUIRED, Msg);
		return false;
		}

	return true;
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:28,代码来源:CCryptosaurEngine.cpp

示例4: mesage_FieldName

int mesage_FieldName(lua_State* L){
	CMessage* msg = cmessage_arg(L, "mesage_Field");
	int i = luaL_checkint(L, 2);
	CDatum* d = msg->GetDatum(i);
	if (!d) return 0;
	lua_pushstring(L, d->id());
	return 1;
}
开发者ID:mwoz,项目名称:Hildim.Source,代码行数:8,代码来源:mblua.cpp

示例5: mesage_SaveFieldBinary

int mesage_SaveFieldBinary(lua_State* L) {
	int err = 0;
	char *b = NULL;
	CMessage* msg = cmessage_arg(L, "mesage_AddFieldBinary");
	CString fldName = luaL_checkstring(L, 2);
	CString path = luaL_checkstring(L, 3);
	char *description;
	DWORD l;

	CDatum *d = msg->GetDatum(fldName);
	if (d->GetVarType() != (VT_ARRAY | VT_UI1) ) {
		err = -1;
		description = "Not Binary Data";
		goto err;
	}
	{
		l = d->GetDataSize();
		b = new char[l];


		SAFEARRAY* pArray = d->value().parray;
		ASSERT(pArray->cDims == 1); // check we have 1 dimension array
		ASSERT(l == pArray->rgsabound[0].cElements * pArray->cbElements); // get size of array
		memcpy(b, (BYTE*)pArray->pvData, l);

		int charsLen = ::MultiByteToWideChar(CP_UTF8, 0, path, lstrlen(path), NULL, 0);
		std::wstring characters(charsLen, '\0');
		::MultiByteToWideChar(CP_UTF8, 0, path, lstrlen(path), &characters[0], charsLen);

		int pf;

		err = _wsopen_s(&pf, characters.c_str(), _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _SH_DENYRW, _S_IWRITE);
		if (err) {
			description = "Open File Error";
			goto err;
		}
		if (l != _write(pf, (b), l)) {
			err = -2;
			description = "Write File Error";
			goto err;
		}

		err = _close(pf);
		if (err){
			description = "Close File Error";
			goto err;
		}
	}
err:
	if (b)
		delete[]b;
	lua_pushinteger(L, err);
	if (err)
		lua_pushstring(L, description);
	else
		lua_pushinteger(L, l);
	return 2;
}
开发者ID:mwoz,项目名称:Hildim.Source,代码行数:58,代码来源:mblua.cpp

示例6: OnGetSerializeFlags

bool IComplexDatum::DeserializeAEONScript (CDatum::ESerializationFormats iFormat, const CString &sTypename, CCharStream *pStream)

//	DeserializeAEONScript
//
//	Deserialize AEONScript

	{
	int i;
	DWORD dwFlags = OnGetSerializeFlags();

	//	If we have an open brace then we've stored everything as a structure.

	if (pStream->GetChar() == '{')
		{
		//	Object must support this

		if (!(dwFlags & FLAG_SERIALIZE_AS_STRUCT))
			return false;

		//	Parse the structure

		CAEONScriptParser Parser(pStream);
		CDatum dData;
		CAEONScriptParser::ETokens iToken = Parser.ParseToken(&dData);
		if (iToken != CAEONScriptParser::tkDatum)
			return false;

		//	Take all the fields in the structure and apply them to our object
		//	(our descendants will do the right thing).

		for (i = 0; i < dData.GetCount(); i++)
			SetElement(dData.GetKey(i), dData.GetElement(i));
		}

	//	Otherwise we expect base64 encoded data

	else
		{
		//	Backup one character because we want the OnDeserialize call to read it.

		pStream->UnreadChar();

		//	Deserialize

		CBase64Decoder Decoder(pStream->GetByteStream());
		if (!OnDeserialize(iFormat, sTypename, Decoder))
			return false;

		//	Read the next character into the stream 

		pStream->RefreshStream();
		pStream->ReadChar();
		}

	return true;
	}
开发者ID:kronosaur,项目名称:Hexarc,代码行数:56,代码来源:IComplexDatum.cpp

示例7: CDatum

CDatum CEsperEngine::GetPortStatus (void) const

//	GetPortStatus
//
//	Returns a struct with well-known fields for status.

	{
	CDatum dStatus = CDatum(CDatum::typeStruct);
	dStatus.SetElement(FIELD_CLASS, STR_ESPER_ENGINE);
	dStatus.SetElement(FIELD_STATUS, NULL_STR);

	return dStatus;
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:13,代码来源:CEsperEngine.cpp

示例8: 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;
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:56,代码来源:AI1.cpp

示例9: mesage_FieldType

int mesage_FieldType(lua_State* L){
	CString type = luaL_typename(L, 2);
	CMessage* msg = cmessage_arg(L, "mesage_Field");
	CDatum* d;
	if (type == "string")
		d = msg->GetDatum(luaL_checkstring(L, 2));
	else
		d = msg->GetDatum(luaL_checkint(L, 2));

	if (!d) return 0;	 
	lua_pushstring(L, d->GetVarTypeText());
	return 1;

}
开发者ID:mwoz,项目名称:Hildim.Source,代码行数:14,代码来源:mblua.cpp

示例10: 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));
		}
	}
开发者ID:kronosaur,项目名称:Hexarc,代码行数:15,代码来源:IComplexDatum.cpp

示例11: Buffer

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;
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:33,代码来源:CAeonRowValue.cpp

示例12: if

void CAeonView::CreateSecondaryData (const CTableDimensions &PrimaryDims, const CRowKey &PrimaryKey, CDatum dFullData, SEQUENCENUMBER RowID, CDatum *retdData)

//	CreateSecondaryData
//
//	Creates the data for a secondary view row.

	{
	int i, j;
	CComplexStruct *pData = new CComplexStruct;

	//	If the list of columns is empty then we just add the primary key

	if (m_Columns.GetCount() == 0)
		pData->SetElement(FIELD_PRIMARY_KEY, PrimaryKey.AsDatum(PrimaryDims));

	//	Otherwise we add all the fields listed in the columns array

	else
		{
		for (i = 0; i < m_Columns.GetCount(); i++)
			{
			//	The special string "primaryKey" means that we insert the 
			//	primary key as a special field.

			if (strEquals(m_Columns[i], FIELD_PRIMARY_KEY))
				pData->SetElement(FIELD_PRIMARY_KEY, PrimaryKey.AsDatum(PrimaryDims));

			//	The special string "*" means that we insert all existing
			//	fields.

			else if (strEquals(m_Columns[i], STR_ALL_COLUMNS))
				{
				for (j = 0; j < dFullData.GetCount(); j++)
					{
					CDatum dKey = dFullData.GetKey(j);
					CDatum dValue = dFullData.GetElement(j);

					if (!dValue.IsNil())
						pData->SetElement(dKey, dValue);
					}
				}

			//	Add the field by name.

			else
				{
				CDatum dColData = dFullData.GetElement(m_Columns[i]);
				if (!dColData.IsNil())
					pData->SetElement(m_Columns[i], dColData);
				}
			}
		}

	//	Done

	*retdData = CDatum(pData);
	}
开发者ID:kronosaur,项目名称:Hexarc,代码行数:57,代码来源:CAeonView.cpp

示例13: SendMessageReplyError

void CAeonEngine::MsgCreateTable (const SArchonMessage &Msg, const CHexeSecurityCtx *pSecurityCtx)

//	MsgCreateTable
//
//	Aeon.createTable {tableDesc}
//
//	{tableDesc} = { name:MyTable1 type:standard x:{keyType:utf8} y:{keyType:int32} z:{keyType:dateTime} }

	{
	CString sError;

	//	Get the table desc and table name

	CDatum dTableDesc = Msg.dPayload.GetElement(0);
	const CString &sTable = dTableDesc.GetElement(FIELD_NAME);

	//	Make sure we are allowed access to this table

	if (!ValidateTableAccess(Msg, pSecurityCtx, sTable))
		return;

	//	See if the table descriptor specifies storage volumes; if so, then we
	//	make sure that the calling service has admin rights.

	if (!dTableDesc.GetElement(FIELD_PRIMARY_VOLUME).IsNil()
			|| !dTableDesc.GetElement(FIELD_BACKUP_VOLUMES).IsNil())
		{
		if (!ValidateAdminAccess(Msg, pSecurityCtx))
			return;
		}

	//	Create

	bool bExists;
	if (!CreateTable(dTableDesc, NULL, &bExists, &sError))
		{
		if (bExists)
			SendMessageReplyError(MSG_ERROR_ALREADY_EXISTS, sError, Msg);
		else
			SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, sError, Msg);
		return;
		}

	//	Done

	SendMessageReply(MSG_OK, CDatum(), Msg);
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:47,代码来源:CAeonEngine.cpp

示例14: switch

CDatum CAeonView::ComputeColumns (CHexeProcess &Process, CDatum dRowData)

//	ComputeColumns
//
//	Returns a new row struct containing any computed columns.

	{
	if (m_ComputedColumns.IsNil() || !m_ComputedColumns.CanInvoke())
		return dRowData;

	//	Compute columns. We should get back a struct of all new columns.

	TArray<CDatum> Args;
	Args.Insert(dRowData);

	CDatum dResult;
	CHexeProcess::ERunCodes iRun = Process.Run(m_ComputedColumns, Args, &dResult);

	switch (iRun)
		{
		case CHexeProcess::runOK:
			{
			//	dResult is a struct containing zero or more columns

			CDatum dNewRowData(new CComplexStruct(dRowData));
			dNewRowData.Append(dResult);
			return dNewRowData;
			}

		case CHexeProcess::runError:
			{
			CDatum dNewRowData(new CComplexStruct(dRowData));
			dNewRowData.SetElement(FIELD_ERROR, strPattern("ERROR: %s", dResult.AsString()));
			return dNewRowData;
			}

		default:
			{
			CDatum dNewRowData(new CComplexStruct(dRowData));
			dNewRowData.SetElement(FIELD_ERROR, ERR_COMPUTED_COLUMN);
			return dNewRowData;
			}
		}
	}
开发者ID:kronosaur,项目名称:Hexarc,代码行数:44,代码来源:CAeonView.cpp

示例15: SendMessageReplyError

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);
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:43,代码来源:ExecSession.cpp


注:本文中的CDatum类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。