| 1 |
|
|---|
| 2 |
|
|---|
| 3 | //定数の基底クラス
|
|---|
| 4 | class ConstBase{
|
|---|
| 5 | const string name;
|
|---|
| 6 | const NamespaceScopes namespaceScopes;
|
|---|
| 7 |
|
|---|
| 8 | public:
|
|---|
| 9 |
|
|---|
| 10 | ConstBase( const NamespaceScopes &namespaceScopes, const string &name )
|
|---|
| 11 | : namespaceScopes( namespaceScopes )
|
|---|
| 12 | , name( name )
|
|---|
| 13 | {
|
|---|
| 14 | }
|
|---|
| 15 | ~ConstBase()
|
|---|
| 16 | {
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | const string &GetName() const
|
|---|
| 20 | {
|
|---|
| 21 | return name;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
|
|---|
| 25 | bool IsEqualSymbol( const string &name ) const;
|
|---|
| 26 | };
|
|---|
| 27 |
|
|---|
| 28 | //定数
|
|---|
| 29 | class CConst:public ConstBase{
|
|---|
| 30 | Type type;
|
|---|
| 31 | _int64 i64data;
|
|---|
| 32 |
|
|---|
| 33 | public:
|
|---|
| 34 | CConst *pNext;
|
|---|
| 35 |
|
|---|
| 36 | CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, _int64 i64data);
|
|---|
| 37 | CConst( const NamespaceScopes &namespaceScopes, const string &name, int value);
|
|---|
| 38 | ~CConst();
|
|---|
| 39 |
|
|---|
| 40 | Type GetType();
|
|---|
| 41 | _int64 GetWholeData();
|
|---|
| 42 | double GetDoubleData();
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | //定数マクロ
|
|---|
| 46 | class CConstMacro:public ConstBase{
|
|---|
| 47 | int ParmNum;
|
|---|
| 48 | char **ppParm;
|
|---|
| 49 | public:
|
|---|
| 50 |
|
|---|
| 51 | CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
|
|---|
| 52 | ~CConstMacro();
|
|---|
| 53 | };
|
|---|
| 54 |
|
|---|
| 55 | //定数管理クラス
|
|---|
| 56 | class CDBConst{
|
|---|
| 57 | CConst **ppHash;
|
|---|
| 58 |
|
|---|
| 59 | CConstMacro **ppobj_Macro;
|
|---|
| 60 | int NumOfMacro;
|
|---|
| 61 |
|
|---|
| 62 | //シングルトンクラスなので、プライベートに置く
|
|---|
| 63 | CDBConst();
|
|---|
| 64 | ~CDBConst();
|
|---|
| 65 | void _free();
|
|---|
| 66 | void Free();
|
|---|
| 67 |
|
|---|
| 68 | public:
|
|---|
| 69 |
|
|---|
| 70 | void Init();
|
|---|
| 71 |
|
|---|
| 72 | void Add( const NamespaceScopes &namespaceScopes, char *buffer);
|
|---|
| 73 | private:
|
|---|
| 74 | void AddConst( const string &name, CConst *newconst);
|
|---|
| 75 | public:
|
|---|
| 76 | void AddConst( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
|
|---|
| 77 | void AddConst( const NamespaceScopes &namespaceScopes, const string &name, int value);
|
|---|
| 78 |
|
|---|
| 79 | private:
|
|---|
| 80 | CConst *GetObjectPtr( const string &name );
|
|---|
| 81 | public:
|
|---|
| 82 |
|
|---|
| 83 | int GetBasicType(char *Name);
|
|---|
| 84 | _int64 GetWholeData(char *Name);
|
|---|
| 85 | double GetDoubleData(char *Name);
|
|---|
| 86 | bool IsStringPtr(char *Name);
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | //シングルトンオブジェクト
|
|---|
| 90 | static CDBConst obj;
|
|---|
| 91 | };
|
|---|