Dv::Util::User Class Reference

A class representing a Unix user. More...

#include <user.h>

List of all members.

Public Member Functions

 User ()
 Initialize to current user, equivalent with User(getuid()).
 User (uid_t uid) throw (std::runtime_error)
 Initialize to user with given uid.
 User (const std::string &name) throw (std::runtime_error)
 Initialize to user with given user name.
uid_t uid () const
 Retrieve uid of this user.
gid_t gid () const
 Retrieve current group id of this user.
const std::string & home () const
 Retrieve pathname of home directory of this user.
const std::string & shell () const
 Retrieve pathname of shell program of this user.
const std::string & name () const
 Retrieve user name of this user.
const std::string & full_name () const
 Retrieve full name (gecos field) of this user.
bool password (const std::string &pass) const
 Return true iff called by root and password matches user's password.
bool operator== (const User &u) const
 Users are equal if they have the same uid.
bool operator< (const User &u) const
 Based on the comparison of the uid's.
bool operator> (const User &u) const
bool operator!= (const User &u) const
bool operator>= (const User &u) const
bool operator<= (const User &u) const

Private Member Functions

void * getpwinfo (void *)

Private Attributes

std::string name_
std::string full_name_
uid_t uid_
gid_t gid_
std::string home_
std::string shell_

Detailed Description

A class representing a Unix user.

This class provides a convenient wrapper around information that is usually obtained using getpwnam().

Definition at line 15 of file user.h.


Constructor & Destructor Documentation

Dv::Util::User::User (  ) 

Initialize to current user, equivalent with User(getuid()).

Dv::Util::User::User ( uid_t  uid  )  throw (std::runtime_error)

Initialize to user with given uid.

Exceptions:
std::runtime_error if not found
Dv::Util::User::User ( const std::string &  name  )  throw (std::runtime_error)

Initialize to user with given user name.

Exceptions:
std::runtime_error if not found

Member Function Documentation

uid_t Dv::Util::User::uid (  )  const [inline]

Retrieve uid of this user.

Definition at line 29 of file user.h.

References uid_.

Referenced by operator<(), and operator==().

gid_t Dv::Util::User::gid (  )  const [inline]

Retrieve current group id of this user.

Definition at line 31 of file user.h.

References gid_.

const std::string& Dv::Util::User::home (  )  const [inline]

Retrieve pathname of home directory of this user.

Definition at line 33 of file user.h.

References home_.

const std::string& Dv::Util::User::shell (  )  const [inline]

Retrieve pathname of shell program of this user.

Definition at line 35 of file user.h.

References shell_.

const std::string& Dv::Util::User::name (  )  const [inline]

Retrieve user name of this user.

Definition at line 37 of file user.h.

References name_.

const std::string& Dv::Util::User::full_name (  )  const [inline]

Retrieve full name (gecos field) of this user.

Definition at line 39 of file user.h.

References full_name_.

bool Dv::Util::User::password ( const std::string &  pass  )  const

Return true iff called by root and password matches user's password.

bool Dv::Util::User::operator== ( const User u  )  const [inline]

Users are equal if they have the same uid.

Definition at line 44 of file user.h.

References uid().

bool Dv::Util::User::operator< ( const User u  )  const [inline]

Based on the comparison of the uid's.

Definition at line 46 of file user.h.

References uid().

bool Dv::Util::User::operator> ( const User u  )  const [inline]

Definition at line 47 of file user.h.

bool Dv::Util::User::operator!= ( const User u  )  const [inline]

Definition at line 48 of file user.h.

bool Dv::Util::User::operator>= ( const User u  )  const [inline]

Definition at line 49 of file user.h.

bool Dv::Util::User::operator<= ( const User u  )  const [inline]

Definition at line 50 of file user.h.

void* Dv::Util::User::getpwinfo ( void *   )  [private]

Member Data Documentation

std::string Dv::Util::User::name_ [private]

Definition at line 53 of file user.h.

Referenced by name().

std::string Dv::Util::User::full_name_ [private]

Definition at line 54 of file user.h.

Referenced by full_name().

uid_t Dv::Util::User::uid_ [private]

Definition at line 55 of file user.h.

Referenced by uid().

gid_t Dv::Util::User::gid_ [private]

Definition at line 56 of file user.h.

Referenced by gid().

std::string Dv::Util::User::home_ [private]

Definition at line 57 of file user.h.

Referenced by home().

std::string Dv::Util::User::shell_ [private]

Definition at line 58 of file user.h.

Referenced by shell().


The documentation for this class was generated from the following file:

dvutil-1.0.10 [ 5 December, 2009]