1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 * @brief This file contains the Keys class.
32 * This is a bucket class for KeyValues.
39 /** Constructs a KeyValue bucket for the specified table. */
40 Keys(TableImplPtr table
);
42 /** Constructs a KeyValue bucket for the specified table, tries to initialize with values from the specified string. */
43 Keys(TableImplPtr table
, cstring initstring
);
45 /** Destructor, a noop. */
49 /** Returns the table this KeyValue bucket belongs to. */
50 TableImplPtr
getTable() const;
53 /** Add a key to the bucket. */
54 void addKey(KeyValuePtr key
);
56 /** Add a key to the bucket from the specified field with the specified value. */
57 void addKey(KeyImplPtr key
, value_type value
);
60 /** Returns a string representation of the keys in the bucket. */
61 std::string
toString() const;
63 /** Returns a vector of strings representing the difference between the other Keys bucket with one entry for each different field. */
64 Strings
getDiff(KeysPtr orig
) const;
67 /** Returns the size of the keys in the bucket. */
70 /** Returns the first KeyValue in the bucket. */
71 KeyValuePtr
first() const;
73 /** Returns an iterator to the first key in the bucket. */
74 KeyImplMap::const_iterator
begin() const;
76 /** Returns the 'end' iterator of the keys in the bucket. */
77 KeyImplMap::const_iterator
end() const;
79 /** Returns an iterator to the result of 'find' with this specific key as argument. */
80 KeyImplMap::const_iterator
find(KeyImplPtr key
) const;
82 /** Returns a KeyValue for this field, asserted not to be the 'end' iterator. */
83 KeyValuePtr
getKey(KeyImplPtr key
) const;
86 /** Determines which keys have changed compared to the other set and marks them as dirty. */
87 void setDirty(KeysPtr oldKeys
);
90 TableImplPtr m_table
; /**< The table this KeyValue bucket belongs to. */
91 KeyImplMap m_keys
; /**< The keys contained in this bucket. */