mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
parent
e04d200d36
commit
7e164291a0
@ -108,6 +108,20 @@ size_t Array::GetLength(void) const
|
|||||||
return m_Data.size();
|
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
|
* Insert the given value at the specified index
|
||||||
*
|
*
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
Iterator End(void);
|
Iterator End(void);
|
||||||
|
|
||||||
size_t GetLength(void) const;
|
size_t GetLength(void) const;
|
||||||
|
bool Contains(const String& value) const;
|
||||||
|
|
||||||
void Insert(unsigned int index, const Value& value);
|
void Insert(unsigned int index, const Value& value);
|
||||||
void Remove(unsigned int index);
|
void Remove(unsigned int index);
|
||||||
|
@ -94,6 +94,9 @@ void Checkable::AddGroup(const String& name)
|
|||||||
|
|
||||||
Array::Ptr groups = GetGroups();
|
Array::Ptr groups = GetGroups();
|
||||||
|
|
||||||
|
if (groups && groups->Contains(name))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!groups)
|
if (!groups)
|
||||||
groups = make_shared<Array>();
|
groups = make_shared<Array>();
|
||||||
|
|
||||||
|
@ -75,6 +75,9 @@ void User::AddGroup(const String& name)
|
|||||||
|
|
||||||
Array::Ptr groups = GetGroups();
|
Array::Ptr groups = GetGroups();
|
||||||
|
|
||||||
|
if (groups && groups->Contains(name))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!groups)
|
if (!groups)
|
||||||
groups = make_shared<Array>();
|
groups = make_shared<Array>();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user