bool ManageJobInit::loadCharCfg(Element * char_ele) { if (NULL == char_ele) { return false; } JobInitCfg job_init_cfg; bool result = true; result = getAttr(char_ele, "job", job_init_cfg.job); result = getAttr(char_ele, "sex", job_init_cfg.sex); result = getAttr(char_ele, "roleid", job_init_cfg.role_id); int mix_id = getMixId(job_init_cfg.job, job_init_cfg.sex); JobInitCfgMap_t::iterator it = m_job_init_cfg_map.find(mix_id); if (it == m_job_init_cfg_map.end()) { m_job_init_cfg_map.insert(std::make_pair(mix_id, job_init_cfg)); } else { return false; } return result; }
float BattleSquad::getAtk(int side) { float atk = getAttr(ATTR_ATTACK, ATTRCALC_FULL); float formation = getAttr(ATTR_FORM, ATTRCALC_FULL); formation = (formation < 0.0f)?0.0f:formation; int soildernum = getUnitNum(); formation = formation * soildernum / 50.0f; formation *= GetFormationBonus(side, getFormation()); atk += formation; return atk; }
float BattleSquad::getDef(int side) { float deff = getAttr(ATTR_DEFENCE, ATTRCALC_FULL); float formation = getAttr(ATTR_FORM, ATTRCALC_FULL); formation = (formation < 0.0f)?0.0f:formation; int soildernum = getUnitNum(); formation = formation * soildernum / 50.0f; formation *= GetFormationBonus(side, getFormation()); deff += formation; return deff; }
void DomCoParentIterator::getCoParent(CoParent **newcp) { if (*newcp != 0) throw OcfaException("Target of getCoParent not a NULL pointer",this); string evidenceid = getVal(); string item = getAttr("item"); string esrc = getAttr("src"); int jobidint = atoi(getAttr("jobid").c_str()); string childref = getAttr("rename"); *newcp = new CoParentImpl(mCaseID ,item,esrc,evidenceid,jobidint); (*newcp)->setRelName(childref); return; }
//============================================================ read track definition line void Track::trackDef(char *s){ char bb[100], *st; if(trackType==0){ trackType=BED_TRACK; st=getAttr(s,"type",bb); if(st!=0){ strtoupper(st); if(strncmp(st,"WIG",3)==0) trackType=WIG_TRACK; if(strncmp(st,"BEDGRAPH" ,8)==0) trackType=BED_GRAPH; if(strncmp(st,"BROADPEAK",8)==0) trackType=BROAD_PEAK; } } st=getAttr(s,"name", bb); if(st!=0) strcpy(trackName,st); }
void CurveGeometry::render() { // we sample the curve everytime we render and whenever the geometry has changed // TODO: track if geo has changed /* pSampled->clear(); getPAttr()->bind(0); //glDrawElements(GL_POINTS, 24, GL_UNSIGNED_BYTE, 0); // glDrawArrays(GL_POINTS, 0, getPAttr()->numElements()); //topology->render(); getPAttr()->unbind(0); */ glBegin( GL_LINE_STRIP ); for(int i=0; i<m_sampling; ++i) { math::Vec3f sample; math::evalCatmullRom( (float *)getPAttr()->getRawPointer(), (float *)getAttr(ATTR_CATMULLT)->getRawPointer(), getPAttr()->numElements(), 3, (float)i / (float)m_sampling, &sample[0] ); glVertex3fv(&sample[0]); } glEnd(); }
struct titleInfoRec *readTitleInfo ( FILE *dbFp, long offset, TitleID searchKey ) { char *line ; int len ; struct titleInfoRec *head = NULL, *tail = NULL, *lrec = NULL ; TitleID titleKey ; (void) fseek ( dbFp, offset, SEEK_SET ) ; titleKey = getTitle ( dbFp ) ; while ( feof ( dbFp ) == 0 && titleKey == searchKey ) { len = getByte ( dbFp ) ; line = getString ( len, dbFp ) ; lrec = newTitleInfoRec ( ) ; lrec -> text = line ; lrec -> attrKey = getAttr ( dbFp ) ; lrec -> next = NULL ; if ( head == NULL ) head = lrec ; else tail -> next = lrec ; tail = lrec ; titleKey = getTitle ( dbFp ) ; } return ( head ) ; }
void ItemAttributes::setStrAttr(const itemAttrTypes& type, const std::string& value) { if (!validateStrAttrType(type)) { return; } if (value.length() == 0) { return; } //this will create the attribute if it does not exist Attribute* attr = getAttr(type); if (attr) { //if has a previous value delete it if (attr->value) { delete(std::string*)attr->value; } //create the new value as string attr->value = (void*)new std::string(value); } }
static void showBacktrace(Link ret){ if (! is_critical(ret)) return; string_t retstring = object_asString(ret); printf("%s\n", retstring->data); free(retstring); Link bt = getAttr(ret, Global->backtrace_key); if ( ! bt ) return; Link * args = array_getArray(bt); size_t argn = array_getLength(bt); Link a; int c; for (c=0; c< argn; c++){ a = args[c]; if (! a ) break; retstring = object_asString(a); printf(" %s\n", retstring->data); free(retstring); } link_free(bt); }
void printu(Schema *s1,Record *r1,Value *v1) { int k; for(k=0;k<s1->numAttr;k++) { getAttr(r1,s1,k,&v1); switch (s1->dataTypes[k]) { case DT_STRING: printf(" %s ",v1->v.stringV); break; case DT_INT: printf(" %d ",v1->v.intV); break; case DT_FLOAT: printf(" %f ",v1->v.floatV); break; case DT_BOOL: break; } } }
xmlNode *nextChild(xmlNode *lastNode, const char *pParentName) { int i = -1; if ( lastNode ) { for (i=0; i<nClass; i++) { if ( pClassNode[i] == lastNode ) break; } // nie znaleziono podanego node-a if ( i == nClass ) return NULL; } // wyszukanie nastepnego node-a for ( i++; i<nClass; i++ ) { if ( !pClassParent[i] ) continue; if ( goc_stringEquals( getAttr( pClassParent[i], "name" ), pParentName ) ) return pClassNode[i]; } // nie ma wiecej return NULL; }
/****************** Print the Schema **********************/ void print(Schema *s1,Record *r1,Value *v1,Record *r2,Schema *s2) { int k; // Traverse the schema for(k=0;k<s1->numAttr;k++) { //printf("\n %d",); //printf("\n Ok very nice"); getAttr(r1,s1,k,&v1); // Setting the attributes according to the datatypes switch (s1->dataTypes[k]) { case DT_STRING: printf(" %s ",v1->v.stringV); setAttr(r2,s2,k,v1); break; case DT_INT: printf(" %d ",v1->v.intV); setAttr(r2,s2,k,v1); break; case DT_FLOAT: printf(" %f ",v1->v.floatV); setAttr(r2,s2,k,v1); break; case DT_BOOL: //printf(" %f ",v1->v.floatV); setAttr(r2,s2,k,v1); break; } } }
//Ανακαλυπτει σε ποιο αντικειμενο relAttr αναφερεται το ονομα attr και αρχικοποιει αντιστοιχα το RAttr t_rc SSQLM::initializeAttr(string* tableName, int tableSize, string attr, relAttr &RAttr) { t_rc rc; string comboTable, comboColumn; //Ψαξε αν το ονομα στηλης περιεχει τελεία (.) int found = attr.find_first_of('.',0); if(found != attr.npos) //το found παιρνει την τιμη npos οταν δεν υπαρχει ο χαρακτηρας που ψαξαμε { //table.attribute μορφης //Σημειωση : Η τελεια δεν εχει νοημα να υπαρχει στο τελος. //Παρε το ονομα του πινακα (το υπο-string μεχρι την τελεία) comboTable = attr.substr(0,found); //Παρε το ονομα στηλης (το υπο-string μετα την τελεια comboColumn = attr.substr(found+1, attr.length()-comboTable.length()-1); //Διαβασμα ολων των χαρακτηρων απο την τελεια και μετα. //Αρχικοποιησε το attribute για το συγκεκριμενο πινακα και στηλη rc = getAttr(comboTable.c_str(),comboColumn.c_str(),RAttr); } else { //attributeName μορφης //Αρχικοποιησε το attribute το οποιο ο χρηστης θεωρει πως ειναι μοναδικο στη βαση rc = getSimpleAttr(tableName, tableSize, attr.c_str(), RAttr); } return rc; }
void BattleSquad::turnStart() { if (this->getUnitNum()==0) { return; } DataLibrary* datalib = DataLibrary::getSingletonPtr(); float ap = getAttr(ATTR_ACTIONPOINT,ATTRCALC_FULL); setActionPoint(ap); setAPSetup(0.0f); setAPBattle(0.0f); std::vector<std::string> activeskills; activeskills = datalib->getChildList(mPath + "/Skill"); std::vector<std::string>::iterator ite; for(ite = activeskills.begin(); ite != activeskills.end(); ite++) { int cooldown = 0; datalib->getData(mPath + "/Skill/" + (*ite) + "/CoolDown", cooldown); if(cooldown > 0) cooldown -= 1; datalib->setData(mPath + "/Skill/" + (*ite) + "/CoolDown", cooldown); } LuaTempContext* luatempcontext = new LuaTempContext(); luatempcontext->strMap["squadid"] = getSquadId(); Trigger("TurnStart", luatempcontext); delete luatempcontext; }
RC evalExpr(Record *record, Schema *schema, Expr *expr, Value **result) { Value *lIn; Value *rIn; MAKE_VALUE(*result, DT_INT, -1); switch (expr->type) { case EXPR_OP: { Operator *op = expr->expr.op; bool twoArgs = (op->type != OP_BOOL_NOT); // lIn = (Value *) malloc(sizeof(Value)); // rIn = (Value *) malloc(sizeof(Value)); CHECK(evalExpr(record, schema, op->args[0], &lIn)); if (twoArgs) CHECK(evalExpr(record, schema, op->args[1], &rIn)); switch (op->type) { case OP_BOOL_NOT: CHECK(boolNot(lIn, *result)) ; break; case OP_BOOL_AND: CHECK(boolAnd(lIn, rIn, *result)) ; break; case OP_BOOL_OR: CHECK(boolOr(lIn, rIn, *result)) ; break; case OP_COMP_EQUAL: CHECK(valueEquals(lIn, rIn, *result)) ; break; case OP_COMP_SMALLER: CHECK(valueSmaller(lIn, rIn, *result)) ; break; default: break; } // cleanup freeVal(lIn); if (twoArgs) freeVal(rIn); } break; case EXPR_CONST: CPVAL(*result, expr->expr.cons); break; case EXPR_ATTRREF: free(*result); CHECK(getAttr(record, schema, expr->expr.attrRef, result)) ; break; } return RC_OK; }
void Attribute::processExtendedAttributes() { NodeList* list = getExtendedAttributes(); if (!list) { return; } uint32_t attr = getAttr(); for (NodeList::iterator i = list->begin(); i != list->end(); ++i) { ExtendedAttribute* ext = dynamic_cast<ExtendedAttribute*>(*i); assert(ext); if (ext->getName() == "Replaceable") { attr |= Replaceable; } else if (ext->getName() == "TreatNullAs") { if (ScopedName* name = dynamic_cast<ScopedName*>(ext->getDetails())) { if (name->getName() == "EmptyString") { attr |= NullIsEmpty; } } } else if (ext->getName() == "TreatUndefinedAs") { if (ScopedName* name = dynamic_cast<ScopedName*>(ext->getDetails())) { if (name->getName() == "EmptyString") { attr |= UndefinedIsEmpty; } else if (name->getName() == "Null") { attr |= UndefinedIsNull; } } } else if (ext->getName() == "PutForwards") { if (ScopedName* name = dynamic_cast<ScopedName*>(ext->getDetails())) { putForwards = name->getName(); } } else if (ext->getName() == "Null" || ext->getName() == "Undefined") { ext->report("Warning: '%s' has been deprecated.", ext->getName().c_str()); } else { ext->report("Warning: unknown extended attribute '%s'.", ext->getName().c_str()); } } setAttr(attr); }
DateTime *DomJobIterator::getStartTime() { if (st != 0) { delete st; st = 0; } st = new misc::DateTime(atol(getAttr("stime").c_str()), "OCFA"); return st; }
DateTime *DomJobIterator::getEndTime() { if (et != NULL) { delete et; et = NULL; } et = new misc::DateTime(atol(getAttr("stime").c_str()), "OCFA"); return et; }
INT32 _qgmPtrTable::getAttr( const SQL_CON_ITR &itr, qgmDbAttr &attr ) { const CHAR *begin = NULL ; UINT32 size = 0 ; QGM_VALUE_PTR( itr, begin, size ) return getAttr( begin, size, attr ) ; }
void lem_save_lemma(struct node *wp, const char *lemma) { struct ilem_form *form = hash_find(word_form_index, getAttr(wp,"xml:id")); if (form) form->literal = (char*)npool_copy((unsigned char *)lemma,lemline_xcp->pool); else vwarning("internal error: word_form_index lookup failed"); }
S32 CConfigFile::getAsInt(const std::string &var){ PyObject *v = getAttr(var); if(v){ S32 ret = (S32)PyInt_AsLong(v); Py_DECREF(v); return ret; } return 0; }
LinkType FeatureFS::linkType() const { if (hasAttr("link_type")) { std::string link_type; getAttr("link_type", link_type); return linkTypeFromString(link_type); } else { throw MissingAttr("data"); } }
F32 CConfigFile::getAsFloat(const std::string &var){ PyObject *v = getAttr(var); if(v){ F32 ret = (F32)PyFloat_AsDouble(v); Py_DECREF(v); return ret; } return 0; }
std::string PropertyFS::name() const { std::string name; if (hasAttr("name")) { getAttr("name", name); return name; } else { throw MissingAttr("name"); } }
boost::optional<std::string> PropertyFS::unit() const { boost::optional<std::string> ret; std::string unit; if (hasAttr("unit")) { getAttr("unit", unit); ret = unit; } return ret; }
boost::optional<std::string> PropertyFS::mapping() const { boost::optional<std::string> ret; std::string mapping; if (hasAttr("mapping")) { getAttr("mapping", mapping); ret = mapping; } return ret; }
boost::optional<std::string> PropertyFS::definition() const { boost::optional<std::string> ret; std::string definition; if (hasAttr("definition")) { getAttr("definition", definition); ret = definition; } return ret; }
static int lfmfs_getattr(const char *path, struct stat *stbuf) { int res = 0; memset(stbuf, 0, sizeof(struct stat)); if(strcmp(path, "/") == 0) { stbuf->st_mode = S_IFDIR | 0755; stbuf->st_nlink = 2; return res; } else if( getAttr( "Artists", path, stbuf )) { return res; } else if( getAttr( "Tags", path, stbuf )) { return res; } return -ENOENT; }
std::string PropertyFS::id() const { std::string t; if (hasAttr("entity_id")) { getAttr("entity_id", t); } else { throw std::runtime_error("Entity has no id!"); } return t; }
void ItemAttributes::increaseIntAttr(itemAttrTypes type, int32_t value) { if(!validateIntAttrType(type)) return; Attribute* attr = getAttr(type); if(attr){ attr->value = reinterpret_cast<void*>(static_cast<ptrdiff_t>(static_cast<uint32_t>(0xFFFFFFFF & reinterpret_cast<ptrdiff_t>(attr->value)) + value)); } }