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

#include <SBEnvironment.h>

Collaboration diagram for lldb::SBEnvironment:
Collaboration graph
[legend]

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. More...
 
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. More...
 
const char * GetValueAtIndex (size_t index)
 Return the value of the environment variable at a given index from the internal list of environment variables. More...
 
SBStringList GetEntries ()
 Return all environment variables contained in this object. More...
 
void PutEntry (const char *name_and_value)
 Add or replace an existing environment variable. More...
 
void SetEntries (const SBStringList &entries, bool append)
 Update this object with the given environment variables. More...
 
bool Set (const char *name, const char *value, bool overwrite)
 Set the value of a given environment variable. More...
 
bool Unset (const char *name)
 Unset an environment variable if exists. More...
 
void Clear ()
 Delete all the environment variables. More...
 

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_RECORD_CONSTRUCTOR_NO_ARGS.

◆ SBEnvironment() [2/3]

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

Definition at line 23 of file SBEnvironment.cpp.

References LLDB_RECORD_CONSTRUCTOR.

◆ ~SBEnvironment()

SBEnvironment::~SBEnvironment ( )
default

Referenced by SBEnvironment().

◆ SBEnvironment() [3/3]

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

Definition at line 28 of file SBEnvironment.cpp.

References ~SBEnvironment().

Member Function Documentation

◆ Clear()

void SBEnvironment::Clear ( )

Delete all the environment variables.

Definition at line 126 of file SBEnvironment.cpp.

References LLDB_RECORD_METHOD_NO_ARGS, and m_opaque_up.

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >().

◆ 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 49 of file SBEnvironment.cpp.

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

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >().

◆ 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 97 of file SBEnvironment.cpp.

References lldb::SBStringList::AppendString(), LLDB_RECORD_METHOD_NO_ARGS, LLDB_RECORD_RESULT, and m_opaque_up.

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >().

◆ 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 59 of file SBEnvironment.cpp.

References GetNumValues(), LLDB_RECORD_METHOD, and m_opaque_up.

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >().

◆ GetNumValues()

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

Definition at line 43 of file SBEnvironment.cpp.

References LLDB_RECORD_METHOD_NO_ARGS, and m_opaque_up.

Referenced by GetNameAtIndex(), GetValueAtIndex(), and lldb_private::repro::RegisterMethods< SBEnvironment >().

◆ 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 69 of file SBEnvironment.cpp.

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

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >().

◆ operator=()

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

◆ 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 107 of file SBEnvironment.cpp.

References LLDB_RECORD_METHOD, and m_opaque_up.

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >(), and SetEntries().

◆ ref()

Environment & SBEnvironment::ref ( ) const
protected

Definition at line 132 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 79 of file SBEnvironment.cpp.

References LLDB_RECORD_METHOD, and m_opaque_up.

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >().

◆ 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 115 of file SBEnvironment.cpp.

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

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >().

◆ 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 91 of file SBEnvironment.cpp.

References LLDB_RECORD_METHOD, and m_opaque_up.

Referenced by lldb_private::repro::RegisterMethods< SBEnvironment >().

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: