BDS Public
Beamlib 3.3.4
This is the Beam C++ class library.
Loading...
Searching...
No Matches
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) 2022 All Right Reserved, Beam Ltd, https://www.beam.ltd.uk
5 * For license see LICENSE.txt at the root of the beamlib source tree.
6 *******************************************************************************
7 */
8#ifndef BNAMEVALUE_H
9#define BNAMEVALUE_H 1
10
11#include <BList.h>
12#include <BString.h>
13
15template <class T> class BNameValue {
16public:
18 }
19 BNameValue(BString name, const T& value){
20 oname = name;
21 ovalue = value;
22 }
23
24 BString getName(){ return oname; }
25 T& getValue(){ return ovalue; }
26private:
27 BString oname;
28 T ovalue;
29};
30
32template <class T> class BNameValueList : public BList< BNameValue<T> > {
33public:
34 T* find(BString name){
35 for(BIter i = this->begin(); !this->isEnd(i); this->next(i)){
36 if(this->get(i).getName() == name)
37 return &this->get(i).getValue();
38 }
39 return 0;
40 }
42 for(BIter i = this->begin(); !this->isEnd(i); this->next(i)){
43 if(this->get(i).getName() == name)
44 return i;
45 }
46 return this->onodes;
47 }
48};
49
50#endif
Iterator for BLists.
Definition BList.h:20
Template based list class.
Definition BList.h:31
void next(BIter &i) const
Iterator for next item in list.
Definition BList_func.h:60
int isEnd(BIter &i) const
True if iterator refers to last item.
Definition BList_func.h:109
BNameValue< T > & get(BIter i)
Get item specified by iterator in list.
Definition BList_func.h:130
BIter begin() const
Iterator for start of list.
Definition BList_func.h:47
Node * onodes
Definition BList.h:106
A simple, templated, name/value pair list.
Definition BNameValue.h:32
BIter findPos(BString name)
Definition BNameValue.h:41
T * find(BString name)
Definition BNameValue.h:34
A simple, templated, name/value pair.
Definition BNameValue.h:15
T & getValue()
Definition BNameValue.h:25
BString getName()
Definition BNameValue.h:24
BNameValue()
Definition BNameValue.h:17
BNameValue(BString name, const T &value)
Definition BNameValue.h:19
This class stores and manipulates ASCII strings.
Definition BString.h:20