Teamcenter C++ API Reference  2312
Functions
Teamcenter::OSEnvironment Namespace Reference

Functions

void addPrefixMapping (const std::string &oldPrefix, const std::string &newPrefix)
 
std::string get (const std::string &name, bool applyOSEnvNameMapping=true, bool throwStdExceptionIfNotFound=false)
 
std::string getMappedName (const std::string &originalName)
 
const std::map< std::string,
std::string > & 
getNamePrefixMap ()
 
bool has (const std::string &name, bool applyOSEnvNameMapping=true)
 
void removePrefixMapping (const std::string &oldPrefix)
 
void set (const std::string &name, const std::string &value, bool applyOSEnvNameMapping=true)
 

Function Documentation

void Teamcenter::OSEnvironment::addPrefixMapping ( const std::string &  oldPrefix,
const std::string &  newPrefix 
)

Adds a name prefix mapping, e.g. from "OLDPREFIX_" to "NEWPREFIX_".
Subsequent calls to getMappedName with "OLDPREFIX_nametrailer" will return "NEWPREFIX_nametrailer"

Parameters
oldPrefix(I) The name prefix that should be mapped to a new_prefix
newPrefix(I) The replacement prefix
std::string Teamcenter::OSEnvironment::get ( const std::string &  name,
bool  applyOSEnvNameMapping = true,
bool  throwStdExceptionIfNotFound = false 
)

Returns the value of the environment variable with the given name.
If name mapping is turned on, the value is retrieved using the mapped environment variable name. If no value is found, the value is retrieved using the originally given variable name.

Returns
  • If the environment variable exists, it returns its value
  • Otherwise, if the parameter #throwStdExceptionIfNotFound is set to false, it returns an empty string
  • Otherwise, it throws an std::exception exception
See Also
getMappedName for more information on mapping definition
Exceptions
<std::exception>if the parameter #throwStdExceptionIfNotFound is set to true and the environment variable was not found.
Parameters
name(I) The name of the unmapped environment variable
applyOSEnvNameMapping(I) Specifies if the name should be mapped using Teamcenter::OSEnvNameMapping.
throwStdExceptionIfNotFound(I) Specifies if an std::exception is to be thrown if the environment variable does not exist.
If set to false, an empty string is returned if the environment variable does not exist.
std::string Teamcenter::OSEnvironment::getMappedName ( const std::string &  originalName)

Returns the mapped name that applies to the provided name.
E.g. it returns "NEWPREFIX_nametrailer" for an input "OLDPREFIX_nametrailer" if the mappings "OLDPREFIX_" to "NEWPREFIX_" has been set through addPrefixMapping.

Returns
The mapped name
Parameters
originalName(I) The name to be checked against mapping
const std::map< std::string, std::string >& Teamcenter::OSEnvironment::getNamePrefixMap ( )

Retrieves the actual map of prefixes.

bool Teamcenter::OSEnvironment::has ( const std::string &  name,
bool  applyOSEnvNameMapping = true 
)

Returns true if an environment variable with the given name is defined.
If name mapping is turned on, the mapped name is used first. If no environment variable with the mapped name can be found, the originally provided name is used.

Returns
  • true if an environment variable with the given (potentially mapped) name exists
  • false otherwise
See Also
getMappedName for more information on mapping definition
Parameters
name(I) The name of the unmapped environment variable
applyOSEnvNameMapping(I) Specifies if the name should be mapped using Teamcenter::OSEnvNameMapping.
void Teamcenter::OSEnvironment::removePrefixMapping ( const std::string &  oldPrefix)

Removes the prefix mapping that has previously been associated through a call to addPrefixMapping
Subsequent calls to getMappedName with "OLDPREFIX_nametrailer" will return "OLDPREFIX_nametrailer"

Parameters
oldPrefix(I) The name prefix that should no longer be mapped to a new prefix
void Teamcenter::OSEnvironment::set ( const std::string &  name,
const std::string &  value,
bool  applyOSEnvNameMapping = true 
)

Sets the environment variable with the given name to the given value.
The environment variable names are mapped using Teamcenter::OSEnvNameMapping unless the parameter #applyOSEnvNameMapping is set to false.

See Also
getMappedName for more information on mapping definition
Parameters
name(I) The name of the unmapped environment variable.
value(I) The value to be given to the potentially mapped environment variable.
applyOSEnvNameMapping(I) Specifies if the name should be mapped using Teamcenter::OSEnvNameMapping.