A Discrete-Event Network Simulator
API
ns3::EnvironmentVariable::Dictionary Class Reference

Key, value dictionary for a single environment variable. More...

#include "environment-variable.h"

+ Collaboration diagram for ns3::EnvironmentVariable::Dictionary:

Public Types

using KeyValueStore = std::unordered_map< std::string, std::string >
 Key, value store type. More...
 

Public Member Functions

 Dictionary (const std::string &envvar, const std::string &delim=";")
 Constructor. More...
 
KeyFoundType Get (const std::string &key="") const
 Get the value corresponding to a key from this dictionary. More...
 
KeyValueStore GetStore () const
 Get the underlying store, for iterating. More...
 

Private Attributes

KeyValueStore m_dict
 The key, value store. More...
 
bool m_exists
 Whether the environment variable exists in the environment. More...
 
std::string m_variable
 The raw environment variable. More...
 

Detailed Description

Key, value dictionary for a single environment variable.

Definition at line 125 of file environment-variable.h.

Member Typedef Documentation

◆ KeyValueStore

using ns3::EnvironmentVariable::Dictionary::KeyValueStore = std::unordered_map<std::string, std::string>

Key, value store type.

Definition at line 153 of file environment-variable.h.

Constructor & Destructor Documentation

◆ Dictionary()

ns3::EnvironmentVariable::Dictionary::Dictionary ( const std::string &  envvar,
const std::string &  delim = ";" 
)

Constructor.

Parse an environment variable containing keys and optional values.

Keys in the environment variable are separated by the delim character. Keys may be assigned values by following the key with the = character; any remaining text up to the next delimiter will be taken as the value. If no = is given the enpty string will be stored as the value.

Parameters
[in]envvarThe environment variable.
[in]delimThe delimiter between key,value pairs.

Definition at line 224 of file environment-variable.cc.

References NS_LOCAL_ASSERT, NS_LOCAL_LOG, and ns3::SplitString().

+ Here is the call graph for this function:

Member Function Documentation

◆ Get()

EnvironmentVariable::KeyFoundType ns3::EnvironmentVariable::Dictionary::Get ( const std::string &  key = "") const

Get the value corresponding to a key from this dictionary.

If the key is empty return the full environment variable value.

Parameters
[in]keyThe key to extract from the environment variable.
Returns
true if the key was found, and the associated value.

Definition at line 197 of file environment-variable.cc.

References m_dict, m_exists, m_variable, and NS_LOCAL_LOG.

◆ GetStore()

EnvironmentVariable::Dictionary::KeyValueStore ns3::EnvironmentVariable::Dictionary::GetStore ( ) const

Get the underlying store, for iterating.

Returns
The key, value store.

Definition at line 270 of file environment-variable.cc.

Member Data Documentation

◆ m_dict

KeyValueStore ns3::EnvironmentVariable::Dictionary::m_dict
private

The key, value store.

Definition at line 166 of file environment-variable.h.

Referenced by Get().

◆ m_exists

bool ns3::EnvironmentVariable::Dictionary::m_exists
private

Whether the environment variable exists in the environment.

Definition at line 162 of file environment-variable.h.

Referenced by Get().

◆ m_variable

std::string ns3::EnvironmentVariable::Dictionary::m_variable
private

The raw environment variable.

Definition at line 164 of file environment-variable.h.

Referenced by Get().


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