winix/core/groups.cpp

102 lines
1.0 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved.
*
*/
#include "groups.h"
namespace Winix
{
Groups::Groups()
{
Clear();
}
void Groups::Clear()
{
table.Clear();
}
void Groups::ReadGroups(Db * db)
{
Clear();
db->GetGroups(table);
}
Group * Groups::GetGroup(long group_id)
{
Table::Iterator i = table.FindId(group_id);
if( i == table.End() )
return 0;
return &(*i);
}
Group * Groups::GetGroup(const std::wstring & name)
{
Table::Iterator i = table.FindName(name);
if( i == table.End() )
return 0;
return &(*i);
}
long Groups::GetGroupId(const std::wstring & name)
{
Group * pgroup = GetGroup(name);
if( !pgroup )
return -1;
return pgroup->id;
}
Groups::Iterator Groups::Begin()
{
return table.Begin();
}
Groups::Iterator Groups::End()
{
return table.End();
}
Groups::SizeType Groups::Size()
{
return table.Size();
}
bool Groups::Remove(long group_id)
{
return table.Remove(group_id);
}
} // namespace Winix