std::string OptionBinds::Item::getValueString() const { if (getValueStr) return getValueStr(); else return option->getValueString(); }
string cConfigItem::getJson() { JsonExport json; json.add("name", config_name); json.add("type", getTypeName()); if(subtype.length()) { json.add("subtype", subtype); } if(description.length()) { json.add("description", description); } if(help.length()) { json.add("help", help); } json.add("set", set); json.add("value", json_encode(getValueStr())); json.add("default", json_encode(defaultValueStr)); json.add("group", group_name); json.add("level", level); json.add("minor", minor); list<sMapValue> menuItems = getMenuItems(); if(menuItems.size()) { ostringstream outStr; int counter = 0; for(list<sMapValue>::iterator iter = menuItems.begin(); iter != menuItems.end(); iter++) { if(counter) { outStr << ';'; } outStr << iter->str << ':' << iter->value; ++counter; } json.add("menu", json_encode(outStr.str())); } return(json.getJson()); }
void BipartiteWeightedMatchingBinding::printTable(raw_ostream &out, std::string funcUnitType, int numOperationsToShare, int numFuncUnitsAvail, Table &weights) { std::string s; std::stringstream ss; const int firstColWidth = 50; ss << setw(firstColWidth) << " "; for (int fu = 0; fu < numFuncUnitsAvail; fu++) { std::string fuId = this->alloc->verilogNameFunction(this->Fp, this->Fp) + "_" + funcUnitType + "_" + utostr(fu); ss << left << setw(30) << fuId; } ss << "\n"; for (int o = 0; o < numOperationsToShare; o++) { std::string instStr = getValueStr(opInstr[o]); limitString(instStr, 30); std::string opStr = instStr + " (idx: " + utostr(o) + ")"; ss << left << setw(firstColWidth) << opStr; for (int fu = 0; fu < numFuncUnitsAvail; fu++) { ss << left << setw(30) << weights[fu][o]; } ss << "\n"; } ss.flush(); out << ss.str(); }
std::vector<Section> Config::getSectionList() { int count = getNumValues("project"); std::vector<Section> ret; for(int i = 0; i < count; i++){ std::string filename = getValueStr("project", i); try { std::ifstream in(filename.c_str()); std::string line; while(getline(in, line).good()){ Section sec; if(parseSection(line, sec)){ sec.source = filename; ret.push_back(sec); } } in.close(); } catch (std::ifstream::failure ex){ LOG("could not load file: " << filename, LOG_VERBOSE); } } return ret; }
bool Config::getValueBool(std::string key, int index){ std::string tmp = getValueStr(key, index); if(tmp == "true" || tmp == "yes" || tmp == "1" || tmp == "si" || tmp == "ja" || tmp == "da" || tmp == "oui" || tmp == "jawohl"){ return true; }else{ return false; } }
std::vector<std::string> Config::getValues(std::string key) { std::vector<std::string> ret; for(int i = 0; i < getNumValues(key); i++) ret.push_back(getValueStr(key, i)); return ret; }
bool Config::containsValue(std::string key, std::string value) { int nv = getNumValues(key); for(int i = 0; i < nv; i++) if(getValueStr(key, i) == value) return true; return false; }
BOOL LLDataPackerAsciiFile::unpackString(std::string& value, const char *name) { BOOL success = TRUE; char valuestr[DP_BUFSIZE]; /* Flawfinder: ignore */ if (!getValueStr(name, valuestr, DP_BUFSIZE)) { return FALSE; } value = valuestr; return success; }
BOOL LLDataPackerAsciiBuffer::unpackF32(F32 &value, const char *name) { BOOL success = TRUE; char valuestr[DP_BUFSIZE]; /* Flawfinder: ignore */ if (!getValueStr(name, valuestr, DP_BUFSIZE)) { return FALSE; } sscanf(valuestr,"%f", &value); return success; }
BOOL LLDataPackerAsciiBuffer::unpackString(std::string& value, const char *name) { BOOL success = TRUE; char valuestr[DP_BUFSIZE]; /*Flawfinder: ignore*/ BOOL res = getValueStr(name, valuestr, DP_BUFSIZE); // NULL terminated if (!res) // { return FALSE; } value = valuestr; return success; }
BOOL LLDataPackerAsciiFile::unpackVector4(LLVector4 &value, const char *name) { BOOL success = TRUE; char valuestr[DP_BUFSIZE]; /*Flawfinder: ignore */ if (!getValueStr(name, valuestr, DP_BUFSIZE)) { return FALSE; } sscanf(valuestr,"%f %f %f %f", &value.mV[0], &value.mV[1], &value.mV[2], &value.mV[3]); return success; }
std::string Config::getValueStr(std::string key, std::string addBefore, std::string separator, std::string addAfter, bool reverse) { std::string ret; if(configItems.count(key) != 0 && getValueStr(key, 0) != ""){ ret.append(addBefore); bool first = true; int start = reverse ? getNumValues(key) - 1 : 0; int end = reverse ? -1 : getNumValues(key); for(int i = start; i != end; i += reverse ? -1 : 1){ if(first){ first = false; }else{ ret.append(separator); } ret.append(getValueStr(key, i)); } ret.append(addAfter); } return ret; }
std::string Config::getValueStr(std::string key, int index, int depth) { //LOG("Looking up: " << key, LOG_DEBUG); if(depth > SPANK_MAX_RECURSE){ LOG("Recurse limit (" << SPANK_MAX_RECURSE << ") exceeded in Config::getValueStr(), probably because of key self referencing (or indirect self referencing).", LOG_ERROR); LOG("Might be in: " << key << "[" << index << "]", LOG_INFO); return ""; } if(configItems.count(key) != 0){ if((unsigned int)index <= configItems[key].value.size()){ std::string ret = configItems[key].value.at(index); //LOG("Parsing string: " << ret, LOG_DEBUG); size_t start = 0; while((start = ret.find("$("), start) != std::string::npos){ size_t stop = ret.find(")", start); //LOG("start: " << start, LOG_DEBUG); //LOG("stop: " << stop, LOG_DEBUG); if(stop == std::string::npos){ LOG("Error parsing key refernce: expected ')' near '" << ret << "'", LOG_ERROR); } std::string ref = ret.substr(start + 2, stop - start - 2); //LOG("reference: " << ref, LOG_DEBUG); std::string rep = getValueStr(ref, 0, depth + 1); //LOG("replacement value: " << rep, LOG_DEBUG); ret.replace(start, stop - start + 1, rep); //LOG("resulting string: " << ret, LOG_DEBUG); } return ret; } } char* env = getenv(key.c_str()); if(env){ return env; } ThrowEx(ConfigException, "Couldn't find config key: '" << key << "'"); return ""; }
BOOL LLDataPackerAsciiBuffer::unpackU16(U16 &value, const char *name) { BOOL success = TRUE; char valuestr[DP_BUFSIZE]; /* Flawfinder: ignore */ if (!getValueStr(name, valuestr, DP_BUFSIZE)) { return FALSE; } S32 in_val; sscanf(valuestr,"%d", &in_val); value = in_val; return success; }
BOOL LLDataPackerAsciiFile::unpackUUID(LLUUID &value, const char *name) { BOOL success = TRUE; char valuestr[DP_BUFSIZE]; /*Flawfinder: ignore */ if (!getValueStr(name, valuestr, DP_BUFSIZE)) { return FALSE; } char tmp_str[64]; /*Flawfinder: ignore */ sscanf(valuestr,"%63s",tmp_str); /* Flawfinder: ignore */ value.set(tmp_str); return success; }
void BipartiteWeightedMatchingBinding::UpdateAssignments(raw_ostream &out, int numOperationsToShare, std::string funcUnitType, int numFuncUnitsAvail, AssignmentInfo &assigned, Table &assignments) { std::string s; std::stringstream ss; // Note that assignments (and weights) are square matrices, // numFuncUnitsAvail x numFuncUnitsAvail // However, numOperationsToShare <= numFuncUnitsAvail so the iteration // below is within bounds assert(numOperationsToShare <= numFuncUnitsAvail); for (int fu = 0; fu < numFuncUnitsAvail; fu++) { for (int o = 0; o < numOperationsToShare; o++) { if (assignments[fu][o]) { Instruction *I = opInstr[o]; std::string fuId = this->alloc->verilogNameFunction(this->Fp, this->Fp) + "_" + funcUnitType + "_" + utostr(fu); this->BindingInstrFU[I] = fuId; int numOperands = 0; for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) { Instruction *operand = dyn_cast<Instruction>(*i); numOperands++; if (!operand) continue; if (assigned.existingOperands[fuId].find(operand) == assigned.existingOperands[fuId].end()) { assigned.existingOperands[fuId].insert(operand); assigned.muxInputs[fuId]++; } } std::string instStr = getValueStr(opInstr[o]); limitString(instStr, 30); ss << instStr << " (idx: " << o << ") -> " << fuId << " (mux inputs: " << assigned.muxInputs[fuId] << ")\n"; // number of operands for mem_dual_port is not 2 //assert(numOperands == 2); assigned.existingInstructions[fuId].insert(I); } } } ss.flush(); out << ss.str(); }
BOOL LLDataPackerAsciiFile::unpackColor4U(LLColor4U &value, const char *name) { BOOL success = TRUE; char valuestr[DP_BUFSIZE]; /*Flawfinder: ignore */ if (!getValueStr(name, valuestr, DP_BUFSIZE)) { return FALSE; } S32 r, g, b, a; sscanf(valuestr,"%d %d %d %d", &r, &g, &b, &a); value.mV[0] = r; value.mV[1] = g; value.mV[2] = b; value.mV[3] = a; return success; }
BOOL LLDataPackerAsciiBuffer::unpackBinaryDataFixed(U8 *value, S32 size, const char *name) { BOOL success = TRUE; char valuestr[DP_BUFSIZE]; /* Flawfinder: ignore */ if (!getValueStr(name, valuestr, DP_BUFSIZE)) { return FALSE; } char *cur_pos = &valuestr[0]; S32 i; for (i = 0; i < size; i++) { S32 val; sscanf(cur_pos,"%02x", &val); value[i] = val; cur_pos += 3; } return success; }
void BipartiteWeightedMatchingBinding::constructWeights(raw_ostream &out, Instruction *I, int operationIdx, std::string funcUnitType, int numFuncUnitsAvail, AssignmentInfo &assigned, Table &weights) { int existingMuxInputsFactor = 1; int newMuxInputsFactor = 10; // note: this is negative, a shared output register reduces the cost int outputRegisterSharableFactor = -5; for (int fu = 0; fu < numFuncUnitsAvail; fu++) { int weight = 0; std::string fuId = this->alloc->verilogNameFunction(this->Fp, this->Fp) + "_" + funcUnitType + "_" + utostr(fu); // check both operands for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) { Instruction *operand = dyn_cast<Instruction>(*i); if (!operand) continue; if (assigned.existingOperands[fuId].find(operand) == assigned.existingOperands[fuId].end()) { weight += newMuxInputsFactor; } else { std::string instStr = getValueStr(I); limitString(instStr, 30); out << instStr << " can share an input with another operation " "already assigned to " << fuId << "\n"; } } bool outputRegSharable = false; for (set<Instruction*>::iterator i = assigned.existingInstructions[fuId].begin(), e = assigned.existingInstructions[fuId].end(); i != e; ++i) { Instruction *shared = *i; // check for shared output register if (assigned.IndependentInstructions[I].find(shared) != assigned.IndependentInstructions[I].end() ) { //errs() << "Shared output: " << *shared << "\n"; outputRegSharable = true; break; } } if (outputRegSharable) { weight += outputRegisterSharableFactor; std::string instStr = getValueStr(I); limitString(instStr, 30); out << instStr << " can share an output register with another " "operation already assigned to " << fuId << "\n"; } weight += existingMuxInputsFactor * assigned.muxInputs[fuId]; weights[fu][operationIdx] = weight; //errs() << "weight " << fu << " " << operationIdx << " = " << // weights[fu][operationIdx] << "\n"; } }
void cConfigItem::setDefaultValue() { if(defaultValueStr.empty() && !naDefaultValueStr) { defaultValueStr = getValueStr(); } }
/** Get the data stored in a given cell of the table. */ QVariant KsViewModel::getValue(int column, int row) const { return getValueStr(column, row); }
std::string Config::getValueStr(std::string key, std::string separator){ return getValueStr(key, "", separator, ""); }