Graphite  Version 3
An experimental 3D geometry processing program
OGF::TextUtils::Environment Class Reference

Manages a set of name-value or name-values pairs, used to manipulate text files. More...

#include <OGF/basic/os/text_utils.h>

Public Member Functions

bool has_variable (const std::string &name) const
 Tests whether a variable exists in this Environment. More...
 
std::string value (const std::string &name) const
 Gets the value of a variable. More...
 
const std::vector< std::string > & values (const std::string &name) const
 Gets the vector of values associated with a variable. More...
 
void set_value (const std::string &name, const std::string &value)
 Sets the value of a variable. More...
 
void set_values (const std::string &name, const std::vector< std::string > &values)
 Sets the values of a variable. More...
 
void append_value (const std::string &name, const std::string &value)
 Appends a value to the set of values associated with a variable. More...
 
void append_values (const std::string &name, const std::vector< std::string > &values)
 Appends a set of values to the set of values associated with a variable. More...
 
void clear_value (const std::string &name)
 Clears the values of a variable. More...
 
void clear ()
 Removes all the variables and their values.
 
void print (std::ostream &out) const
 Outputs the contents of this Enviroment to a stream. More...
 

Detailed Description

Manages a set of name-value or name-values pairs, used to manipulate text files.

Definition at line 61 of file text_utils.h.

Member Function Documentation

◆ append_value()

void OGF::TextUtils::Environment::append_value ( const std::string &  name,
const std::string &  value 
)

Appends a value to the set of values associated with a variable.

If the variable did not exist, it creates it. If one of the values has the form "$var" and a variable named "var" exists in this Environment, then it is replaced with the set of values of variable "var".

Parameters
[in]namename of the variable
[in]valuevalue to be associated with the variable

◆ append_values()

void OGF::TextUtils::Environment::append_values ( const std::string &  name,
const std::vector< std::string > &  values 
)

Appends a set of values to the set of values associated with a variable.

If the variable did not exist, it creates it. If one of the values has the form "$var" and a variable named "var" exists in this Environment, then it is replaced with the set of values of variable "var".

Parameters
[in]namename of the variable
[in]valuesnew vector of values to be associated with the variable

◆ clear_value()

void OGF::TextUtils::Environment::clear_value ( const std::string &  name)

Clears the values of a variable.

If the variable did not exist, it creates it with an empty value. If it already existed, it overwrites its contents with an empty value.

Parameters
[in]namename of the variable

◆ has_variable()

bool OGF::TextUtils::Environment::has_variable ( const std::string &  name) const

Tests whether a variable exists in this Environment.

Parameters
[in]namename of the variable
Return values
trueif the variable exists
falseotherwise

◆ print()

void OGF::TextUtils::Environment::print ( std::ostream &  out) const

Outputs the contents of this Enviroment to a stream.

Parameters
[in,out]outthe stream where the contents of this Environment should be output

◆ set_value()

void OGF::TextUtils::Environment::set_value ( const std::string &  name,
const std::string &  value 
)

Sets the value of a variable.

If the variable did not exist, it creates it. If it already existed, it overwrites its previous content. If value has the form "$var" and a variable named "var" exists in this Environment, then it is replaced with the set of values of variable "var".

Parameters
[in]namename of the variable
[in]valuenew value of the variable

◆ set_values()

void OGF::TextUtils::Environment::set_values ( const std::string &  name,
const std::vector< std::string > &  values 
)

Sets the values of a variable.

If the variable did not exist, it creates it. If it already existed, it overwrites its previous content. If one of the values has the form "$var" and a variable named "var" exists in this Environment, then it is replaced with the set of values of variable "var".

Parameters
[in]namename of the variable
[in]valuesnew vector of values to be associated with the variable

◆ value()

std::string OGF::TextUtils::Environment::value ( const std::string &  name) const

Gets the value of a variable.

Parameters
[in]namename of the variable
Returns
the value of variable variable if it existed, or an empty string otherwise, then this creates the variable

◆ values()

const std::vector<std::string>& OGF::TextUtils::Environment::values ( const std::string &  name) const

Gets the vector of values associated with a variable.

If the variable does not exists, throws an assertion failure.

Parameters
[in]namename of the variable
Returns
a const reference to the vector of values associated with variable name
Precondition
has_variable(name)

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