source: dev/trunk/ab5.0/abdev/ab_common/include/Lexical/Const.h@ 621

Last change on this file since 621 was 603, checked in by dai_9181, 17 years ago

ObjectModuleに関連するクラス一式をab_commonプロジェクトに移動した。

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