LLDB mainline
Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
lldb::SBEnvironment Class Reference

#include <SBEnvironment.h>

Public Member Functions

 SBEnvironment ()
 
 SBEnvironment (const lldb::SBEnvironment &rhs)
 
 ~SBEnvironment ()
 
const lldb::SBEnvironmentoperator= (const lldb::SBEnvironment &rhs)
 
const char * Get (const char *name)
 Return the value of a given environment variable.
 
size_t GetNumValues ()
 
const char * GetNameAtIndex (size_t index)
 Return the name of the environment variable at a given index from the internal list of environment variables.
 
const char * GetValueAtIndex (size_t index)
 Return the value of the environment variable at a given index from the internal list of environment variables.
 
SBStringList GetEntries ()
 Return all environment variables contained in this object.
 
void PutEntry (const char *name_and_value)
 Add or replace an existing environment variable.
 
void SetEntries (const SBStringList &entries, bool append)
 Update this object with the given environment variables.
 
bool Set (const char *name, const char *value, bool overwrite)
 Set the value of a given environment variable.
 
bool Unset (const char *name)
 Unset an environment variable if exists.
 
void Clear ()
 Delete all the environment variables.
 

Protected Member Functions

 SBEnvironment (lldb_private::Environment rhs)
 
lldb_private::Environmentref () const
 

Private Attributes

std::unique_ptr< lldb_private::Environmentm_opaque_up
 

Friends

class SBPlatform
 
class SBTarget
 
class SBLaunchInfo
 

Detailed Description

Definition at line 16 of file SBEnvironment.h.

Constructor & Destructor Documentation

◆ SBEnvironment() [1/3]

SBEnvironment::SBEnvironment ( )

Definition at line 19 of file SBEnvironment.cpp.

References LLDB_INSTRUMENT_VA.

◆ SBEnvironment() [2/3]

SBEnvironment::SBEnvironment ( const lldb::SBEnvironment rhs)

Definition at line 23 of file SBEnvironment.cpp.

References LLDB_INSTRUMENT_VA.

◆ ~SBEnvironment()

SBEnvironment::~SBEnvironment ( )
default

◆ SBEnvironment() [3/3]

SBEnvironment::SBEnvironment ( lldb_private::Environment  rhs)
protected

Definition at line 28 of file SBEnvironment.cpp.

Member Function Documentation

◆ Clear()

void SBEnvironment::Clear ( )

Delete all the environment variables.

Definition at line 118 of file SBEnvironment.cpp.

References LLDB_INSTRUMENT_VA, and m_opaque_up.

◆ Get()

const char * SBEnvironment::Get ( const char *  name)

Return the value of a given environment variable.

Parameters
[in]nameThe name of the environment variable.
Returns
The value of the environment variable or null if not present. If the environment variable has no value but is present, a valid pointer to an empty string will be returned.

Definition at line 47 of file SBEnvironment.cpp.

References lldb_private::ConstString::AsCString(), LLDB_INSTRUMENT_VA, and m_opaque_up.

◆ GetEntries()

SBStringList SBEnvironment::GetEntries ( )

Return all environment variables contained in this object.

Each variable is returned as a string with the following format name=value

Returns
Return an lldb::SBStringList object with the environment variables.

Definition at line 91 of file SBEnvironment.cpp.

References lldb::SBStringList::AppendString(), lldb_private::Environment::compose(), LLDB_INSTRUMENT_VA, and m_opaque_up.

◆ GetNameAtIndex()

const char * SBEnvironment::GetNameAtIndex ( size_t  index)

Return the name of the environment variable at a given index from the internal list of environment variables.

Parameters
[in]indexThe index of the environment variable in the internal list.
Returns
The name at the given index or null if the index is invalid.

Definition at line 57 of file SBEnvironment.cpp.

References lldb_private::ConstString::AsCString(), GetNumValues(), LLDB_INSTRUMENT_VA, and m_opaque_up.

◆ GetNumValues()

size_t SBEnvironment::GetNumValues ( )
Returns
The number of environment variables.

Definition at line 41 of file SBEnvironment.cpp.

References LLDB_INSTRUMENT_VA, and m_opaque_up.

Referenced by GetNameAtIndex(), and GetValueAtIndex().

◆ GetValueAtIndex()

const char * SBEnvironment::GetValueAtIndex ( size_t  index)

Return the value of the environment variable at a given index from the internal list of environment variables.

Parameters
[in]indexThe index of the environment variable in the internal list.
Returns
The value at the given index or null if the index is invalid. If the environment variable has no value but is present, a valid pointer to an empty string will be returned.

Definition at line 66 of file SBEnvironment.cpp.

References lldb_private::ConstString::AsCString(), GetNumValues(), LLDB_INSTRUMENT_VA, and m_opaque_up.

◆ operator=()

const SBEnvironment & SBEnvironment::operator= ( const lldb::SBEnvironment rhs)

Definition at line 33 of file SBEnvironment.cpp.

References lldb_private::clone(), LLDB_INSTRUMENT_VA, and m_opaque_up.

◆ PutEntry()

void SBEnvironment::PutEntry ( const char *  name_and_value)

Add or replace an existing environment variable.

The input must be a string with the format name=value

Parameters
[in]name_and_valueThe entry to set which conforms to the format mentioned above.

Definition at line 101 of file SBEnvironment.cpp.

References LLDB_INSTRUMENT_VA, and m_opaque_up.

Referenced by SetEntries().

◆ ref()

Environment & SBEnvironment::ref ( ) const
protected

Definition at line 124 of file SBEnvironment.cpp.

References m_opaque_up.

Referenced by lldb::SBLaunchInfo::SetEnvironment().

◆ Set()

bool SBEnvironment::Set ( const char *  name,
const char *  value,
bool  overwrite 
)

Set the value of a given environment variable.

If the variable exists, its value is updated only if overwrite is true.

Parameters
[in]nameThe name of the environment variable to set.
[in]valueThe value of the environment variable to set.
[in]overwriteFlag that indicates whether to overwrite an existing environment variable.
Returns
Return whether the variable was added or modified.

Definition at line 75 of file SBEnvironment.cpp.

References LLDB_INSTRUMENT_VA, and m_opaque_up.

◆ SetEntries()

void SBEnvironment::SetEntries ( const SBStringList entries,
bool  append 
)

Update this object with the given environment variables.

The input is a list of entries with the same format required by SBEnvironment::PutEntry.

If append is false, the provided environment will replace the existing environment. Otherwise, existing values will be updated of left untouched accordingly.

Parameters
[in]entriesThe environment variable entries.
[in]appendFlag that controls whether to replace the existing environment.

Definition at line 108 of file SBEnvironment.cpp.

References lldb::SBStringList::GetSize(), lldb::SBStringList::GetStringAtIndex(), LLDB_INSTRUMENT_VA, m_opaque_up, and PutEntry().

◆ Unset()

bool SBEnvironment::Unset ( const char *  name)

Unset an environment variable if exists.

Parameters
[in]nameThe name of the environment variable to unset.
Returns
Return whether a variable was actually unset.

Definition at line 85 of file SBEnvironment.cpp.

References LLDB_INSTRUMENT_VA, and m_opaque_up.

Friends And Related Function Documentation

◆ SBLaunchInfo

friend class SBLaunchInfo
friend

Definition at line 125 of file SBEnvironment.h.

◆ SBPlatform

friend class SBPlatform
friend

Definition at line 123 of file SBEnvironment.h.

◆ SBTarget

friend class SBTarget
friend

Definition at line 124 of file SBEnvironment.h.

Member Data Documentation

◆ m_opaque_up

std::unique_ptr<lldb_private::Environment> lldb::SBEnvironment::m_opaque_up
private

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