Beam-lib  2.16.3
This is the Beam C++ class library.
BNameValue.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * BNameValue.h Beam Name Vlaue Object
3  * T.Barnaby, BEAM Ltd, 16/8/00
4  * Copyright (c) 2012 All Right Reserved, Beam Ltd, http://www.beam.ltd.uk
5  *******************************************************************************
6  */
7 #ifndef BNAMEVALUE_H
8 #define BNAMEVALUE_H 1
9 
10 #include <BList.h>
11 #include <BString.h>
12 
13 template <class T> class BNameValue {
14 public:
16  }
17  BNameValue(BString name, const T& value){
18  oname = name;
19  ovalue = value;
20  }
21 
22  BString getName(){ return oname; }
23  T& getValue(){ return ovalue; }
24 private:
25  BString oname;
26  T ovalue;
27 };
28 
29 template <class T> class BNameValueList : public BList< BNameValue<T> > {
30 public:
31  T* find(BString name){
32  for(BIter i = this->begin(); !this->isEnd(i); this->next(i)){
33  if(this->get(i).getName() == name)
34  return &this->get(i).getValue();
35  }
36  return 0;
37  }
39  for(BIter i = this->begin(); !this->isEnd(i); this->next(i)){
40  if(this->get(i).getName() == name)
41  return i;
42  }
43  return this->onodes;
44  }
45 };
46 
47 #endif
Iterator for BList.
Definition: BList.h:18
Definition: BString.h:18
Template based list class.
Definition: BList.h:30
int isEnd(BIter &i) const
True if iterator refers to last item.
Definition: BList_func.h:98
BNameValue(BString name, const T &value)
Definition: BNameValue.h:17
T * find(BString name)
Definition: BNameValue.h:31
BNameValue()
Definition: BNameValue.h:15
BString getName()
Definition: BNameValue.h:22
Definition: BNameValue.h:13
BIter begin() const
Iterator for start of list.
Definition: BList_func.h:36
BIter findPos(BString name)
Definition: BNameValue.h:38
void next(BIter &i) const
Iterator for next item in list.
Definition: BList_func.h:49
Node * onodes
Definition: BList.h:103
Definition: BNameValue.h:29
BNameValue< T > & get(BIter i)
Get item specified by iterator in list.
Definition: BList_func.h:119
T & getValue()
Definition: BNameValue.h:23