source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/Enum.h@ 505

Last change on this file since 505 was 505, checked in by dai_9181, 16 years ago

NamespaceScopes、NamespaceScopesCollectionクラスをab_commonプロジェクトに移動した。

File size: 1.5 KB
Line 
1#pragma once
2
3class EnumMember
4{
5 std::string name;
6 std::string value;
7 int sourceIndex;
8public:
9 EnumMember( const std::string &name, const std::string &value, int sourceIndex )
10 : name( name )
11 , value( value )
12 , sourceIndex( sourceIndex )
13 {
14 }
15 const std::string &GetName() const
16 {
17 return name;
18 }
19 const std::string &GetValueStr() const
20 {
21 return value;
22 }
23 int GetSourceIndex() const
24 {
25 return sourceIndex;
26 }
27};
28
29class EnumInfo
30 : public Symbol
31{
32
33 BOOL bConst;
34
35 std::vector<EnumMember> members;
36public:
37
38 EnumInfo( const NamespaceScopes &namespaceScopes, const std::string &name )
39 : Symbol( namespaceScopes, name )
40 {
41 }
42
43 const std::vector<EnumMember> &GetMembers() const
44 {
45 return members;
46 }
47
48 void Collect( const char *buffer, int nowLine );
49
50 const EnumMember &GetEnumMember( const std::string &memberName ) const
51 {
52 BOOST_FOREACH( const EnumMember &member, members )
53 {
54 if( member.GetName() == memberName )
55 {
56 return member;
57 }
58 }
59 throw;
60 }
61};
62
63class EnumInfoCollection
64 : public std::vector<EnumInfo>
65{
66public:
67 const EnumInfo *Find( const Symbol &symbol ) const
68 {
69 const EnumInfoCollection &thisEnumInfoCollection = *this;
70 BOOST_FOREACH( const EnumInfo &enumInfo, thisEnumInfoCollection )
71 {
72 if( enumInfo.IsEqualSymbol( symbol ) )
73 {
74 return &enumInfo;
75 }
76 }
77 return NULL;
78 };
79
80 void InitEnum(void);
81 char *GenerateSourceCode(void);
82};
Note: See TracBrowser for help on using the repository browser.