added const access for operator[] (issue #7)
This commit is contained in:
parent
83621790f4
commit
bcc6eaff82
|
|
@ -110,7 +110,7 @@ public:
|
||||||
* @param index field index
|
* @param index field index
|
||||||
* @return Field
|
* @return Field
|
||||||
*/
|
*/
|
||||||
const Field &get(uint8_t index);
|
const Field &get(uint8_t index) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of elements on this array
|
* Get number of elements on this array
|
||||||
|
|
@ -141,6 +141,16 @@ public:
|
||||||
{
|
{
|
||||||
return ArrayFieldProxy(this, index);
|
return ArrayFieldProxy(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a const field
|
||||||
|
* @param index field index
|
||||||
|
* @return Field
|
||||||
|
*/
|
||||||
|
const Field &operator[](uint8_t index) const
|
||||||
|
{
|
||||||
|
return get(index);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write encoded payload to the given buffer.
|
* Write encoded payload to the given buffer.
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,16 @@ public:
|
||||||
return AssociativeFieldProxy(this, name);
|
return AssociativeFieldProxy(this, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a const field
|
||||||
|
*
|
||||||
|
* @param name field name
|
||||||
|
*/
|
||||||
|
const Field &operator[](const std::string& name) const
|
||||||
|
{
|
||||||
|
return get(name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write encoded payload to the given buffer.
|
* Write encoded payload to the given buffer.
|
||||||
* @param buffer
|
* @param buffer
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ Array::Array(const Array &array)
|
||||||
* @param index field index
|
* @param index field index
|
||||||
* @return Field
|
* @return Field
|
||||||
*/
|
*/
|
||||||
const Field &Array::get(uint8_t index)
|
const Field &Array::get(uint8_t index) const
|
||||||
{
|
{
|
||||||
// used if index does not exist
|
// used if index does not exist
|
||||||
static ShortString empty;
|
static ShortString empty;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue