summaryrefslogtreecommitdiff
path: root/include/listkey.h
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:33 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:33 -0400
commit8d3fc864d094eeadc721f8e93436b37a5fab173e (patch)
tree05e201c67dca55b4ccdf90ad479a25d95e3b1e63 /include/listkey.h
Imported Upstream version 1.5.3
Diffstat (limited to 'include/listkey.h')
-rw-r--r--include/listkey.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/include/listkey.h b/include/listkey.h
new file mode 100644
index 0000000..8f1c59c
--- /dev/null
+++ b/include/listkey.h
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * listkey.h - code for base class 'listkey'. listkey is the basis for all
+ * types of keys for indexing into modules
+ * (e.g. verse, word,
+ * place, etc.)
+ *
+ * $Id: listkey.h,v 1.13 2001/08/09 10:39:51 scribe Exp $
+ *
+ * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#ifndef SWLSTKEY_H
+#define SWLSTKEY_H
+
+#include <swkey.h>
+
+#include <defs.h>
+
+ /** ListKey is the basis for all
+ * types of keys that have lists of specified indexes
+ * (e.g. a list of verses, place, etc.)
+ */
+class SWDLLEXPORT ListKey : public SWKey {
+
+ static SWClass classdef;
+ void init ();
+protected:
+ int arraypos;
+ int arraymax;
+ int arraycnt;
+ SWKey **array;
+public:
+ /** initializes instance of ListKey
+ *
+ * @param ikey text key
+ */
+ ListKey (const char *ikey = 0);
+ ListKey (ListKey const &k);
+ /** cleans up instance of ListKey
+ */
+ virtual ~ ListKey ();
+
+ virtual SWKey *clone () const;
+ /** Clears out elements of list
+ */
+ virtual void ClearList ();
+ /** Returns number of elements in list
+ * @return number of elements in list
+ */
+ virtual int Count ();
+ /** Removes current element from list
+ */
+ virtual void Remove ();
+ /** Sets key to element number
+ *
+ * @param ielement element number to set to
+ * @return error status
+ */
+ virtual char SetToElement (int ielement, SW_POSITION = TOP);
+ /** Gets a key element number
+ *
+ * @param pos element number to get (or default current)
+ * @return Key or null on error
+ */
+ virtual SWKey *GetElement (int pos = -1);
+ /** Adds an element to the list
+ * @param ikey the element to add
+ */
+ ListKey & operator << (const SWKey &ikey) { add(ikey); return *this; }
+ virtual void add(const SWKey &ikey);
+
+ /** Equates this ListKey to another ListKey object
+ *
+ * @param ikey other ListKey object
+ */
+ virtual void copyFrom(const ListKey & ikey);
+ virtual void copyFrom(const SWKey & ikey) { SWKey::copyFrom(ikey); }
+
+ /** Positions this key
+ *
+ * @param p position
+ * @return *this
+ */
+ virtual void setPosition(SW_POSITION);
+ /** Decrements a number of elements
+ */
+ virtual void decrement(int step);
+ /** Increments a number of elements
+ */
+ virtual void increment(int step);
+
+ virtual char Traversable () { return 1; }
+ virtual long Index () const { return arraypos; }
+
+ /**
+ * Returns the index for the new one given as as parameter.
+ * The first parameter is the new index.
+ */
+ virtual long Index (long index) { SetToElement (index); return Index (); }
+
+ SWKEY_OPERATORS
+ ListKey & operator =(const ListKey &key) { copyFrom(key); return *this; }
+};
+
+
+#endif