aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/service/svcs/svc_eval.h
blob: d198c1d1d0f72e4d5576c54f318e1e50d692d39a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _SVC_EVAL_H
#define _SVC_EVAL_H

#include <bfc/dispatch.h>
#include <api/service/services.h>

class NOVTABLE svc_evaluator : public Dispatchable {
public:
  static FOURCC getServiceType() { return WaSvc::EVALUATOR; }

  const char *getEvalType();	// "php", "perl", "math", "xmlgen", etc.

// these are for future optimization -- BU
  //  void assignVar(const char *name, const char *value);
  //  const char *getVarValue(const char *name);
  //  int getVarIndex(const char *name);
  //  const char *getVarValueByIndex(int pos);

  int setEvalString(const char *string, int length, BOOL isBinary);
  // free the returned memory with api->sysFree()
  const char *evaluate(int *length, BOOL *isBinary);

protected:
  enum {
    GETEVALTYPE, ASSIGNVAR, GETVARVALUE, GETVARINDEX, GETVARVALUEBYINDEX,
    SETEVALSTRING, EVALUATE
  };
};

inline
const char *svc_evaluator::getEvalType() {
  return _call(GETEVALTYPE, (const char *)NULL);
}

inline
int svc_evaluator::setEvalString(const char *string, int length, BOOL isBinary){
  return _call(SETEVALSTRING, FALSE, string, length, isBinary);
}

inline
const char *svc_evaluator::evaluate(int *length, BOOL *isBinary) {
  return _call(EVALUATE, (const char *)NULL, length, isBinary);
}

// implementor derives from this one
class NOVTABLE svc_evaluatorI : public svc_evaluator {
public:
  virtual const char *getEvalType()=0;

//  void assignVar(const char *name, const char *value);
//  const char *getVarValue(const char *name);
//  int getVarIndex(const char *name);
//  const char *getVarValueByIndex(int pos);

  // implementor should make a copy of the string (if needed)
  virtual int setEvalString(const char *string, int length, BOOL isBinary)=0;
  // implementor should alloc returned mem w/ api->sysMalloc()
  virtual const char *evaluate(int *length, BOOL *isBinary)=0;

protected:
  RECVS_DISPATCH;
};

#endif