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; } } }
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); }
CString ExecuteLispCommand (const CString &sInput) { CString sOutput; CDatum dExpression; if (!CHexeDocument::ParseLispExpression(sInput, &dExpression, &sOutput)) return sOutput; CDatum dResult; CHexeProcess::ERunCodes iRun = g_Process.Run(dExpression, &dResult); switch (iRun) { case CHexeProcess::runOK: case CHexeProcess::runError: return dResult.AsString(); default: return CString("Unable to complete run."); } }
bool CAeonView::CreateSecondaryKeys (CHexeProcess &Process, CDatum dData, SEQUENCENUMBER RowID, TArray<CRowKey> *retKeys) // CreateSecondaryKeys // // Creates a secondary key from the data and rowID. We return TRUE if all of // the key values are non-nil. FALSE if one or more values are nil. { int i; bool bAllValid = true; // Pull the dimensions from the data TArray<CDatum> KeyData; for (i = 0; i < m_Keys.GetCount(); i++) { CDatum dValue; CDatum dKeyDesc = m_Keys[i]; // If this is a function then we need to evaluate it. if (dKeyDesc.CanInvoke()) { TArray<CDatum> Args; Args.Insert(dData); CHexeProcess::ERunCodes iRun = Process.Run(dKeyDesc, Args, &dValue); switch (iRun) { case CHexeProcess::runOK: // dValue is a valid value for a key break; case CHexeProcess::runError: dValue = CDatum(strPattern("(%s)", dValue.AsString())); break; default: dValue = CDatum(STR_ERROR_KEY); } } // Otherwise this specifies a field in the data to use as a key else dValue = dData.GetElement((const CString &)dKeyDesc); // We don't support Nil keys, so we have to replace these with a // a special value. if (dValue.IsNil()) { dValue = CDatum(STR_EMPTY_KEY); // If we're not valid if we're excluding nil keys if (m_bExcludeNil) bAllValid = false; } // Add to list KeyData.Insert(dValue); } // Generate the keys. // If we use list keys then we need to create permuted keys retKeys->DeleteAll(); if (m_bUsesListKeys) CreatePermutedKeys(KeyData, 0, TArray<CDatum>(), RowID, retKeys); // Otherwise we just create the key normally else { CRowKey *pNewKey = retKeys->Insert(); CRowKey::CreateFromDatumAndRowID(m_Dims, KeyData, RowID, pNewKey); } // Done return bAllValid; }