odlgen_utils.h

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-2008 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021    Author: Eric Viara <viara@sysra.com>
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       // variable dimension attribute
00039       tGetCount,
00040       tSetCount,
00041       // collections
00042       tGetColl,
00043       tSetColl,
00044       tAddItemToColl,
00045       tRmvItemFromColl,
00046       tSetItemInColl,
00047       tUnsetItemInColl,
00048       tGetItemAt,
00049       tGetOidItemAt,
00050       tRetrieveItemAt,
00051       tRetrieveOidItemAt,
00052       // casting methods
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     // keep now for now
00093     enum AttrStyle {
00094       ImplicitAttrStyle = 10,
00095       ExplicitAttrStyle
00096     };
00097 
00098     enum ErrorPolicy {
00099       StatusErrorPolicy = 20,
00100       ExceptionErrorPolicy
00101     };
00102 
00103     AttrStyle attr_style; // keep it for now
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

Generated on Mon Dec 22 18:16:00 2008 for eyedb by  doxygen 1.5.3