svc_eval.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _SVC_EVAL_H
  2. #define _SVC_EVAL_H
  3. #include <bfc/dispatch.h>
  4. #include <api/service/services.h>
  5. class NOVTABLE svc_evaluator : public Dispatchable {
  6. public:
  7. static FOURCC getServiceType() { return WaSvc::EVALUATOR; }
  8. const char *getEvalType(); // "php", "perl", "math", "xmlgen", etc.
  9. // these are for future optimization -- BU
  10. // void assignVar(const char *name, const char *value);
  11. // const char *getVarValue(const char *name);
  12. // int getVarIndex(const char *name);
  13. // const char *getVarValueByIndex(int pos);
  14. int setEvalString(const char *string, int length, BOOL isBinary);
  15. // free the returned memory with api->sysFree()
  16. const char *evaluate(int *length, BOOL *isBinary);
  17. protected:
  18. enum {
  19. GETEVALTYPE, ASSIGNVAR, GETVARVALUE, GETVARINDEX, GETVARVALUEBYINDEX,
  20. SETEVALSTRING, EVALUATE
  21. };
  22. };
  23. inline
  24. const char *svc_evaluator::getEvalType() {
  25. return _call(GETEVALTYPE, (const char *)NULL);
  26. }
  27. inline
  28. int svc_evaluator::setEvalString(const char *string, int length, BOOL isBinary){
  29. return _call(SETEVALSTRING, FALSE, string, length, isBinary);
  30. }
  31. inline
  32. const char *svc_evaluator::evaluate(int *length, BOOL *isBinary) {
  33. return _call(EVALUATE, (const char *)NULL, length, isBinary);
  34. }
  35. // implementor derives from this one
  36. class NOVTABLE svc_evaluatorI : public svc_evaluator {
  37. public:
  38. virtual const char *getEvalType()=0;
  39. // void assignVar(const char *name, const char *value);
  40. // const char *getVarValue(const char *name);
  41. // int getVarIndex(const char *name);
  42. // const char *getVarValueByIndex(int pos);
  43. // implementor should make a copy of the string (if needed)
  44. virtual int setEvalString(const char *string, int length, BOOL isBinary)=0;
  45. // implementor should alloc returned mem w/ api->sysMalloc()
  46. virtual const char *evaluate(int *length, BOOL *isBinary)=0;
  47. protected:
  48. RECVS_DISPATCH;
  49. };
  50. #endif