📄 amzi.h
字号:
}
inline TF CLogicServer::CallStr(TERMptr tp, aCHAR* s)
{
TF tf = lsCallStr(m_eng, tp, s);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
inline TF CLogicServer::Redo(void)
{
TF tf = lsRedo(m_eng);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
inline TF CLogicServer::ClearCall(void)
{
TF tf = lsClearCall(m_eng);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
// Asserting and retracting
inline void CLogicServer::Asserta(TERM t)
{
RC rc = lsAsserta(m_eng, t);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::Assertz(TERM t)
{
RC rc = lsAssertz(m_eng, t);
if (rc) throw CLSException(m_eng);
}
inline TF CLogicServer::Retract(TERM t)
{
TF tf = lsRetract(m_eng, t);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
inline void CLogicServer::AssertaStr(aCHAR* s)
{
RC rc = lsAssertaStr(m_eng, s);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::AssertzStr(aCHAR* s)
{
RC rc = lsAssertzStr(m_eng, s);
if (rc) throw CLSException(m_eng);
}
inline TF CLogicServer::RetractStr(aCHAR* s)
{
TF tf = lsRetractStr(m_eng, s);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
// String/Term conversion functions
inline void CLogicServer::TermToStr(TERM t, aCHAR* s, int i)
{
RC rc = lsTermToStr(m_eng, t, s, i);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::TermToStrQ(TERM t, aCHAR* s, int i)
{
RC rc = lsTermToStrQ(m_eng, t, s, i);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::StrToTerm(TERMptr tp, aCHAR* s)
{
RC rc = lsStrToTerm(m_eng, tp, s);
if (rc) throw CLSException(m_eng);
}
// Making Prolog types
inline void CLogicServer::MakeAtom(TERMptr tp, aCHAR* s)
{
RC rc = lsMakeAtom(m_eng, tp, s);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::MakeStr(TERMptr tp, aCHAR* s)
{
RC rc = lsMakeStr(m_eng, tp, s);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::MakeInt(TERMptr tp, intC i)
{
RC rc = lsMakeInt(m_eng, tp, i);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::MakeFloat(TERMptr tp, double f)
{
RC rc = lsMakeFloat(m_eng, tp, f);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::MakeAddr(TERMptr tp, VOIDptr vp)
{
RC rc = lsMakeAddr(m_eng, tp, vp);
if (rc) throw CLSException(m_eng);
}
// Getting C values from Prolog terms
inline pTYPE CLogicServer::GetTermType(TERM t)
{
pTYPE pT = lsGetTermType(m_eng, t);
if (pT == pERR)
throw CLSException(m_eng);
return pT;
}
inline void CLogicServer::GetTerm(TERM t, cTYPE ct, VOIDptr vp)
{
RC rc = lsGetTerm(m_eng, t, ct, vp);
if (rc) throw CLSException(m_eng);
}
inline int CLogicServer::StrTermLen(TERM t)
{
int len = lsStrTermLen(m_eng, t);
if (len == NOTOK)
throw CLSException(m_eng);
return len;
}
// Structure hacking functions
inline void CLogicServer::GetFA(TERM t, aCHAR* s, ARITYptr ap)
{
RC rc = lsGetFA(m_eng, t, s, ap);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::MakeFA(TERMptr tp, aCHAR* s, ARITY a)
{
RC rc = lsMakeFA(m_eng, tp, s, a);
if (rc) throw CLSException(m_eng);
}
inline TF CLogicServer::UnifyArg(TERMptr tp, int i, cTYPE ct, VOIDptr vp)
{
TF tf = lsUnifyArg(m_eng, tp, i, ct, vp);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
inline void CLogicServer::GetArg(TERM t, int i, cTYPE ct, VOIDptr vp)
{
RC rc = lsGetArg(m_eng, t, i, ct, vp);
if (rc) throw CLSException(m_eng);
}
inline pTYPE CLogicServer::GetArgType(TERM t, int i)
{
pTYPE pT = lsGetArgType(m_eng, t, i);
if (pT == pERR)
throw CLSException(m_eng);
return pT;
}
inline int CLogicServer::StrArgLen(TERM t, int i)
{
int len = lsStrArgLen(m_eng, t, i);
if (len == NOTOK)
throw CLSException(m_eng);
return len;
}
inline TF CLogicServer::Unify(TERM t1, TERM t2)
{
TF tf = lsUnify(m_eng, t1, t2);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
// List hacking functions
inline void CLogicServer::MakeList(TERMptr tp)
{
RC rc = lsMakeList(m_eng, tp);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::PushList(TERMptr tp, TERM t)
{
RC rc = lsPushList(m_eng, tp, t);
if (rc) throw CLSException(m_eng);
}
inline RC CLogicServer::PopList(TERMptr tp, cTYPE ct, VOIDptr vp)
{
RC rc = lsPopList(m_eng, tp, ct, vp);
if (rc != OK && rc != NOTOK)
throw CLSException(m_eng);
return rc;
}
inline RC CLogicServer::GetHead(TERM t, cTYPE ct, VOIDptr vp)
{
RC rc = lsGetHead(m_eng, t, ct, vp);
if (rc != OK && rc != NOTOK)
throw CLSException(m_eng);
return rc;
}
inline TERM CLogicServer::GetTail(TERM t)
{
TERM tTail = lsGetTail(m_eng, t);
if (tTail == NULL)
throw CLSException(m_eng);
return tTail;
}
// Stream I/O functions
inline void CLogicServer::SetStream(STREAM st, int i)
{
RC rc = lsSetStream(m_eng, st, i);
if (rc) throw CLSException(m_eng);
}
inline int CLogicServer::GetStream(STREAM st)
{
int iStr = lsGetStream(m_eng, st);
if (iStr == NOTOK)
throw CLSException(m_eng);
return iStr;
}
inline void CLogicServer::SetInput(pX_GETC vfgetc, pX_UNGETC vfunget)
{
RC rc = lsSetInput(m_eng, vfgetc, vfunget);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::SetOutput(pX_PUTC vfputc, pX_PUTS vfputs)
{
RC rc = lsSetOutput(m_eng, vfputc, vfputs);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::SetIOArg(VOIDptr vp)
{
RC rc = lsSetIOArg(m_eng, vp);
if (rc) throw CLSException(m_eng);
}
// Miscellaneous functions
inline void CLogicServer::GetVersion(aCHAR* s)
{
RC rc = lsGetVersion(m_eng, s);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::SetCommandArgs(int pargc, aCHAR** pargv)
{
RC rc = lsSetCommandArgs(m_eng, pargc, pargv);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::ErrRaise(aCHAR* s)
{
lsErrRaise(m_eng, s);
return;
}
// For Unicode build, here are single byte equivalents
#ifdef _UNICODE
inline CLogicServer::CLogicServer(char * ininame)
{
RC rc = lsInitA(&m_eng, ininame);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::Init(char * ininame)
{
RC rc = lsInitA(&m_eng, ininame);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::Init2(char * inistring)
{
RC rc = lsInit2A(&m_eng, inistring);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::AddLSX(char* s, void * vp)
{
RC rc = lsAddLSXA(m_eng, s, vp);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::AddLSX(char* s)
{
RC rc = lsAddLSXA(m_eng, s, NULL);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::AddPred(char* s, ARITY a, ExtPred f, VOIDptr v)
{
RC rc = lsAddPredA(m_eng, s, a, f, v);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::InitPreds(PRED_INITAptr preds)
{
RC rc = lsInitPredsA(m_eng, preds);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::Load(char *xplname)
{
RC rc = lsLoadA(m_eng, xplname);
if (rc) throw CLSException(m_eng);
}
inline TF CLogicServer::ExecStr(TERMptr tp, char* s)
{
TF tf = lsExecStrA(m_eng, tp, s);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
inline TF CLogicServer::CallStr(TERMptr tp, char* s)
{
TF tf = lsCallStrA(m_eng, tp, s);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
inline void CLogicServer::AssertaStr(char* s)
{
RC rc = lsAssertaStrA(m_eng, s);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::AssertzStr(char* s)
{
RC rc = lsAssertzStrA(m_eng, s);
if (rc) throw CLSException(m_eng);
}
inline TF CLogicServer::RetractStr(char* s)
{
TF tf = lsRetractStrA(m_eng, s);
if (tf != TRUE && tf != FALSE)
throw CLSException(m_eng);
return tf;
}
inline void CLogicServer::TermToStr(TERM t, char* s, int i)
{
RC rc = lsTermToStrA(m_eng, t, s, i);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::TermToStrQ(TERM t, char* s, int i)
{
RC rc = lsTermToStrQA(m_eng, t, s, i);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::StrToTerm(TERMptr tp, char* s)
{
RC rc = lsStrToTermA(m_eng, tp, s);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::MakeAtom(TERMptr tp, char* s)
{
RC rc = lsMakeAtomA(m_eng, tp, s);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::MakeStr(TERMptr tp, char* s)
{
RC rc = lsMakeStrA(m_eng, tp, s);
if (rc) throw CLSException(m_eng);
}
#define MAX_FUNCTOR 1000
inline void CLogicServer::GetFA(TERM t, char* s, ARITYptr ap)
{
RC rc = lsGetFAA(m_eng, t, s, ap);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::MakeFA(TERMptr tp, char* s, ARITY a)
{
RC rc = lsMakeFAA(m_eng, tp, s, a);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::SetOutput(pX_PUTC vfputc, pX_PUTSA vfputs)
{
RC rc = lsSetOutputA(m_eng, vfputc, vfputs);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::GetVersion(char* s)
{
RC rc = lsGetVersionA(m_eng, s);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::SetCommandArgs(int pargc, char** pargv)
{
RC rc = lsSetCommandArgsA(m_eng, pargc, pargv);
if (rc) throw CLSException(m_eng);
}
inline void CLogicServer::ErrRaise(char* s)
{
lsErrRaiseA(m_eng, s);
return;
}
#endif //_UNICODE
/*--------------------------------*/
/* CLSException implementation */
/* */
inline int CLSException::GetRC()
{
return lsGetExceptRC(m_eng);
}
inline void CLSException::GetMsg(aCHAR* msg, int len)
{
lsGetExceptMsg(m_eng, msg, len);
}
inline ExType CLSException::GetType()
{
return lsGetExceptType(m_eng);
}
inline void CLSException::GetReadFileName(aCHAR* name, int len)
{
//lsGetExceptReadFileName(m_eng, name, len);
}
inline void CLSException::GetReadBuffer(aCHAR* buf, int len)
{
lsGetExceptReadBuffer(m_eng, buf, len);
}
inline void CLSException::GetCallStack(aCHAR* cs, int len)
{
lsGetExceptCallStack(m_eng, cs, len);
}
inline intC CLSException::GetReadLineno()
{
return lsGetExceptLineno(m_eng);
}
#ifdef _UNICODE
inline void CLSException::GetMsg(char* msg, int len)
{
lsGetExceptMsgA(m_eng, msg, len);
}
inline void CLSException::GetReadFileName(char* name, int len)
{
lsGetExceptReadFileNameA(m_eng, name, len);
}
inline void CLSException::GetReadBuffer(char* buf, int len)
{
lsGetExceptReadBufferA(m_eng, buf, len);
}
inline void CLSException::GetCallStack(char* cs, int len)
{
lsGetExceptCallStackA(m_eng, cs, len);
}
#endif // _UNICODE
#endif /* MSC vs. non MSC C++ definitions */
#endif /* __cplusplus */
#endif /* LOGIC_SERVER_DEFINED */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -