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