RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
Public Member Functions | Static Public Member Functions | List of all members
rstudio::launcher_plugins::system::User Class Reference

Class which represents a system user. More...

#include <User.hpp>

Public Member Functions

 User (bool in_isEmpty=false)
 Constructor. More...
 
 User (const User &in_other)
 Copy constructor. More...
 
 User (User &&in_other) noexcept=default
 Move constructor. More...
 
Useroperator= (const User &in_other)
 Overloaded assignment operator. More...
 
Useroperator= (User &&in_other) noexcept=default
 Overloaded move operator. More...
 
bool operator== (const User &in_other) const
 Equality operator. More...
 
bool operator!= (const User &in_other) const
 Inequality operator. More...
 
bool exists () const
 Checks whether the user represented by this object exists. More...
 
bool isAllUsers () const
 Returns whether this object represents all users or not. See the default constructor for more details. More...
 
bool isEmpty () const
 Checks whether this user is empty or not. More...
 
const FilePathgetHomePath () const
 Gets the user home path, if it exists. More...
 
GidType getGroupId () const
 Gets the ID of this user's primary group. More...
 
const std::string & getShell () const
 Returns the login shell of this user. More...
 
const std::string & getRealName () const
 Returns the user's real name ("John Doe", not "jdoe") More...
 
UidType getUserId () const
 Gets the ID of this user. More...
 
const std::string & getUsername () const
 Returns the name of this user. More...
 

Static Public Member Functions

static FilePath getUserHomePath (const std::string &in_envOverride=std::string())
 Gets the user home path, as set in the environment. More...
 
static Error getCurrentUser (User &out_currentUser)
 Gets the current user. More...
 
static Error getUserFromIdentifier (const std::string &in_username, User &out_user)
 Gets a user from its username. More...
 
static Error getUserFromIdentifier (UidType in_userId, User &out_user)
 Gets a user from its user ID. More...
 

Detailed Description

Class which represents a system user.

Constructor & Destructor Documentation

◆ User() [1/3]

rstudio::launcher_plugins::system::User::User ( bool  in_isEmpty = false)
explicit

Constructor.

Creates a user object which is either empty or represents all users.

Parameters
in_isEmptyTrue to create an empty user; False to create a user which represents all users. Default: false.

◆ User() [2/3]

rstudio::launcher_plugins::system::User::User ( const User in_other)

Copy constructor.

Parameters
in_otherThe user to copy.

◆ User() [3/3]

rstudio::launcher_plugins::system::User::User ( User &&  in_other)
defaultnoexcept

Move constructor.

Parameters
in_otherThe user to move into this User.

Member Function Documentation

◆ exists()

bool rstudio::launcher_plugins::system::User::exists ( ) const

Checks whether the user represented by this object exists.

If this is an empty user, or is a user object which represents all users, this method will return false as it does not represent a user which exists on the system.

Returns
True if this user exists; false otherwise.

◆ getCurrentUser()

static Error rstudio::launcher_plugins::system::User::getCurrentUser ( User out_currentUser)
static

Gets the current user.

Parameters
out_currentUserThe user this process is currently executing on behalf of. This object will be the empty user if this function returns an error.
Returns
Success if the user could be retrieved; Error otherwise.

◆ getGroupId()

GidType rstudio::launcher_plugins::system::User::getGroupId ( ) const

Gets the ID of this user's primary group.

Returns
The ID of this user's primary group.

◆ getHomePath()

const FilePath& rstudio::launcher_plugins::system::User::getHomePath ( ) const

Gets the user home path, if it exists.

Returns
The user's home path, if it exists; empty path otherwise.

◆ getRealName()

const std::string& rstudio::launcher_plugins::system::User::getRealName ( ) const

Returns the user's real name ("John Doe", not "jdoe")

Returns
The real name of this user. Not available on all systems and configurations; an empty string is returned if the value is not known.

◆ getShell()

const std::string& rstudio::launcher_plugins::system::User::getShell ( ) const

Returns the login shell of this user.

Returns
The login shell of this user.

◆ getUserFromIdentifier() [1/2]

static Error rstudio::launcher_plugins::system::User::getUserFromIdentifier ( const std::string &  in_username,
User out_user 
)
static

Gets a user from its username.

Parameters
in_usernameThe name of the user to create.
out_userThe created user.
Returns
Success if the user could be retrieved; Error otherwise.

◆ getUserFromIdentifier() [2/2]

static Error rstudio::launcher_plugins::system::User::getUserFromIdentifier ( UidType  in_userId,
User out_user 
)
static

Gets a user from its user ID.

Parameters
in_userIdThe ID of the user to create.
out_userThe created user.
Returns
Success if the user could be retrieved; Error otherwise.

◆ getUserHomePath()

static FilePath rstudio::launcher_plugins::system::User::getUserHomePath ( const std::string &  in_envOverride = std::string())
static

Gets the user home path, as set in the environment.

Parameters
in_envOverrideIf set, overrides the name of the environment variable to use as the user's home path. Multiple overrides may be specified by delimiting them with '|' in order of precedence.
Returns
The user home path, as set in the environment.

◆ getUserId()

UidType rstudio::launcher_plugins::system::User::getUserId ( ) const

Gets the ID of this user.

Returns
The ID of this user.

◆ getUsername()

const std::string& rstudio::launcher_plugins::system::User::getUsername ( ) const

Returns the name of this user.

Returns
The name of this user ("*" for all users).

◆ isAllUsers()

bool rstudio::launcher_plugins::system::User::isAllUsers ( ) const

Returns whether this object represents all users or not. See the default constructor for more details.

Returns
True if this object represents all users; false otherwise.

◆ isEmpty()

bool rstudio::launcher_plugins::system::User::isEmpty ( ) const

Checks whether this user is empty or not.

Returns
True if this is user is empty; False otherwise.

◆ operator!=()

bool rstudio::launcher_plugins::system::User::operator!= ( const User in_other) const

Inequality operator.

Parameters
in_otherThe user to compare with this user.
Returns
False if this user and in_other have the same user ID; true otherwise.

◆ operator=() [1/2]

User& rstudio::launcher_plugins::system::User::operator= ( const User in_other)

Overloaded assignment operator.

Parameters
in_otherThe user to copy to this one.
Returns
This user.

◆ operator=() [2/2]

User& rstudio::launcher_plugins::system::User::operator= ( User &&  in_other)
defaultnoexcept

Overloaded move operator.

Parameters
in_otherThe user to move to this one.
Returns
This user.

◆ operator==()

bool rstudio::launcher_plugins::system::User::operator== ( const User in_other) const

Equality operator.

Parameters
in_otherThe user to compare with this user.
Returns
True if this user and in_other have the same user ID; false otherwise.

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