diff options
author | Tor Lillqvist <tml@collabora.com> | 2017-06-19 11:37:43 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2017-06-19 12:23:24 +0300 |
commit | c3fae6be6067572aaf9f0c72ad35b69019a79135 (patch) | |
tree | dab6a4ac276daa0fcc54d09b36f42323376c56eb /include/formula/tokenarray.hxx | |
parent | Drop another friend declaration (diff) | |
download | core-c3fae6be6067572aaf9f0c72ad35b69019a79135.tar.gz core-c3fae6be6067572aaf9f0c72ad35b69019a79135.zip |
Add yet another kind of iterator for the two arrays in FormulaTokenArray
This one has no extra functionality at all, and its only purpose is to
be used in range-based for loops. If there is a cleaner way to do
this, feel free. Not sure if this functionality could or should be
combined with either of the two existing iterator classes related to
FormulaTokenArray (FormulaTokenIterator and
FormulaTokenArrayPlainIterator). Probably not.
Change-Id: I32599b0800fd2585624d3742a46ad4896ce7e47a
Diffstat (limited to 'include/formula/tokenarray.hxx')
-rw-r--r-- | include/formula/tokenarray.hxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx index 2014994e03fc..7252613cf713 100644 --- a/include/formula/tokenarray.hxx +++ b/include/formula/tokenarray.hxx @@ -112,6 +112,30 @@ public: typedef std::unordered_set<OpCode, std::hash<std::underlying_type<OpCode>::type> > unordered_opcode_set; +class FORMULA_DLLPUBLIC FormulaTokenArrayStandardIterator +{ +private: + FormulaToken** mpBegin; + FormulaToken** mpEnd; + +public: + FormulaTokenArrayStandardIterator(FormulaToken** pBegin, sal_uInt16 nSize) : + mpBegin(pBegin), + mpEnd(pBegin + nSize) + { + } + + FormulaToken** begin() const + { + return mpBegin; + } + + FormulaToken** end() const + { + return mpEnd; + } +}; + class FORMULA_DLLPUBLIC FormulaTokenArray { protected: @@ -247,7 +271,19 @@ public: } FormulaToken** GetArray() const { return pCode; } + + FormulaTokenArrayStandardIterator Tokens() const + { + return FormulaTokenArrayStandardIterator(pCode, nLen); + } + FormulaToken** GetCode() const { return pRPN; } + + FormulaTokenArrayStandardIterator RPNTokens() const + { + return FormulaTokenArrayStandardIterator(pRPN, nRPN); + } + sal_uInt16 GetLen() const { return nLen; } sal_uInt16 GetCodeLen() const { return nRPN; } FormulaError GetCodeError() const { return nError; } |