KCoreAddons

KUserOrGroupId< T > Struct Template Reference

#include <kuser.h>

Inheritance diagram for KUserOrGroupId< T >:

Public Types

typedef T NativeType
 

Public Member Functions

bool isValid () const
 
bool isValid () const
 
NativeType nativeId () const
 
void * nativeId () const
 
bool operator!= (const KUserOrGroupId &other) const
 
bool operator!= (const KUserOrGroupId< void * > &other) const
 
bool operator== (const KUserOrGroupId &other) const
 
bool operator== (const KUserOrGroupId< void * > &other) const
 
QString toString () const
 
QString toString () const
 

Protected Member Functions

 KUserOrGroupId ()
 
 KUserOrGroupId (const KUserOrGroupId< T > &other)
 
 KUserOrGroupId (const KUserOrGroupId< void * > &other)
 
 KUserOrGroupId (NativeType nativeId)
 
 KUserOrGroupId (void *nativeId)
 
KUserOrGroupIdoperator= (const KUserOrGroupId< T > &other)
 
KUserOrGroupId< void * > & operator= (const KUserOrGroupId< void * > &other)
 

Detailed Description

template<typename T>
struct KUserOrGroupId< T >

A platform independent user or group ID.

This struct is required since Windows does not have an integer uid_t/gid_t type but instead uses an opaque binary blob (SID) which must free allocated memory. On UNIX this is simply a uid_t/gid_t and all operations are inline, so there is no runtime overhead over using the uid_t/gid_t directly. On Windows this is an implicitly shared class that frees the underlying SID once no more references remain.

Unlike KUser/KUserGroup this does not query additional information, it is simply an abstraction over the native user/group ID type. If more information is necessary, a KUser or KUserGroup instance can be constructed from this ID

Author
Alex Richardson arich.nosp@m.ards.nosp@m.on.kd.nosp@m.e@gm.nosp@m.ail.c.nosp@m.om

Definition at line 59 of file kuser.h.

Member Typedef Documentation

◆ NativeType

template<typename T >
T KUserOrGroupId< T >::NativeType

Definition at line 60 of file kuser.h.

Constructor & Destructor Documentation

◆ KUserOrGroupId() [1/6]

template<typename T >
KUserOrGroupId< T >::KUserOrGroupId ( )
inlineprotected

Creates an invalid KUserOrGroupId.

Definition at line 582 of file kuser.h.

◆ KUserOrGroupId() [2/6]

template<typename T >
KUserOrGroupId< T >::KUserOrGroupId ( NativeType nativeId)
explicitprotected

Creates a KUserOrGroupId from a native user/group ID.

On windows this will not take ownership over the passed SID, a copy will be created instead.

◆ KUserOrGroupId() [3/6]

template<typename T >
KUserOrGroupId< T >::KUserOrGroupId ( const KUserOrGroupId< T > & other)
inlineprotected

Copy constructor.

This is very fast, objects can be passed by value

Definition at line 592 of file kuser.h.

◆ ~KUserOrGroupId() [1/2]

template<typename T >
KUserOrGroupId< T >::~KUserOrGroupId ( )
inlineprotected

Definition at line 603 of file kuser.h.

◆ KUserOrGroupId() [4/6]

KUserOrGroupId< void * >::KUserOrGroupId ( )
protected

Definition at line 737 of file kuser_win.cpp.

◆ ~KUserOrGroupId() [2/2]

KUserOrGroupId< void * >::~KUserOrGroupId ( )
protected

Definition at line 742 of file kuser_win.cpp.

◆ KUserOrGroupId() [5/6]

KUserOrGroupId< void * >::KUserOrGroupId ( const KUserOrGroupId< void * > & other)
protected

Definition at line 747 of file kuser_win.cpp.

◆ KUserOrGroupId() [6/6]

KUserOrGroupId< void * >::KUserOrGroupId ( void * nativeId)
protected

Definition at line 760 of file kuser_win.cpp.

Member Function Documentation

◆ isValid() [1/2]

template<typename T >
bool KUserOrGroupId< T >::isValid ( ) const
inline
Returns
true if this object references a valid user/group ID.
Note
If this returns true it doesn't necessarily mean that the referenced user/group exists, it only checks whether this value could be a valid user/group ID.

Definition at line 557 of file kuser.h.

◆ isValid() [2/2]

bool KUserOrGroupId< void * >::isValid ( ) const

Definition at line 766 of file kuser_win.cpp.

◆ nativeId() [1/2]

template<typename T >
KUserOrGroupId< T >::NativeType KUserOrGroupId< T >::nativeId ( ) const
inline
Returns
A user/group ID that can be used in operating system specific functions
Note
On Windows the returned pointer will be freed once the last KUserOrGroupId referencing this user/group ID is deleted. Make sure that the KUserOrGroupId object remains valid as long as the native pointer is needed.

Definition at line 572 of file kuser.h.

◆ nativeId() [2/2]

void * KUserOrGroupId< void * >::nativeId ( ) const

Definition at line 772 of file kuser_win.cpp.

◆ operator!=() [1/2]

template<typename T >
bool KUserOrGroupId< T >::operator!= ( const KUserOrGroupId< T > & other) const
inline
Returns
whether this KUserOrGroupId is not equal to other

Definition at line 567 of file kuser.h.

◆ operator!=() [2/2]

bool KUserOrGroupId< void * >::operator!= ( const KUserOrGroupId< void * > & other) const

Definition at line 793 of file kuser_win.cpp.

◆ operator=() [1/2]

template<typename T >
KUserOrGroupId< T > & KUserOrGroupId< T >::operator= ( const KUserOrGroupId< T > & other)
inlineprotected

Definition at line 597 of file kuser.h.

◆ operator=() [2/2]

KUserOrGroupId< void * > & KUserOrGroupId< void * >::operator= ( const KUserOrGroupId< void * > & other)
inlineprotected

Definition at line 753 of file kuser_win.cpp.

◆ operator==() [1/2]

template<typename T >
bool KUserOrGroupId< T >::operator== ( const KUserOrGroupId< T > & other) const
inline
Returns
whether this KUserOrGroupId is equal to other

Definition at line 562 of file kuser.h.

◆ operator==() [2/2]

bool KUserOrGroupId< void * >::operator== ( const KUserOrGroupId< void * > & other) const

Definition at line 781 of file kuser_win.cpp.

◆ toString() [1/2]

template<typename T >
QString KUserOrGroupId< T >::toString ( ) const
inline
Returns
A string representation of this user ID, not the name of the user On UNIX this is a simple integer, e.g. "0" for root. On Windows this is a string like e.g. "S-1-5-32-544" for the Administrators group

Definition at line 577 of file kuser.h.

◆ toString() [2/2]

QString KUserOrGroupId< void * >::toString ( ) const

Definition at line 799 of file kuser_win.cpp.


The documentation for this struct was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.