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

Last change on this file since 750 was 750, checked in by イグトランス (egtra), 16 years ago

BOOST_FOREACHを可能なものはVC++ 2005 for eachへ置換(やや速くなる)。

File size: 1.4 KB
RevLine 
[182]1#pragma once
[4]2
[406]3class EnumMember
4{
5 std::string name;
6 std::string value;
7 int sourceIndex;
[4]8public:
[406]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 }
[4]27};
28
[406]29class EnumInfo
30 : public Symbol
31{
[103]32
[4]33 BOOL bConst;
34
[406]35 std::vector<EnumMember> members;
[4]36public:
37
[406]38 EnumInfo( const NamespaceScopes &namespaceScopes, const std::string &name )
39 : Symbol( namespaceScopes, name )
40 {
41 }
[4]42
[406]43 const std::vector<EnumMember> &GetMembers() const
[103]44 {
[406]45 return members;
[103]46 }
[406]47
48 const EnumMember &GetEnumMember( const std::string &memberName ) const
[103]49 {
[750]50 foreach( const EnumMember &member, members )
[406]51 {
52 if( member.GetName() == memberName )
53 {
54 return member;
55 }
56 }
57 throw;
[103]58 }
[547]59
60 std::vector<EnumMember> &GetEnumMembers()
61 {
62 return members;
63 }
[406]64};
[4]65
[406]66class EnumInfoCollection
67 : public std::vector<EnumInfo>
68{
[4]69public:
[406]70 const EnumInfo *Find( const Symbol &symbol ) const
71 {
72 const EnumInfoCollection &thisEnumInfoCollection = *this;
[750]73 foreach( const EnumInfo &enumInfo, thisEnumInfoCollection )
[406]74 {
75 if( enumInfo.IsEqualSymbol( symbol ) )
76 {
77 return &enumInfo;
78 }
79 }
80 return NULL;
81 };
[4]82};
Note: See TracBrowser for help on using the repository browser.