本文整理汇总了C++中VarMap类的典型用法代码示例。如果您正苦于以下问题:C++ VarMap类的具体用法?C++ VarMap怎么用?C++ VarMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VarMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: generateOutTuple
bool generateOutTuple(std::vector<std::string> &s, lindaTuple &newTuple,
VarMap &localVars,
FunctSet &userDefinedFuncs, LoopMap &loopSymbols, int threadNum) {
for (std::vector<std::string>::iterator it = s.begin(); it != s.end(); it++) {
if (isExp(*it)) {
int result = evaluateExp(*it, loopSymbols, userDefinedFuncs, localVars, threadNum);
if (result != -1) {
newTuple.push_back(new intObj(result));
} else {
// wait and block
}
} else if (isVarPattern(*it)) {
if (localVars.find(*it) != localVars.end()) {
newTuple.push_back(localVars[*it]);
} else {
std::cout<< "Can not find local var " << *it << std::endl;
return false;
}
}
else if (isString(*it))
newTuple.push_back(new stringObj(*it));
else if (isInt(*it))
newTuple.push_back(new intObj(atoi(it->c_str())));
else if (isDouble(*it))
newTuple.push_back(new doubleObj(atof(it->c_str())));
else {
std::cout << "Parse input error: " << *it << std::endl;
exit(EXIT_FAILURE);
}
}
return true;
}
开发者ID:Jiafield,项目名称:LindaModel,代码行数:32,代码来源:tokenizer.cpp
示例2: run_one_test
Test::Result run_one_test(const std::string&, const VarMap& vars) override
{
Test::Result result("OCB wide block KAT");
const std::vector<uint8_t> key = vars.get_req_bin("Key");
const std::vector<uint8_t> nonce = vars.get_req_bin("Nonce");
const std::vector<uint8_t> ad = vars.get_req_bin("AD");
const std::vector<uint8_t> input = vars.get_req_bin("In");
const std::vector<uint8_t> expected = vars.get_req_bin("Out");
const size_t bs = key.size();
Botan::secure_vector<uint8_t> buf(input.begin(), input.end());
Botan::OCB_Encryption enc(new OCB_Wide_Test_Block_Cipher(bs), std::min<size_t>(bs, 32));
enc.set_key(key);
enc.set_ad(ad);
enc.start(nonce);
enc.finish(buf);
result.test_eq("Ciphertext matches", buf, expected);
Botan::OCB_Decryption dec(new OCB_Wide_Test_Block_Cipher(bs), std::min<size_t>(bs, 32));
dec.set_key(key);
dec.set_ad(ad);
dec.start(nonce);
dec.finish(buf);
result.test_eq("Decryption correct", buf, input);
return result;
}
开发者ID:evpo,项目名称:EncryptPad,代码行数:29,代码来源:test_ocb.cpp
示例3: walkReplaceBuiltin
ACCExpr *cleanupBool(ACCExpr *expr)
{
if (!expr)
return expr;
inBool++; // can be invoked recursively!
walkReplaceBuiltin(expr);
inBool--;
int varIndex = 0;
VarMap varMap;
DdManager * mgr = Cudd_Init(MAX_NAME_COUNT,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0);
varIndex = 0;
varMap.clear();
DdNode *bdd = tree2BDD(mgr, expr, varMap);
char const *inames[MAX_NAME_COUNT];
for (auto item: varMap)
inames[item.second->index] = strdup(item.first.c_str());
char * fform = Cudd_FactoredFormString(mgr, bdd, inames);
Cudd_RecursiveDeref(mgr, bdd);
int err = Cudd_CheckZeroRef(mgr);
if (trace_bool)
printf("%s: expr '%s' val = %s\n", __FUNCTION__, tree2str(expr).c_str(), fform);
assert(err == 0 && "Reference counting");
ACCExpr *ret = str2tree(fform);
free(fform);
Cudd_Quit(mgr);
return ret;
}
开发者ID:cambridgehackers,项目名称:atomicc,代码行数:27,代码来源:expr.cpp
示例4: TestSlice2
void TestSlice2(const VarMap& mp){
for(VarMap::const_iterator vmIt = mp.begin(); vmIt != mp.end(); ++vmIt){
std::cerr<<"-------------------------"<<std::endl;
std::cerr<<"Variable: "<<vmIt->first<<std::endl;
std::cerr<<"Slines: {";
for(unsigned int sl : vmIt->second.slines){
std::cerr<<sl<<",";
}
std::cerr<<"}"<<std::endl;
std::cerr<<"dvars: {";
for(std::string dv : vmIt->second.dvars){
std::cerr<<dv<<",";
}
std::cerr<<"}"<<std::endl;
std::cerr<<"is aliase for: {";
for(std::string al : vmIt->second.aliases){
std::cerr<<al<<",";
}
std::cerr<<"}"<<std::endl;
std::cerr<<"cfuntions: {";
for(auto cfunc : vmIt->second.cfunctions){
std::cerr<<cfunc.first<<" "<<cfunc.second<<",";
}
std::cerr<<"}"<<std::endl;
std::cerr<<"-------------------------"<<std::endl;
}
}
开发者ID:msayagh,项目名称:srcSlice,代码行数:27,代码来源:output.cpp
示例5: get_var
void get_var(Pu *L, const PuString &name, __pu_value *&v)
{
VarMap *pvarmap = L->varstack.top();
VarMap::Bucket_T *ik = pvarmap->find(name);
if (ik != 0)
{
v = &ik->value;
return;
}
pvarmap = L->varstack.bottom();
ik = pvarmap->find(name);
if (ik != 0)
{
v = &ik->value;
return;
}
if (L->upvalue && L->upvalue != pvarmap)
{
pvarmap = L->upvalue;
ik = pvarmap->find(name);
if (ik != 0)
{
v = &ik->value;
return;
}
}
MAKE_TEMP_VALUE(v);
error(L,7);
}
开发者ID:verylucky,项目名称:PuppyLanguage,代码行数:33,代码来源:pu.cpp
示例6: createVarSc
AstVarScope* createVarSc(AstVarScope* oldvarscp, string name, int width/*0==fromoldvar*/) {
// Because we've already scoped it, we may need to add both the AstVar and the AstVarScope
if (!oldvarscp->scopep()) oldvarscp->v3fatalSrc("Var unscoped");
AstVar* varp;
AstNodeModule* addmodp = oldvarscp->scopep()->modp();
// We need a new AstVar, but only one for all scopes, to match the new AstVarScope
VarMap::iterator iter = m_modVarMap.find(make_pair(addmodp,name));
if (iter != m_modVarMap.end()) {
// Created module's AstVar earlier under some other scope
varp = iter->second;
} else {
if (width==0) {
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, oldvarscp->varp());
varp->widthSignedFrom(oldvarscp);
} else { // Used for vset and dimensions, so can zero init
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, AstBitPacked(), width);
}
addmodp->addStmtp(varp);
m_modVarMap.insert(make_pair(make_pair(addmodp, name), varp));
}
AstVarScope* varscp = new AstVarScope (oldvarscp->fileline(), oldvarscp->scopep(), varp);
oldvarscp->scopep()->addVarp(varscp);
return varscp;
}
开发者ID:torc-isi,项目名称:torc,代码行数:25,代码来源:V3Delayed.cpp
示例7: getCID
QString DownloadQueue::getCID(const VarMap &map){
if (map.size() < 1)
return "";
auto it = map.constBegin();
return (it.value()).toString();
}
开发者ID:Acidburn0zzz,项目名称:eiskaltdcpp,代码行数:8,代码来源:DownloadQueue.cpp
示例8: insertVarMapIntoDOM
void ClientOptions::insertVarMapIntoDOM(ticpp::Element* parent, const VarMap &vars)
{
for (VarMap::const_iterator it = vars.begin(), end = vars.end(); it != end; ++it)
{
ticpp::Element* var = new ticpp::Element("var");
var->SetAttribute("name", it->first.c_str());
var->SetAttribute("value", it->second.c_str());
parent->LinkEndChild( var );
}
}
开发者ID:Kezeali,项目名称:Fusion,代码行数:10,代码来源:FusionClientOptions.cpp
示例9:
//=================================================================================
/*virtual*/ Node::ValueStringError BoundedPointListNode::SetValueFromString( const std::string& valueString )
{
VarMap varMap;
if( !ConvertValueStringToVarMap( valueString, varMap ) )
return VSE_SYNTAX;
Bounds trialBounds = bounds;
if( varMap.end() != varMap.find( "xMin" ) )
trialBounds.min.set_e1( varMap[ "xMin" ] );
if( varMap.end() != varMap.find( "xMax" ) )
trialBounds.max.set_e1( varMap[ "xMax" ] );
if( varMap.end() != varMap.find( "yMin" ) )
trialBounds.min.set_e2( varMap[ "yMin" ] );
if( varMap.end() != varMap.find( "yMax" ) )
trialBounds.max.set_e2( varMap[ "yMax" ] );
if( trialBounds == bounds )
return VSE_NO_CHANGE;
if( !trialBounds.IsValid() )
return VSE_INVALID;
if( !SetBounds( trialBounds ) )
return VSE_INVALID;
return VSE_NONE;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:26,代码来源:BoundedPointListNode.cpp
示例10: int
//=================================================================================
/*virtual*/ Node::ValueStringError BoundedIntegerNode::SetValueFromString( const std::string& valueString )
{
VarMap varMap;
if( !ConvertValueStringToVarMap( valueString, varMap ) )
return VSE_SYNTAX;
Data trialData = data;
if( varMap.end() != varMap.find( "min" ) )
trialData.min = int( varMap[ "min" ] );
if( varMap.end() != varMap.find( "max" ) )
trialData.max = int( varMap[ "max" ] );
if( varMap.end() != varMap.find( "value" ) )
trialData.value = int( varMap[ "value" ] );
if( varMap.end() != varMap.find( "multiple" ) )
trialData.multiple = int( varMap[ "multiple" ] );
if( !trialData.IsValid() )
return VSE_INVALID;
if( trialData == data )
return VSE_NO_CHANGE;
data = trialData;
return VSE_NONE;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:26,代码来源:BoundedIntegerNode.cpp
示例11: run_one_test
Test::Result run_one_test(const std::string&, const VarMap& vars) override
{
const std::vector<uint8_t> record = vars.get_req_bin("Record");
const size_t output = vars.get_req_sz("Output");
uint16_t res = Botan::TLS::check_tls_cbc_padding(record.data(), record.size());
Test::Result result("TLS CBC padding check");
result.test_eq("Expected", res, output);
return result;
}
开发者ID:randombit,项目名称:botan,代码行数:11,代码来源:test_tls.cpp
示例12: result
Test::Result
PK_Signature_Generation_Test::run_one_test(const std::string&, const VarMap& vars)
{
const std::vector<uint8_t> message = get_req_bin(vars, "Msg");
const std::vector<uint8_t> signature = get_req_bin(vars, "Signature");
const std::string padding = get_opt_str(vars, "Padding", default_padding(vars));
std::unique_ptr<Botan::RandomNumberGenerator> rng;
if(vars.count("Nonce"))
{
rng.reset(new Fixed_Output_RNG(get_req_bin(vars, "Nonce")));
}
Test::Result result(algo_name() + "/" + padding + " signature generation");
std::unique_ptr<Botan::Private_Key> privkey = load_private_key(vars);
std::unique_ptr<Botan::Public_Key> pubkey(Botan::X509::load_key(Botan::X509::BER_encode(*privkey)));
Botan::PK_Signer signer(*privkey, padding);
Botan::PK_Verifier verifier(*pubkey, padding);
const std::vector<uint8_t> generated_signature = signer.sign_message(message, rng ? *rng : Test::rng());
result.test_eq("generated signature matches KAT", generated_signature, signature);
result.test_eq("generated signature valid", verifier.verify_message(message, generated_signature), true);
check_invalid_signatures(result, verifier, message, signature);
result.test_eq("correct signature valid", verifier.verify_message(message, signature), true);
return result;
}
开发者ID:Chaosvex,项目名称:botan,代码行数:30,代码来源:test_pubkey.cpp
示例13:
//=================================================================================
/*static*/ bool Node::ConvertValueStringFromVarMap( std::string& valueString, const VarMap& varMap )
{
valueString = "";
for( VarMap::const_iterator iter = varMap.begin(); iter != varMap.end(); iter++ )
{
std::string key = iter->first;
double numericalValue = iter->second;
std::ostringstream stream;
stream << numericalValue;
std::string value = stream.str();
if( !valueString.empty() )
valueString += ", ";
valueString += key + "=" + value;
}
return true;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:18,代码来源:Node.cpp
示例14: visit
virtual void visit(AstVarRef* nodep, AstNUser*) {
if (nodep->lvalue() && !nodep->user2()) {
nodep->user2(true); // mark this ref as visited
AstVar* key = nodep->varp();
VarMap::iterator it = m_lhsmapp->find(key);
if (it == m_lhsmapp->end()) {
// this key does not exist yet, so create it
RefVec* refs = new RefVec();
refs->push_back(nodep);
m_lhsmapp->insert(pair<AstVar*, RefVec*>(key, refs));
} else {
(*it).second->push_back(nodep);
}
nodep->user3p(m_sel); // attach the sel to this varref
}
nodep->iterateChildren(*this);
}
开发者ID:torc-isi,项目名称:torc,代码行数:18,代码来源:V3Tristate.cpp
示例15:
static __pu_value *get_varref(Pu *L, PuString &name)
{
VarMap *pvarmap = L->varstack.top();
VarMap::Bucket_T *ik = pvarmap->find(name);
if (ik != 0)
{
return &(ik->value);
}
pvarmap = L->varstack.bottom();
ik = pvarmap->find(name);
if (ik != 0)
{
return &(ik->value);
}
return NULL;
}
开发者ID:verylucky,项目名称:PuppyLanguage,代码行数:18,代码来源:pu.cpp
示例16: run_one_test
Test::Result run_one_test(const std::string& algo, const VarMap& vars) override
{
Test::Result result(algo + " Decoding");
std::unique_ptr<Botan::EME> eme;
try
{
eme.reset(Botan::get_eme(algo));
}
catch(Botan::Lookup_Error&)
{
result.note_missing(algo);
return result;
}
const std::vector<uint8_t> ciphertext = vars.get_req_bin("RawCiphertext");
const std::vector<uint8_t> plaintext = vars.get_opt_bin("Plaintext");
const bool is_valid = vars.get_req_bool("ValidInput");
if(is_valid == false)
{
result.test_eq("Plaintext value is empty for invalid EME inputs", plaintext.size(), 0);
}
uint8_t valid_mask = 0;
Botan::secure_vector<uint8_t> decoded =
eme->unpad(valid_mask, ciphertext.data(), ciphertext.size());
result.confirm("EME valid_mask has expected value", valid_mask == 0x00 || valid_mask == 0xFF);
result.test_eq("EME decoding valid/invalid matches", valid_mask == 0xFF, is_valid);
if(is_valid && valid_mask == 0xFF)
{
result.test_eq("EME decoded plaintext correct", decoded, plaintext);
}
// TODO: also test that encoding is accepted
return result;
}
开发者ID:evpo,项目名称:EncryptPad,代码行数:41,代码来源:test_pk_pad.cpp
示例17: evaluateExp
int evaluateExp(std::string expr, LoopMap &loopSymbols, FunctSet &userDefinedFuncs, VarMap &localVars, int threadNum) {
int result = -1;
std::string expName = (expr).substr(0, (expr).find("("));
std::string expNameT = expName + std::to_string(static_cast<long long int>(threadNum));
size_t start = (expr).find("(") + 1;
size_t end = (expr).find_last_of(")");
std::string params = (expr).substr(start, end - start);
if (userDefinedFuncs.find(expNameT) != userDefinedFuncs.end()) {
// Case 1: The expression is a user defined function
if (!isInt(params)) {
if (loopSymbols.find(params) != loopSymbols.end()) {
params = std::to_string(static_cast<long long int>(loopSymbols[params]));
} else if (localVars.find(params) != localVars.end()) {
intObj *intO = dynamic_cast<intObj *>(localVars[params]);
params = std::to_string(static_cast<long long int>(intO->get()));
}
}
int status = system(("./" + expNameT + " " + params).c_str());
result = WEXITSTATUS(status);
} else {
// Case 2: The expression is inp or rdp
//std::cout << "condition is " << expr << std::endl;
LINDA_TYPE type = findFunctionType(expr);
//std::cout << "expr type is " << type << std::endl;
std::vector<std::string> elems;
if (type == INP) {
getInOutElems(expr, elems);
return inp(elems, localVars, userDefinedFuncs, loopSymbols, threadNum);
} else if (type == RDP) {
getInOutElems(expr, elems);
return rdp(elems, localVars, userDefinedFuncs, loopSymbols, threadNum);
} else {
std::cout << "Couldn't evaluate expression " << expr << std::endl;
std::cout << "No boolean return type or couldn't find expr name" << std::endl;
exit(EXIT_FAILURE);
}
}
return result;
}
开发者ID:Jiafield,项目名称:LindaModel,代码行数:40,代码来源:tokenizer.cpp
示例18: __pu_value
__pu_value *reg_var(Pu *L, const PuString &varname)
{
__pu_value *got = NULL;
VarMap *varmap = L->varstack.top();
VarMap::Bucket_T *it = varmap->find(varname);
if (it != 0)
{
got = &(it->value);
}
else
{
VarMap *varmap = L->varstack.bottom();
VarMap::Bucket_T *it = varmap->find(varname);
if (it != 0)
{
got = &(it->value);
}
}
if (got == NULL)
{
VarMap *varmap = L->varstack.top();
VarMap::Bucket_T *ret = varmap->insert(varname, __pu_value(L));
got = &(ret->value);
}
return got;
}
开发者ID:verylucky,项目名称:PuppyLanguage,代码行数:28,代码来源:pu.cpp
示例19:
//=================================================================================
/*virtual*/ Node::ValueStringError ConeNode::SetValueFromString( const std::string& valueString )
{
ValueStringError vse = VectorE3GANode::SetValueFromString( valueString );
if( !( vse == VSE_NONE || vse == VSE_NO_CHANGE ) )
return vse;
VarMap varMap;
if( !ConvertValueStringToVarMap( valueString, varMap ) )
return VSE_SYNTAX;
double trialConeAngle = coneAngle;
if( varMap.end() != varMap.find( "coneAngle" ) )
trialConeAngle = varMap[ "coneAngle" ];
if( trialConeAngle < 0.0 || trialConeAngle > M_PI )
return VSE_INVALID;
if( trialConeAngle == coneAngle && vse == VSE_NO_CHANGE )
return VSE_NO_CHANGE;
coneAngle = trialConeAngle;
return VSE_NONE;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:24,代码来源:ConeNode.cpp
示例20:
//=================================================================================
/*virtual*/ Node::ValueStringError BivectorE3GANode::SetValueFromString( const std::string& valueString )
{
VarMap varMap;
if( !ConvertValueStringToVarMap( valueString, varMap ) )
return VSE_SYNTAX;
// Get the new bivector.
c3ga::bivectorE3GA trialBivector = *bivector;
if( varMap.end() != varMap.find( "yz" ) )
trialBivector.set_e2_e3( varMap[ "yz" ] );
if( varMap.end() != varMap.find( "zx" ) )
trialBivector.set_e3_e1( varMap[ "zx" ] );
if( varMap.end() != varMap.find( "xy" ) )
trialBivector.set_e1_e2( varMap[ "xy" ] );
// Validate the new bivector.
if( c3ga::norm( trialBivector ) > maxArea )
return VSE_INVALID;
// Get the new max-area.
double trialMaxArea = maxArea;
if( varMap.end() != varMap.find( "maxArea" ) )
trialMaxArea = varMap[ "maxArea" ];
// Validate the new max-area.
if( trialMaxArea <= 0.0 )
return VSE_INVALID;
// Reject if no change occurred.
if( c3ga::equals( trialBivector, *bivector, 0.0 ) && trialMaxArea == maxArea )
return VSE_NO_CHANGE;
// Accept the new values.
*bivector = trialBivector;
maxArea = trialMaxArea;
return VSE_NONE;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:38,代码来源:BivectorE3GANode.cpp
注:本文中的VarMap类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论