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
RevLine 
[182]1#pragma once
[4]2
[215]3#include <Namespace.h>
[4]4
[406]5class EnumMember
6{
7 std::string name;
8 std::string value;
9 int sourceIndex;
[4]10public:
[406]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 }
[4]29};
30
[406]31class EnumInfo
32 : public Symbol
33{
[103]34
[4]35 BOOL bConst;
36
[406]37 std::vector<EnumMember> members;
[4]38public:
39
[406]40 EnumInfo( const NamespaceScopes &namespaceScopes, const std::string &name )
41 : Symbol( namespaceScopes, name )
42 {
43 }
[4]44
[406]45 const std::vector<EnumMember> &GetMembers() const
[103]46 {
[406]47 return members;
[103]48 }
[406]49
50 void Collect( const char *buffer, int nowLine );
51
52 const EnumMember &GetEnumMember( const std::string &memberName ) const
[103]53 {
[406]54 BOOST_FOREACH( const EnumMember &member, members )
55 {
56 if( member.GetName() == memberName )
57 {
58 return member;
59 }
60 }
61 throw;
[103]62 }
[406]63};
[4]64
[406]65class EnumInfoCollection
66 : public std::vector<EnumInfo>
67{
[4]68public:
[406]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 };
[4]81
[406]82 void InitEnum(void);
83 char *GenerateSourceCode(void);
[4]84};
Note: See TracBrowser for help on using the repository browser.