#ifndef INCLUDED_BOBCAT_USER
#define INCLUDED_BOBCAT_USER

#include <string>

struct passwd;

namespace FBB
{
class User
{
    std::string d_name;
    std::string d_password;
    std::string d_realname;
    std::string d_homedir;
    std::string d_shell;
    size_t d_uid;
    size_t d_gid;

    public:
        User();                         // 1.cc
        User(std::string const &name);  // 2.cc details of user 'name'
        User(size_t uid);               // 3.cc details of user whose ID is 
                                        //      uid

        User(User const &other) = default;
        User(User &&tmp);               // 4.cc

        User &operator=(User const &rhs) = default;
        User &operator=(User &&tmp);

        void verify() const;        // kept for bacward compatibility

        size_t eGroupid() const;
        size_t eUserid() const;
        size_t groupid() const;                                     // .f
        bool inGroup(size_t gid, bool useEffective = true) const;
        size_t userid() const;                                      // .f
        bool inGroup(size_t gid) const;
        std::string const &homedir() const;                         // .f
        std::string const &name() const;                            // .f
        std::string const &password() const;                        // .f
        std::string const &realname() const;                        // .f
        std::string const &shell() const;                           // .f

    private:
        void assign(passwd const *pwd); // assign pwd fields to this object
        static void failure();          // throws Exception
};

inline size_t User::groupid() const
{
    return d_gid;
}
inline std::string const &User::homedir() const
{
    return d_homedir;
}
inline std::string const &User::name() const
{
    return d_name;
}
inline std::string const &User::password() const
{
    return d_password;
}
inline std::string const &User::realname() const
{
    return d_realname;
}
inline std::string const &User::shell() const
{
    return d_shell;
}
inline size_t User::userid() const
{
    return d_uid;
}

} // FBB

#endif
