1 | #pragma once
|
---|
2 |
|
---|
3 | #include <Type.h>
|
---|
4 | #include <Symbol.h>
|
---|
5 |
|
---|
6 |
|
---|
7 | void AddConst( const NamespaceScopes &namespaceScopes, char *buffer );
|
---|
8 |
|
---|
9 | //定数
|
---|
10 | class CConst : public Symbol, public Jenga::Common::ObjectInHashmap<CConst>
|
---|
11 | {
|
---|
12 | Type type;
|
---|
13 | _int64 i64data;
|
---|
14 |
|
---|
15 | // XMLシリアライズ用
|
---|
16 | private:
|
---|
17 | friend class boost::serialization::access;
|
---|
18 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
19 | {
|
---|
20 | trace_for_serialize( "serializing - CConst" );
|
---|
21 |
|
---|
22 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
|
---|
23 | ar & BOOST_SERIALIZATION_NVP( type );
|
---|
24 | ar & BOOST_SERIALIZATION_NVP( i64data );
|
---|
25 | }
|
---|
26 |
|
---|
27 | public:
|
---|
28 | CConst( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &newType, _int64 i64data)
|
---|
29 | : Symbol( namespaceScopes, name )
|
---|
30 | , type( newType )
|
---|
31 | , i64data( i64data )
|
---|
32 | {
|
---|
33 | }
|
---|
34 | CConst( const NamespaceScopes &namespaceScopes, const std::string &name, int value)
|
---|
35 | : Symbol( namespaceScopes, name )
|
---|
36 | , type( Type(DEF_LONG) )
|
---|
37 | , i64data( value )
|
---|
38 | {
|
---|
39 | }
|
---|
40 | CConst()
|
---|
41 | {
|
---|
42 | }
|
---|
43 | ~CConst()
|
---|
44 | {
|
---|
45 | }
|
---|
46 |
|
---|
47 | virtual const std::string &GetKeyName() const
|
---|
48 | {
|
---|
49 | return GetName();
|
---|
50 | }
|
---|
51 |
|
---|
52 | Type GetType()
|
---|
53 | {
|
---|
54 | return type;
|
---|
55 | }
|
---|
56 | _int64 GetWholeData()
|
---|
57 | {
|
---|
58 | return i64data;
|
---|
59 | }
|
---|
60 | double GetDoubleData();
|
---|
61 | };
|
---|
62 | class Consts : public Jenga::Common::Hashmap<CConst>
|
---|
63 | {
|
---|
64 | // XMLシリアライズ用
|
---|
65 | private:
|
---|
66 | friend class boost::serialization::access;
|
---|
67 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
68 | {
|
---|
69 | trace_for_serialize( "serializing - Consts" );
|
---|
70 |
|
---|
71 | ar & boost::serialization::make_nvp("Hashmap_CConst",
|
---|
72 | boost::serialization::base_object<Jenga::Common::Hashmap<CConst>>(*this));
|
---|
73 | }
|
---|
74 |
|
---|
75 | public:
|
---|
76 |
|
---|
77 | void Add( const NamespaceScopes &namespaceScopes, char *buffer);
|
---|
78 | void Add( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
|
---|
79 | void Add( const NamespaceScopes &namespaceScopes, const string &name, int value);
|
---|
80 |
|
---|
81 | private:
|
---|
82 | CConst *GetObjectPtr( const string &name );
|
---|
83 | public:
|
---|
84 |
|
---|
85 | int GetBasicType(const char *Name);
|
---|
86 | _int64 GetWholeData(const char *Name);
|
---|
87 | double GetDoubleData(const char *Name);
|
---|
88 | bool IsStringPtr(const char *Name);
|
---|
89 | };
|
---|
90 |
|
---|
91 | //定数マクロ
|
---|
92 | class ConstMacro : public Symbol, public Jenga::Common::ObjectInHashmap<ConstMacro>
|
---|
93 | {
|
---|
94 | std::vector<std::string> parameters;
|
---|
95 | std::string expression;
|
---|
96 |
|
---|
97 | // XMLシリアライズ用
|
---|
98 | private:
|
---|
99 | friend class boost::serialization::access;
|
---|
100 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
101 | {
|
---|
102 | trace_for_serialize( "serializing - ConstMacro" );
|
---|
103 |
|
---|
104 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
|
---|
105 | ar & BOOST_SERIALIZATION_NVP( parameters );
|
---|
106 | ar & BOOST_SERIALIZATION_NVP( expression );
|
---|
107 | }
|
---|
108 |
|
---|
109 | public:
|
---|
110 | ConstMacro( const NamespaceScopes &namespaceScopes, const std::string &name, const std::vector<std::string> ¶meters, const string &expression )
|
---|
111 | : Symbol( namespaceScopes, name )
|
---|
112 | , parameters( parameters )
|
---|
113 | , expression( expression )
|
---|
114 | {
|
---|
115 | }
|
---|
116 | ConstMacro()
|
---|
117 | {
|
---|
118 | }
|
---|
119 | ~ConstMacro()
|
---|
120 | {
|
---|
121 | }
|
---|
122 |
|
---|
123 | virtual const std::string &GetKeyName() const
|
---|
124 | {
|
---|
125 | return GetName();
|
---|
126 | }
|
---|
127 |
|
---|
128 | const std::vector<std::string> &GetParameters() const
|
---|
129 | {
|
---|
130 | return parameters;
|
---|
131 | }
|
---|
132 | const std::string &GetExpression() const
|
---|
133 | {
|
---|
134 | return expression;
|
---|
135 | }
|
---|
136 |
|
---|
137 | bool GetCalcBuffer( const char *parameterStr, char *dest ) const;
|
---|
138 | };
|
---|
139 | class ConstMacros : public Jenga::Common::Hashmap<ConstMacro>
|
---|
140 | {
|
---|
141 | // XMLシリアライズ用
|
---|
142 | private:
|
---|
143 | friend class boost::serialization::access;
|
---|
144 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
145 | {
|
---|
146 | trace_for_serialize( "serializing - ConstMacros" );
|
---|
147 |
|
---|
148 | ar & boost::serialization::make_nvp("Hashmap_ConstMacro",
|
---|
149 | boost::serialization::base_object<Jenga::Common::Hashmap<ConstMacro>>(*this));
|
---|
150 | }
|
---|
151 |
|
---|
152 | public:
|
---|
153 | void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr );
|
---|
154 | ConstMacro *Find( const std::string &name );
|
---|
155 | };
|
---|