libDwm-0.9.45
DwmGroup.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2006, 2016
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
39//---------------------------------------------------------------------------
40
41#ifndef _DWMGROUP_HH_
42#define _DWMGROUP_HH_
43
44extern "C" {
45#include <grp.h>
46}
47
48#include <iostream>
49#include <mutex>
50#include <string>
51#include <vector>
52
53namespace Dwm {
54
55 //--------------------------------------------------------------------------
59 //--------------------------------------------------------------------------
60 class Group
61 {
62 public:
63 //------------------------------------------------------------------------
65 //------------------------------------------------------------------------
66 Group(gid_t gid);
67
68 //------------------------------------------------------------------------
70 //------------------------------------------------------------------------
71 Group(const std::string & name);
72
73 //------------------------------------------------------------------------
75 //------------------------------------------------------------------------
76 void Set(const struct group & group);
77
78 //------------------------------------------------------------------------
80 //------------------------------------------------------------------------
81 gid_t Id() const;
82
83 //------------------------------------------------------------------------
85 //------------------------------------------------------------------------
86 const std::string & Name() const;
87
88 //------------------------------------------------------------------------
90 //------------------------------------------------------------------------
91 const std::string & Password() const;
92
93 //------------------------------------------------------------------------
95 //------------------------------------------------------------------------
96 const std::vector<std::string> & Members() const;
97
98 //------------------------------------------------------------------------
100 //------------------------------------------------------------------------
101 friend std::ostream & operator << (std::ostream & os, const Group & group);
102
103 private:
104 gid_t _id;
105 std::string _name;
106 std::string _password;
107 std::vector<std::string> _members;
108
109 static std::mutex _mutex;
110 };
111
112} // namespace Dwm
113
114#endif // _DWMGROUP_HH_
115
116//---------------------------- emacs settings -----------------------------
117// Local Variables:
118// mode: C++
119// tab-width: 2
120// indent-tabs-mode: nil
121// c-basic-offset: 2
122// End:
123//-------------------------------------------------------------------------
Encapsulates an /etc/group entry.
Definition DwmGroup.hh:61
friend std::ostream & operator<<(std::ostream &os, const Group &group)
Prints to an ostream in /etc/group format.
const std::string & Password() const
Returns the group password.
gid_t Id() const
Returns the group ID.
void Set(const struct group &group)
Use the contents of group to fill all of our members.
Group(gid_t gid)
Construct from a group ID.
const std::vector< std::string > & Members() const
Returns the group members.
const std::string & Name() const
Returns the group name.
Group(const std::string &name)
Construct from a group name.