當前位置: 首頁>>代碼示例>>C++>>正文


C++ Class函數代碼示例

本文整理匯總了C++中Class函數的典型用法代碼示例。如果您正苦於以下問題:C++ Class函數的具體用法?C++ Class怎麽用?C++ Class使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Class函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: switch

bool Player::setIntByHash(uint16_t propHash, LevelObjValue value, const Level* level) noexcept
{
	switch (propHash)
	{
	case str2int16("strength"):
		strength = std::clamp(value, 0, Class()->MaxStrength());
		break;
	case str2int16("magic"):
		magic = std::clamp(value, 0, Class()->MaxMagic());
		break;
	case str2int16("dexterity"):
		dexterity = std::clamp(value, 0, Class()->MaxDexterity());
		break;
	case str2int16("vitality"):
		vitality = std::clamp(value, 0, Class()->MaxVitality());
		break;
	case str2int16("lifeDamage"):
		lifeDamage = std::max(value, 0);
		break;
	case str2int16("manaDamage"):
		manaDamage = std::max(value, 0);
		break;
	default:
		return false;
	}
	updateNameAndDescr = true;
	return true;
}
開發者ID:dgengin,項目名稱:DGEngine,代碼行數:28,代碼來源:Player.cpp

示例2: environment_variable_get

Variable environment_variable_get(Scope* scope, Variable variable){
    for(unsigned int v = 0; v < scope->variables.size(); v++){
        if( (scope->variables[v].name == variable.name or variable.name==IGNORE)
        and (scope->variables[v].type.name == variable.type.name or variable.type.name==IGNORE)){
            return scope->variables[v];
        }
    }

    if(scope->parent == NULL){
        #ifdef DEV_ERRORS
        fail(DEV_BLANK_TYPE);
        #endif // DEV_ERRORS

        return Variable("", Class(), false, false);
    }

    if(environment_variable_exists(scope->parent, variable)){
        return environment_variable_get(scope->parent, variable);
    }

    #ifdef DEV_ERRORS
    fail(DEV_BLANK_TYPE);
    #endif // DEV_ERRORS

    return Variable("", Class(), false, false);
}
開發者ID:IsaacShelton,項目名稱:Boomslang,代碼行數:26,代碼來源:scope.cpp

示例3: connectPrereqsToTargets

void connectPrereqsToTargets(const std::string & s, Graph & g) {
    auto it = s.begin();
    std::set<Class>::iterator targetIt;
    while (it != s.end()) {
        if (*it == ':') {
            std::string target(s.begin(), it);
            targetIt = g.classes.find(Class(target));
            assert(targetIt != g.classes.end());
            ++it;
            break;
        }
        ++it;
    }
    while (it != s.end()) {
        ++it;
        auto endit = it;
        while (endit != s.end() && *endit != ' ') { ++endit; }
        std::string prereq(std::string(it, endit));
        std::set<Class>::iterator prereqIt =
            g.classes.find(Class(prereq));
        assert(prereqIt != g.classes.end());
        g.connect(targetIt, prereqIt);
        it = endit;
    }
}
開發者ID:chrzhang,項目名稱:abc,代碼行數:25,代碼來源:main.cpp

示例4: assert

static at *call_method(at *obj, struct hashelem *hx, at *args)
{
   at *fun = hx->function;
   assert(FUNCTIONP(fun));
   
   if (Class(fun) == de_class) {
      // DE
      at *p = eval_arglist(args);
      return with_object(obj, fun, p, hx->sofar);

   } else if (Class(fun) == df_class) {
      // DF
      return with_object(obj, fun, args, hx->sofar);

   } else if (Class(fun) == dm_class) {
      // DM
      at *p = new_cons(new_cons(fun, args), NIL);
      at *q = with_object(obj, at_mexpand, p, hx->sofar);
      return eval(q);
      
   } else {
      // DX, DY, DH
      at *p = new_cons(fun, new_cons(obj, args));
      return Class(fun)->listeval(fun, p);
   }
}
開發者ID:barak,項目名稱:lush,代碼行數:26,代碼來源:oostruct.c

示例5: lush_delete

void lush_delete(at *p)
{
   if (!p || ZOMBIEP(p))
      return;

   class_t *cl = classof(p);
   if (cl->dontdelete)
      error(NIL, "cannot delete this object", p);
   
   run_notifiers(p);
   
   if (cl->has_compiled_part) {
      assert(isa(p, object_class));
      /* OO objects may have two parts          */
      /* lush_delete has to delete both of them */
      object_t *obj = Mptr(p);
      struct CClass_object *cobj = obj->cptr;
      oostruct_dispose(obj);
      cobj->Vtbl->Cdestroy(cobj);
      
   } else {
      if (Class(p)->dispose)
         Mptr(p) = Class(p)->dispose(Mptr(p));
      else
         Mptr(p) = NULL;
   }
   zombify(p);
}
開發者ID:barak,項目名稱:lush,代碼行數:28,代碼來源:oostruct.c

示例6: return

bool Player::hasMaxStats() const noexcept
{
	return (strength >= Class()->MaxStrength() &&
		magic >= Class()->MaxMagic() &&
		dexterity >= Class()->MaxDexterity() &&
		vitality >= Class()->MaxVitality());
}
開發者ID:dgengin,項目名稱:DGEngine,代碼行數:7,代碼來源:Player.cpp

示例7: Header_new

Header* Header_new(ProcessList* pl) {
   Header* this = calloc(1, sizeof(Header));
   this->leftMeters = Vector_new(Class(Meter), true, DEFAULT_SIZE);
   this->rightMeters = Vector_new(Class(Meter), true, DEFAULT_SIZE);
   this->margin = true;
   this->pl = pl;
   return this;
}
開發者ID:adnandzebic,項目名稱:htop,代碼行數:8,代碼來源:Header.c

示例8: sprintf

static const char *generic_name(at *p)
{
   if (Class(p)->classname)
      sprintf(string_buffer, "::%s:%p", NAMEOF(Class(p)->classname),Mptr(p));
   else
      sprintf(string_buffer, "::%p:%p", Class(p), Mptr(p));
   
   return mm_strdup(string_buffer);
}
開發者ID:barak,項目名稱:lush,代碼行數:9,代碼來源:oostruct.c

示例9: environment_generic_method_exists

bool environment_generic_method_exists(TokenContext context, Scope* scope, Method method, Class actual_class, Class generic_class){
    for(size_t i = 0; i < scope->methods.size(); i++){
        if( (scope->methods[i].name == method.name or method.name==IGNORE)
        and (scope->methods[i].parent == method.parent or method.parent==NULL)
        and (context_class_compare(context, Class(scope->methods[i].return_type), Class(method.return_type)) or method.return_type == IGNORE_CLASS)
        and (generic_arguments_equal(context, scope->methods[i].arguments, method.arguments, actual_class, generic_class))){
            return true;
        }
    }

    return false;
}
開發者ID:IsaacShelton,項目名稱:Boomslang,代碼行數:12,代碼來源:scope.cpp

示例10: heuristicid

/* linux driver says the release id is not always right */
static int
heuristicid(uint32_t csp, uint32_t maxpkt)
{
	if(Class(csp) == 0x02)
		return TypeH;
	else if(maxpkt == 0x40)
		return TypeHX;
	else if(Class(csp) == 0x00 || Class(csp) == 0xFF)
		return TypeH;
	else{
		fprint(2, "serial: chip unknown, setting to HX version\n");
		return TypeHX;
	}
}
開發者ID:dalmonian,項目名稱:harvey,代碼行數:15,代碼來源:prolific.c

示例11: class_

void Component::classes(void){
	class_(Component::StencilType, Class(
		"Stencil",
		Stencil::page,
		Stencil::request,
		Stencil::call
	));
	class_(Component::ThemeType, Class(
		"Theme",
		Theme::page,
		nullptr,
		Theme::call
	));
}
開發者ID:gitter-badger,項目名稱:stencila,代碼行數:14,代碼來源:component-instance.cpp

示例12: environment_method_get

Method environment_method_get(TokenContext context, Scope* scope, Method method){
    for(size_t i = 0; i < scope->methods.size(); i++){
        if( (scope->methods[i].name == method.name or method.name==IGNORE)
        and (scope->methods[i].parent == method.parent or method.parent==NULL)
        and (context_class_compare(context, Class(scope->methods[i].return_type), Class(method.return_type)) or method.return_type == IGNORE_CLASS)
        and (arguments_equal(context, scope->methods[i].arguments, method.arguments))){
            return scope->methods[i];
        }
    }

    #ifdef DEV_ERRORS
    fail(DEV_BLANK_TYPE);
    #endif // DEV_ERRORS

    return Method{"", NULL, IGNORE_ARGS, IGNORE_CLASS};
}
開發者ID:IsaacShelton,項目名稱:Boomslang,代碼行數:16,代碼來源:scope.cpp

示例13: Class

Variable::Variable(){
    name = "";
    type = Class("");
    is_final = false;
    is_static = false;
    is_private = false;
}
開發者ID:IsaacShelton,項目名稱:Boomslang,代碼行數:7,代碼來源:scope.cpp

示例14: sizeof

aConfItem	*make_conf(void)
{
	Reg	aConfItem *aconf;

	aconf = (struct ConfItem *)MyMalloc(sizeof(aConfItem));

#ifdef	DEBUGMODE
	aconfs.inuse++;
#endif
	istat.is_conf++;
	istat.is_confmem += sizeof(aConfItem);

	bzero((char *)&aconf->ipnum, sizeof(struct IN_ADDR));
	aconf->clients = aconf->port = 0;
	aconf->next = NULL;
	aconf->host = aconf->passwd = aconf->name = aconf->name2 = NULL;
#ifdef XLINE
	aconf->name3 = NULL;
#endif
	aconf->ping = NULL;
	aconf->status = CONF_ILLEGAL;
	aconf->pref = -1;
	aconf->hold = time(NULL);
	aconf->source_ip = NULL;
	aconf->flags = 0L;
	Class(aconf) = NULL;
	return (aconf);
}
開發者ID:DanielOaks,項目名稱:irc2-mirror,代碼行數:28,代碼來源:list.c

示例15: lush_delete_maybe

/* similar to lush_delete, but don't raise error with permanent objects */
void lush_delete_maybe(at *p)
{
   if (p) {
      if (!Class(p)->dontdelete)
         lush_delete(p);
   }
}
開發者ID:barak,項目名稱:lush,代碼行數:8,代碼來源:oostruct.c


注:本文中的Class函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。