diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-07-07 08:51:21 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-07-09 09:55:22 +0000 |
commit | 88099bec32481b83b41f3966c2a88ebf4034f1fe (patch) | |
tree | bd703eae788918a6430dd5973af70ce84e40f7a4 /searchsummary/src/tests/extractkeywords/simplequerystack.h | |
parent | 1d12f4b4b92771dfe7e245b88ce89adc911c509e (diff) |
clean up various issues with ParseItem class
* SimpleQueryStack only used for one unit test, move it there
* Actual instances of ParseItem also only used for same unit test.
Split out the object representation into a separate
SimpleQueryStackItem class in the unit test directory.
* give location ITEM_LOCATION_TERM instead of overloading NUMTERM
* ParseItem::ITEM_PAREN never used for anything, remove it
* add comment for removal of PAREN enum in prelude/query/Item.java
* refactor flag handling with one method per flag
Diffstat (limited to 'searchsummary/src/tests/extractkeywords/simplequerystack.h')
-rw-r--r-- | searchsummary/src/tests/extractkeywords/simplequerystack.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/searchsummary/src/tests/extractkeywords/simplequerystack.h b/searchsummary/src/tests/extractkeywords/simplequerystack.h new file mode 100644 index 00000000000..97dd6418e48 --- /dev/null +++ b/searchsummary/src/tests/extractkeywords/simplequerystack.h @@ -0,0 +1,69 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "simplequerystackitem.h" +#include <vespa/searchlib/util/rawbuf.h> +#include <vespa/vespalib/stllike/string.h> + +namespace search { + +/** + * A stack of SimpleQueryStackItems. + * + * A simple stack consisting of a list of SimpleQueryStackItems. + * It is able to generate a binary encoding of itself + * to a RawBuf. + */ +class SimpleQueryStack +{ +private: + /** The number of items on the stack. */ + uint32_t _numItems; + + /** The top of the stack. + * Warning: FastQT_ProximityEmul currently assumes this is the head + * of a singly linked list (linked with _next). + */ + SimpleQueryStackItem *_stack; + +public: + SimpleQueryStack(const SimpleQueryStack &) = delete; + SimpleQueryStack& operator=(const SimpleQueryStack &) = delete; + /** + * Constructor for SimpleQueryStack. + */ + SimpleQueryStack(); + /** + * Destructor for SimpleQueryStack. + */ + ~SimpleQueryStack(); + /** + * Push an item on the stack. + * @param item The SimpleQueryStackItem to push. + */ + void Push(SimpleQueryStackItem *item); + + + /** + * Encode the contents of the stack in a binary buffer. + * @param buf Pointer to a buffer containing the encoded contents. + */ + void AppendBuffer(RawBuf *buf) const; + + /** + * Return the number of items on the stack. + * @return The number of items on the stack. + */ + uint32_t GetSize(); + /** + * Set the number of items on the stack. + * This can be used by QTs that change the stack + * under the hood. Use with care! + * @param numItems The number of items on the stack. + */ + void SetSize(uint32_t numItems) { _numItems = numItems; } +}; + +} // namespace search + |