4 #include "KVClassFactory.h"
5 #include "KVNameValueList.h"
87 if (&o !=
this) o.
Copy(*
this);
142 if (!list.
Contains(
"="))
return false;
146 while (!list.
End()) {
195 for (
auto& par : *
this) {
196 if (list.
Length()) list +=
",";
197 list +=
Form(
"%s=", par.GetName());
199 list += par.GetString();
200 else if (par.IsDouble())
201 list +=
Form(
"%g", par.GetDouble());
202 else if (par.IsInt())
203 list +=
Form(
"%d", par.GetInt());
274 for (
Int_t ii = 0; ii < np1; ii += 1) {
279 TIter next(&toBeRemoved);
305 cout <<
"KVNameValueList::" <<
GetName() <<
" : " <<
GetTitle() <<
" (" <<
this <<
")" << endl;
310 if (!_options.
End()) exclude = _options.
Next();
315 if (
n.EndsWith(
"_lo") ||
n.EndsWith(
"_hi")) {
316 n.Remove(
n.Length() - 3, 3);
341 else cout <<
"KVNameValueList";
343 for (
int i = 0; i <
GetNpar(); ++i) {
359 if (i <
GetNpar() - 1) cout <<
",";
379 for (
Int_t ii = 0; ii < np1; ii += 1) {
380 for (
Int_t jj = 0; jj < np2; jj += 1) {
553 while ((par = next())) {
557 Error(
"GetNameIndex",
"Parameter \"%s\" not found, -1 returned",
name);
577 Error(
"GetNameAt",
"index has to be less than %d, empty string is returned",
GetNpar());
598 Error(
"GetStringValue(const Char_t*)",
"\"%s\" does not correspond to an existing parameter, default value \"-1\" is returned",
name);
629 Error(
"GetStringValue(Int_t)",
"index has to be less than %d, \"-1\" is returned\n",
GetNpar());
676 Error(
"ReadEnvFile",
"The file %s does not exist",
filename);
721 TIter next_nv(name_value_list);
723 while ((nv_pair = (
TEnvRec*)next_nv())) {
735 if (!
fIgnoreBool && (PARVAL ==
"TRUE" || PARVAL ==
"FALSE" || PARVAL ==
"ON" || PARVAL ==
"OFF"
736 || PARVAL ==
"YES" || PARVAL ==
"NO" || PARVAL ==
"OK" || PARVAL ==
"NOT"))
753 auto envfile = std::make_unique<KVEnv>();
754 envfile->SetValue(
"KVNameValueList.Name",
GetName());
755 envfile->SetValue(
"KVNameValueList.Title",
GetTitle());
864 for (
int i = 0; i < other.
GetNpar(); ++i) {
889 if (!_options.
End()) exclude = _options.
Next();
893 if (
n.EndsWith(
"_lo") ||
n.EndsWith(
"_hi")) {
894 n.Remove(
n.Length() - 3, 3);
896 if (output !=
"{") output +=
", ";
906 if (output !=
"{") output +=
", ";
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
char * Form(const char *fmt,...)
Factory class for generating skeleton files for new classes.
void GenerateCode()
Generate header and implementation file for currently-defined class.
void AddGetSetMethods(const KVNameValueList &)
For each named parameter in the list, we add protected member variables with the name and type of the...
Extension of TEnv to allow the writing of comments in the file.
Extended version of ROOT THashList.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
void Copy(TObject &nvl) const override
Int_t GetIntValue(const Char_t *name) const
Bool_t HasValue64bit(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
std::unique_ptr< KVEnv > ProduceEnvFile()
Put all name-value pairs in this list as a TEnv format.
void RemoveParameter(const Char_t *name)
void SetValue64bit(const Char_t *name, ULong64_t)
void SetFromEnv(TEnv *tenv, const TString &prefix="")
const Char_t * GetNameAt(Int_t idx) const
void ls(Option_t *opt="") const override
Int_t GetNpar() const
return the number of stored parameters
void ReadEnv(const TEnv &)
virtual void ClearSelection(const TRegexp &)
virtual void ReadEnvFile(const Char_t *filename)
TString List(Option_t *opt="") const
void Concatenate(const KVNameValueList &nvl)
virtual void WriteEnvFile(const Char_t *filename)
Write all name-value pairs in this list as a TEnv format file.
Int_t GetNameIndex(const Char_t *name) const
void Merge(const KVNameValueList &)
KVNamedParameter * FindParameter(const Char_t *name) const
return the parameter object with the asking name
Int_t Compare(const TObject *nvl) const override
KVNameValueList & operator=(const KVNameValueList &)
KVHashList fList
list of KVNamedParameter objects
Bool_t HasIntParameter(const Char_t *name) const
void Clear(Option_t *opt="") override
void WriteClass(const Char_t *classname, const Char_t *classdesc, const Char_t *base_class="")
ULong64_t GetValue64bit(const Char_t *name) const
bool Set(const KVString &)
Bool_t HasParameter(const Char_t *name) const
void Print(Option_t *opt="") const override
void AddValue(const KVNamedParameter &p)
KVHashList * GetList() const
TString GetTStringValue(const Char_t *name) const
void WriteToEnv(TEnv *tenv, const TString &prefix="")
A generic named parameter storing values of different types.
const Char_t * GetString() const
void Set(const char *, const char *)
void Add(const KVNamedParameter &p)
Double_t GetDouble() const
void WriteToEnv(TEnv *, const TString &p="")
Write parameter in TEnv, using optional prefix p as "p.[name]".
TString GetTString() const
TString List(Option_t *opt="") const
void ls(Option_t *opt="") const override
void Copy(TObject &obj) const override
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
TObject * FindObject(const char *name) const override
void Clear(Option_t *option="") override
void SetOwner(Bool_t enable=kTRUE) override
TObject * At(Int_t idx) const override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
virtual Int_t GetEntries() const
const char * GetValue() const
const char * GetName() const override
THashList * GetTable() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
void Add(TObject *obj) override
void Delete(Option_t *option="") override
void Copy(TObject &named) const override
virtual void SetTitle(const char *title="")
const char * GetName() const override
const char * GetTitle() const override
virtual void SetName(const char *name)
virtual const char * GetName() const
virtual void Error(const char *method, const char *msgfmt,...) const
static Int_t IncreaseDirLevel()
static void IndentLevel()
static Int_t DecreaseDirLevel()
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
unsigned long long ULong64_t
Type GetType(const std::string &Name)