当前位置: 首页>>代码示例>>C++>>正文


C++ Enum类代码示例

本文整理汇总了C++中Enum的典型用法代码示例。如果您正苦于以下问题:C++ Enum类的具体用法?C++ Enum怎么用?C++ Enum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Enum类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

void UpdateFieldDumper::BuildUpdateFieldEnum(Enum& enumData, std::string const& name, std::vector<UpdateField> const& data, std::string const& end, std::string const& fieldBase)
{
    enumData.SetName(name);

    std::uint32_t i = 0;
    while (i < data.size())
    {
        UpdateField const* field = &data[i];
        std::string name = GetInputData()->GetString(data[i].NameAddress);
        if (name == "CGUnitData::npcFlags[UMNW0]")
        {
            name = "CGUnitData::npcFlags";
            field = &data[i + 1];
        }

        std::string oldName = GetOldName(name.c_str());
        if (!oldName.empty())
            name = oldName;

        enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), name,
            static_cast<std::ostringstream&>(std::ostringstream() << "Size: " << field->Size << ", Flags: " << GetUpdateFieldFlagName(field->Flags)).str()));

        i += field->Size;
    }

    enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), end, ""));
}
开发者ID:imbavirus,项目名称:wow-tools,代码行数:27,代码来源:UpdateFieldDumper.cpp

示例2: semantic

bool CheckSpecifier::visit(EnumSpecifierAST *ast)
{
    unsigned sourceLocation = ast->firstToken();
    if (ast->name)
        sourceLocation = ast->name->firstToken();

    Name *name = semantic()->check(ast->name, _scope);
    Enum *e = control()->newEnum(sourceLocation, name);
    e->setStartOffset(tokenAt(ast->firstToken()).offset);
    e->setEndOffset(tokenAt(ast->lastToken()).offset);
    e->setVisibility(semantic()->currentVisibility());
    _scope->enterSymbol(e);
    _fullySpecifiedType.setType(e);
    for (EnumeratorAST *enumerator = ast->enumerators; enumerator;
            enumerator = enumerator->next) {
        Identifier *id = identifier(enumerator->identifier_token);
        if (! id)
            continue;
        NameId *enumeratorName = control()->nameId(id);
        Declaration *decl = control()->newDeclaration(enumerator->firstToken(),
                                                         enumeratorName);
        e->addMember(decl);
    }
    accept(ast->next);
    return false;
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例3: property

void AlgorithmWidget::property(const char* name, Enum& value)
{
	QStringList enums;
	for (int i = 0; i < value.size(); ++i)
		enums << value.names()[i];

	QtProperty* property = enum_manager->addProperty(nice_name(name));
	enum_manager->setValue(property, value);
	enum_manager->setEnumNames(property, enums);
	property_browser->addProperty(property);
	enum_pointers[property] = &value;
}
开发者ID:purpleKarrot,项目名称:libMaoni,代码行数:12,代码来源:AlgorithmWidget.cpp

示例4: DumpUIErrors

void DumpUIErrors(std::shared_ptr<Process> wow)
{
    static std::uintptr_t const UIErrorsOffset = 0xCB01D0;
    static std::size_t const UIErrorsSize = 945;

    Enum uiErrors;
    uiErrors.SetName("GAME_ERROR_TYPE");
    std::vector<UIErrorInfo> errors = wow->ReadArray<UIErrorInfo>(UIErrorsOffset, UIErrorsSize);
    for (std::size_t i = 0; i < errors.size(); ++i)
    {
        std::string error = wow->Read<std::string>(errors[i].ErrorName);
        if (!error.empty())
            uiErrors.AddMember(Enum::Member(i, error, ""));
    }

    DumpEnum(uiErrors, "UIErrors");
}
开发者ID:treewords,项目名称:wow-tools,代码行数:17,代码来源:Main.cpp

示例5: DumpFrameXML_Events

void DumpFrameXML_Events(std::shared_ptr<Process> wow)
{
    static std::uintptr_t const FrameXML_EventsOffset = 0xE66430;
    static std::size_t const FrameXML_EventsSize = 1054;

    Enum frameXML;
    frameXML.SetName("FrameXML_Events");
    std::vector<char const*> events = wow->ReadArray<char const*>(FrameXML_EventsOffset, FrameXML_EventsSize);
    for (std::size_t i = 0; i < events.size(); ++i)
    {
        std::string evt = wow->Read<std::string>(events[i]);
        if (!evt.empty())
            frameXML.AddMember(Enum::Member(i, evt, ""));
    }

    DumpEnum(frameXML, "FrameXML_Events");
}
开发者ID:treewords,项目名称:wow-tools,代码行数:17,代码来源:Main.cpp

示例6: parseAndValidateNewTypeName

void PackageParser::parseEnum(const EmojicodeString &documentation, bool exported) {
    EmojicodeChar name, enamespace;
    parseAndValidateNewTypeName(&name, &enamespace);
    
    Enum *eenum = new Enum(name, package_, documentation);
    
    package_->registerType(Type(eenum, false), name, enamespace, exported);
    
    auto token = stream_.consumeToken(IDENTIFIER);
    if (token.value[0] != E_GRAPES) {
        ecCharToCharStack(token.value[0], s);
        throw CompilerErrorException(token, "Expected 🍇 but found %s instead.", s);
    }
    while (stream_.nextTokenIsEverythingBut(E_WATERMELON)) {
        eenum->addValueFor(stream_.consumeToken().value[0]);
    }
    stream_.consumeToken(IDENTIFIER);
}
开发者ID:DDMATTOS,项目名称:emojicode,代码行数:18,代码来源:PackageParser.cpp

示例7: li_module_enum_create

// Enum *e = Module:EnumCreate(name)
int li_module_enum_create(lua_State *L)
{
	CHECK_COUNT("enumCreate",2)
	CHECK_ARGUMENT("enumCreate",2,string)
	
	// check we have a module, then convert it to a Module
	CHECK_ARGUMENT_TYPE("typeCreate",1,Module,m)

	// now create the Enum
	Enum *e = new Enum(m, new std::string(lua_tostring(L, 2)));
	if(e == NULL) gen_error("enum could not be created");
	
	// now add this enum to the module
	m->objectAdd(new std::string(luaL_checkstring(L, 2)), e);
	
	CREATE_TABLE(L, e);
	e->lua_table(L);
		
	// now we just return the table :)
	return 1;
}
开发者ID:sparlane,项目名称:generator,代码行数:22,代码来源:luainterface.cpp

示例8: if

MY_OPERATOR_SCOPE::MY_OPERATOR::UpdateType MY_OPERATOR_SCOPE::MY_OPERATOR::convertEnumToUpdateType(Enum const &e) {
	string value = e.getValue();
	
	if(value == "NODE") {
		return MY_OPERATOR_SCOPE::MY_OPERATOR::NODE;
	}
	else if(value == "EDGE") {
		return MY_OPERATOR_SCOPE::MY_OPERATOR::EDGE;
	}
	else {
		// throw something
		throw("Invalid update type in convertEnumToUpdateType");
	}
}
开发者ID:raghukiran1224,项目名称:samples,代码行数:14,代码来源:PointMapMatcher_2.cpp

示例9: name

//-------------------------------------------------------------------------------------------------
bool Enum::operator==(const Enum& other) const
{
    return name() == other.name();
}
开发者ID:earlye,项目名称:ponder,代码行数:5,代码来源:enum.cpp

示例10: value

const bool Enum::operator > ( const Enum& other ) const
{
	return value() > other.value();
}
开发者ID:npapier,项目名称:vgsdk,代码行数:4,代码来源:Enum.cpp

示例11: onEnumMember

void TalkyUnit::onEnumMember(const std::string name) {
    // cout << "new enum member " << name << endl;
    Enum* theEnum = dynamic_cast<Enum*> (currentDefinition);
    theEnum->onNewMember(name);
}
开发者ID:newcl,项目名称:talky,代码行数:5,代码来源:talky_unit.cpp

示例12: getEnum

	uint64_t DeltaCodeArr::lookup(uint64_t pos) const {
		Enum e;
		getEnum(pos, &e);
		return e.next();
	}
开发者ID:hoangmit,项目名称:mscds,代码行数:5,代码来源:deltaarray.cpp

示例13: p

void HeaderFile::parse()
{
    Parser p( contents() );
    p.scan( "\nclass " );
    while ( !p.atEnd() ) {
        EString className = p.identifier();
        EString superclass = 0;
        p.whitespace();
        if ( p.lookingAt( ":" ) ) {
            p.step();
            EString inheritance = p.word();
            if ( inheritance != "public" ) {
                (void)new Error( this, p.line(),
                                 "Non-public inheritance for class " +
                                 className );
                return;
            }
            EString parent = p.identifier();
            if ( parent.isEmpty() ) {
                (void)new Error( this, p.line(),
                                 "Cannot parse superclass name for class " +
                                 className );
                return;
            }
            superclass = parent;
        }
        p.whitespace();
        if ( p.lookingAt( "{" ) ) {
            Class * c = Class::find( className );
            if ( !c )
                c = new Class( className, 0, 0 );
            c->setParent( superclass );
            if ( c && c->file() ) {
                (void) new Error( this, p.line(),
                                  "Class " + className +
                                  " conflicts with " + className + " at " +
                                  c->file()->name() + ":" +
                                  fn( c->line() ) );
                (void) new Error( c->file(), c->line(),
                                  "Class " + className +
                                  " conflicts with " + className + " at " +
                                  name() + ":" +
                                  fn( p.line() ) );
            }
            else {
                c->setSource( this, p.line() );
            }
            p.step();
            bool ok = false;
            do {
                ok = false;
                p.whitespace();
                while ( p.lookingAt( "public:" ) ||
                        p.lookingAt( "private:" ) ||
                        p.lookingAt( "protected:" ) ) {
                    p.scan( ":" );
                    p.step();
                    p.whitespace();
                }
                if ( p.lookingAt( "virtual " ) )
                    p.scan( " " );
                p.whitespace();
                EString t;
                EString n;
                uint l = p.line();
                if ( p.lookingAt( "operator " ) ) {
                    n = p.identifier();
                }
                else if ( p.lookingAt( "enum " ) ) {
                    p.scan( " " );
                    Enum * e = new Enum( c, p.word(), this, l );
                    p.whitespace();
                    if ( p.lookingAt( "{" ) ) {
                        bool again = true;
                        while ( again ) {
                            p.step();
                            p.whitespace();
                            EString v = p.word();
                            if ( v.isEmpty() )
                                (void)new Error( this, p.line(),
                                                 "Could not parse "
                                                 "enum value" );
                            else
                                e->addValue( v );
                            p.whitespace();
                            if ( p.lookingAt( "=" ) ) {
                                p.step();
                                p.whitespace();
                                (void)p.value();
                                p.whitespace();
                            }
                            again = p.lookingAt( "," );
                        }
                        if ( p.lookingAt( "}" ) ) {
                            p.step();
                            ok = true;
                        }
                        else {
                            (void)new Error( this, p.line(),
                                             "Enum definition for " +
//.........这里部分代码省略.........
开发者ID:aox,项目名称:aox,代码行数:101,代码来源:headerfile.cpp

示例14: getEnum

uint64_t DiffArray<IntArray>::lookup(uint64_t pos) const {
	Enum e;
	getEnum(pos, &e);
	return e.next();
}
开发者ID:hoangmit,项目名称:mscds,代码行数:5,代码来源:diffarray.hpp


注:本文中的Enum类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。