本文整理汇总了C++中KVNameValueList::GetParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ KVNameValueList::GetParameter方法的具体用法?C++ KVNameValueList::GetParameter怎么用?C++ KVNameValueList::GetParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KVNameValueList
的用法示例。
在下文中一共展示了KVNameValueList::GetParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Merge
void KVNameValueList::Merge(const KVNameValueList& other)
{
// Merge other list into this one.
// Any parameters in 'other' which do not exist in this one are added.
// Any parameters which exist in both have their values summed.
for (int i = 0; i < other.GetNpar(); ++i) {
KVNamedParameter* np_other = other.GetParameter(i);
AddValue(*np_other);
}
}
示例2: AddGetSetMethods
void KVClassFactory::AddGetSetMethods(const KVNameValueList& nvl)
{
// For each named parameter in the list, we add protected member variables and
// public Get/Set methods with the name and type of the parameter.
// Example: given a list containing NAME="some string" NUMBER=3 [integer]
// PI=3.141592 [double], we generate the methods
// void SetNAME(const TString&);
// const TString& GetNAME() const;
// void SetNUMBER(Int_t);
// Int_t GetNUMBER() const;
// void SetPI(Double_t);
// Double_t GetPI() const;
int npars = nvl.GetNpar();
for(int i=0; i<npars; i++){
KVNamedParameter* par = nvl.GetParameter(i);
if(par->IsString()){
KVClassMember* v = AddMember(par->GetName(),"TString","member automatically generated by KVClassFactory::AddGetSetMethods");
KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void");
m->AddArgument("const TString&");
m->SetMethodBody(
Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
" %s=arg1;", v->GetName())
);
m = AddMethod(Form("Get%s",par->GetName()), "const TString&", "public", kFALSE, kTRUE);
m->SetMethodBody(
Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
" return %s;", v->GetName())
);
// make sure #include "TString.h" appears in header file
if( ! fHeadInc.FindObject("TString.h") ) AddHeaderIncludeFile("TString.h");
}
else if(par->IsInt()){
KVClassMember* v = AddMember(par->GetName(),"Int_t","member automatically generated by KVClassFactory::AddGetSetMethods");
KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void");
m->AddArgument("Int_t");
m->SetMethodBody(
Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
" %s=arg1;", v->GetName())
);
m = AddMethod(Form("Get%s",par->GetName()), "Int_t", "public", kFALSE, kTRUE);
m->SetMethodBody(
Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
" return %s;", v->GetName())
);
}
else if(par->IsDouble()){
KVClassMember* v = AddMember(par->GetName(),"Double_t","member automatically generated by KVClassFactory::AddGetSetMethods");
KVClassMethod* m = AddMethod(Form("Set%s",par->GetName()), "void");
m->AddArgument("Double_t");
m->SetMethodBody(
Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
" %s=arg1;", v->GetName())
);
m = AddMethod(Form("Get%s",par->GetName()), "Double_t", "public", kFALSE, kTRUE);
m->SetMethodBody(
Form(" // Method automatically generated by KVClassFactory::AddGetSetMethods\n"
"\n"
" return %s;", v->GetName())
);
}
}
}