source: dev/trunk/abdev/BasicCompiler_Common/include/Enum.h@ 407

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

Enum.cpp/Enum.hを移動した

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