variables.cpp File Reference

#include "variables.hpp"

Go to the source code of this file.

Functions

std::string get_value (std::string const &name, variable_map const *local_variables)
std::string expand (std::string str, variable_map const *local_variables)

Variables

variable_map global_variables


Detailed Description

Definition in file variables.cpp.


Function Documentation

std::string expand ( std::string  str,
variable_map const *  local_variables = 0 
)

Expand variables in a string using a local map and the global map.

Parameters:
str The string to expand
local_variables The optional, local map; can be null
Returns:
The expanded string

Definition at line 26 of file variables.cpp.

Referenced by artifact_impl::expand(), and parse_graph().

std::string get_value ( std::string const &  name,
variable_map const *  local_variables 
)

Get a variable’s value. Try the local variables first; if not found try the global variables. If still not found, define the name with an empty string and return an empty string. Subsequent lookups of the same name will find the empty string. Exercise for reader: print a message the first time the undefined variable’s name is used.

Parameters:
name The variable name
local_variables Pointer to the local variables map or null

Definition at line 15 of file variables.cpp.

References global_variables.

Referenced by expand().


Variable Documentation

variable_map global_variables

Listing 57-7. The variables.cpp File Implements the expand Function

Definition at line 5 of file variables.cpp.

Referenced by get_value(), and parse_graph().


Generated on Sun Nov 30 09:53:23 2008 for Exploring C++ - Final Forms of Key Examples by  doxygen 1.5.3