Enhanced the dictionary object (added get by index and getParameter methods)
This commit is contained in:
parent
cbf88aff25
commit
dc96053576
@ -59,13 +59,19 @@ Dictionary Dictionary::get(const char *parameter)
|
||||
|
||||
Dictionary Dictionary::operator()(const char *parameter)
|
||||
{
|
||||
return get(parameter);
|
||||
}
|
||||
|
||||
Dictionary Dictionary::get(const unsigned int index)
|
||||
{
|
||||
unsigned int position(0);
|
||||
if(isListEmpty(_head->_next))return Dictionary();
|
||||
|
||||
Dictionary *cursor = _head->_next;
|
||||
|
||||
while(!isListEmpty(cursor))
|
||||
{
|
||||
if(strcmp(cursor->_parameter,parameter) == 0)
|
||||
if(position++ == index)
|
||||
return *cursor;
|
||||
cursor = cursor->_next;
|
||||
}
|
||||
@ -73,6 +79,11 @@ Dictionary Dictionary::operator()(const char *parameter)
|
||||
return Dictionary();
|
||||
}
|
||||
|
||||
Dictionary Dictionary::operator()(const unsigned int index)
|
||||
{
|
||||
return get(index);
|
||||
}
|
||||
|
||||
unsigned int Dictionary::count()
|
||||
{
|
||||
unsigned int counter(0);
|
||||
@ -158,3 +169,4 @@ void Dictionary::dispose()
|
||||
}
|
||||
|
||||
void Dictionary::clear() {this->dispose();}
|
||||
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
boolean deleteParameter(const char *parameter);
|
||||
Dictionary get(const char *parameter);
|
||||
Dictionary operator()(const char *parameter);
|
||||
Dictionary get(const unsigned int index);
|
||||
Dictionary operator()(const unsigned int index);
|
||||
unsigned int count();
|
||||
void clear();
|
||||
void dispose();
|
||||
@ -47,6 +49,7 @@ public:
|
||||
return false;
|
||||
return strcmp(_value,"true") == 0 || strcmp(_value,"TRUE") == 0 ? true : false;
|
||||
}
|
||||
const char *getParameter() const{return _parameter == NULL ? "" : _parameter;}
|
||||
protected:
|
||||
Dictionary();
|
||||
Dictionary(const char *parameter, const char *value);
|
||||
|
Loading…
Reference in New Issue
Block a user