From 70150fd8f9e7dec0b67d4b8dc227d8ac68a273b8 Mon Sep 17 00:00:00 2001 From: john30 Date: Sun, 23 Apr 2017 11:56:53 +0200 Subject: [PATCH] added const[] accessor --- src/lib/ebus/symbol.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/ebus/symbol.h b/src/lib/ebus/symbol.h index f414da66..0c88e31d 100644 --- a/src/lib/ebus/symbol.h +++ b/src/lib/ebus/symbol.h @@ -170,6 +170,18 @@ class SymbolString { return m_data[index]; } + /** + * Return a reference to the symbol at the specified index. + * @param index the index of the symbol to return. + * @return the reference to the symbol at the specified index, or SYN if not available. + */ + symbol_t operator[](const size_t index) const { + if (index >= m_data.size()) { + return SYN; + } + return m_data[index]; + } + /** * Return whether this instance is equal to the other instance. * @param other the other instance.