2012-05-10 12:06:41 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
|
|
|
* *
|
|
|
|
* 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; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
2012-05-11 13:33:57 +02:00
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
2012-05-10 12:06:41 +02:00
|
|
|
******************************************************************************/
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
#include "i2-base.h"
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2012-05-08 15:14:20 +02:00
|
|
|
/**
|
|
|
|
* Returns an iterator to the beginning of the dictionary.
|
|
|
|
*
|
|
|
|
* @returns An iterator.
|
|
|
|
*/
|
2012-06-30 15:22:51 +02:00
|
|
|
Dictionary::Iterator Dictionary::Begin(void)
|
2012-04-18 15:22:25 +02:00
|
|
|
{
|
|
|
|
return m_Data.begin();
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:14:20 +02:00
|
|
|
/**
|
|
|
|
* Returns an iterator to the end of the dictionary.
|
|
|
|
*
|
|
|
|
* @returns An iterator.
|
|
|
|
*/
|
2012-06-30 15:22:51 +02:00
|
|
|
Dictionary::Iterator Dictionary::End(void)
|
2012-04-18 15:22:25 +02:00
|
|
|
{
|
|
|
|
return m_Data.end();
|
|
|
|
}
|
2012-04-30 15:30:45 +02:00
|
|
|
|
2012-05-08 15:14:20 +02:00
|
|
|
/**
|
|
|
|
* Returns the number of elements in the dictionary.
|
|
|
|
*
|
|
|
|
* @returns Number of elements.
|
|
|
|
*/
|
2012-04-30 15:30:45 +02:00
|
|
|
long Dictionary::GetLength(void) const
|
|
|
|
{
|
|
|
|
return m_Data.size();
|
|
|
|
}
|
2012-06-14 11:18:20 +02:00
|
|
|
|
2012-06-17 16:37:36 +02:00
|
|
|
/**
|
|
|
|
* Checks whether the dictionary contains the specified key.
|
|
|
|
*
|
|
|
|
* @param key The key.
|
|
|
|
* @returns true if the dictionary contains the key, false otherwise.
|
|
|
|
*/
|
2012-06-14 11:18:20 +02:00
|
|
|
bool Dictionary::Contains(const string& key) const
|
|
|
|
{
|
|
|
|
return (m_Data.find(key) != m_Data.end());
|
|
|
|
}
|
2012-07-09 10:09:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the specified key from the dictionary.
|
|
|
|
*
|
|
|
|
* @param key The key.
|
|
|
|
*/
|
2012-07-09 16:19:56 +02:00
|
|
|
void Dictionary::Remove(const string& key)
|
2012-07-09 10:09:53 +02:00
|
|
|
{
|
|
|
|
Dictionary::Iterator it;
|
|
|
|
it = m_Data.find(key);
|
|
|
|
|
|
|
|
if (it == m_Data.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Data.erase(it);
|
|
|
|
}
|