00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _EYEDB_ODLGEN_UTILS_H
00026 #define _EYEDB_ODLGEN_UTILS_H
00027
00028 namespace eyedb {
00029
00030 class GenCodeHints {
00031
00032 public:
00033 enum OpType {
00034 tGet = 0,
00035 tSet,
00036 tGetOid,
00037 tSetOid,
00038
00039 tGetCount,
00040 tSetCount,
00041
00042 tGetColl,
00043 tSetColl,
00044 tAddItemToColl,
00045 tRmvItemFromColl,
00046 tSetItemInColl,
00047 tUnsetItemInColl,
00048 tGetItemAt,
00049 tGetOidItemAt,
00050 tRetrieveItemAt,
00051 tRetrieveOidItemAt,
00052
00053 tCast,
00054 tSafeCast,
00055 tLastOp
00056 };
00057
00058 class Style {
00059
00060 public:
00061 Style(const char *);
00062
00063 Status getStatus() const {return status;}
00064 const char *getString(OpType op, const char *name,
00065 const char *prefix = "");
00066
00067 ~Style();
00068
00069 private:
00070 Status status;
00071 struct Desc {
00072 OpType op;
00073 char *fmt;
00074 struct CompDesc {
00075 char *cfmt;
00076 int cnt;
00077 struct Item {
00078 enum {No, Name, Prefix} which;
00079 const char *(*fun)(const char *);
00080 } items[4];
00081
00082 ~CompDesc() {free(cfmt);}
00083 } comp;
00084 ~Desc() {free(fmt);}
00085 } desc[tLastOp];
00086 Status compile();
00087 void parse_file(const char *);
00088 Status compile(Desc *);
00089 static const char *opTypeStr(OpType op);
00090 } *style;
00091
00092
00093 enum AttrStyle {
00094 ImplicitAttrStyle = 10,
00095 ExplicitAttrStyle
00096 };
00097
00098 enum ErrorPolicy {
00099 StatusErrorPolicy = 20,
00100 ExceptionErrorPolicy
00101 };
00102
00103 AttrStyle attr_style;
00104 Bool gen_class_stubs;
00105 Bool gen_down_casting;
00106 Bool class_enums;
00107 Bool attr_cache;
00108 Bool gen_date;
00109 ErrorPolicy error_policy;
00110 char *dirname, *fileprefix;
00111 const char *stubs;
00112 char *c_suffix, *h_suffix;
00113
00114 GenCodeHints();
00115
00116 void setDirName(const char *_dirname) {
00117 free(dirname);
00118 dirname = strdup(_dirname);
00119 }
00120
00121 void setFilePrefix(const char *_fileprefix) {
00122 free(fileprefix);
00123 fileprefix = strdup(_fileprefix);
00124 }
00125
00126 void setCSuffix(const char *_c_suffix) {
00127 free(c_suffix);
00128 c_suffix = strdup(_c_suffix);
00129 }
00130
00131 void setHSuffix(const char *_h_suffix) {
00132 free(h_suffix);
00133 h_suffix = strdup(_h_suffix);
00134 }
00135
00136 Status setStyle(const char *);
00137
00138 ~GenCodeHints() {
00139 free(dirname);
00140 free(fileprefix);
00141 free(c_suffix);
00142 free(h_suffix);
00143 delete style;
00144 }
00145
00146 private:
00147 GenCodeHints(const GenCodeHints &);
00148 GenCodeHints& operator=(const GenCodeHints &);
00149 };
00150
00151 }
00152
00153 #endif