mirror of https://github.com/Icinga/icinga2.git
parent
e04d200d36
commit
7e164291a0
|
@ -108,6 +108,20 @@ size_t Array::GetLength(void) const
|
|||
return m_Data.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the array contains the specified value.
|
||||
*
|
||||
* @param value The value.
|
||||
* @returns true if the array contains the value, false otherwise.
|
||||
*/
|
||||
bool Array::Contains(const String& value) const
|
||||
{
|
||||
ASSERT(!OwnsLock());
|
||||
ObjectLock olock(this);
|
||||
|
||||
return (std::find(m_Data.begin(), m_Data.end(), value) != m_Data.end());
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the given value at the specified index
|
||||
*
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
Iterator End(void);
|
||||
|
||||
size_t GetLength(void) const;
|
||||
bool Contains(const String& value) const;
|
||||
|
||||
void Insert(unsigned int index, const Value& value);
|
||||
void Remove(unsigned int index);
|
||||
|
|
|
@ -94,6 +94,9 @@ void Checkable::AddGroup(const String& name)
|
|||
|
||||
Array::Ptr groups = GetGroups();
|
||||
|
||||
if (groups && groups->Contains(name))
|
||||
return;
|
||||
|
||||
if (!groups)
|
||||
groups = make_shared<Array>();
|
||||
|
||||
|
|
|
@ -75,6 +75,9 @@ void User::AddGroup(const String& name)
|
|||
|
||||
Array::Ptr groups = GetGroups();
|
||||
|
||||
if (groups && groups->Contains(name))
|
||||
return;
|
||||
|
||||
if (!groups)
|
||||
groups = make_shared<Array>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue